Пример #1
0
        //==============================================
        // Misc
        //==============================================
        #region Misc
        private void SetCurrentStage(OperationStage currentStage)
        {
            if (currentStage != CurrentStage)
            {
                CurrentStage       = currentStage;
                MainButton.Content = currentStage.ToString();
            }

            ToggleMainButton(CurrentStage != OperationStage.Done);
            CleanUpdateCheckBox.IsEnabled = CurrentStage == OperationStage.Update;
        }
Пример #2
0
        /// <summary>
        /// Runs all registered tasks.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="stage">The stage.</param>
        /// <returns>Task.</returns>
        /// <exception cref="Trident.Workflow.WorkFlowCancelledException">Task {task.GetType()} cancelled the workflow during {stage.ToString()} stage of the {context.Operation.ToString()}</exception>
        protected virtual async Task RunTasks(BusinessContext context, OperationStage stage)
        {
            if (this.Tasks != null)
            {
                GuardOnlyOneStageBitSet(stage);

                var tasksToRun = (stage == OperationStage.All)
                    ? this.Tasks
                    : this.Tasks.Where(x => x.Stage.HasFlag(stage)).ToList();

                foreach (var task in tasksToRun)
                {
                    if (await task.ShouldRun(context) && !await task.Run(context))
                    {
                        throw new WorkFlowCancelledException($"Task {task.GetType()} cancelled the workflow during {stage.ToString()} stage of the {context.Operation.ToString()} operation", task.GetType());
                    }
                }
            }
        }