<commit_before>﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Diagnostics;
using Windows.Web.Http;
using Windows.Web.Http.Filters;
using Windows.Web.Http.Headers;
using Windows.Storage;
using Windows.Storage.Search;
using Windows.UI.Xaml;

namespace SecuritySystemUWP
{
    public class OneDrive : IStorage
    {
        private HttpClient httpClient;
        private CancellationTokenSource cts;
        private bool isLoggedIn = false;
        private Mutex uploadPicturesMutexLock = new Mutex();
        private DispatcherTimer refreshTimer;

        private int numberUploaded = 0;
        
        /*******************************************************************************************
        * PUBLIC METHODS
        *******************************************************************************************/
        public OneDrive()
        {
            refreshTimer = new DispatcherTimer();
            refreshTimer.Interval = TimeSpan.FromMinutes(25);
            refreshTimer.Tick += refreshTimer_Tick;
            refreshTimer.Start();
            CreateHttpClient(ref httpClient);
            cts = new CancellationTokenSource();
        }

        public async void Dispose()
        {
            await Logout();
            refreshTimer.Stop();
            cts.Dispose();
            httpClient.Dispose();
        }

        public async void UploadPictures(string camera)
        {
            if (isLoggedIn)
            {
                uploadPicturesMutexLock.WaitOne();

                try
                {
                    QueryOptions querySubfolders = new QueryOptions();
                    querySubfolders.FolderDepth = FolderDepth.Deep;

                    StorageFolder cacheFolder = KnownFolders.PicturesLibrary;
                    cacheFolder = await cacheFolder.GetFolderAsync(AppSettings.FolderName);
                    var result = cacheFolder.CreateFileQueryWithOptions(querySubfolders);
                    var files = await result.GetFilesAsync();

                    foreach (StorageFile file in files)
                    {
                        string imageName = string.Format(AppSettings.ImageNameFormat, camera, DateTime.Now.ToString("MM_dd_yyyy/HH"), DateTime.UtcNow.Ticks.ToString());
                        try
                        {<commit_msg>Removing logout from Dispose() in OneDrive<commit_after>﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Diagnostics;
using Windows.Web.Http;
using Windows.Web.Http.Filters;
using Windows.Web.Http.Headers;
using Windows.Storage;
using Windows.Storage.Search;
using Windows.UI.Xaml;

namespace SecuritySystemUWP
{
    public class OneDrive : IStorage
    {
        private HttpClient httpClient;
        private CancellationTokenSource cts;
        private bool isLoggedIn = false;
        private Mutex uploadPicturesMutexLock = new Mutex();
        private DispatcherTimer refreshTimer;

        private int numberUploaded = 0;
        
        /*******************************************************************************************
        * PUBLIC METHODS
        *******************************************************************************************/
        public OneDrive()
        {
            refreshTimer = new DispatcherTimer();
            refreshTimer.Interval = TimeSpan.FromMinutes(25);
            refreshTimer.Tick += refreshTimer_Tick;
            refreshTimer.Start();
            CreateHttpClient(ref httpClient);
            cts = new CancellationTokenSource();
        }

        public void Dispose()
        {
            //await Logout();
            refreshTimer.Stop();
            cts.Dispose();
            httpClient.Dispose();
        }

        public async void UploadPictures(string camera)
        {
            if (isLoggedIn)
            {
                uploadPicturesMutexLock.WaitOne();

                try
                {
                    QueryOptions querySubfolders = new QueryOptions();
                    querySubfolders.FolderDepth = FolderDepth.Deep;

                    StorageFolder cacheFolder = KnownFolders.PicturesLibrary;
                    cacheFolder = await cacheFolder.GetFolderAsync(AppSettings.FolderName);
                    var result = cacheFolder.CreateFileQueryWithOptions(querySubfolders);
                    var files = await result.GetFilesAsync();

                    foreach (StorageFile file in files)
                    {
                        string imageName = string.Format(AppSettings.ImageNameFormat, camera, DateTime.Now.ToString("MM_dd_yyyy/HH"), DateTime.UtcNow.Ticks.ToString());
                        try
                        {
{'fraction_non_alphanumeric': 0.1439440674480773, 'fraction_numerical': 0.0012338062924120913, 'mean_word_length': 2.1119641714651314, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4370173', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1088, 'n_words': 244}