async static Task StartUpload() { ResetCancellationToken(); //wait for all upload complete if remaining //await WaitForComplete(); FFolderLogic.Reset_ProcessingStatus(); while (FlickrLogic.IsUpload) { var folder = FFolderLogic.GetForUpload(); if (folder == null) { FlickrLogic.IsUpload = false; } else { CurrentFolderPath = folder.Path; FFileLogic fLogic = new FFileLogic(folder); fLogic.Reset_ProcessingStatus(); await UploadFolder(); } } }
public static async Task Scan() { var l = db.FFolders.Where(r => r.UserId == Flickr.User.UserId).ToList(); foreach (var item in l) { FFileLogic logic = new FFileLogic(item); await logic.Scan(); } }
async static Task UploadFolder() { if (string.IsNullOrEmpty(CurrentFolderPath)) { } else { try { var task = Task.Factory.StartNew(() => { FFileLogic fFileLogic = new FFileLogic(CurrentFolderPath); ParallelOptions opt = new ParallelOptions(); opt.MaxDegreeOfParallelism = MaxUpload; opt.CancellationToken = CancellationToken; try { var r = Parallel.ForEach(fFileLogic.TakeBuffer(), opt , file => { if (string.IsNullOrEmpty(CurrentFolderPath)) { } else { FlickrLogic logic = new FlickrLogic(CurrentFolderPath); if (file == null) { } else if (file.Status == FFileStatus.New) { var t = logic.Upload(file.Id); try { Task.WaitAll(t); } catch (Exception ex1) { } } else if (file.Status == FFileStatus.Existing) { //logic.Processing_HashCodeFound(file.Id); try { logic.Processing_HashCodeFound(file.Id); } catch (Exception) { } } } } ); } catch (Exception ex) { } }); await task; } catch (Exception ex) { } } }
public FlickrLogic(string path) : base(path) { fFileLogic = new FFileLogic(path); flickr = new Flickr(); }