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