示例#1
0
        public T GetFlow <T>(IDesigner designer)
        {
            FlowChart flowChart = new FlowChart();

            flowChart.ElementList = new List <Element>();
            foreach (var v in designer.GetActivityControlList())
            {
                flowChart.ElementList.Add(new Element()
                {
                    Name = v.Name, X坐标 = v.X坐标, Y坐标 = v.Y坐标, 分支集合 = v.分支集合, 结点数据 = v.结点数据, 类型 = v.类型, 说明 = v.说明
                });
            }

            flowChart.ElementRelationList = new List <ElementRelation>();
            foreach (var r in designer.GetActivityPathList())
            {
                flowChart.ElementRelationList.Add(new ElementRelation()
                {
                    Name = r.Name, 路由 = r.路由, 目标 = r.目标, 起点 = r.起点, 说明 = r.说明,
                });
            }

            flowChart.FlowData = designer.流程数据;
            //-

            WindowsWorkflowObject wf = (new XomlConverter()).GetFlowObject <WindowsWorkflowObject>(flowChart);

            T t = (T)((object)wf);

            return((T)t);
        }
示例#2
0
        public void LoadFlow <T>(T obj, IDesigner designer)
        {
            designer.Clear(false);
            WindowsWorkflowObject wf = obj as WindowsWorkflowObject;

            FlowChart flowChart = (new XomlConverter(wf.Xoml, wf.Rules, wf.Layout)).GetFlowChart();

            designer.流程数据 = flowChart.FlowData;
            foreach (var v in flowChart.ElementList)
            {
                if (v.类型 == "节")
                {
                    ActivityControl q = new WaitControl()
                    {
                        Name = v.Name, X坐标 = v.X坐标, Y坐标 = v.Y坐标, 标题 = v.Name, 说明 = ((WaitControlData)v.结点数据).说明, 类型 = v.类型, 分支集合 = v.分支集合, 结点数据 = v.结点数据
                    };
                    designer.AddActivity(q);
                }
                if (v.类型 == "头")
                {
                    ActivityControl q = new BeginControl()
                    {
                        Name = v.Name, X坐标 = v.X坐标, Y坐标 = v.Y坐标, 类型 = v.类型, 分支集合 = v.分支集合
                    };
                    designer.AddActivity(q);
                }
                if (v.类型 == "归档")
                {
                    ActivityControl q = new EndControl()
                    {
                        Name = v.Name
                    };
                    designer.AddActivity(q);
                }
            }

            foreach (var v in flowChart.ElementRelationList)
            {
                if (v.Name == "启动流程")
                {
                    v.路由 = "开始状态";
                }
                designer.AddActivityPath(v.Name, v.起点, v.目标, v.路由, v.说明);
            }
        }
        private void menu_Test_Click(object sender, RoutedEventArgs e)
        {
            if (isCreate)
            {
                XomlLoder             xl  = new XomlLoder();
                WindowsWorkflowObject wfo = xl.GetFlow <WindowsWorkflowObject>(designer);



                if (wfo == null)
                {
                    MessageBox.Show("流程验证失败");
                    return;
                }

                wxwinter.wf.Test.test ts = new wxwinter.wf.Test.test(wfo.Xoml, wfo.Rules);
                ts.Show();
            }
        }
示例#4
0
        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);
        }