示例#1
0
        public async Task <Case> Route <TStep>(RouteVariable routeVariable) where TStep : Enum
        {
            //var www = await caseRepository.GetById(caseId);
            var @case = await caseRepository.Get()
                        .Include(a => a.Tracks)
                        .Include(a => a.FlowParameters)
                        .FirstAsync(b => b.Id == routeVariable.CaseId);

            var workFlow    = GetEventInstance <TStep>(@case.WorkFlowReference, @case, routeVariable);
            var currentStep = workFlow.Next();

            @case.Route <TStep>(currentStep);
            caseRepository.Update(@case);
            try
            {
                bpmsUnitOfWork.Commit();
            }
            catch (Exception ex)
            {
                logger.LogError(ex, "CaseRepository");
                throw;
            }
            return(@case);
        }
示例#2
0
        private WorkFlow <TStep> GetEventInstance <TStep>(string workFlowReference, Case @case, RouteVariable routeVariable) where TStep : Enum
        {
            var workflowEnum                     = Enum.Parse(typeof(TStep), @case.Tracks.Single(a => a.IsLatestTrack).FlowStep.ToString()) as Enum;
            var workFlowRefereceType             = Type.GetType(workFlowReference);
            List <IFlowParameter> flowParameters = null;

            if (routeVariable != null && routeVariable.WorkflowParameters != null && routeVariable.WorkflowParameters.Count > 0)
            {
                flowParameters = new List <IFlowParameter>();
                foreach (var workflowParameter in routeVariable.WorkflowParameters)
                {
                    var flowParameter = new FlowParameter(routeVariable.CaseId, workflowParameter.Key, workflowParameter.Value);
                    flowParameters.Add(flowParameter);
                }
            }

            var workflowStep = new WorkflowStep <TStep>((TStep)workflowEnum, new CyclicAssignmentMethod(), new List <Guid>(), string.Empty);
            var instance     = (WorkFlow <TStep>)Activator.CreateInstance(workFlowRefereceType, workflowStep, flowParameters);

            return(instance);
        }