/// <summary> /// 生成工作流模板的类 /// </summary> /// <param name="workflowId">工作流id</param> /// <param name="state">读写状态:新建\修改\浏览</param> /// <param name="taskItems"></param> /// <param name="lineItems"></param> public WorkFlowData(string workflowId, string state, ArrayList taskItems, ArrayList lineItems) { if (WorkFlowId.Trim().Length == 0 || WorkFlowId == null) { throw new Exception("初始化WorkFlowData类错误,State 不能为空!"); } if (State.Trim().Length == 0 || State == null) { throw new Exception("初始化WorkFlowData类错误,State 不能为空!"); } if (TaskItems == null) { throw new Exception("初始化WorkFlowData类错误,TaskItems 不能为空!"); } if (LineItems == null) { throw new Exception("初始化WorkFlowData类错误,LineItems 不能为空!"); } WorkFlowId = workflowId; TaskItems = taskItems; LineItems = lineItems; State = state; }
/// <summary> /// 读取流程模板 /// </summary> public void ReadWorkFlow( ) { if (WorkFlowId.Trim().Length == 0 || WorkFlowId == null) { throw new Exception("ReadWorkFlow方法错误,WorkFlowId 不能为空!"); } int taskType; Point p = new Point(0, 0); TaskItems.Clear(); LineItems.Clear(); BaseComponent startTask = null, endTask = null; #region 读取任务节点 DataTable table = RDIFrameworkService.Instance.WorkFlowTemplateService.GetWorkTasks(SystemInfo.UserInfo, WorkFlowId); if (table != null && table.Rows.Count > 0) { foreach (DataRow dr in table.Rows) { taskType = Convert.ToInt32(dr[WorkTaskTable.FieldTaskTypeId].ToString()); p.X = Convert.ToInt32(dr[WorkTaskTable.FieldIXPosition].ToString()); p.Y = Convert.ToInt32(dr[WorkTaskTable.FieldIYPosition].ToString()); switch (taskType) { case 1: //启动节点 var st = new StartTask(p, 0) { TaskName = dr[WorkTaskTable.FieldTaskCaption].ToString(), TaskId = dr[WorkTaskTable.FieldWorkTaskId].ToString(), TaskType = taskType, OperRule = dr[WorkTaskTable.FieldOperRule].ToString(), WorkFlowId = dr[WorkTaskTable.FieldWorkFlowId].ToString(), Description = dr[WorkTaskTable.FieldDescription].ToString() }; TaskItems.Add(st); break; case 2: //结束节点 var edTask = new EndTask(p, 0) { TaskName = dr[WorkTaskTable.FieldTaskCaption].ToString(), TaskId = dr[WorkTaskTable.FieldWorkTaskId].ToString(), TaskType = taskType, WorkFlowId = dr[WorkTaskTable.FieldWorkFlowId].ToString(), Description = dr[WorkTaskTable.FieldDescription].ToString() }; TaskItems.Add(edTask); break; case 3: //交互节点 var alterTask = new AlternateTask(p, 0) { TaskName = dr[WorkTaskTable.FieldTaskCaption].ToString(), TaskId = dr[WorkTaskTable.FieldWorkTaskId].ToString(), TaskType = taskType, OperRule = dr[WorkTaskTable.FieldOperRule].ToString(), WorkFlowId = dr[WorkTaskTable.FieldWorkFlowId].ToString(), IsJumpSelf = Convert.ToBoolean(dr[WorkTaskTable.FieldIsJumpSelf]), Description = dr[WorkTaskTable.FieldDescription].ToString() }; TaskItems.Add(alterTask); break; case 4: //判断节点 var judgeTask = new JudgeTask(p, 0) { TaskName = dr[WorkTaskTable.FieldTaskCaption].ToString(), TaskId = dr[WorkTaskTable.FieldWorkTaskId].ToString(), TaskType = taskType, WorkFlowId = dr[WorkTaskTable.FieldWorkFlowId].ToString(), TaskTypeAndOr = dr[WorkTaskTable.FieldTaskTypeAndOr].ToString(), Description = dr[WorkTaskTable.FieldDescription].ToString() }; TaskItems.Add(judgeTask); break; case 5: //查看节点 var viewTask = new ViewTask(p, 0) { TaskName = dr[WorkTaskTable.FieldTaskCaption].ToString(), TaskId = dr[WorkTaskTable.FieldWorkTaskId].ToString(), TaskType = taskType, WorkFlowId = dr[WorkTaskTable.FieldWorkFlowId].ToString(), IsJumpSelf = Convert.ToBoolean(dr[WorkTaskTable.FieldIsJumpSelf]), OperRule = dr[WorkTaskTable.FieldOperRule].ToString(), Description = dr[WorkTaskTable.FieldDescription].ToString() }; TaskItems.Add(viewTask); break; case 6: //子流程节点 var subFlowTask = new SubFlowTask(p, 0) { TaskName = dr[WorkTaskTable.FieldTaskCaption].ToString(), TaskId = dr[WorkTaskTable.FieldWorkTaskId].ToString(), TaskType = taskType, WorkFlowId = dr[WorkTaskTable.FieldWorkFlowId].ToString(), Description = dr[WorkTaskTable.FieldDescription].ToString() }; TaskItems.Add(subFlowTask); break; } } } #endregion **********读取任务节点end #region 读取连线 table = RDIFrameworkService.Instance.WorkFlowTemplateService.GetWorkLinks(SystemInfo.UserInfo, WorkFlowId); if (table != null && table.Rows.Count > 0) { foreach (DataRow dr in table.Rows) { for (int j = 0; j < TaskItems.Count; j++) //查找起止点 { if (startTask == null || endTask == null) { if (startTask == null && ((BaseComponent)TaskItems[j]).TaskId.Equals(dr[WorkLinkTable.FieldStartTaskId].ToString()) == true) { startTask = (BaseComponent)TaskItems[j]; } if (endTask == null && ((BaseComponent)TaskItems[j]).TaskId.Equals(dr[WorkLinkTable.FieldEndTaskId].ToString()) == true) { endTask = (BaseComponent)TaskItems[j]; } } } var lnk = new Link(startTask, endTask) { linkGuid = dr[WorkLinkTable.FieldWorkLinkId].ToString(), flowGuid = dr[WorkLinkTable.FieldWorkFlowId].ToString(), CommandName = dr[WorkLinkTable.FieldCommandName].ToString(), Condition = dr[WorkLinkTable.FieldCondition].ToString(), Des = dr[WorkLinkTable.FieldDescription].ToString() }; if (startTask != endTask) { if (dr[WorkLinkTable.FieldBreakX].ToString() != "") { string[] xx = dr[WorkLinkTable.FieldBreakX].ToString().Split(','); string[] yy = dr[WorkLinkTable.FieldBreakY].ToString().Split(','); for (int mm = 0; mm < xx.Length; mm++) { lnk.breakPointX.Insert(lnk.breakPointX.Count - 1, xx[mm]); lnk.breakPointY.Insert(lnk.breakPointY.Count - 1, yy[mm]); } } } LineItems.Add(lnk); startTask = null; endTask = null; } } #endregion }