コード例 #1
0
        public bool UpdateWorkflow(WorkflowDC workflow)
        {
            Enforce.ArgumentNotNull(workflow, "workflow");
            Enforce.ArgumentNotNull(workflow.Id, "workflow.Id");
            Enforce.ArgumentNotNull(workflow.StartState, "workflow.StartState");
            Enforce.ArgumentNotNull(workflow.DisplayName, "workflow.DisplayName");
            Enforce.ArgumentGreaterThanZero(workflow.States.Count, "workflow.States");

            var validator            = new WorkflowValidation();
            ValidationResult results = validator.Validate(workflow);

            IRepositoryHelper repoHelper = new RepositoryHelper(_connectionString);

            try
            {
                var unitOfWork      = new JsonUnitOfWork(_connectionString);
                var wfRepo          = new WorkflowRepository(unitOfWork);
                var workflowUpdated = wfRepo.Update(workflow.GetWorkflow());

                var stateRepo = new StateRepository(unitOfWork);
                stateRepo.SetWorkflowStates(workflow.Id, workflow.States.ToRepoList());

                var actRepo = new StateActivityRepository(unitOfWork);
                actRepo.SetWorkflowStates(workflow.Id, workflow.Activities.ToRepoList());

                var tranRepo = new StateTransitionRepository(unitOfWork);
                tranRepo.SetWorkflowStates(workflow.Id, workflow.Transitions.ToRepoList());

                repoHelper.GetUnitOfWork().SaveChanges();
            }
            catch (Exception ex)
            {
                var message = ex.Message;
                throw;
            }
            return(true);
        }
コード例 #2
0
 /// <summary>
 /// Validate the workplan under different aspects. Aspects can be combined using '|' operator.
 /// </summary>
 /// <param name="workplan">Workplan to validate</param>
 /// <param name="aspects">Enum flag aspects to validate</param>
 /// <returns><remarks>True</remarks> if validation succeeded. Otherwise <remarks>false</remarks>.</returns>
 public static ValidationResult Validate(IWorkplan workplan, ValidationAspect aspects)
 {
     return(WorkflowValidation.Validate(workplan, aspects));
 }