Example #1
0
 public UpdateManager(DbUpdaterConfigurationSection settings, ILogger log, CommandLineParams commandLineParams)
 {
     _log = log;
     if (_log == null)
         throw new ArgumentNullException("log");
     _settings = settings;
     if (settings == null)
         throw new ArgumentNullException("settings");
     _commandLineParams = commandLineParams;
 }
Example #2
0
        private void RunSingleUpdate(DbUpdaterConfigurationSection settings, LogWrapper.ILogger logger, DbUpdaterMultipleSourceConfigurationSection multipleSettings, int configurationIndex, CommandLineParams commandLineParams)
        {
            var bw = new BackgroundWorker();
            bw.WorkerReportsProgress = true;
            bw.DoWork += (sender, args) =>
            {
                var updater = new UpdateManager(settings, logger, commandLineParams);
                updater.UpdateProgress += (s, e) => bw.ReportProgress(0, e);
                updater.Update();
            };

            bw.ProgressChanged += Update_ProgressChanged;
            bw.RunWorkerCompleted += (s, e) =>
            {
                IsUpdateInProgress = false;
                if (e.Error != null)
                {
                    DisplayText += "Error: " + e.Error.Message +Environment.NewLine;
                    OnFinishUpdateProcess(true);
                    return;
                }
                if (e.Cancelled)
                {
                    DisplayText += "Cancelled" + Environment.NewLine;
                    OnFinishUpdateProcess(true);
                    return;
                }

                RunSingleUpdateFromMultipleInstance(multipleSettings, logger, configurationIndex, commandLineParams);
            };

            IsUpdateInProgress = true;
            bw.RunWorkerAsync();
        }