public static async Task <WorkflowHandlingResponse> StartWorkflowAsync( WorkflowStartInfo startInfo) { WorkflowHandlingResponse handlingResponse = await WorkflowManager.wfHandler.StartWorkflowAsync(startInfo); return(handlingResponse); }
public WorkflowHandlingResponse StartWorkflow( WorkflowStartInfo startInfo) { WorkflowFindData workflowFindData = new WorkflowFindData() { StartType = startInfo.StartType, Code = startInfo.Code }; WorkflowInfo wfInfo = this.FindWorkflow(workflowFindData); if (wfInfo == null) { throw new WorkflowException(string.Format("workflow with code: '{0}' not found", (object)workflowFindData.Code)); } using (UnitOfWork unitOfWork = new UnitOfWork((IDataContextAsync) new WorkflowDbContext())) { WorkflowStep workflowStep = unitOfWork.RepositoryAsync <WorkflowStep>().Queryable(false, true, (List <Expression <Func <WorkflowStep, object> > >)null).Where <WorkflowStep>((Expression <Func <WorkflowStep, bool> >)(wfStep => (int)wfStep.StepType == 1 && wfStep.WorkflowInfoId == wfInfo.ID)).SingleOrDefault <WorkflowStep>(); if (workflowStep == null) { throw new WorkflowException(string.Format("no start step for workflow with code '{0}'", (object)startInfo.Code)); } int?nullable = startInfo.StarterOrganizationId; if (!nullable.HasValue && SecurityManager.CurrentUserContext != null) { startInfo.StarterOrganizationId = SecurityManager.CurrentUserContext.OrganizationId; } if (startInfo.ExchangeData == null) { startInfo.ExchangeData = new WFExchangeData(); } List <WorkflowInstanceState> workflowInstanceStateList = new List <WorkflowInstanceState>(); WorkflowInstanceState workflowInstanceState1 = new WorkflowInstanceState(); workflowInstanceState1.AccomplishTime = new DateTime?(DateTime.Now); workflowInstanceState1.ExchangeData = (string)startInfo.ExchangeData; workflowInstanceState1.InstantiationTime = DateTime.Now; workflowInstanceState1.ObjectState = ObjectState.Added; nullable = new int?(); workflowInstanceState1.SenderWorkflowInstanceStateId = nullable; workflowInstanceState1.UserComment = "شروع فرایند"; workflowInstanceState1.StateStatus = WfStateStatus.Close; workflowInstanceState1.Title = string.Format("شروع فرایند {0} {1}", (object)wfInfo.Title, (object)startInfo.InstanceTitle); workflowInstanceState1.UserId = startInfo.StarterUserId; workflowInstanceState1.WorkflowStepId = workflowStep.ID; WorkflowInstanceState workflowInstanceState2 = workflowInstanceState1; workflowInstanceStateList.Add(workflowInstanceState2); WFExchangeData wfExchangeData1 = new WFExchangeData(); WFExchangeData wfExchangeData2 = wfExchangeData1; nullable = startInfo.StarterOrganizationId; ref int?local1 = ref nullable; int num; string str1; if (!local1.HasValue) { str1 = (string)null; } else { num = local1.GetValueOrDefault(); str1 = num.ToString(); } wfExchangeData2.Add("_StarterOrganizationId_", str1); WFExchangeData wfExchangeData3 = wfExchangeData1; num = startInfo.StarterUserId; string str2 = num.ToString(); wfExchangeData3.Add("_StarterUserId_", str2); wfExchangeData1.Add("_InstanceTitle_", string.Format("{0}", (object)startInfo.InstanceTitle)); wfExchangeData1.Add("_WorkflowTitle_", string.Format("{0}", (object)wfInfo.Title)); wfExchangeData1.Add("_RelatedRecordId_", string.Format("{0}", (object)startInfo.RelatedRecordId)); bool flag = false; WorkflowStep currentStep = workflowStep; WFExchangeData exchangeData = startInfo.ExchangeData; WorkflowInstanceState senderInstanceState = workflowInstanceState2; WFExchangeData initialExchangeData = wfExchangeData1; nullable = new int?(); int? actionId = nullable; ref bool local2 = ref flag;
public static WorkflowHandlingResponse StartWorkflow( WorkflowStartInfo startInfo) { return(WorkflowManager.wfHandler.StartWorkflow(startInfo)); }