public bool CanExecute(BackupPlan plan) { var placeholders = new Placeholders(); systemOperations.LoadSystemPlaceholders(placeholders); var stepTypes = new HashSet <string>(plan.Steps.Select(step => step.StepType)); return (!stepTypes.Select(type => serviceProvider.Get <IStepExecution>(s => s.Type == type) ?.CanExecuteSupportedSteps(plan.Steps, placeholders)) .Any(result => !(result ?? true))); }
public async Task ExecuteAsync(BackupPlan plan, PlanExecutionEvents events) { await Task.Run(() => { try { events.OnIsRunning(true); var placeholders = new Placeholders(); systemOperations.LoadSystemPlaceholders(placeholders); int stepsFinished = 0; events.OnProgress(0); int planProgress = 0; foreach (var step in plan.Steps) { var stepExecution = serviceProvider.Get <IStepExecution>(s => s.Type == step.StepType); if (stepExecution != null) { var stepEvents = new StepExecutionEvents(); stepEvents.ProgressUpdated += (o, e) => events.OnProgress(planProgress + e.Progress / plan.Steps.Count()); stepEvents.StatusTextUpdated += (o, e) => events.OnStatusText(e.StatusText); stepExecution.Execute(step, placeholders, stepEvents); stepsFinished++; planProgress = stepsFinished * 100 / plan.Steps.Count(); events.OnProgress(planProgress); } else { events.OnHasErrors(true, $"Unknown execution step '{step.StepType}'"); break; } } } catch (Exception ex) { events.OnHasErrors(true, ex.Message); } finally { events.OnIsRunning(false); events.OnStatusText("Finished successfully"); } }); }
public PlanIsRunningUpdatedEventArgs(BackupPlan backupPlan, bool isRunning) { BackupPlan = backupPlan; IsRunning = isRunning; }
public PlanHasErrorsUpdatedEventArgs(BackupPlan backupPlan, bool hasErrors, string statusText = "") { BackupPlan = backupPlan; HasErrors = hasErrors; StatusText = statusText; }
public PlanProgressUpdatedEventArgs(BackupPlan backupPlan, int progress) { BackupPlan = backupPlan; Progress = progress; }
public PlanCanExecuteUpdatedEventArgs(BackupPlan backupPlan, bool canExecute) { BackupPlan = backupPlan; CanExecute = canExecute; }
public PlanStatusTextUpdatedEventArgs(BackupPlan backupPlan, string statusText) { BackupPlan = backupPlan; StatusText = statusText; }
public PlanExecutionEvents(BackupPlan backupPlan) { this.backupPlan = backupPlan; }
public ManualPlanExecution(PlanExecutionHelper planExecutionHelper, BackupPlan backupPlan, PlanExecutionEvents events) { this.planExecutionHelper = planExecutionHelper; this.backupPlan = backupPlan; this.events = events; }
public IPlanExecution Create(BackupPlan plan, PlanExecutionEvents events) => new ManualPlanExecution(planExecutionHelper, plan, events);