protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { FolderGallery gallery = new FolderGallery(); UploadedFilesRepeater.DataSource = gallery.GetItems(Request.QueryString["path"]); UploadedFilesRepeater.DataBind(); } }
public void Upload() { // FIXME: use mkstemp try { ThreadAssist.ProxyToMain (Dialog.Hide); GLib.File source = GLib.FileFactory.NewForPath (Path.Combine (gallery_path, gallery_name)); GLib.File target = GLib.FileFactory.NewForPath (Path.Combine (dest.Path, source.Basename)); if (dest.IsNative) gallery_path = dest.Path; progress_dialog.Message = Catalog.GetString ("Building Gallery"); progress_dialog.Fraction = 0.0; FolderGallery gallery; if (static_radio.Active) { gallery = new HtmlGallery (selection, gallery_path, gallery_name); } else if (original_radio.Active) { gallery = new OriginalGallery (selection, gallery_path, gallery_name); } else { gallery = new FolderGallery (selection, gallery_path, gallery_name); } if (scale) { Log.DebugFormat ("Resize Photos to {0}.", size); gallery.SetScale (size); } else { Log.Debug ("Exporting full size."); } if (exportTags) gallery.ExportTags = true; if (exportTagIcons) gallery.ExportTagIcons = true; gallery.Description = description; gallery.GenerateLayout (); FilterSet filter_set = new FilterSet (); if (scale) filter_set.Add (new ResizeFilter ((uint) size)); filter_set.Add (new ChmodFilter ()); filter_set.Add (new UniqueNameFilter (new SafeUri (gallery_path))); for (int photo_index = 0; photo_index < selection.Count; photo_index++) { try { progress_dialog.Message = System.String.Format (Catalog.GetString ("Exporting \"{0}\"..."), selection[photo_index].Name); progress_dialog.Fraction = photo_index / (double) selection.Count; gallery.ProcessImage (photo_index, filter_set); progress_dialog.ProgressText = System.String.Format (Catalog.GetString ("{0} of {1}"), (photo_index + 1), selection.Count); } catch (Exception e) { Log.Error (e.ToString ()); progress_dialog.Message = String.Format (Catalog.GetString ("Error Copying \"{0}\" to Gallery:{2}{1}"), selection[photo_index].Name, e.Message, Environment.NewLine); progress_dialog.ProgressText = Catalog.GetString ("Error"); if (progress_dialog.PerformRetrySkip ()) photo_index--; } } // create the zip tarballs for original if (gallery is OriginalGallery) { bool include_tarballs; try { include_tarballs = Preferences.Get<bool> (INCLUDE_TARBALLS_KEY); } catch (NullReferenceException){ include_tarballs = true; Preferences.Set (INCLUDE_TARBALLS_KEY, true); } if (include_tarballs) (gallery as OriginalGallery).CreateZip (); } // we've created the structure, now if the destination was local (native) we are done // otherwise we xfer if (!dest.IsNative) { Log.DebugFormat ("Transferring \"{0}\" to \"{1}\"", source.Path, target.Path); progress_dialog.Message = String.Format (Catalog.GetString ("Transferring to \"{0}\""), target.Path); progress_dialog.ProgressText = Catalog.GetString ("Transferring..."); source.CopyRecursive (target, GLib.FileCopyFlags.Overwrite, new GLib.Cancellable (), Progress); } // No need to check result here as if result is not true, an Exception will be thrown before progress_dialog.Message = Catalog.GetString ("Export Complete."); progress_dialog.Fraction = 1.0; progress_dialog.ProgressText = Catalog.GetString ("Exporting Photos Completed."); progress_dialog.ButtonLabel = Gtk.Stock.Ok; if (open) { Log.DebugFormat (String.Format ("Open URI \"{0}\"", target.Uri.ToString ())); ThreadAssist.ProxyToMain (() => { GtkBeans.Global.ShowUri (Dialog.Screen, target.Uri.ToString () ); }); } // Save these settings for next time Preferences.Set (SCALE_KEY, scale); Preferences.Set (SIZE_KEY, size); Preferences.Set (OPEN_KEY, open); Preferences.Set (EXPORT_TAGS_KEY, exportTags); Preferences.Set (EXPORT_TAG_ICONS_KEY, exportTagIcons); Preferences.Set (METHOD_KEY, static_radio.Active ? "static" : original_radio.Active ? "original" : "folder" ); Preferences.Set (URI_KEY, uri_chooser.Uri); } catch (System.Exception e) { Log.Error (e.ToString ()); progress_dialog.Message = e.ToString (); progress_dialog.ProgressText = Catalog.GetString ("Error Transferring"); } finally { // if the destination isn't local then we want to remove the temp directory we // created. if (!dest.IsNative) System.IO.Directory.Delete (gallery_path, true); ThreadAssist.ProxyToMain (() => { Dialog.Destroy(); }); } }
public void Upload () { // FIXME use mkstemp Gnome.Vfs.Result result = Gnome.Vfs.Result.Ok; try { Dialog.Hide (); Gnome.Vfs.Uri source = new Gnome.Vfs.Uri (Path.Combine (gallery_path, gallery_name)); Gnome.Vfs.Uri target = dest.Clone(); target = target.AppendFileName(source.ExtractShortName ()); if (dest.IsLocal) gallery_path = Gnome.Vfs.Uri.GetLocalPathFromUri (dest.ToString ()); progress_dialog.Message = Catalog.GetString ("Building Gallery"); progress_dialog.Fraction = 0.0; FolderGallery gallery; if (static_radio.Active) { gallery = new HtmlGallery (selection, gallery_path, gallery_name); } else if (original_radio.Active) { gallery = new OriginalGallery (selection, gallery_path, gallery_name); } else { gallery = new FolderGallery (selection, gallery_path, gallery_name); } if (scale) { System.Console.WriteLine ("setting scale to {0}", size); gallery.SetScale (size); } else { System.Console.WriteLine ("Exporting full size image"); } if (rotate) { System.Console.WriteLine ("Exporting rotated image"); gallery.SetRotate(); } if (exportTags) gallery.SetExportTags (); if (exportTagIcons) gallery.SetExportTagIcons (); gallery.Description = description; gallery.GenerateLayout (); FilterSet filter_set = new FilterSet (); if (scale) filter_set.Add (new ResizeFilter ((uint) size)); else if (rotate) filter_set.Add (new OrientationFilter ()); filter_set.Add (new ChmodFilter ()); filter_set.Add (new UniqueNameFilter (gallery_path)); for (int photo_index = 0; photo_index < selection.Count; photo_index++) { try { progress_dialog.Message = System.String.Format (Catalog.GetString ("Uploading picture \"{0}\""), selection[photo_index].Name); progress_dialog.Fraction = photo_index / (double) selection.Count; gallery.ProcessImage (photo_index, filter_set); progress_dialog.ProgressText = System.String.Format (Catalog.GetString ("{0} of {1}"), (photo_index + 1), selection.Count); } catch (Exception e) { progress_dialog.Message = String.Format (Catalog.GetString ("Error uploading picture \"{0}\" to Gallery:{2}{1}"), selection[photo_index].Name, e.Message, Environment.NewLine); progress_dialog.ProgressText = Catalog.GetString ("Error"); if (progress_dialog.PerformRetrySkip ()) photo_index--; } } //create the zip tarballs for original if (gallery is OriginalGallery) { bool include_tarballs; try { include_tarballs = (bool)Preferences.Get (INCLUDE_TARBALLS_KEY); } catch (NullReferenceException){ include_tarballs = true; Preferences.Set (INCLUDE_TARBALLS_KEY, true); } if (include_tarballs) (gallery as OriginalGallery).CreateZip (); } // we've created the structure, now if the destination was local we are done // otherwise we xfer if (!dest.IsLocal) { Console.WriteLine(target); System.Console.WriteLine ("Xfering {0} to {1}", source.ToString (), target.ToString ()); result = Gnome.Vfs.Xfer.XferUri (source, target, Gnome.Vfs.XferOptions.Default, Gnome.Vfs.XferErrorMode.Abort, Gnome.Vfs.XferOverwriteMode.Replace, Progress); } if (result == Gnome.Vfs.Result.Ok) { progress_dialog.Message = Catalog.GetString ("Done Sending Photos"); progress_dialog.Fraction = 1.0; progress_dialog.ProgressText = Catalog.GetString ("Transfer Complete"); progress_dialog.ButtonLabel = Gtk.Stock.Ok; } else { progress_dialog.ProgressText = result.ToString (); progress_dialog.Message = Catalog.GetString ("Error While Transferring"); } if (open) { GnomeUtil.UrlShow (target.ToString ()); } // Save these settings for next time Preferences.Set (SCALE_KEY, scale); Preferences.Set (SIZE_KEY, size); Preferences.Set (OPEN_KEY, open); Preferences.Set (ROTATE_KEY, rotate); Preferences.Set (EXPORT_TAGS_KEY, exportTags); Preferences.Set (EXPORT_TAG_ICONS_KEY, exportTagIcons); Preferences.Set (METHOD_KEY, static_radio.Active ? "static" : original_radio.Active ? "original" : "folder" ); Preferences.Set (URI_KEY, uri_chooser.Uri); } catch (System.Exception e) { // Console.WriteLine (e); progress_dialog.Message = e.ToString (); progress_dialog.ProgressText = Catalog.GetString ("Error Transferring"); } finally { // if the destination isn't local then we want to remove the temp directory we // created. if (!dest.IsLocal) System.IO.Directory.Delete (gallery_path, true); Gtk.Application.Invoke (delegate { Dialog.Destroy(); }); } }