示例#1
0
        //得到自定义流程图
        public static flowcharStruct getFlowcharStruct(string xaml)
        {
            char[] sp = { ',' };
            char[] sl = { ' ' };
            //(1)
            WorkflowStruct.flowcharStruct flowcharStruct = new WorkflowStruct.flowcharStruct();

            //(2)
            DynamicActivity dynamicActivity = tool.activityByXaml(xaml) as DynamicActivity;
            Activity        activity        = tool.getImplementation(dynamicActivity);
            Flowchart       flowchar        = activity as Flowchart;

            if (flowchar == null)
            {
                return(null);
            }

            //(3)=====================================

            //(3.1)----------------------------------------------------------------------------------
            flowcharStruct.beginNode.DisplayName = "开始";
            flowcharStruct.beginNode.id          = "begin";

            //(3.1.1)
            if (WorkflowViewStateService.GetViewState(flowchar)["ShapeLocation"] != null)
            {
                string ShapeLocation = WorkflowViewStateService.GetViewState(flowchar)["ShapeLocation"].ToString();
                flowcharStruct.beginNode.ShapeSize.x = double.Parse(ShapeLocation.Split(sp)[0]);
                flowcharStruct.beginNode.ShapeSize.y = double.Parse(ShapeLocation.Split(sp)[1]);
            }

            //(3.1.2)
            if (WorkflowViewStateService.GetViewState(flowchar)["ShapeSize"] != null)
            {
                string ShapeSize = WorkflowViewStateService.GetViewState(flowchar)["ShapeSize"].ToString();
                flowcharStruct.beginNode.ShapeSize.width  = double.Parse(ShapeSize.Split(sp)[0]);
                flowcharStruct.beginNode.ShapeSize.height = double.Parse(ShapeSize.Split(sp)[1]);
            }

            //(3.1.3)
            if (WorkflowViewStateService.GetViewState(flowchar)["ConnectorLocation"] != null)
            {
                string              ConnectorLocation = WorkflowViewStateService.GetViewState(flowchar)["ConnectorLocation"].ToString();
                string[]            points            = ConnectorLocation.Split(sl);
                WorkflowStruct.line oneline           = new WorkflowStruct.line();
                oneline.beginNodeID = flowchar.Id;
                oneline.text        = flowchar.DisplayName;
                foreach (string item in points)
                {
                    double x = double.Parse(item.Split(sp)[0]);
                    double y = double.Parse(item.Split(sp)[1]);
                    oneline.connectorPoint.Add(new WorkflowStruct.point()
                    {
                        x = x, y = y
                    });
                }
                flowcharStruct.lineList.Add(oneline);
            }

            //(3.2)--------------------------------------------------------------------------------
            foreach (FlowNode flowNode in flowchar.Nodes)
            {
                FlowStep flowStep = flowNode as FlowStep;
                if (flowStep != null)
                {
                    WorkflowStruct.node node = new WorkflowStruct.node();

                    node.DisplayName = flowStep.Action.DisplayName;
                    node.id          = flowStep.Action.Id;

                    //(3.2.1)
                    if (WorkflowViewStateService.GetViewState(flowStep)["ShapeLocation"] != null)
                    {
                        string ShapeLocation = WorkflowViewStateService.GetViewState(flowStep)["ShapeLocation"].ToString();
                        node.ShapeSize.x = double.Parse(ShapeLocation.Split(sp)[0]);
                        node.ShapeSize.y = double.Parse(ShapeLocation.Split(sp)[1]);
                    }

                    //(3.2.2)
                    if (WorkflowViewStateService.GetViewState(flowStep)["ShapeSize"] != null)
                    {
                        string ShapeSize = WorkflowViewStateService.GetViewState(flowStep)["ShapeSize"].ToString();
                        node.ShapeSize.width  = double.Parse(ShapeSize.Split(sp)[0]);
                        node.ShapeSize.height = double.Parse(ShapeSize.Split(sp)[1]);
                    }

                    //(3.2.3)
                    if (WorkflowViewStateService.GetViewState(flowStep).Count(p => p.Key == "ConnectorLocation") == 1)
                    {
                        string              ConnectorLocation = WorkflowViewStateService.GetViewState(flowStep)["ConnectorLocation"].ToString();
                        string[]            points            = ConnectorLocation.Split(sl);
                        WorkflowStruct.line line = new WorkflowStruct.line();
                        line.beginNodeID = flowStep.Action.Id;
                        line.text        = flowStep.Action.DisplayName;
                        foreach (string item in points)
                        {
                            double x = double.Parse(item.Split(sp)[0]);
                            double y = double.Parse(item.Split(sp)[1]);
                            line.connectorPoint.Add(new WorkflowStruct.point()
                            {
                                x = x, y = y
                            });
                        }
                        flowcharStruct.lineList.Add(line);
                    }

                    flowcharStruct.nodeList.Add(node);
                }
            }

            //(3.3)-------------------------------------------------------------
            foreach (FlowNode flowNode in flowchar.Nodes)
            {
                FlowSwitch <string> flowSwitch = flowNode as FlowSwitch <string>;

                if (flowSwitch != null)
                {
                    WorkflowStruct.node node = new WorkflowStruct.node();

                    node.DisplayName = flowSwitch.Expression.DisplayName;
                    node.id          = flowSwitch.Expression.Id;

                    //(3.3.1)
                    if (WorkflowViewStateService.GetViewState(flowSwitch)["ShapeLocation"] != null)
                    {
                        string ShapeLocation = WorkflowViewStateService.GetViewState(flowSwitch)["ShapeLocation"].ToString();
                        node.ShapeSize.x = double.Parse(ShapeLocation.Split(sp)[0]);
                        node.ShapeSize.y = double.Parse(ShapeLocation.Split(sp)[1]);
                    }

                    //(3.3.2)
                    if (WorkflowViewStateService.GetViewState(flowSwitch)["ShapeSize"] != null)
                    {
                        string ShapeSize = WorkflowViewStateService.GetViewState(flowSwitch)["ShapeSize"].ToString();
                        node.ShapeSize.width  = double.Parse(ShapeSize.Split(sp)[0]);
                        node.ShapeSize.height = double.Parse(ShapeSize.Split(sp)[1]);
                    }

                    //(3.3.3)

                    if (WorkflowViewStateService.GetViewState(flowSwitch).Count(p => p.Key == "Default") == 1)
                    {
                        string              ConnectorLocation = WorkflowViewStateService.GetViewState(flowSwitch)["Default"].ToString();
                        string[]            points            = ConnectorLocation.Split(sl);
                        WorkflowStruct.line line = new WorkflowStruct.line();
                        line.beginNodeID = flowSwitch.Expression.Id;
                        line.text        = flowSwitch.Expression.DisplayName;
                        foreach (string item in points)
                        {
                            double x = double.Parse(item.Split(sp)[0]);
                            double y = double.Parse(item.Split(sp)[1]);
                            line.connectorPoint.Add(new WorkflowStruct.point()
                            {
                                x = x, y = y
                            });
                        }
                        flowcharStruct.lineList.Add(line);
                    }

                    //(3.3.4)
                    foreach (var v in flowSwitch.Cases)
                    {
                        System.Activities.Statements.FlowNode next = v.Value;
                        System.Console.WriteLine(v.Key);
                        string caseValue = v.Key + "Connector";
                        if (WorkflowViewStateService.GetViewState(flowSwitch).Count(p => p.Key == caseValue) == 1)
                        {
                            string              ConnectorLocation = WorkflowViewStateService.GetViewState(flowSwitch)[caseValue].ToString();
                            string[]            points            = ConnectorLocation.Split(sl);
                            WorkflowStruct.line line = new WorkflowStruct.line();
                            line.beginNodeID = flowSwitch.Expression.Id;
                            line.text        = flowSwitch.Expression.DisplayName;
                            foreach (string item in points)
                            {
                                double x = double.Parse(item.Split(sp)[0]);
                                double y = double.Parse(item.Split(sp)[1]);
                                line.connectorPoint.Add(new WorkflowStruct.point()
                                {
                                    x = x, y = y
                                });
                            }
                            flowcharStruct.lineList.Add(line);
                        }
                    }
                    flowcharStruct.nodeList.Add(node);
                }
            }

            return(flowcharStruct);
        }//end
示例#2
0
        //得到自定义流程图
        public static flowcharStruct getFlowcharStruct(string xaml)
        {
            char[] sp = { ',' };
            char[] sl = { ' ' };
            //(1)
            WorkflowStruct.flowcharStruct flowcharStruct = new WorkflowStruct.flowcharStruct();

            //(2)
            DynamicActivity dynamicActivity = tool.activityByXaml(xaml) as DynamicActivity;
            Activity activity = tool.getImplementation(dynamicActivity);
            Flowchart flowchar = activity as Flowchart;

            if (flowchar == null)
            {
                return null;
            }

            //(3)=====================================

            //(3.1)----------------------------------------------------------------------------------
            flowcharStruct.beginNode.DisplayName = "开始";
            flowcharStruct.beginNode.id = "begin";

            //(3.1.1)
            if (WorkflowViewStateService.GetViewState(flowchar)["ShapeLocation"] != null)
            {
                string ShapeLocation = WorkflowViewStateService.GetViewState(flowchar)["ShapeLocation"].ToString();
                flowcharStruct.beginNode.ShapeSize.x = double.Parse(ShapeLocation.Split(sp)[0]);
                flowcharStruct.beginNode.ShapeSize.y = double.Parse(ShapeLocation.Split(sp)[1]);
            }

            //(3.1.2)
            if (WorkflowViewStateService.GetViewState(flowchar)["ShapeSize"] != null)
            {
                string ShapeSize = WorkflowViewStateService.GetViewState(flowchar)["ShapeSize"].ToString();
                flowcharStruct.beginNode.ShapeSize.width = double.Parse(ShapeSize.Split(sp)[0]);
                flowcharStruct.beginNode.ShapeSize.height = double.Parse(ShapeSize.Split(sp)[1]);
            }

            //(3.1.3)
            if (WorkflowViewStateService.GetViewState(flowchar)["ConnectorLocation"] != null)
            {
                string ConnectorLocation = WorkflowViewStateService.GetViewState(flowchar)["ConnectorLocation"].ToString();
                string[] points = ConnectorLocation.Split(sl);
                WorkflowStruct.line oneline = new WorkflowStruct.line();
                oneline.beginNodeID = flowchar.Id;
                oneline.text = flowchar.DisplayName;
                foreach (string item in points)
                {
                    double x = double.Parse(item.Split(sp)[0]);
                    double y = double.Parse(item.Split(sp)[1]);
                    oneline.connectorPoint.Add(new WorkflowStruct.point() { x = x, y = y });
                }
                flowcharStruct.lineList.Add(oneline);
            }

            //(3.2)--------------------------------------------------------------------------------
            foreach (FlowNode flowNode in flowchar.Nodes)
            {
                FlowStep flowStep = flowNode as FlowStep;
                if (flowStep != null)
                {
                    WorkflowStruct.node node = new WorkflowStruct.node();

                    node.DisplayName = flowStep.Action.DisplayName;
                    node.id = flowStep.Action.Id;

                    //(3.2.1)
                    if (WorkflowViewStateService.GetViewState(flowStep)["ShapeLocation"] != null)
                    {
                        string ShapeLocation = WorkflowViewStateService.GetViewState(flowStep)["ShapeLocation"].ToString();
                        node.ShapeSize.x = double.Parse(ShapeLocation.Split(sp)[0]);
                        node.ShapeSize.y = double.Parse(ShapeLocation.Split(sp)[1]);
                    }

                    //(3.2.2)
                    if (WorkflowViewStateService.GetViewState(flowStep)["ShapeSize"] != null)
                    {
                        string ShapeSize = WorkflowViewStateService.GetViewState(flowStep)["ShapeSize"].ToString();
                        node.ShapeSize.width = double.Parse(ShapeSize.Split(sp)[0]);
                        node.ShapeSize.height = double.Parse(ShapeSize.Split(sp)[1]);
                    }

                    //(3.2.3)
                    if (WorkflowViewStateService.GetViewState(flowStep).Count(p => p.Key == "ConnectorLocation") == 1)
                    {
                        string ConnectorLocation = WorkflowViewStateService.GetViewState(flowStep)["ConnectorLocation"].ToString();
                        string[] points = ConnectorLocation.Split(sl);
                        WorkflowStruct.line line = new WorkflowStruct.line();
                        line.beginNodeID = flowStep.Action.Id;
                        line.text = flowStep.Action.DisplayName;
                        foreach (string item in points)
                        {
                            double x = double.Parse(item.Split(sp)[0]);
                            double y = double.Parse(item.Split(sp)[1]);
                            line.connectorPoint.Add(new WorkflowStruct.point() { x = x, y = y });
                        }
                        flowcharStruct.lineList.Add(line);
                    }

                    flowcharStruct.nodeList.Add(node);
                }
            }

            //(3.3)-------------------------------------------------------------
            foreach (FlowNode flowNode in flowchar.Nodes)
            {

                FlowSwitch<string> flowSwitch = flowNode as FlowSwitch<string>;

                if (flowSwitch != null)
                {
                    WorkflowStruct.node node = new WorkflowStruct.node();

                    node.DisplayName = flowSwitch.Expression.DisplayName;
                    node.id = flowSwitch.Expression.Id;

                    //(3.3.1)
                    if (WorkflowViewStateService.GetViewState(flowSwitch)["ShapeLocation"] != null)
                    {
                        string ShapeLocation = WorkflowViewStateService.GetViewState(flowSwitch)["ShapeLocation"].ToString();
                        node.ShapeSize.x = double.Parse(ShapeLocation.Split(sp)[0]);
                        node.ShapeSize.y = double.Parse(ShapeLocation.Split(sp)[1]);
                    }

                    //(3.3.2)
                    if (WorkflowViewStateService.GetViewState(flowSwitch)["ShapeSize"] != null)
                    {
                        string ShapeSize = WorkflowViewStateService.GetViewState(flowSwitch)["ShapeSize"].ToString();
                        node.ShapeSize.width = double.Parse(ShapeSize.Split(sp)[0]);
                        node.ShapeSize.height = double.Parse(ShapeSize.Split(sp)[1]);
                    }

                    //(3.3.3)

                    if (WorkflowViewStateService.GetViewState(flowSwitch).Count(p => p.Key == "Default") == 1)
                    {
                        string ConnectorLocation = WorkflowViewStateService.GetViewState(flowSwitch)["Default"].ToString();
                        string[] points = ConnectorLocation.Split(sl);
                        WorkflowStruct.line line = new WorkflowStruct.line();
                        line.beginNodeID = flowSwitch.Expression.Id;
                        line.text = flowSwitch.Expression.DisplayName;
                        foreach (string item in points)
                        {
                            double x = double.Parse(item.Split(sp)[0]);
                            double y = double.Parse(item.Split(sp)[1]);
                            line.connectorPoint.Add(new WorkflowStruct.point() { x = x, y = y });
                        }
                        flowcharStruct.lineList.Add(line);
                    }

                    //(3.3.4)
                    foreach (var v in flowSwitch.Cases)
                    {

                        System.Activities.Statements.FlowNode next = v.Value;
                        System.Console.WriteLine(v.Key);
                        string caseValue = v.Key + "Connector";
                        if (WorkflowViewStateService.GetViewState(flowSwitch).Count(p => p.Key == caseValue) == 1)
                        {
                            string ConnectorLocation = WorkflowViewStateService.GetViewState(flowSwitch)[caseValue].ToString();
                            string[] points = ConnectorLocation.Split(sl);
                            WorkflowStruct.line line = new WorkflowStruct.line();
                            line.beginNodeID = flowSwitch.Expression.Id;
                            line.text = flowSwitch.Expression.DisplayName;
                            foreach (string item in points)
                            {
                                double x = double.Parse(item.Split(sp)[0]);
                                double y = double.Parse(item.Split(sp)[1]);
                                line.connectorPoint.Add(new WorkflowStruct.point() { x = x, y = y });
                            }
                            flowcharStruct.lineList.Add(line);
                        }
                    }
                    flowcharStruct.nodeList.Add(node);
                }

            }

            return flowcharStruct;
        }