Beispiel #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;
 }
Beispiel #2
0
        /// <summary>
        /// commandline should look like : /closeonerror=true /connectionstring="aaa";
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        private static CommandLineParams CreateCommandLineArguments(string[] args)
        {
            var result = new CommandLineParams();
            foreach (var param in args)
            {
                CommandLineArgument arg = CreateCommandLineArgument(param);
                if (arg == null)
                    continue;
                if (arg.Key.ToLower() == "RunFromConsole".ToLower())
                {
                    result.RunFromConsole = Convert.ToBoolean(arg.Value);
                }

                if (arg.Key.ToLower() == "ConnectionString".ToLower())
                {
                    result.ConnectionString = arg.Value;
                }
            }
            return result;
        }
Beispiel #3
0
        private void RunSingleUpdateFromMultipleInstance(DbUpdaterMultipleSourceConfigurationSection settings, LogWrapper.ILogger logger, int configurationIndex, CommandLineParams commandLineParams)
        {
            if (settings == null || settings.DbUpdaterConfigurations == null)
            {
                OnFinishUpdateProcess(false);
                return;
            }

            if (configurationIndex >= settings.DbUpdaterConfigurations.Count)
            {
                OnFinishUpdateProcess(false);
                return;
            }

            DbUpdaterConfigurationSection currentSettings = settings.DbUpdaterConfigurations[configurationIndex];
            if (string.IsNullOrEmpty(currentSettings.ConnectionString))
            {
                currentSettings.ConnectionString = settings.ConnectionString;
            }

            RunSingleUpdate(currentSettings, logger, settings, configurationIndex + 1, commandLineParams);
        }
Beispiel #4
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();
        }