private void Upload() { progress_item = new ProgressItem(); progress_item.Changed += HandleProgressChanged; fr.Connection.OnUploadProgress += HandleFlickrProgress; System.Collections.ArrayList ids = new System.Collections.ArrayList(); for (int index = 0; index < selection.Items.Length; index++) { try { IBrowsableItem photo = selection.Items [index]; progress_dialog.Message = System.String.Format( Catalog.GetString("Uploading picture \"{0}\""), photo.Name); progress_dialog.Fraction = photo_index / (double)selection.Count; photo_index++; progress_dialog.ProgressText = System.String.Format( Catalog.GetString("{0} of {1}"), photo_index, selection.Count); info = new FileInfo(photo.DefaultVersionUri.LocalPath); FilterSet stack = new Filters.FilterSet(); if (scale) { stack.Add(new ResizeFilter((uint)size)); } string id = fr.Upload(photo, stack, is_public, is_family, is_friend); ids.Add(id); if (Core.Database != null && photo is Photo) { Core.Database.Exports.Create((photo as Photo).Id, (photo as Photo).DefaultVersionId, ExportStore.FlickrExportType, auth.User.UserId + ":" + auth.User.Username + ":" + current_service.Name + ":" + id); } progress_dialog.Message = Catalog.GetString("Done Sending Photos"); progress_dialog.Fraction = 1.0; progress_dialog.ProgressText = Catalog.GetString("Upload Complete"); progress_dialog.ButtonLabel = Gtk.Stock.Ok; } catch (System.Exception e) { progress_dialog.Message = String.Format(Catalog.GetString("Error Uploading To {0}: {1}"), current_service.Name, e.Message); progress_dialog.ProgressText = Catalog.GetString("Error"); System.Console.WriteLine(e); if (progress_dialog.PerformRetrySkip()) { index--; } } } if (open && ids.Count != 0) { string view_url = string.Format("http://www.{0}/tools/uploader_edit.gne?ids", current_service.Name); bool first = true; foreach (string id in ids) { view_url = view_url + (first ? "=" : ",") + id; first = false; } GnomeUtil.UrlShow(progress_dialog, view_url); } }
private void Upload() { sent_bytes = 0; approx_size = 0; System.Uri album_uri = null; System.Console.WriteLine("Starting Upload to Smugmug, album {0} - {1}", album.Title, album.AlbumID); FilterSet filters = new FilterSet(); filters.Add(new JpegFilter()); if (scale) { filters.Add(new ResizeFilter((uint)size)); } if (rotate) { filters.Add(new OrientationFilter()); } while (photo_index < items.Length) { try { IBrowsableItem item = items[photo_index]; FileInfo file_info; Console.WriteLine("uploading {0}", photo_index); progress_dialog.Message = String.Format(Catalog.GetString("Uploading picture \"{0}\" ({1} of {2})"), item.Name, photo_index + 1, items.Length); progress_dialog.ProgressText = string.Empty; progress_dialog.Fraction = ((photo_index) / (double)items.Length); photo_index++; FilterRequest request = new FilterRequest(item.DefaultVersionUri); filters.Convert(request); file_info = new FileInfo(request.Current.LocalPath); if (approx_size == 0) //first image { approx_size = file_info.Length * items.Length; } else { approx_size = sent_bytes * items.Length / (photo_index - 1); } int image_id = account.SmugMug.Upload(request.Current.LocalPath, album.AlbumID); if (Core.Database != null && item is Photo && image_id >= 0) { Core.Database.Exports.Create((item as Photo).Id, (item as Photo).DefaultVersionId, ExportStore.SmugMugExportType, account.SmugMug.GetAlbumUrl(image_id).ToString()); } sent_bytes += file_info.Length; if (album_uri == null) { album_uri = account.SmugMug.GetAlbumUrl(image_id); } } catch (System.Exception e) { progress_dialog.Message = String.Format(Mono.Unix.Catalog.GetString("Error Uploading To Gallery: {0}"), e.Message); progress_dialog.ProgressText = Mono.Unix.Catalog.GetString("Error"); System.Console.WriteLine(e); if (progress_dialog.PerformRetrySkip()) { photo_index--; if (photo_index == 0) { approx_size = 0; } } } } progress_dialog.Message = Catalog.GetString("Done Sending Photos"); progress_dialog.Fraction = 1.0; progress_dialog.ProgressText = Mono.Unix.Catalog.GetString("Upload Complete"); progress_dialog.ButtonLabel = Gtk.Stock.Ok; if (browser && album_uri != null) { GnomeUtil.UrlShow(album_uri.ToString()); } }
private void Upload() { Album album = null; if (create_album_radiobutton.Active) { string name = album_name_entry.Text; if (name.Length == 0) { HigMessageDialog mbox = new HigMessageDialog(Dialog, Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString("Album must have a name"), Catalog.GetString("Please name your album or choose an existing album.")); mbox.Run(); mbox.Destroy(); return; } string description = album_description_entry.Text; string location = album_location_entry.Text; try { album = account.Facebook.CreateAlbum(name, description, location); } catch (FacebookException fe) { HigMessageDialog mbox = new HigMessageDialog(Dialog, Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString("Creating a new album failed"), String.Format(Catalog.GetString("An error occurred creating a new album.\n\n{0}"), fe.Message)); mbox.Run(); mbox.Destroy(); return; } } else { AlbumStore store = (AlbumStore)existing_album_combobox.Model; album = store.Albums [existing_album_combobox.Active]; } long sent_bytes = 0; FilterSet filters = new FilterSet(); filters.Add(new JpegFilter()); filters.Add(new ResizeFilter((uint)size)); for (int i = 0; i < items.Length; i++) { try { IBrowsableItem item = items [i]; FileInfo file_info; Console.WriteLine("uploading {0}", i); progress_dialog.Message = String.Format(Catalog.GetString("Uploading picture \"{0}\" ({1} of {2})"), item.Name, i + 1, items.Length); progress_dialog.ProgressText = string.Empty; progress_dialog.Fraction = i / (double)items.Length; FilterRequest request = new FilterRequest(item.DefaultVersionUri); filters.Convert(request); file_info = new FileInfo(request.Current.LocalPath); Mono.Facebook.Photo photo = album.Upload(captions [i] ?? "", request.Current.LocalPath); sent_bytes += file_info.Length; } catch (Exception e) { progress_dialog.Message = String.Format(Catalog.GetString("Error Uploading To Facebook: {0}"), e.Message); progress_dialog.ProgressText = Catalog.GetString("Error"); Console.WriteLine(e); if (progress_dialog.PerformRetrySkip()) { i--; } } } progress_dialog.Message = Catalog.GetString("Done Sending Photos"); progress_dialog.Fraction = 1.0; progress_dialog.ProgressText = Catalog.GetString("Upload Complete"); progress_dialog.ButtonLabel = Gtk.Stock.Ok; Dialog.Destroy(); }
private void Upload() { album.UploadProgress += HandleUploadProgress; sent_bytes = 0; approx_size = 0; System.Console.WriteLine("Starting Upload to Picasa"); FilterSet filters = new FilterSet(); filters.Add(new JpegFilter()); if (scale) { filters.Add(new ResizeFilter((uint)size)); } if (rotate) { filters.Add(new OrientationFilter()); } Array.Sort(items, new DateComparer()); while (photo_index < items.Length) { try { IBrowsableItem item = items[photo_index]; FileInfo file_info; Console.WriteLine("uploading {0}", photo_index); progress_dialog.Message = String.Format(Catalog.GetString("Uploading picture \"{0}\" ({1} of {2})"), item.Name, photo_index + 1, items.Length); photo_index++; PicasaPicture picture; using (FilterRequest request = new FilterRequest(item.DefaultVersionUri)) { filters.Convert(request); file_info = new FileInfo(request.Current.LocalPath); if (approx_size == 0) //first image { approx_size = file_info.Length * items.Length; } else { approx_size = sent_bytes * items.Length / (photo_index - 1); } picture = album.UploadPicture(request.Current.LocalPath, Path.ChangeExtension(item.Name, "jpg"), item.Description); sent_bytes += file_info.Length; } if (Core.Database != null && item is Photo) { Core.Database.Exports.Create((item as Photo).Id, (item as Photo).DefaultVersionId, ExportStore.PicasaExportType, picture.Link); } //tagging if (item.Tags != null && export_tag) { foreach (Tag tag in item.Tags) { picture.AddTag(tag.Name); } } } catch (System.Threading.ThreadAbortException te) { Log.Exception(te); System.Threading.Thread.ResetAbort(); } catch (System.Exception e) { progress_dialog.Message = String.Format(Catalog.GetString("Error Uploading To Gallery: {0}"), e.Message); progress_dialog.ProgressText = Catalog.GetString("Error"); System.Console.WriteLine(e); if (progress_dialog.PerformRetrySkip()) { photo_index--; } } } progress_dialog.Message = Catalog.GetString("Done Sending Photos"); progress_dialog.Fraction = 1.0; progress_dialog.ProgressText = Catalog.GetString("Upload Complete"); progress_dialog.ButtonLabel = Gtk.Stock.Ok; if (browser) { GnomeUtil.UrlShow(album.Link); } }
private void Upload() { account.Gallery.Progress = new ProgressItem(); account.Gallery.Progress.Changed += HandleProgressChanged; System.Console.WriteLine("Starting upload"); FilterSet filters = new FilterSet(); if (account.Version == GalleryVersion.Version1) { filters.Add(new WhiteListFilter(new string [] { ".jpg", ".jpeg", ".png", ".gif" })); } if (scale) { filters.Add(new ResizeFilter((uint)size)); } else if (rotate) { filters.Add(new OrientationFilter()); } while (photo_index < items.Length) { IBrowsableItem item = items [photo_index]; System.Console.WriteLine("uploading {0}", photo_index); progress_dialog.Message = System.String.Format(Catalog.GetString("Uploading picture \"{0}\""), item.Name); progress_dialog.Fraction = photo_index / (double)items.Length; photo_index++; progress_dialog.ProgressText = System.String.Format(Catalog.GetString("{0} of {1}"), photo_index, items.Length); FilterRequest req = new FilterRequest(item.DefaultVersionUri); filters.Convert(req); try { int id = album.Add(item, req.Current.LocalPath); if (item != null && item is Photo && Core.Database != null && id != 0) { Core.Database.Exports.Create((item as Photo).Id, (item as Photo).DefaultVersionId, ExportStore.Gallery2ExportType, String.Format("{0}:{1}", album.Gallery.Uri.ToString(), id.ToString())); } } catch (System.Exception e) { progress_dialog.Message = String.Format(Catalog.GetString("Error uploading picture \"{0}\" to Gallery: {1}"), item.Name, e.Message); progress_dialog.ProgressText = Catalog.GetString("Error"); Console.WriteLine(e); if (progress_dialog.PerformRetrySkip()) { photo_index--; } } } progress_dialog.Message = Catalog.GetString("Done Sending Photos"); progress_dialog.Fraction = 1.0; progress_dialog.ProgressText = Catalog.GetString("Upload Complete"); progress_dialog.ButtonLabel = Gtk.Stock.Ok; if (browser) { GnomeUtil.UrlShow(album.GetUrl()); } }