private void buttonSelfWaitActivity_Click(object sender, RoutedEventArgs e) { if (isCreate) { WaitControlData wd = new WaitControlData(); wd.处理方式 = "到人"; wd.办理时限 = 5; wd.办理查看业务表单 = this.designer.流程数据.启动时填写的表单; wd.办理人员 = ""; WaitControl wc = new WaitControl() { X坐标 = 150, Y坐标 = 200, 类型 = "节", 结点数据=wd }; ToolWindows.SetWindowWaitControl swc = new ToolWindows.SetWindowWaitControl(wc, designer.NameList); swc.接件部门.IsEnabled = false; swc.接件职能.IsEnabled = false; swc.处理方式.IsReadOnly = true; swc.ShowDialog(); if (swc.ButtonSelect == "ok") { designer.AddActivity(wc); } swc.Close(); } }
private void buttonWaitActivity_Click(object sender, RoutedEventArgs e) { if (isCreate) { WaitControlData wd = new WaitControlData(); wd.办理查看业务表单 = this.designer.流程数据.启动时填写的表单; wd.办理时限 = 5; wd.处理方式 = "组接件"; WaitControl wc = new WaitControl() { X坐标 = 150, Y坐标 = 200, 类型 = "节", 结点数据 = wd }; ToolWindows.SetWindowWaitControl swc = new ToolWindows.SetWindowWaitControl(wc, designer.NameList); swc.办理人员.IsEnabled = false; swc.处理方式.IsReadOnly = true; swc.ShowDialog(); if (swc.ButtonSelect == "ok") { designer.AddActivity(wc); } swc.Close(); } }
void ShowState(object activity) { if (activity is System.Workflow.ComponentModel.CompositeActivity) { CompositeActivity Workflow = activity as CompositeActivity; foreach (var v in Workflow.EnabledActivities) { var ee = new Element(); ee.类型 = "节"; ee.说明 = v.Description; ee.Name = v.Name; ee.X坐标 = 0; ee.Y坐标 = 0; ee.分支集合 = new List <string>(); if (v is StateActivity) { StateActivity sta = v as StateActivity; foreach (var c in sta.EnabledActivities) { foreach (var cc in ((CompositeActivity)c).EnabledActivities) { if (cc is wxwinter.wf.WFLib.等待提交) { wxwinter.wf.WFLib.等待提交 waitsubmit = cc as wxwinter.wf.WFLib.等待提交; WaitControlData wd = new WaitControlData(); wd.办理查看业务表单 = waitsubmit.办理查看业务表单; wd.办理人员 = waitsubmit.办理人员; wd.办理时限 = waitsubmit.办理时限; wd.办理提交选项 = waitsubmit.办理提交选项; wd.办理添写业务表单 = waitsubmit.办理添写业务表单; wd.处理方式 = waitsubmit.处理方式; wd.接件部门 = waitsubmit.接件部门; wd.接件职能 = waitsubmit.接件职能; wd.启动窗体 = waitsubmit.启动窗体; wd.说明 = waitsubmit.Description; ee.结点数据 = wd; } if (cc is wxwinter.wf.WFLib.条件容器) { wxwinter.wf.WFLib.条件容器 ic = cc as wxwinter.wf.WFLib.条件容器; foreach (var fz in ic.EnabledActivities) { wxwinter.wf.WFLib.条件分支 ifz = fz as wxwinter.wf.WFLib.条件分支; ee.分支集合.Add(ifz.条件); } } } } } ElementList.Add(ee); } } }
public T GetFlowObject <T>(FlowChart flowChart) { string lzm = string.Format(Resource.myState, "结束状态", "900", "700"); //------------------------------------------------------------------------- wxwinter.wf.WFLib.状态机模板 workflow = new wxwinter.wf.WFLib.状态机模板(); RuleConditionReference ruleconditionreference1 = new RuleConditionReference(); ruleconditionreference1.ConditionName = "启用"; workflow.SetValue(WorkflowChanges.ConditionProperty, ruleconditionreference1); FlowChartData fcd = flowChart.FlowData as FlowChartData; if (fcd != null) { workflow.模板版本 = fcd.模板版本; workflow.模板编号 = fcd.模板编号; workflow.模板名称 = fcd.模板名称; workflow.模板说明 = fcd.模板说明; workflow.启动时填写的表单 = fcd.启动时填写的表单; workflow.数据表单列表 = fcd.数据表单列表; } //-开始结点 workflow.InitialStateName = "开始状态"; StateActivity 开始状态 = new StateActivity("开始状态"); StateInitializationActivity 开始状态自动容器 = new StateInitializationActivity("开始状态自动容器"); wxwinter.wf.WFLib.初始化 开始启动流程 = new wxwinter.wf.WFLib.初始化(); 开始启动流程.Name = "开始启动流程"; workflow.Activities.Add(开始状态); 开始状态.Activities.Add(开始状态自动容器); 开始状态自动容器.Activities.Add(开始启动流程); //////////////// foreach (var node in flowChart.ElementList) { lzm = lzm + string.Format(Resource.myState, node.Name, node.X坐标, node.Y坐标); if (node.类型 == "头") { var r = flowChart.ElementRelationList.FirstOrDefault(p => p.起点 == node.Name && p.路由 == "开始状态"); if (r != null) { SetStateActivity 启动流程 = new SetStateActivity("启动流程"); 启动流程.TargetStateName = r.目标; 开始状态自动容器.Activities.Add(启动流程); } } } //---------------------------------------------------------------- //-完成结点 StateActivity 结束状态 = new StateActivity("结束状态"); workflow.Activities.Add(结束状态); workflow.CompletedStateName = "结束状态"; StateActivity 归档状态 = new StateActivity("归档状态"); StateInitializationActivity 归档状态自动容器 = new StateInitializationActivity("归档状态自动容器"); wxwinter.wf.WFLib.归档 流程归档 = new wxwinter.wf.WFLib.归档(); 流程归档.Name = "流程归档"; workflow.Activities.Add(归档状态); 归档状态.Activities.Add(归档状态自动容器); 归档状态自动容器.Activities.Add(流程归档); SetStateActivity 完成流程 = new SetStateActivity("完成流程"); 完成流程.TargetStateName = "结束状态"; 归档状态自动容器.Activities.Add(完成流程); // WindowsWorkflowObject wf = new WindowsWorkflowObject(); foreach (var node in flowChart.ElementList) { if (node.类型 == "节") { string n = node.Name; System.Workflow.Activities.StateActivity state = new System.Workflow.Activities.StateActivity(); state.Name = n; System.Workflow.Activities.EventDrivenActivity eda = new System.Workflow.Activities.EventDrivenActivity(); eda.Name = n + "_等待容器"; wxwinter.wf.WFLib.等待提交 waitsubmit = new wxwinter.wf.WFLib.等待提交(); waitsubmit.Name = n + "_处理中"; waitsubmit.状态名称 = n + "_处理中"; WaitControlData wd = node.结点数据 as WaitControlData; waitsubmit.办理查看业务表单 = wd.办理查看业务表单; waitsubmit.办理人员 = wd.办理人员; waitsubmit.办理时限 = wd.办理时限; waitsubmit.办理提交选项 = wd.办理提交选项; waitsubmit.办理添写业务表单 = wd.办理添写业务表单; waitsubmit.处理方式 = wd.处理方式; waitsubmit.接件部门 = wd.接件部门; waitsubmit.接件职能 = wd.接件职能; waitsubmit.启动窗体 = wd.启动窗体; waitsubmit.Description = wd.说明; wxwinter.wf.WFLib.条件容器 ir = new wxwinter.wf.WFLib.条件容器(); ir.Name = n + "_处理分支"; string ts = ""; foreach (var v in node.分支集合) { wxwinter.wf.WFLib.条件分支 fz = new wxwinter.wf.WFLib.条件分支(); fz.Name = n + "_处理分支_" + v.ToString(); fz.条件 = v.ToString(); ir.Activities.Add(fz); ts = ts + v.ToString() + ","; var r = flowChart.ElementRelationList.FirstOrDefault(p => p.起点 == node.Name && p.路由 == v); if (r == null) { wf = null; T tp = (T)((object)wf); return((T)tp); } else { SetStateActivity tp = new SetStateActivity(node.Name + "_到_" + r.目标); tp.TargetStateName = r.目标; fz.Activities.Add(tp); } } if (ts != "") { waitsubmit.办理提交选项 = ts.Remove(ts.Length - 1); } eda.Activities.Add(waitsubmit); eda.Activities.Add(ir); state.Activities.Add(eda); workflow.Activities.Add(state); } } string q = WorkflowClassToXomlString(workflow); wf.Xoml = q.Replace("utf-16", "utf-8"); wf.Rules = Resource.myRule; wf.Layout = string.Format(Resource.myLayout, lzm); T t = (T)((object)wf); return((T)t); }