public ITaskInstance createTaskInstance(IWorkflowSession currentSession, RuntimeContext runtimeContxt, IProcessInstance processInstance, Task task, Activity activity) { LoanTaskInstance taskInstance = new LoanTaskInstance(); taskInstance.Sn=(String)processInstance.getProcessInstanceVariable("sn"); taskInstance.ApplicantName=(String)processInstance.getProcessInstanceVariable("applicantName"); taskInstance.LoanValue=(int)processInstance.getProcessInstanceVariable("loanValue"); taskInstance.RiskFlag=(Boolean)processInstance.getProcessInstanceVariable("RiskFlag"); taskInstance.Decision=(Boolean)processInstance.getProcessInstanceVariable("Decision"); return taskInstance; }
//throws EngineException ,KernelException public Boolean taskInstanceCanBeCompleted(IWorkflowSession currentSession, RuntimeContext runtimeContext, IProcessInstance processInstance, ITaskInstance taskInstance) { IPersistenceService persistenceService = runtimeContext.PersistenceService; Int32 aliveWorkItemCount = persistenceService.GetAliveWorkItemCountForTaskInstance(taskInstance.Id); if (aliveWorkItemCount == 0) { return true; } else { return false; } }
/// <summary> /// Gets the runtime context. /// </summary> /// <returns></returns> public static RuntimeContext getRuntimeContext() { if (ctx == null) { ctx = new RuntimeContext(); ctx.IsEnableTrace = true; //转移条件表达式解析服务 ctx.ConditionResolver = new FireWorkflow.Net.Engine.Condition.ConditionResolver(); //实例对象存取服务 Type type = Type.GetType("FireWorkflow.Net.Persistence.OracleDAL.PersistenceServiceDAL, FireWorkflow.Net.Persistence.OracleDAL"); if (type != null) { ctx.PersistenceService = (IPersistenceService)Activator.CreateInstance(type, new object[] { "OracleServer" }); } else throw new Exception("默认FireWorkflow.Net.Persistence.OracleDAL程序集没有引入!"); //流程定义服务,通过该服务获取流程定义 DefinitionService4DBMS ds4dbms = new FireWorkflow.Net.Engine.Definition.DefinitionService4DBMS(); //ds4fs.DefinitionFiles.Add("/org/fireflow/example/workflowdefinition/demo_workflow.xml"); ctx.DefinitionService = ds4dbms; //内核管理器 ctx.KernelManager = new KernelManager(); //TaskInstance 管理器,负责TaskInstance的创建、运行、结束。 BasicTaskInstanceManager btim = new FireWorkflow.Net.Engine.Taskinstance.BasicTaskInstanceManager(); btim.DefaultTaskInstanceCreator = new FireWorkflow.Net.Engine.Taskinstance.DefaultTaskInstanceCreator(); btim.DefaultFormTaskInstanceRunner = new FireWorkflow.Net.Engine.Taskinstance.DefaultFormTaskInstanceRunner(); btim.DefaultToolTaskInstanceRunner = new FireWorkflow.Net.Engine.Taskinstance.DefaultToolTaskInstanceRunner(); btim.DefaultSubflowTaskInstanceRunner = new FireWorkflow.Net.Engine.Taskinstance.DefaultSubflowTaskInstanceRunner(); btim.DefaultFormTaskInstanceCompletionEvaluator = new FireWorkflow.Net.Engine.Taskinstance.DefaultFormTaskInstanceCompletionEvaluator(); btim.DefaultToolTaskInstanceCompletionEvaluator = new FireWorkflow.Net.Engine.Taskinstance.DefaultToolTaskInstanceCompletionEvaluator(); btim.DefaultSubflowTaskInstanceCompletionEvaluator = new FireWorkflow.Net.Engine.Taskinstance.DefaultSubflowTaskInstanceCompletionEvaluator(); btim.DefaultTaskInstanceEventListener = new FireWorkflow.Net.Engine.Taskinstance.DefaultTaskInstanceEventListener(); ctx.TaskInstanceManager = btim; //日历服务 ctx.CalendarService = new FireWorkflow.Net.Engine.Calendar.DefaultCalendarService(); //bean工厂,fire workflow默认使用spring作为其实现 lwz 2010-3-21 edit 改为 C# type加载 ctx.BeanFactory = new FireWorkflow.Net.Engine.Beanfactory.BeanFactory(); } return ctx; }
// throws EngineException, KernelException public void run(IWorkflowSession currentSession, RuntimeContext runtimeContext, IProcessInstance processInstance, ITaskInstance taskInstance) { if (taskInstance.TaskType!= TaskTypeEnum.FORM)//!Task.FORM.Equals(taskInstance.TaskType)) { throw new EngineException(processInstance, taskInstance.Activity, "DefaultFormTaskInstanceRunner:TaskInstance的任务类型错误,只能为FORM类型"); } DynamicAssignmentHandler dynamicAssignmentHandler = ((WorkflowSession)currentSession).consumeCurrentDynamicAssignmentHandler(); FormTask task = (FormTask)taskInstance.Task; // performer(id,name,type,handler) Participant performer = task.Performer; if (performer == null || performer.AssignmentHandler.Trim().Equals("")) { throw new EngineException(processInstance, taskInstance.Activity, "流程定义错误,Form类型的 task必须指定performer及其AssignmentHandler"); } assign(currentSession, processInstance, runtimeContext, taskInstance, task, performer, dynamicAssignmentHandler); }
public ITaskInstance createTaskInstance(IWorkflowSession currentSession, RuntimeContext runtimeContxt, IProcessInstance processInstance, Task task, Activity activity) { GoodsDeliverTaskInstance taskInst = new GoodsDeliverTaskInstance(); String sn = (String)processInstance.getProcessInstanceVariable("sn"); taskInst.Sn = sn; String customerName = (String)processInstance.getProcessInstanceVariable("customerName"); taskInst.CustomerName = customerName; String goodsName = (String)processInstance.getProcessInstanceVariable("goodsName"); taskInst.GoodsName = goodsName; long quantity = (long)processInstance.getProcessInstanceVariable("quantity"); taskInst.Quantity = quantity; //taskInst.BizInfo= return taskInst; }
public void setRuntimeContext(RuntimeContext ctx) { this.RuntimeContext = ctx; }
// throws EngineException public ITaskInstance createTaskInstance(IWorkflowSession currentSession, RuntimeContext runtimeContxt, IProcessInstance processInstance, Task task, Activity activity) { TaskInstance taskInstance = new TaskInstance(); return taskInstance; }
/// <summary> /// 判断TaskInstance是否可以结束,缺省的判断规则是:没有活动的WorkItem即可结束。 /// 业务代码可以重载该函数,对特定的Task采取特殊的判断规则。 /// </summary> /// <param name="currentSession"></param> /// <param name="runtimeContext"></param> /// <param name="processInstance"></param> /// <param name="taskInstance"></param> /// <returns></returns> protected Boolean taskInstanceCanBeCompleted(IWorkflowSession currentSession, RuntimeContext runtimeContext, IProcessInstance processInstance, ITaskInstance taskInstance) { Task task = taskInstance.Task; String taskInstanceCompletionEvaluatorName = null; ITaskInstanceCompletionEvaluator taskInstanceCompletionEvaluator = null; TaskTypeEnum taskType = task.TaskType; taskInstanceCompletionEvaluatorName = task.TaskInstanceCompletionEvaluator; if (!String.IsNullOrEmpty(taskInstanceCompletionEvaluatorName.Trim())) { IBeanFactory beanFactory = runtimeContext.BeanFactory; taskInstanceCompletionEvaluator = (ITaskInstanceCompletionEvaluator)beanFactory.GetBean(taskInstanceCompletionEvaluatorName); } if (taskInstanceCompletionEvaluator == null) { if (TaskTypeEnum.FORM == taskType) { taskInstanceCompletionEvaluatorName = processInstance.WorkflowProcess.FormTaskInstanceCompletionEvaluator; } else if (TaskTypeEnum.TOOL == taskType) { taskInstanceCompletionEvaluatorName = processInstance.WorkflowProcess.ToolTaskInstanceCompletionEvaluator; } else if (TaskTypeEnum.SUBFLOW == taskType) { taskInstanceCompletionEvaluatorName = processInstance.WorkflowProcess.SubflowTaskInstanceCompletionEvaluator; } if (!String.IsNullOrEmpty(taskInstanceCompletionEvaluatorName.Trim())) { IBeanFactory beanFactory = runtimeContext.BeanFactory; taskInstanceCompletionEvaluator = (ITaskInstanceCompletionEvaluator)beanFactory.GetBean(taskInstanceCompletionEvaluatorName); } } if (taskInstanceCompletionEvaluator == null) { if (TaskTypeEnum.FORM == taskType) { taskInstanceCompletionEvaluator = this.DefaultFormTaskInstanceCompletionEvaluator; } else if (TaskTypeEnum.TOOL == taskType) { taskInstanceCompletionEvaluator = this.DefaultToolTaskInstanceCompletionEvaluator; } else if (TaskTypeEnum.SUBFLOW == taskType) { taskInstanceCompletionEvaluator = this.DefaultSubflowTaskInstanceCompletionEvaluator; } } if (taskInstanceCompletionEvaluator != null) { return taskInstanceCompletionEvaluator.taskInstanceCanBeCompleted(currentSession, runtimeContext, processInstance, taskInstance); } else { WorkflowProcess process = taskInstance.WorkflowProcess; throw new EngineException(taskInstance.ProcessInstanceId, process, taskInstance.TaskId, "无法获取TaskInstanceCompletionEvaluator,TaskId=" + task.Id + ", taskType=" + taskInstance.TaskType); } }
public Object doInWorkflowSession(RuntimeContext ctx) { switch (t) { case '2': return ctx.PersistenceService.FindProcessInstancesByProcessIdAndVersion(processId, version); //case '3': return ctx.PersistenceService.findProcessInstancesByProcessId(actorId, processId, taskId); default: return ctx.PersistenceService.FindProcessInstancesByProcessId(processId); } }
// throws EngineException, KernelException public void run(IWorkflowSession currentSession, RuntimeContext runtimeContext, IProcessInstance processInstance, ITaskInstance taskInstance) { if (taskInstance.TaskType != TaskTypeEnum.SUBFLOW) { throw new EngineException(processInstance, taskInstance.Activity, "DefaultSubflowTaskInstanceRunner:TaskInstance的任务类型错误,只能为SUBFLOW类型"); } Task task = taskInstance.Task; SubWorkflowProcess Subflow = ((SubflowTask)task).SubWorkflowProcess; WorkflowDefinition subWorkflowDef = runtimeContext.DefinitionService.GetTheLatestVersionOfWorkflowDefinition(Subflow.WorkflowProcessId); if (subWorkflowDef == null) { WorkflowProcess parentWorkflowProcess = taskInstance.WorkflowProcess; throw new EngineException(taskInstance.ProcessInstanceId, parentWorkflowProcess, taskInstance.TaskId, "系统中没有Id为" + Subflow.WorkflowProcessId + "的流程定义"); } WorkflowProcess subWorkflowProcess = subWorkflowDef.getWorkflowProcess(); if (subWorkflowProcess == null) { WorkflowProcess parentWorkflowProcess = taskInstance.WorkflowProcess; throw new EngineException(taskInstance.ProcessInstanceId, parentWorkflowProcess, taskInstance.TaskId, "系统中没有Id为" + Subflow.WorkflowProcessId + "的流程定义"); } IPersistenceService persistenceService = runtimeContext.PersistenceService; //更改任务的状态和开始时间 ((TaskInstance)taskInstance).State = TaskInstanceStateEnum.RUNNING; ((TaskInstance)taskInstance).StartedTime = runtimeContext.CalendarService.getSysDate(); persistenceService.SaveOrUpdateTaskInstance(taskInstance); IProcessInstance subProcessInstance = currentSession.createProcessInstance(subWorkflowProcess.Name, taskInstance); //初始化流程变量,从父实例获得初始值 Dictionary<String, Object> processVars = ((TaskInstance)taskInstance).AliveProcessInstance.ProcessInstanceVariables; List<DataField> datafields = subWorkflowProcess.DataFields; for (int i = 0; datafields != null && i < datafields.Count; i++) { DataField df = (DataField)datafields[i]; if (df.DataType == DataTypeEnum.STRING) { if (processVars[df.Name] != null && (processVars[df.Name] is String)) { subProcessInstance.setProcessInstanceVariable(df.Name, processVars[df.Name]); } else if (df.InitialValue != null) { subProcessInstance.setProcessInstanceVariable(df.Name, df.InitialValue); } else { subProcessInstance.setProcessInstanceVariable(df.Name, ""); } } else if (df.DataType == DataTypeEnum.INTEGER) { if (processVars[df.Name] != null && (processVars[df.Name] is Int32)) { subProcessInstance.setProcessInstanceVariable(df.Name, processVars[df.Name]); } else if (df.InitialValue != null) { try { Int32 intValue = Int32.Parse(df.InitialValue); subProcessInstance.setProcessInstanceVariable(df.Name, intValue); } catch { } } else { subProcessInstance.setProcessInstanceVariable(df.Name, (Int32)0); } } else if (df.DataType == DataTypeEnum.FLOAT) { if (processVars[df.Name] != null && (processVars[df.Name] is float)) { subProcessInstance.setProcessInstanceVariable(df.Name, processVars[df.Name]); } else if (df.InitialValue != null) { float floatValue = float.Parse(df.InitialValue); subProcessInstance.setProcessInstanceVariable(df.Name, floatValue); } else { subProcessInstance.setProcessInstanceVariable(df.Name, (float)0); } } else if (df.DataType == DataTypeEnum.BOOLEAN) { if (processVars[df.Name] != null && (processVars[df.Name] is Boolean)) { subProcessInstance.setProcessInstanceVariable(df.Name, processVars[df.Name]); } else if (df.InitialValue != null) { Boolean booleanValue = Boolean.Parse(df.InitialValue); subProcessInstance.setProcessInstanceVariable(df.Name, booleanValue); } else { subProcessInstance.setProcessInstanceVariable(df.Name, false); } } else if (df.DataType == DataTypeEnum.DATETIME) { //TODO 需要完善一下 ( 父子流程数据传递——时间类型的数据还未做传递-不知道为什么?) //wmj2003 20090925 补充上了 if (processVars[df.Name] != null && (processVars[df.Name] is DateTime)) { subProcessInstance.setProcessInstanceVariable(df.Name, processVars[df.Name]); } else if (df.InitialValue != null) { try { DateTime dateTmp = DateTime.Parse(df.InitialValue); subProcessInstance.setProcessInstanceVariable(df.Name, dateTmp); } catch { subProcessInstance.setProcessInstanceVariable(df.Name, null); } } } //TODO 应将下面这句删除!这里还需要吗?应该直接subProcessInstance.run()就可以了。 runtimeContext.PersistenceService.SaveOrUpdateProcessInstance(subProcessInstance); subProcessInstance.run(); } }
public Object doInWorkflowSession(RuntimeContext ctx) { IPersistenceService persistenceService = ctx.PersistenceService; return persistenceService.FindTaskInstanceById(taskInstanceId); }
public DefinitionService4FileSystem(RuntimeContext rc) { this.RuntimeContext = rc; this.DefinitionFiles = new List<string>(); }
public WorkflowSession(RuntimeContext ctx) { this.RuntimeContext = ctx; }
public Object doInWorkflowSession(RuntimeContext ctx) { ProcessInstance processInstance = new ProcessInstance(); processInstance.CreatorId=creatorId; processInstance.ProcessId=wfProcess.Id; processInstance.Version=workflowDef.Version; processInstance.DisplayName = wfProcess.DisplayName; processInstance.Name = wfProcess.Name; processInstance.State = ProcessInstanceEnum.INITIALIZED; processInstance.CreatedTime=ctx.CalendarService.getSysDate(); processInstance.ParentProcessInstanceId=parentProcessInstanceId; processInstance.ParentTaskInstanceId=parentTaskInstanceId; ctx.PersistenceService.SaveOrUpdateProcessInstance(processInstance); return processInstance; }
public bool taskInstanceCanBeCompleted(IWorkflowSession currentSession, RuntimeContext runtimeContext, IProcessInstance processInstance, ITaskInstance taskInstance) { IPersistenceService persistenceService = runtimeContext.PersistenceService; List<IWorkItem> workItems = persistenceService.FindWorkItemsForTaskInstance(taskInstance.Id); //从流程变量中获取业务流水号 String sn = (String)processInstance.getProcessInstanceVariable("sn"); //已经完成的WorkItem数量 int completedWorkItemCount = 0; //审批同意的决定的数量 int approvedDecitionCount = 0; StringBuilder examinerList = new StringBuilder();//所有审核人名单 StringBuilder approverList = new StringBuilder();//同意者名单 StringBuilder opponentList = new StringBuilder();//不同意者名单 for (int i = 0; i < workItems.Count; i++) { IWorkItem wi = workItems[i]; if (wi.State == WorkItemEnum.COMPLETED) { completedWorkItemCount++; WebDemo.Example.LoanProcess.Persistence.ApproveInfo approveInfo = approveInfoDAO.findBySnAndUserId(sn, wi.ActorId); if (approveInfo != null) { examinerList.Append(approveInfo.Approver).Append(","); if (approveInfo.Decision) { approvedDecitionCount++; approverList.Append(approveInfo.Approver).Append(","); } else { opponentList.Append(approveInfo.Approver).Append(","); } } } } //------------------判断是否可以结束该汇签任务----------- float size =(float)workItems.Count; float theRule = 2 / 3f; float currentCompletedPercentage = completedWorkItemCount / size;//已经完成的工单占总工单的比例 float currentAggreePercentage = approvedDecitionCount / size;//已经同意的比例 //如果完成的工单数量小于2/3,则直接返回false,即不可以结束TaskInstance if (currentCompletedPercentage < theRule) { return false; } //如果同意的数量达到2/3则直接结束TaskInstance else if (currentAggreePercentage >= theRule) { //修改流程变量的值 processInstance.setProcessInstanceVariable("Decision", true); //将最终审批决定纪录到业务表中 LoanInfo loanInfo = loanInfoDAO.findBySn(sn); if (loanInfo!=null) { loanInfo.Decision = true; loanInfo.ExaminerList=examinerList.ToString(); loanInfo.ApproverList=approverList.ToString(); loanInfo.OpponentList=opponentList.ToString(); loanInfoDAO.attachDirty(loanInfo); } return true; } //当所有的workItem结束时,可以结束TaskInstance else if (completedWorkItemCount == workItems.Count) { LoanInfo loanInfo = loanInfoDAO.findBySn(sn); if (currentAggreePercentage < theRule) { //修改流程变量的值 processInstance.setProcessInstanceVariable("Decision", false); //将最终审批决定记录到业务表中 if (loanInfo != null) loanInfo.Decision = false; loanInfo.ExaminerList=examinerList.ToString(); loanInfo.ApproverList=approverList.ToString(); loanInfo.OpponentList=opponentList.ToString(); loanInfoDAO.attachDirty(loanInfo); } else { //修改流程变量的值 processInstance.setProcessInstanceVariable("Decision", true); //将最终审批决定记录到业务表中 if (loanInfo != null) loanInfo.Decision = true; loanInfo.ExaminerList=examinerList.ToString(); loanInfo.ApproverList=approverList.ToString(); loanInfo.OpponentList=opponentList.ToString(); loanInfoDAO.attachDirty(loanInfo); } return true; } return false; }
// throws EngineException, KernelException /// <summary>分配, 按照当前任务的参与者插入工单</summary> /// <param name="currentSession"></param> /// <param name="processInstance"></param> /// <param name="runtimeContext"></param> /// <param name="taskInstance"></param> /// <param name="formTask"></param> /// <param name="part"></param> /// <param name="dynamicAssignmentHandler"></param> protected void assign(IWorkflowSession currentSession, IProcessInstance processInstance, RuntimeContext runtimeContext, ITaskInstance taskInstance, FormTask formTask, Participant part, DynamicAssignmentHandler dynamicAssignmentHandler) { //如果有指定的Actor,则按照指定的Actor分配任务 if (dynamicAssignmentHandler != null) { dynamicAssignmentHandler.assign((IAssignable)taskInstance, part.Name); } else { IPersistenceService persistenceService = runtimeContext.PersistenceService; List<ITaskInstance> taskInstanceList = persistenceService.FindTaskInstancesForProcessInstance(taskInstance.ProcessInstanceId, taskInstance.ActivityId); ITaskInstance theLastCompletedTaskInstance = null; for (int i = 0; taskInstanceList != null && i < taskInstanceList.Count; i++) { ITaskInstance tmp = (ITaskInstance)taskInstanceList[i]; if (tmp.Id.Equals(taskInstance.Id)) continue; if (!tmp.TaskId.Equals(taskInstance.TaskId)) continue; if (tmp.State != TaskInstanceStateEnum.COMPLETED) continue; if (theLastCompletedTaskInstance == null) { theLastCompletedTaskInstance = tmp; } else { if (theLastCompletedTaskInstance.StepNumber < tmp.StepNumber) { theLastCompletedTaskInstance = tmp; } } } //如果是循环且LoopStrategy==REDO,则分配个上次完成该工作的操作员 if (theLastCompletedTaskInstance != null && (LoopStrategyEnum.REDO==formTask.LoopStrategy || currentSession.isInWithdrawOrRejectOperation())) { List<IWorkItem> workItemList = persistenceService.FindCompletedWorkItemsForTaskInstance(theLastCompletedTaskInstance.Id); ITaskInstanceManager taskInstanceMgr = runtimeContext.TaskInstanceManager; for (int k = 0; k < workItemList.Count; k++) { IWorkItem completedWorkItem = (IWorkItem)workItemList[k]; IWorkItem newFromWorkItem = taskInstanceMgr.createWorkItem(currentSession, processInstance, taskInstance, completedWorkItem.ActorId); newFromWorkItem.claim();//并自动签收 } } else { IBeanFactory beanFactory = runtimeContext.BeanFactory; //从spring中获取到对应任务的Performer,创建工单 //201004 add lwz 参与者通过业务接口实现默认获取用户 switch (part.AssignmentType) { case AssignmentTypeEnum.Current: runtimeContext.AssignmentBusinessHandler.assignCurrent( currentSession, processInstance, (IAssignable)taskInstance); break; case AssignmentTypeEnum.Role: runtimeContext.AssignmentBusinessHandler.assignRole( currentSession, processInstance, (IAssignable)taskInstance, part.PerformerValue); break; case AssignmentTypeEnum.Agency: runtimeContext.AssignmentBusinessHandler.assignAgency( currentSession, processInstance, (IAssignable)taskInstance, part.PerformerValue); break; case AssignmentTypeEnum.Fixed: runtimeContext.AssignmentBusinessHandler.assignFixed( currentSession, processInstance, (IAssignable)taskInstance, part.PerformerValue); break; case AssignmentTypeEnum.Superiors: runtimeContext.AssignmentBusinessHandler.assignSuperiors( currentSession, processInstance, (IAssignable)taskInstance); break; default: IAssignmentHandler assignmentHandler = (IAssignmentHandler)beanFactory.GetBean(part.AssignmentHandler); //modified by wangmj 20090904 ((IAssignmentHandler)assignmentHandler).assign((IAssignable)taskInstance, part.PerformerValue); break; } } } }
public Object doInWorkflowSession(RuntimeContext ctx) { IPersistenceService persistenceService = ctx.PersistenceService; return persistenceService.FindTaskInstancesForProcessInstance(processInstanceId, activityId); }
public object doInWorkflowSession(RuntimeContext ctx) { WorkflowDefinition workflowDef = ctx.DefinitionService.GetTheLatestVersionOfWorkflowDefinition(wfprocessId); WorkflowProcess wfProcess = null; wfProcess = workflowDef.getWorkflowProcess(); if (wfProcess == null) { throw new Exception("Workflow process NOT found,id=[" + wfprocessId + "]"); } ProcessInstance processInstance = new ProcessInstance(); processInstance.CreatorId=creatorId; processInstance.ProcessId=wfProcess.Id; processInstance.Version=workflowDef.Version; processInstance.DisplayName=wfProcess.DisplayName; processInstance.Name=wfProcess.Name; processInstance.State=ProcessInstanceEnum.INITIALIZED; processInstance.CreatedTime=ctx.CalendarService.getSysDate(); processInstance.ParentProcessInstanceId=parentProcessInstanceId; processInstance.ParentTaskInstanceId=parentTaskInstanceId; ctx.PersistenceService.SaveOrUpdateProcessInstance( processInstance); // 初始化流程变量 List<DataField> datafields = wfProcess.DataFields; for (int i = 0; datafields != null && i < datafields.Count; i++) { DataField df = (DataField)datafields[i]; if (df.DataType == DataTypeEnum.STRING) { if (df.InitialValue != null) { processInstance.setProcessInstanceVariable(df.Name, df.InitialValue); } else { processInstance.setProcessInstanceVariable(df.Name, ""); } } else if (df.DataType == DataTypeEnum.INTEGER) { if (df.InitialValue != null) { try { Int32 intValue = Int32.Parse(df.InitialValue); processInstance.setProcessInstanceVariable(df.Name, intValue); } catch (Exception ) { } } else { processInstance.setProcessInstanceVariable(df.Name, (Int32)0); } } else if (df.DataType == DataTypeEnum.LONG) { if (df.InitialValue != null) { try { long longValue = long.Parse(df.InitialValue); processInstance.setProcessInstanceVariable(df.Name, longValue); } catch (Exception ) { } } else { processInstance.setProcessInstanceVariable(df.Name, (long)0); } } else if (df.DataType == DataTypeEnum.FLOAT) { if (df.InitialValue != null) { float floatValue = float.Parse(df.InitialValue); processInstance.setProcessInstanceVariable(df.Name, floatValue); } else { processInstance.setProcessInstanceVariable(df.Name, (float)0); } } else if (df.DataType == DataTypeEnum.DOUBLE) { if (df.InitialValue != null) { Double doubleValue = Double.Parse(df.InitialValue); processInstance.setProcessInstanceVariable(df .Name, doubleValue); } else { processInstance.setProcessInstanceVariable(df.Name, (Double)0); } } else if (df.DataType == DataTypeEnum.BOOLEAN) { if (df.InitialValue != null) { Boolean booleanValue = Boolean.Parse(df.InitialValue); processInstance.setProcessInstanceVariable(df.Name, booleanValue); } else { processInstance.setProcessInstanceVariable(df.Name, false); } } else if (df.DataType == DataTypeEnum.DATETIME) { // TODO 需要完善一下 if (df.InitialValue != null && df.DataPattern != null) { try { //SimpleDateFormat dFormat = new SimpleDateFormat(df.DataPattern); DateTime dateTmp = DateTime.Parse(df.InitialValue); processInstance.setProcessInstanceVariable(df.Name, dateTmp); } catch (Exception ) { processInstance.setProcessInstanceVariable(df.Name, null); //e.printStackTrace(); } } else { processInstance.setProcessInstanceVariable(df.Name, null); } } } ctx.PersistenceService.SaveOrUpdateProcessInstance( processInstance); return processInstance; }
public Object doInWorkflowSession(RuntimeContext ctx) { switch (t) { case '2': return ctx.PersistenceService.FindTodoWorkItems(actorId, processId); case '3': return ctx.PersistenceService.FindTodoWorkItems(actorId, processId, taskId); default: return ctx.PersistenceService.FindTodoWorkItems(actorId); } }
public Object doInWorkflowSession(RuntimeContext ctx) { IPersistenceService persistenceService = ctx.PersistenceService; return persistenceService.FindWorkItemById(workItemId); }