public FFile UpdateSets(int fileID) { var file = fFileLogic.Get(fileID); if (file != null && (file.Status == FFileStatus.Uploaded_NoSet || file.Status == FFileStatus.Uploaded_InSet) ) { FlickrLogic.Log(file.Path, NoticeType.Upload, "Add to photo sets"); SetLogic l = new SetLogic(); string setID = l.AddPhoto(file); if (string.IsNullOrEmpty(setID)) { } else { file = fFileLogic.DoUpdate(fileID, file1 => { file1.SetsID = setID; file1.Status = FFileStatus.Uploaded_SyncSet; }); } } return(file); }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { var g = sender as DataGridView; var name = g.Columns[e.ColumnIndex].DataPropertyName; if (name == "IsDownload") { var idCell = g.Rows[e.RowIndex].Cells[0]; var id = (string)idCell.Value; var isDownload = (bool)g.Rows[e.RowIndex].Cells[e.ColumnIndex].EditedFormattedValue; SetLogic l = new SetLogic(); l.UpdateIsDownload(id, isDownload); } }
async static Task StartDownload() { ResetDownloadCancellationToken(); SetLogic setLogic = new SetLogic(); setLogic.Reset_DownloadProcessingStatus(); while (FlickrLogic.IsDownload) { var set = setLogic.GetForDownload(); if (set == null) { FlickrLogic.IsDownload = false; } else { CurrentDownloadSetId = set.SetsID; await DownloadSet(); } } }
async static Task DownloadSet() { if (string.IsNullOrEmpty(CurrentDownloadSetId)) { } else { try { var task = Task.Factory.StartNew(() => { Flickr flickr = new Flickr(); var list = flickr.PhotosetsGetPhotos(CurrentDownloadSetId); SetLogic sL = new SetLogic(); string saveFolder = sL.GetDownloadFolderPath(CurrentDownloadSetId); if (list == null || list.Count == 0 || string.IsNullOrEmpty(saveFolder)) { } else { ParallelOptions opt = new ParallelOptions(); opt.MaxDegreeOfParallelism = MaxUpload; opt.CancellationToken = DownloadCancellationToken; try { var r1 = Parallel.ForEach(list, opt , photo => { var sizes = flickr.PhotosGetSizes(photo.PhotoId); if (sizes == null || sizes.Count == 0) { } else { var org = sizes.FirstOrDefault(r => r.Label == "Original" && r.MediaType == MediaType.Photos); if (org == null) { } else { Uri uri = new Uri(org.Source); string filename = Path.GetFileName(uri.LocalPath); WebClient webClient = new WebClient(); string filePath = Path.Combine(saveFolder, filename); if (File.Exists(filePath)) { } else { webClient.DownloadFile(org.Source, filePath); FlickrLogic.Log(filePath, NoticeType.DownloadDone, "Downloaded"); } } } } ); } catch (Exception ex) { } } }); await task; } catch (Exception ex) { } } }
public FFile UpdateSets(int fileID) { var file = fFileLogic.Get(fileID); if (file != null && (file.Status == FFileStatus.Uploaded_NoSet || file.Status == FFileStatus.Uploaded_InSet) ) { FlickrLogic.Log(file.Path, NoticeType.Upload, "Add to photo sets"); SetLogic l = new SetLogic(); string setID = l.AddPhoto(file); if (string.IsNullOrEmpty(setID)) { } else { file = fFileLogic.DoUpdate(fileID, file1 => { file1.SetsID = setID; file1.Status = FFileStatus.Uploaded_SyncSet; }); } } return file; }
public static void ResetOAuth() { FUserLogic l = new FUserLogic(); var v = l.GetFirst(); if (v != null) { OAuthAccessToken = v.OAuthAccessToken; OAuthAccessTokenSecret = v.OAuthAccessTokenSecret; Flickr flickr = new Flickr(); User = flickr.TestLogin(); if (User == null || string.IsNullOrEmpty(User.UserName)) { OAuthAccessToken = ""; OAuthAccessTokenSecret = ""; } else { SetLogic setL = new SetLogic(); setL.DownloadPhotsets(); FFolderLogic.Scan(); } } }