public override Command Copy() { var x = new CheckIfNewer(_workFolder, _package, _singleFile); x.RunAfterCompletedWithResultFalse = this.RunAfterCompletedWithResultFalse; x.RunAfterCompletedWithResultTrue = this.RunAfterCompletedWithResultTrue; x.AddResultsOfPreviousCommands(this.ResultsOfPreviousCommands); return x; }
IEnumerable<Command> ICommandBuilder.GetCommands(string workFolder, IEnumerable<IUpdatePackage> updatePackages, IEnumerable<INotificationReceiver> notificationReceivers) { var commands = new Queue<Command>(); foreach (var package in updatePackages) { _logger.Debug("Building commands for {PackageName}", package.PackageName); var checkIfNewer = new CheckIfNewer(workFolder, package, _singleFile); var getFile = new DeleteOldAndGetNewFile(workFolder, package, _singleFile, _logger); var unzipFile = new UnzipFile(workFolder, package); var cleanupOldUnpackedFiles = new CleanupOldUnpackedFiles(workFolder, package, _directory, _logger); checkIfNewer.RunAfterCompletedWithResultTrue = getFile; getFile.RunAfterCompletedWithResultTrue = cleanupOldUnpackedFiles; getFile.RunAfterCompletedWithResultFalse = new SendErrorNotifications(notificationReceivers, getFile, _blackboard); cleanupOldUnpackedFiles.RunAfterCompletedWithResultTrue = unzipFile; cleanupOldUnpackedFiles.RunAfterCompletedWithResultFalse = new SendErrorNotifications(notificationReceivers, cleanupOldUnpackedFiles, _blackboard); Command finalCommand = unzipFile; if (!package.Settings.DownloadOnly) { var runInstallerCommand = new RunInstallerCommand(package.Settings.InstallerCommand, package.Settings.InstallerCommandArguments, workFolder, package, _runExternalCommand, _logger); unzipFile.RunAfterCompletedWithResultTrue = runInstallerCommand; unzipFile.RunAfterCompletedWithResultFalse = new SendErrorNotifications(notificationReceivers, unzipFile, _blackboard); finalCommand = runInstallerCommand; Command updateDatabase = null; if (!package.Settings.SkipDatabaseUpdate) { updateDatabase = new UpdateDatabase( package.Settings.DatabaseUpdaterCommand, package.Settings.DatabaseUpdaterCommandArguments, package.Settings.ConnectionString, workFolder, package, _runExternalCommand, _logger); runInstallerCommand.RunAfterCompletedWithResultTrue = updateDatabase; runInstallerCommand.RunAfterCompletedWithResultFalse = new SendErrorNotifications(notificationReceivers, runInstallerCommand, _blackboard); finalCommand = updateDatabase; } if (package.Settings.CheckUrlsAfterInstallation != null) { ProxySettings proxySettings = null; if (package.Settings.CheckUrlProxySettings != null) { proxySettings = new ProxySettings(); proxySettings.Address = package.Settings.CheckUrlProxySettings.Address; if (!String.IsNullOrEmpty(package.Settings.CheckUrlProxySettings.Password) && !String.IsNullOrEmpty(package.Settings.CheckUrlProxySettings.Username)) { proxySettings.Username = package.Settings.CheckUrlProxySettings.Username; proxySettings.Password = package.Settings.CheckUrlProxySettings.Password; } } foreach (var url in package.Settings.CheckUrlsAfterInstallation) { var checkUrlHttpStatusIs200 = new CheckUrlHttpStatusIs200(url, package, _htmlGetter, _logger, proxySettings); finalCommand.RunAfterCompletedWithResultTrue = checkUrlHttpStatusIs200; finalCommand.RunAfterCompletedWithResultFalse = new SendErrorNotifications(notificationReceivers, finalCommand.Copy(), _blackboard); finalCommand = checkUrlHttpStatusIs200; } } // ggf. Versionsinfo Datei auslesen if (!string.IsNullOrEmpty(package.Settings.ReadVersionInfoFrom)) { var getVersionInfo = new GetVersionInfo(workFolder, package, package.Settings.ReadVersionInfoFrom, _singleFile, _blackboard); finalCommand.RunAfterCompletedWithResultTrue = getVersionInfo; finalCommand.RunAfterCompletedWithResultFalse = new SendErrorNotifications(notificationReceivers, finalCommand.Copy(), _blackboard); finalCommand = getVersionInfo; } } // Entpacktes Verzeichnis löschen (anhängen immer an finalCommand) var cleanupOldAfterDeployment = new CleanupOldUnpackedFiles(workFolder, package, _directory, _logger); finalCommand.RunAfterCompletedWithResultTrue = cleanupOldAfterDeployment; finalCommand.RunAfterCompletedWithResultFalse = new SendErrorNotifications(notificationReceivers, finalCommand.Copy(), _blackboard); finalCommand = cleanupOldAfterDeployment; // Abschließende Nachricht verschicken (anhängen immer an finalCommand) var sendNotifications = new SendNotifications(notificationReceivers, package.Settings.DownloadOnly, package.Settings.SkipDatabaseUpdate, package, _nowGetter, _blackboard); finalCommand.RunAfterCompletedWithResultTrue = sendNotifications; finalCommand.RunAfterCompletedWithResultFalse = new SendErrorNotifications(notificationReceivers, finalCommand.Copy(), _blackboard); finalCommand = sendNotifications; // Blackboard aufräumen für unser package var cleanupBlackboard = new CleanupBlackboard(package, _blackboard); finalCommand.RunAfterCompletedWithResultTrue = cleanupBlackboard; finalCommand.RunAfterCompletedWithResultFalse = new SendErrorNotifications(notificationReceivers, finalCommand.Copy(), _blackboard); finalCommand = cleanupBlackboard; commands.Enqueue(checkIfNewer); // mit checkIfNewer beginnt die Abarbeitungskette } return commands; }