public override int Prepare() { if (import_info != null) { throw new ImportException("Busy"); } import_info = new ArrayList(); foreach (string path in base_paths) { try { if (System.IO.Directory.Exists(path)) { GetListing(new System.IO.DirectoryInfo(path)); } else if (System.IO.File.Exists(path)) { GetListing(new System.IO.DirectoryInfo(System.IO.Path.GetDirectoryName(path)), new System.IO.FileInfo [] { new System.IO.FileInfo(path) }, false); } } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } directories = new Stack(); xmptags = new XmpTagsImporter(store, tag_store); roll = rolls.Create(); Photo.ResetMD5Cache(); return(import_info.Count); }
public void Run(object o, EventArgs e) { Photo[] photos = App.Instance.Organizer.SelectedPhotos(); if (photos.Length == 0) { Log.Debug("no photos selected, returning"); return; } DateTime import_time = photos[0].Time; foreach (Photo p in photos) { if (p.Time > import_time) { import_time = p.Time; } } RollStore rolls = App.Instance.Database.Rolls; Roll roll = rolls.Create(import_time); foreach (Photo p in photos) { HyenaSqliteCommand cmd = new HyenaSqliteCommand("UPDATE photos SET roll_id = ? " + "WHERE id = ? ", roll.Id, p.Id); App.Instance.Database.Database.Execute(cmd); p.RollId = roll.Id; } Log.Debug("RetroactiveRoll done: " + photos.Length + " photos in roll " + roll.Id); }
void DoImport() { while (photo_scan_running) { Thread.Sleep(1000); // FIXME: we can do this with a better primitive! } FireEvent(ImportEvent.ImportStarted); App.Instance.Database.Sync = false; created_directories = new Stack <SafeUri> (); imported_photos = new List <uint> (); copied_files = new List <SafeUri> (); original_files = new List <SafeUri> (); metadata_importer = new MetadataImporter(); CreatedRoll = rolls.Create(); EnsureDirectory(Global.PhotoUri); try { int i = 0; int total = Photos.Count; foreach (var info in Photos.Items) { if (import_cancelled) { RollbackImport(); return; } ThreadAssist.ProxyToMain(() => ReportProgress(i++, total)); try { ImportPhoto(info, CreatedRoll); } catch (Exception e) { Log.DebugFormat("Failed to import {0}", info.DefaultVersion.Uri); Log.DebugException(e); FailedImports.Add(info.DefaultVersion.Uri); } } PhotosImported = imported_photos.Count; FinishImport(); } catch (Exception e) { RollbackImport(); throw e; } finally { Cleanup(); } }
void CreateRolls(Roll [] rolls) { if (rolls == null) { rolls = from_db.Rolls.GetRolls(); } RollStore from_store = from_db.Rolls; RollStore to_store = to_db.Rolls; foreach (Roll roll in rolls) { if (from_store.PhotosInRoll(roll) == 0) { continue; } roll_map [roll.Id] = (to_store.Create(roll.Time).Id); } }