private String GetPhotoSetID(String Sets) { Flickr f = FlickrManager.GetAuthInstance(); PhotosetCollection photosets = f.PhotosetsGetList(); foreach (Photoset pset in photosets) { if (Sets == pset.Title) { return(pset.PhotosetId); } Console.WriteLine(pset.Title); } return(""); }
private void bgWorker_DoWork(object sender, DoWorkEventArgs e) { List <PhotoLocal> PhotofileList = GetPhotoPathList(txtPhotoPath.Text); if (PhotofileList == null || PhotofileList.Count == 0) { MessageBox.Show("画像フォルダを指定してください"); return; } String Desc = txtDescription.Text; String Tags = txtTags.Text; String Sets = txtSets.Text; Boolean IsPrivate = false; List <String> PhotoID = new List <String>(); int resize = 100; try { resize = Convert.ToInt32(txtResize.Text); } catch (FormatException ex) { txtResize.AppendText(ex.Message); } if (Directory.Exists(Config.WorkDirectory) == false) { Directory.CreateDirectory(Config.WorkDirectory); } Flickr f = FlickrManager.GetAuthInstance(); f.OnUploadProgress += new EventHandler <FlickrNet.UploadProgressEventArgs>(Flickr_OnUploadProgress); foreach (PhotoLocal photofile in PhotofileList) { //txtResult.AppendText(photofile.Title + " ...\n"); Console.WriteLine(photofile.Title + " ..."); String srcimg = photofile.Path; String dstimg = System.IO.Path.Combine( Config.WorkDirectory, Path.GetFileNameWithoutExtension(srcimg) + ".JPG"); Resize(srcimg, dstimg, resize); PhotoID.Add(f.UploadPicture(dstimg, photofile.Title, Desc, Tags, IsPrivate, false, false)); } if (String.IsNullOrEmpty(Sets) == true) { return; } //txtResult.AppendText(String.Format("Create Sets: {0} ...\n", Sets)); Console.Write(String.Format("Create Sets: {0} ...\n", Sets)); int StartIndex = 0; String PhotosetID; PhotosetID = GetPhotoSetID(Sets); if (PhotosetID == "") { Photoset photoset = f.PhotosetsCreate(Sets, PhotoID[0]); PhotosetID = photoset.PhotosetId; StartIndex++; } if (StartIndex >= PhotoID.Count) { return; } for (int i = StartIndex; i < PhotoID.Count; i++) { f.PhotosetsAddPhoto(PhotosetID, PhotoID[i]); } }