Esempio n. 1
0
        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)));
        }
Esempio n. 2
0
        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");
                }
            });
        }
Esempio n. 3
0
 public PlanIsRunningUpdatedEventArgs(BackupPlan backupPlan, bool isRunning)
 {
     BackupPlan = backupPlan;
     IsRunning  = isRunning;
 }
Esempio n. 4
0
 public PlanHasErrorsUpdatedEventArgs(BackupPlan backupPlan, bool hasErrors, string statusText = "")
 {
     BackupPlan = backupPlan;
     HasErrors  = hasErrors;
     StatusText = statusText;
 }
Esempio n. 5
0
 public PlanProgressUpdatedEventArgs(BackupPlan backupPlan, int progress)
 {
     BackupPlan = backupPlan;
     Progress   = progress;
 }
Esempio n. 6
0
 public PlanCanExecuteUpdatedEventArgs(BackupPlan backupPlan, bool canExecute)
 {
     BackupPlan = backupPlan;
     CanExecute = canExecute;
 }
Esempio n. 7
0
 public PlanStatusTextUpdatedEventArgs(BackupPlan backupPlan, string statusText)
 {
     BackupPlan = backupPlan;
     StatusText = statusText;
 }
Esempio n. 8
0
 public PlanExecutionEvents(BackupPlan backupPlan)
 {
     this.backupPlan = backupPlan;
 }
Esempio n. 9
0
 public ManualPlanExecution(PlanExecutionHelper planExecutionHelper, BackupPlan backupPlan, PlanExecutionEvents events)
 {
     this.planExecutionHelper = planExecutionHelper;
     this.backupPlan          = backupPlan;
     this.events = events;
 }
Esempio n. 10
0
 public IPlanExecution Create(BackupPlan plan, PlanExecutionEvents events) => new ManualPlanExecution(planExecutionHelper, plan, events);