private async Task ExecutePackage(UpdatePackage package) { // Versioned Commands foreach (var command in EnumerableHelper.Enumerate(package.VersionedCommands)) { try { await ExecuteCommandAsync(command); } catch (Exception ex) { await LogUpdateErrorAsync(package.ModuleIdentifier, command.Version, command.Description, ex); throw; } await LogUpdateSuccessAsync(package.ModuleIdentifier, command.Version, command.Description); } // Always Run Commands foreach (var command in EnumerableHelper.Enumerate(package.AlwaysUpdateCommands)) { await ExecuteCommandAsync(command); } }
private async Task ExecutePackage(UpdatePackage package, CancellationToken?cancellationToken) { // Versioned Commands foreach (var command in EnumerableHelper.Enumerate(package.VersionedCommands)) { if (IsCancelled(cancellationToken)) { // If cancelled, don't try the next version package, but do try and run the always run commands. break; } try { await ExecuteCommandAsync(command); } catch (Exception ex) { await LogUpdateErrorAsync(package.ModuleIdentifier, command.Version, command.Description, ex); throw; } await LogUpdateSuccessAsync(package.ModuleIdentifier, command.Version, command.Description); } // Always Run Commands foreach (var command in EnumerableHelper.Enumerate(package.AlwaysUpdateCommands)) { await ExecuteCommandAsync(command); } }
private IEnumerable <UpdatePackage> FindDependencies(UpdatePackage packageToGetDependenciesFor, Dictionary <string, IEnumerable <UpdatePackage> > dependentModuleLookup) { var dependencies = EnumerableHelper .Enumerate(packageToGetDependenciesFor.DependentModules) .SelectMany(moduleCode => dependentModuleLookup.GetOrDefault(moduleCode, Enumerable.Empty <UpdatePackage>())); return(dependencies); }
public IEnumerable <UpdatePackage> Create(IEnumerable <ModuleVersion> versionHistory) { var moduleVersion = versionHistory.SingleOrDefault(m => m.Module == ModuleIdentifier); var package = new UpdatePackage(); var dbCommandFactory = new DbUpdateCommandFactory(); package.VersionedCommands = dbCommandFactory.Create(GetType().Assembly, moduleVersion, ScriptPath); package.ModuleIdentifier = ModuleIdentifier; package.DependentModules = DependentModules; yield return(package); }