예제 #1
0
 public ComponentUpdaterUIController(IUpdaterUI updaterUI, UpdateMode updateMode)
 {
     this.updaterUI  = updaterUI;
     this.updateMode = updateMode;
     try
     {
         this.updaterUI.Cancelled += (s, e) =>
         {
             if (this.http != null)
             {
                 this.http.Stop();
             }
             this.http = null;
         };
     }
     catch (Exception ex)
     {
         Log.Debug(ex, "ComponentUpdaterUI");
     }
 }
예제 #2
0
파일: Db.cs 프로젝트: swgshaw/f-spot
 public Db(IImageFileFactory imageFileFactory, IThumbnailService thumbnailService, IUpdaterUI updaterDialog)
 {
     this.imageFileFactory = imageFileFactory;
     this.thumbnailService = thumbnailService;
     this.updaterDialog    = updaterDialog;
 }
예제 #3
0
        public static void Run(FSpotDatabaseConnection database, IUpdaterUI updaterDialog)
        {
            db     = database;
            dialog = updaterDialog;

            db_version = GetDatabaseVersion();

            if (updates.Count == 0)
            {
                return;
            }

            if (db_version == LatestVersion)
            {
                return;
            }
            else if (db_version > LatestVersion)
            {
                if (!silent)
                {
                    Log.Information("The existing database version is more recent than this version of F-Spot expects.");
                }
                return;
            }

            uint timer = 0;

            if (!silent)
            {
                timer = Log.InformationTimerStart("Updating F-Spot Database");
            }

            // Only create and show the dialog if one or more of the updates to be done is
            // marked as being slow
            bool slow = false;

            foreach (Version version in updates.Keys)
            {
                if (version > db_version && (updates [version] as Update).IsSlow)
                {
                    slow = true;
                }
                break;
            }

            if (slow && !silent)
            {
                dialog.Show();
            }

            db.BeginTransaction();
            try {
                List <Version> keys = new List <Version> ();
                foreach (Version k in updates.Keys)
                {
                    keys.Add(k);
                }
                keys.Sort();
                foreach (Version version in keys)
                {
                    if (version <= db_version)
                    {
                        continue;
                    }
                    dialog.Pulse();
                    (updates [version] as Update).Execute(db, db_version);
                }

                db.CommitTransaction();
            } catch (Exception e) {
                if (!silent)
                {
                    Log.DebugException(e);
                    Log.Warning("Rolling back database changes because of Exception");
                }
                // There was an error, roll back the database
                db.RollbackTransaction();

                // Pass the exception on, this is fatal
                throw e;
            }

            dialog.Destroy();

            if (db_version == LatestVersion && !silent)
            {
                Log.InformationTimerPrint(timer, "Database updates completed successfully (in {0}).");
            }
        }