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; }
/// <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; }
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); }
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(); }