public void BeginExam(BeginExamModel data) { var proxy = new WorkflowProxy(); string processName = data.ProcessName; //获取下一步的NodeName,用于获取该Node对应的Team和用户列表 string nodeName = proxy.GetFirstNodeName(processName); //获取node对应的用户 List<User> users = teamRepo.GetAllUsersByNodeName(processName, nodeName); foreach (User user in users) { var processInstance = new ProcessInstance { ProcessName = processName, Actor = user.UserID, ActorName = user.UserName }; var taskUser = new TaskUser(); taskUser.UserId = user.UserID; taskUser.UserName = user.UserName; taskUser.UserRole = "Student"; processInstance.IncludeActors.Add(taskUser); processInstance = proxy.CreateProcessInstance(processInstance); LogHelper.Instanse.WriteInfo( string.Format("发起流程,用户-{0},InstanceID-{1}", taskUser.UserId, processInstance.InstanceID)); } }
public Process(Context context) : base(context) { Constructor = new ProcessConstructor(context, "Process", new ProcessInstance(context.Events.EventEmitter.InstancePrototype, false)); Instance = Constructor.Construct(); Populate(); }
private static AppProcess SetupAppProcess(ProcessInstance val) { if (!string.Equals(val.Command.ToUpper(), CommandMessage.START)) { return null; } string args = val.ProcessArgs. AddArgument(PROCESS_ARG_KEY.LOG_CONFIG, val.LogConfigFilePath). AddArgument(PROCESS_ARG_KEY.AOTU_RESTART, val.AutoRestart.ToString()). AddArgument(PROCESS_ARG_KEY.NAME, val.Name). AddArgument(PROCESS_ARG_KEY.ID, val.InstanceID.ToString()); AppProcess module = new AppProcess(val.InstanceID, val.Name, val.WorkProcessPath, args, val.AutoRestart); logger.DebugFormat("Setup worker processes for the setting. {0}", val.SerializeToString()); return module; }
/// <summary> /// Saves information about changed scheme to the store /// </summary> /// <param name="processInstance">Instance of the process whith changed scheme <see cref="ProcessInstance.ProcessScheme"/></param> public void BindProcessToNewScheme(ProcessInstance processInstance) { BindProcessToNewScheme(processInstance, false); }
//流程结束事件 void ProcessInstanceEvents_OnProcessCompleted(ProcessInstance ProcInst) { //try //{ // Hashtable paramsTable = GetDataFields(ProcInst); // this.SendArgs(new ProcessCompletedArgs(ProcInst.Originator.Name, ProcInst.Process.SetID, ProcInst.ID, (int)ProcInst.Status, ProcInst.Process.Name, ProcInst.Process.FullName, ProcInst.Folio, paramsTable)); //} //catch (Exception ex) //{ // _log.Error("OnProcessCompleted Error at process " + ProcInst.ID + "and status=" + ProcInst.Status, ex); //} }
/// <summary> /// Set process instance status to <see cref="ProcessStatus.Idled"/> /// </summary> /// <param name="processInstance">Instance of the process</param> /// <exception cref="ImpossibleToSetStatusException"></exception> public void SetWorkflowIdled(ProcessInstance processInstance) { SetCustomStatus(processInstance, ProcessStatus.Idled); }
/// <summary> /// Set process instance status to <see cref="ProcessStatus.Terminated"/> /// </summary> /// <param name="processInstance">Instance of the process</param> /// <exception cref="ImpossibleToSetStatusException"></exception> #pragma warning disable 612 public void SetWorkflowTerminated(ProcessInstance processInstance, ErrorLevel level, string errorMessage) #pragma warning restore 612 { SetCustomStatus(processInstance, ProcessStatus.Terminated); }
public async Task <bool> ExecuteConditionAsync(string name, ProcessInstance processInstance, WorkflowRuntime runtime, string actionParameter, CancellationToken token) { throw new NotImplementedException(); }
/// <summary> /// Saves persisted <see cref="ParameterPurpose.Persistence"/> parameters of the process to store /// </summary> /// <param name="processInstance">Instance of the process</param> public void SavePersistenceParameters(ProcessInstance processInstance) { var parametersToSave = processInstance.ProcessParameters.Where(ptp => ptp.Purpose == ParameterPurpose.Persistence && ptp.Value != null) .ToDictionary(ptp => ptp.Name, ptp => { if (ptp.Type == typeof(UnknownParameterType)) { return((string)ptp.Value); } return(ParametersSerializer.Serialize(ptp.Value, ptp.Type)); }); var parametersToRemove = processInstance.ProcessParameters.Where(ptp => ptp.Purpose == ParameterPurpose.Persistence && ptp.Value == null).Select(ptp => ptp.Name).ToList(); if (!parametersToSave.Any() && !parametersToRemove.Any()) { return; } var db = _connector.GetDatabase(); var key = GetKeyForProcessPersistence(processInstance.ProcessId); var oldPrarmetersValue = db.StringGet(key); if (!oldPrarmetersValue.HasValue) { if (parametersToSave.Any()) { db.StringSet(key, JsonConvert.SerializeObject(parametersToSave)); } } else { var existingParameters = JsonConvert.DeserializeObject <Dictionary <string, string> >(oldPrarmetersValue); parametersToRemove.ForEach(p => existingParameters.Remove(p)); foreach (var ptsKey in parametersToSave.Keys) { if (existingParameters.ContainsKey(ptsKey)) { existingParameters[ptsKey] = parametersToSave[ptsKey]; } else { existingParameters.Add(ptsKey, parametersToSave[ptsKey]); } } if (existingParameters.Any()) { db.StringSet(key, JsonConvert.SerializeObject(existingParameters)); } else { db.KeyDelete(key); } } }
public void Holiday() { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load("Definitions\\Holiday.xml"); //using (var unitWork = UnitOfWork.Start()) //{ // ProcessDefinitionCreationContext creationContext = new ProcessDefinitionCreationContext(); // ProcessDefinition processDefinition = creationContext.CreateProcessDefinition(xmlDocument); // creationContext.ResolveReferences(); // var processBlockRepository = new EFRepository<ProcessBlock>(); // processBlockRepository.Add(processDefinition); // unitWork.Flush(); //} //using (var unitWork = UnitOfWork.Start()) //{ // var processDefinitionRepository = new EFRepository<ProcessDefinition>(); // ProcessDefinition processDefinition = // processDefinitionRepository.With(w => w.Nodes).With(w => w.Attributes).First(); // ProcessInstance processInstance = new ProcessInstance(processDefinition); // ExecutionContext executionContext = new ExecutionContext(processDefinition, processInstance); // IDictionary<string, object> attributeValues = new Dictionary<string, object>(); // attributeValues.Add("requester", "hugo"); // attributeValues.Add("start date", DateTime.Today); // attributeValues.Add("end dat", DateTime.Today); // executionContext.StartProcess(); // var processInstanceRepository = new EFRepository<ProcessInstance>(); // processInstanceRepository.Add(processInstance); // unitWork.Flush(); //} //進入evaluation,分成兩個分支 //using (var unitWork = UnitOfWork.Start()) //{ // var processDefinitionRepository = new EFRepository<ProcessDefinition>(); // ProcessDefinition processDefinition = processDefinitionRepository.First(); // var processInstanceRepository = new EFRepository<ProcessInstance>(); // ProcessInstance processInstance = processInstanceRepository.With(w => w.RootFlow).First(); // IRepository<Flow> flowRepository = new EFRepository<Flow>(); // var rootFlow = // flowRepository.With(w => w.Node) // .With(w => w.AttributeInstances) // .With<AttributeInstance>(w => w.Attribute) // .With(w =>w.Children) // .Single(s => s.Id == processInstance.RootFlow.Id); // ExecutionContext executionContext = new ExecutionContext(processDefinition, processInstance, rootFlow); // IDictionary<string, object> attributeValues = new Dictionary<string, object>(); // attributeValues.Add("evaluation result", "approve"); // executionContext.PerformActivity(attributeValues); // processInstanceRepository.Save(processInstance); // unitWork.Flush(); //} //HR notification -> Join //using (var unitWork = UnitOfWork.Start()) //{ // var processDefinitionRepository = new EFRepository<ProcessDefinition>(); // ProcessDefinition processDefinition = processDefinitionRepository.First(); // var processInstanceRepository = new EFRepository<ProcessInstance>(); // ProcessInstance processInstance = processInstanceRepository.First(); // IRepository<Flow> flowRepository = new EFRepository<Flow>(); // var hrFlow = // flowRepository.With(w => w.Node) // .With(w => w.AttributeInstances) // .With<AttributeInstance>(w => w.Attribute) // .With(w => w.Children) // .With(w => w.Parent) // .Single(s => s.Name == "hr"); // ExecutionContext executionContext = new ExecutionContext(processDefinition, processInstance, hrFlow); // executionContext.PerformActivity(); // processInstanceRepository.Save(processInstance); // unitWork.Flush(); //} //approval notification -> Join using (var unitWork = UnitOfWork.Start()) { var processDefinitionRepository = new EFRepository <ProcessDefinition>(); ProcessDefinition processDefinition = processDefinitionRepository.First(); var processInstanceRepository = new EFRepository <ProcessInstance>(); ProcessInstance processInstance = processInstanceRepository.First(); IRepository <Flow> flowRepository = new EFRepository <Flow>(); var requesterFlow = flowRepository.With(w => w.Node) .With(w => w.AttributeInstances) .With(w => w.Children) .With(w => w.Parent) .Single(s => s.Name == "requester"); ExecutionContext executionContext = new ExecutionContext(new User("ae"), processDefinition, processInstance, requesterFlow); executionContext.PerformActivity(); processInstanceRepository.Save(processInstance); unitWork.Flush(); } }
public void SetWorkflowTerminated(ProcessInstance processInstance, ErrorLevel level, string errorMessage) { SetCustomStatus(processInstance.ProcessId, ProcessStatus.Terminated); }
public bool AuthorManagerCheck(ProcessInstance processInstance, WorkflowRuntime runtime, string identityId, string parameter) { var managers = Document.GetAuthorManagers(processInstance.ProcessId); return(managers != null?managers.Select(c => c.ToString()).ToList().Contains(identityId) : false); }
public void HelloWorld2() { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load("Definitions\\HelloWorld2.xml"); ProcessDefinition processDefinition = new ProcessDefinition(); ProcessInstance processInstance = new ProcessInstance(); var user = new User("h.c"); #region no use using (var unitWork = UnitOfWork.Start()) { ProcessDefinitionCreationContext creationContext = new ProcessDefinitionCreationContext(); processDefinition = creationContext.CreateProcessDefinition(xmlDocument); creationContext.ResolveReferences(); var processBlockRepository = new EFRepository <ProcessBlock>(); if (!processBlockRepository.Any(s => s.Name == processDefinition.Name)) { processBlockRepository.Add(processDefinition); } unitWork.Flush(); } // 准备processInstance using (var unitWork = UnitOfWork.Start()) { var processDefinitionRepository = new EFRepository <ProcessDefinition>(); processDefinition = processDefinitionRepository.With(w => w.Nodes).With(w => w.Attributes).FirstOrDefault(s => s.Name == "Hello world 2"); //ProcessInstance processInstance = new ProcessInstance(new User("ae"), processDefinition); //ExecutionContext executionContext = new ExecutionContext(processDefinition, processInstance); var userContext = new EFRepository <User>(); user = userContext.FirstOrDefault(s => s.UniqueName == user.UniqueName); ExecutionContext executionContext = new ExecutionContext(user, processDefinition); //ProcessInstance processInstance = executionContext.StartProcess(); //var processInstanceRepository = new EFRepository<ProcessInstance>(); //processInstanceRepository.Add(processInstance); processInstance = executionContext.StartProcess(); var processInstanceRepository = new EFRepository <ProcessInstance>(); processInstanceRepository.Add(processInstance); unitWork.Flush(); } #endregion using (var unitWork = UnitOfWork.Start()) { //var processDefinitionRepository = new EFRepository<ProcessDefinition>(); //ProcessDefinition processDefinition = processDefinitionRepository.Where(s => s.Name == "Hello world 2").FirstOrDefault(); var processInstanceRepository = new EFRepository <ProcessInstance>(); // 获得第一个进程实例,该方法无法获得预定(helloworld2) // processInstance = processInstanceRepository.With(w => w.RootFlow).FirstOrDefault(s => s.ProcessDefinitionId == processDefinition.Id); IRepository <Flow> flowRepository = new EFRepository <Flow>(); var rootFlow = flowRepository.With(w => w.Node) .With(w => w.AttributeInstances) .Single(q => q.ProcessInstanceId == processInstance.Id); ExecutionContext executionContext = new ExecutionContext(user, processDefinition, processInstance, rootFlow); IDictionary <string, object> attributeValues = new Dictionary <string, object>(); attributeValues.Add("the text attrib", ":-("); executionContext.PerformActivity(attributeValues); processInstanceRepository.Save(processInstance); unitWork.Flush(); } }
public IEnumerable <string> AuthorManagerGet(ProcessInstance processInstance, WorkflowRuntime runtime, string parameter) { var managers = Document.GetAuthorManagers(processInstance.ProcessId); return(managers != null?managers.Select(c => c.ToString()).ToList() : new List <string>()); }
public virtual void testFailedTask() { ProcessInstance pi = runtimeService.startProcessInstanceByKey("failedTask"); assertJobRetriesForActivity(pi, "failingTask"); }
public virtual void FAILING_testFailedIntermediateThrowingSignalEvent() { ProcessInstance pi = runtimeService.startProcessInstanceByKey("failedIntermediateThrowingSignalEvent"); assertJobRetriesForActivity(pi, "failingSignalEvent"); }
/// <summary> /// </summary> /// <param name="instanceid">流程ID</param> /// <param name="tokenid">节点ID</param> /// <param name="transitionName">按钮名称(离开当前节点的TransitionName)</param> public void Process(ProcessModel data) { var proxy = new WorkflowProxy(); var processInstance = new ProcessInstance(); processInstance.InstanceID = data.InstanceId; processInstance.TokenID = data.TokenId; processInstance.RouterName = data.TransitionName; var item = new VariableInstance(); if (processInstance.RouterName == "到是否参加社会保险") { int flag = 0; if (!string.IsNullOrWhiteSpace(data.TemplateData)) { dynamic jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject<object>(data.TemplateData); string idCardNumber = jsonObj.ShenFenZhengHaoMa; if (socialSpRepo.Entities.Any(m => m.IDCardNumber == idCardNumber)) { flag = 1; } else { flag = 0; socialSpRepo.Insert(new SocialSecurityPersonnel() { IDCardNumber = idCardNumber }); } } item.VariableName = "flag"; item.Value = flag; processInstance.Variables.Add(item); } //将表单数据保存至流程的变量中,以便在审核环节能够读出表单的数据(变量值不能超过2000) if (!string.IsNullOrWhiteSpace(data.TemplateData)) { VariableInstance pageUrl = proxy.GetCurrentTaskSetPage(processInstance.InstanceID, processInstance.TokenID); item = new VariableInstance(); item.Value = data.TemplateData; item.VariableName = pageUrl.Value.ToString(); processInstance.Variables.Add(item); } //获取下一个节点名并启动流程 string userId = ""; var list = proxy.GetTransitionNextNodeRoles(data.DefineName, data.TokenName, data.TransitionName); if (list != null && list.Count > 0) { string nodeName = list[0]; User choosenUser = teamRepo.GetNextUserByNodeName(data.DefineName, nodeName); //var choosenUser = GetRandomUserId(users); if (choosenUser == null) { throw new BusinessException("找不到下一步处理人"); } assignedUserRepo.Insert(new AssignedUser { InDate = DateTime.Now, InstanceID = data.InstanceId, UserID = choosenUser.UserID, Nodename = nodeName, ProcessName = data.DefineName, InUser = data.User.UserID }); var user = new TaskUser { UserId = choosenUser.UserID, UserName = choosenUser.UserName }; userId = choosenUser.UserID; processInstance.IncludeActors.Add(user); } proxy.ProcessExecuter(processInstance); LogHelper.Instanse.WriteInfo( string.Format("InstanceID:-{0},TokenID:-{1},推给了-{2}", processInstance.InstanceID, processInstance.TokenID, userId)); if (!string.IsNullOrEmpty(data.TemplateData)) { userAnswerRepo.Insert(new UserAnwser() { TemplateData = data.TemplateData, TemplateName = data.TemplateName, InDate = DateTime.Now, ProcessName = data.DefineName, NodeName = data.TokenName, UserID = data.User.UserID, InstanceID = data.InstanceId, TokenID = data.TokenId }); } }
public void UpdatePersistenceState(ProcessInstance processInstance, TransitionDefinition transition) { var paramIdentityId = processInstance.GetParameter(DefaultDefinitions.ParameterIdentityId.Name); var paramImpIdentityId = processInstance.GetParameter(DefaultDefinitions.ParameterImpersonatedIdentityId.Name); var identityId = paramIdentityId == null ? string.Empty : (string)paramIdentityId.Value; var impIdentityId = paramImpIdentityId == null ? identityId : (string)paramImpIdentityId.Value; var dbcoll = Store.GetCollection <WorkflowProcessInstance>(MongoDBConstants.WorkflowProcessInstanceCollectionName); WorkflowProcessInstance inst = dbcoll.FindOneById(processInstance.ProcessId); if (inst != null) { if (!string.IsNullOrEmpty(transition.To.State)) { inst.StateName = transition.To.State; } inst.ActivityName = transition.To.Name; inst.PreviousActivity = transition.From.Name; if (!string.IsNullOrEmpty(transition.From.State)) { inst.PreviousState = transition.From.State; } if (transition.Classifier == TransitionClassifier.Direct) { inst.PreviousActivityForDirect = transition.From.Name; if (!string.IsNullOrEmpty(transition.From.State)) { inst.PreviousStateForDirect = transition.From.State; } } else if (transition.Classifier == TransitionClassifier.Reverse) { inst.PreviousActivityForReverse = transition.From.Name; if (!string.IsNullOrEmpty(transition.From.State)) { inst.PreviousStateForReverse = transition.From.State; } } dbcoll.Save(inst); } var history = new WorkflowProcessTransitionHistory() { ActorIdentityId = impIdentityId, ExecutorIdentityId = identityId, Id = Guid.NewGuid(), IsFinalised = false, ProcessId = processInstance.ProcessId, FromActivityName = transition.From.Name, FromStateName = transition.From.State, ToActivityName = transition.To.Name, ToStateName = transition.To.State, TransitionClassifier = transition.Classifier.ToString(), TransitionTime = _runtime.RuntimeDateTimeNow, TriggerName = string.IsNullOrEmpty(processInstance.ExecutedTimer) ? processInstance.CurrentCommand : processInstance.ExecutedTimer }; var dbcollTransition = Store.GetCollection <WorkflowProcessTransitionHistory>(MongoDBConstants.WorkflowProcessTransitionHistoryCollectionName); dbcollTransition.Insert(history); }
public virtual void testFailedIntermediateCatchingTimerEvent() { ProcessInstance pi = runtimeService.startProcessInstanceByKey("failedIntermediateCatchingTimerEvent"); assertJobRetriesForActivity(pi, "failingTimerEvent"); }
public async Task <IEnumerable <string> > MyRuleGetAsync(ProcessInstance processInstance, WorkflowRuntime runtime, string parameter) { return(new List <string>()); }
/// <summary> /// Fills system <see cref="ParameterPurpose.System"/> parameters of the process /// </summary> /// <param name="processInstance">Instance of the process</param> public void FillSystemProcessParameters(ProcessInstance processInstance) { var db = _connector.GetDatabase(); var workflowProcessInstanceValue = db.StringGet(GetKeyForProcessInstance(processInstance.ProcessId)); if (!workflowProcessInstanceValue.HasValue) { throw new ProcessNotFoundException(processInstance.ProcessId); } var workflowProcessInstance = JsonConvert.DeserializeObject <WorkflowProcessInstance>(workflowProcessInstanceValue); var systemParameters = processInstance.ProcessScheme.Parameters.Where(p => p.Purpose == ParameterPurpose.System).ToList(); var parameters = new List <ParameterDefinitionWithValue>(systemParameters.Count) { ParameterDefinition.Create( systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterProcessId.Name), processInstance.ProcessId), ParameterDefinition.Create( systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterPreviousState.Name), workflowProcessInstance.PreviousState), ParameterDefinition.Create( systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterCurrentState.Name), workflowProcessInstance.StateName), ParameterDefinition.Create( systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterPreviousStateForDirect.Name), workflowProcessInstance.PreviousStateForDirect), ParameterDefinition.Create( systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterPreviousStateForReverse.Name), workflowProcessInstance.PreviousStateForReverse), ParameterDefinition.Create( systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterPreviousActivity.Name), workflowProcessInstance.PreviousActivity), ParameterDefinition.Create( systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterCurrentActivity.Name), workflowProcessInstance.ActivityName), ParameterDefinition.Create( systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterPreviousActivityForDirect.Name), workflowProcessInstance.PreviousActivityForDirect), ParameterDefinition.Create( systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterPreviousActivityForReverse.Name), workflowProcessInstance.PreviousActivityForReverse), ParameterDefinition.Create( systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterSchemeCode.Name), processInstance.ProcessScheme.Name), ParameterDefinition.Create( systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterSchemeId.Name), workflowProcessInstance.SchemeId), ParameterDefinition.Create( systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterIsPreExecution.Name), false), ParameterDefinition.Create( systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterParentProcessId.Name), workflowProcessInstance.ParentProcessId), ParameterDefinition.Create( systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterRootProcessId.Name), workflowProcessInstance.RootProcessId) }; processInstance.AddParameters(parameters); }
public bool MyRuleCheck(ProcessInstance processInstance, WorkflowRuntime runtime, string identityId, string parameter) { return(false); }
/// <summary> /// Set process instance status to <see cref="ProcessStatus.Initialized"/> /// </summary> /// <param name="processInstance">Instance of the process</param> /// <exception cref="ImpossibleToSetStatusException"></exception> public void SetWorkflowIniialized(ProcessInstance processInstance) { SetCustomStatus(processInstance, ProcessStatus.Initialized, true); }
public async Task <bool> MyRuleCheckAsync(ProcessInstance processInstance, WorkflowRuntime runtime, string identityId, string parameter) { return(false); }
/// <summary> /// Set process instance status to <see cref="ProcessStatus.Finalized"/> /// </summary> /// <param name="processInstance">Instance of the process</param> /// <exception cref="ImpossibleToSetStatusException"></exception> public void SetWorkflowFinalized(ProcessInstance processInstance) { SetCustomStatus(processInstance, ProcessStatus.Finalized); }
/// <summary> /// /// </summary> public ProcessCompletedEventImpl(string appName, string appVersion, string serviceName, string serviceFullName, string serviceType, string serviceVersion, string executionId, string processDefinitionId, string processInstanceId, ProcessInstance processInstance) : base(appName, appVersion, serviceName, serviceFullName, serviceType, serviceVersion, executionId, processDefinitionId, processInstanceId) { this.processInstance = processInstance; }
/// <summary> /// Updates system parameters of the process in the store /// </summary> /// <param name="processInstance">Instance of the process</param> /// <param name="transition">Last executed transition</param> public void UpdatePersistenceState(ProcessInstance processInstance, TransitionDefinition transition) { var db = _connector.GetDatabase(); var key = GetKeyForProcessInstance(processInstance.ProcessId); var processInstanceValue = db.StringGet(key); if (!processInstanceValue.HasValue) { throw new ProcessNotFoundException(processInstance.ProcessId); } var inst = JsonConvert.DeserializeObject <WorkflowProcessInstance>(processInstanceValue); var paramIdentityId = processInstance.GetParameter(DefaultDefinitions.ParameterIdentityId.Name); var paramImpIdentityId = processInstance.GetParameter(DefaultDefinitions.ParameterImpersonatedIdentityId.Name); var identityId = paramIdentityId == null ? string.Empty : (string)paramIdentityId.Value; var impIdentityId = paramImpIdentityId == null ? identityId : (string)paramImpIdentityId.Value; if (!string.IsNullOrEmpty(transition.To.State)) { inst.StateName = transition.To.State; } inst.ActivityName = transition.To.Name; inst.PreviousActivity = transition.From.Name; if (!string.IsNullOrEmpty(transition.From.State)) { inst.PreviousState = transition.From.State; } if (transition.Classifier == TransitionClassifier.Direct) { inst.PreviousActivityForDirect = transition.From.Name; if (!string.IsNullOrEmpty(transition.From.State)) { inst.PreviousStateForDirect = transition.From.State; } } else if (transition.Classifier == TransitionClassifier.Reverse) { inst.PreviousActivityForReverse = transition.From.Name; if (!string.IsNullOrEmpty(transition.From.State)) { inst.PreviousStateForReverse = transition.From.State; } } inst.ParentProcessId = processInstance.ParentProcessId; inst.RootProcessId = processInstance.RootProcessId; var history = new WorkflowProcessTransitionHistory() { ActorIdentityId = impIdentityId, ExecutorIdentityId = identityId, IsFinalised = transition.To.IsFinal, FromActivityName = transition.From.Name, FromStateName = transition.From.State, ToActivityName = transition.To.Name, ToStateName = transition.To.State, TransitionClassifier = transition.Classifier.ToString(), TransitionTime = _runtime.RuntimeDateTimeNow, TriggerName = string.IsNullOrEmpty(processInstance.ExecutedTimer) ? processInstance.CurrentCommand : processInstance.ExecutedTimer }; var batch = db.CreateBatch(); batch.StringSetAsync(key, JsonConvert.SerializeObject(inst)); batch.ListRightPushAsync(GetKeyForProcessHistory(processInstance.ProcessId), JsonConvert.SerializeObject(history)); batch.Execute(); }
public JoinPoint(ProcessInstance processInstance) { this._processInstance = processInstance; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Deployment public void testCompletingJoinInSubProcess() public virtual void testCompletingJoinInSubProcess() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); assertTrue(processInstance.Ended); }
public void UpdatePersistenceState(ProcessInstance processInstance, TransitionDefinition transition) { var paramIdentityId = processInstance.GetParameter(DefaultDefinitions.ParameterIdentityId.Name); var paramImpIdentityId = processInstance.GetParameter(DefaultDefinitions.ParameterImpersonatedIdentityId.Name); var identityId = paramIdentityId == null ? string.Empty : (string)paramIdentityId.Value; var impIdentityId = paramImpIdentityId == null ? identityId : (string)paramImpIdentityId.Value; using (var connection = new NpgsqlConnection(ConnectionString)) { var inst = WorkflowProcessInstance.SelectByKey(connection, processInstance.ProcessId); if (inst != null) { if (!string.IsNullOrEmpty(transition.To.State)) { inst.StateName = transition.To.State; } inst.ActivityName = transition.To.Name; inst.PreviousActivity = transition.From.Name; if (!string.IsNullOrEmpty(transition.From.State)) { inst.PreviousState = transition.From.State; } if (transition.Classifier == TransitionClassifier.Direct) { inst.PreviousActivityForDirect = transition.From.Name; if (!string.IsNullOrEmpty(transition.From.State)) { inst.PreviousStateForDirect = transition.From.State; } } else if (transition.Classifier == TransitionClassifier.Reverse) { inst.PreviousActivityForReverse = transition.From.Name; if (!string.IsNullOrEmpty(transition.From.State)) { inst.PreviousStateForReverse = transition.From.State; } } inst.ParentProcessId = processInstance.ParentProcessId; inst.RootProcessId = processInstance.RootProcessId; inst.Update(connection); } var history = new WorkflowProcessTransitionHistory() { ActorIdentityId = impIdentityId, ExecutorIdentityId = identityId, Id = Guid.NewGuid(), IsFinalised = false, ProcessId = processInstance.ProcessId, FromActivityName = transition.From.Name, FromStateName = transition.From.State, ToActivityName = transition.To.Name, ToStateName = transition.To.State, TransitionClassifier = transition.Classifier.ToString(), TransitionTime = _runtime.RuntimeDateTimeNow, TriggerName = string.IsNullOrEmpty(processInstance.ExecutedTimer) ? processInstance.CurrentCommand : processInstance.ExecutedTimer }; history.Insert(connection); } }
//转换DataFields private static Hashtable GetDataFields(ProcessInstance procInst) { var paramsTable = new Hashtable(); foreach (DataField dataField in procInst.DataFields) { if (dataField.Value.GetType() == typeof(DateTime)) { _log.WarnFormat("发现DateTime类型的流程变量,请尽快修改避免使用,Key={0}|Value={1}|ProcInstId={2}" , dataField.Name , dataField.Value , procInst.ID); var time = (DateTime)dataField.Value; if (time > DateTime.MaxValue) paramsTable.Add(dataField.Name, DateTime.MaxValue); if (time < DateTime.MinValue) paramsTable.Add(dataField.Name, DateTime.MinValue); } else paramsTable.Add(dataField.Name, dataField.Value); } return paramsTable; }
public string StartProcessInstance(string definitionId, string inputXml, string processCorrelationId) { try { ProcessDefinition pd = PackageRepository.GetProcess(definitionId); if (pd == null) throw new ApplicationException("Process definition not found: " + definitionId); pd.ValidateProcessInputXml(inputXml); using (TransactionScope ts = new TransactionScope(_transactionOption)) { ProcessInstance pi = new ProcessInstance(); pi.StartDate = DateTime.Now; pi.StartedBy = System.Threading.Thread.CurrentPrincipal.Identity.Name; pi.InstanceId = Guid.NewGuid().ToString("N"); pi.ProcessDefinitionId = definitionId; pi.Environment = this; pi.Activate(); log.Info("Created new process instance for process {0}.{1}: {2}", pd.Name, pd.Version, pi.InstanceId); pi.SetProcessInputData(inputXml); pi.CreateStartToken(); pi.Passivate(); InstanceRepository.InsertNewProcessInstance(pi); ts.Complete(); NotifyReadyProcessSaved(); return pi.InstanceId; } } catch (Exception ex) { log.Error(string.Format("Error starting process: {0}", ex)); throw; } }
public MultiInstanceTask(Task tsk, ProcessInstance pi) : base(tsk, pi) { }
/// <summary> /// Called before serialization /// </summary> public virtual void Passivate() { _processInstance = null; _activated = false; }
public void FillPersistedProcessParameters(ProcessInstance processInstance) { processInstance.AddParameters(GetPersistedProcessParameters(processInstance.ProcessId, processInstance.ProcessScheme)); }
public virtual void testFailedBoundaryTimerEvent() { ProcessInstance pi = runtimeService.startProcessInstanceByKey("failedBoundaryTimerEvent"); assertJobRetriesForActivity(pi, "userTask"); }
public void FillSystemProcessParameters(ProcessInstance processInstance) { processInstance.AddParameters(GetSystemProcessParameters(processInstance.ProcessId, processInstance.ProcessScheme)); }
/// <summary> /// Fills system <see cref="ParameterPurpose.System"/> and persisted <see cref="ParameterPurpose.Persistence"/> parameters of the process /// </summary> /// <param name="processInstance">Instance of the process</param> public void FillProcessParameters(ProcessInstance processInstance) { FillPersistedProcessParameters(processInstance); FillSystemProcessParameters(processInstance); }
public virtual void SetProcessInstance(ProcessInstance pi) { if (this.ProcessInstanceId != null && this.ProcessInstanceId != pi.InstanceId) throw new ApplicationException("Invalid process instance ID"); this._processInstance = pi; }
private async Task <bool> MyAsyncCondition(ProcessInstance processInstance, WorkflowRuntime runtime, string actionParameter, CancellationToken token) { //Execute your asynchronous code here. You can use await in your code. return(false); }