Exemple #1
0
 internal void AddNonUIOperationConfig(NonUIOperationConfig config)
 {
     NonUIOperations.Add(config);
 }
        public void CreateLineNode(WorkflowConfig wfConfig, Root rt, Line line)
        {
            string     lineId   = line.ID;
            StepConfig fromStep = null;
            StepConfig toStep   = null;
            int        index;
            string     nodeId;

            #region 循环查找
            for (int i = 0; i < rt.Nodes.Count; i++)
            {
                nodeId = rt.Nodes[i].ID.Value;
                index  = lineId.IndexOf(nodeId);
                if (index != -1)
                {
                    if (steps.Keys.Contains(nodeId))
                    {
                        if (index == 0)
                        {
                            fromStep = steps[nodeId];
                            RouteStepConfig routeStepConfig = fromStep as RouteStepConfig;
                            if (routeStepConfig != null)
                            {
                                ConnectionConfig connectionConfig = new ConnectionConfig();
                                connectionConfig.DisplayName = line.Text;
                                connectionConfig.PlugName    = line.PlugName;
                                connectionConfig.Name        = line.Name;
                                routeStepConfig.Connections.Add(connectionConfig);
                            }
                        }
                        else
                        {
                            toStep = steps[nodeId];
                        }
                    }
                    else
                    {
                        StepConfig stepConfig = null;
                        #region 将nodes转化为workflowconfig
                        switch ((NodeType)rt.Nodes[i].NodeType.Value)
                        {
                        case NodeType.Begin:
                            BeginStepConfig beginStep = new BeginStepConfig(wfConfig);
                            beginStep.Id             = rt.Nodes[i].ID.Value;
                            beginStep.Name           = rt.Nodes[i].Name.Value;
                            beginStep.DisplayName    = rt.Nodes[i].Text.Value;;
                            beginStep.Height         = rt.Nodes[i].Height.Value;
                            beginStep.Width          = rt.Nodes[i].Width.Value;
                            beginStep.Left           = rt.Nodes[i].X.Value;
                            beginStep.Top            = rt.Nodes[i].Y.Value;
                            beginStep.CreatorRegName = rt.Nodes[i].CreatorRegName.Value;
                            steps.Add(nodeId, beginStep);
                            wfConfig.Steps.Add(beginStep);
                            stepConfig = beginStep;
                            break;

                        case NodeType.End:
                            EndStepConfig endStep = new EndStepConfig(wfConfig);
                            endStep.Id          = rt.Nodes[i].ID.Value;
                            endStep.Name        = rt.Nodes[i].Name.Value;
                            endStep.DisplayName = rt.Nodes[i].Text.Value;;
                            endStep.Height      = rt.Nodes[i].Height.Value;
                            endStep.Width       = rt.Nodes[i].Width.Value;
                            endStep.Left        = rt.Nodes[i].X.Value;
                            endStep.Top         = rt.Nodes[i].Y.Value;
                            endStep.PlugRegName = rt.Nodes[i].PlugRegName.Value;
                            steps.Add(nodeId, endStep);
                            wfConfig.Steps.Add(endStep);
                            stepConfig = endStep;
                            break;

                        case NodeType.Auto:
                            AutoStepConfig autoStep = new AutoStepConfig(wfConfig);
                            autoStep.Id          = rt.Nodes[i].ID.Value;
                            autoStep.Name        = rt.Nodes[i].Name.Value;
                            autoStep.DisplayName = rt.Nodes[i].Text.Value;;
                            autoStep.Height      = rt.Nodes[i].Height.Value;
                            autoStep.Width       = rt.Nodes[i].Width.Value;
                            autoStep.Left        = rt.Nodes[i].X.Value;
                            autoStep.Top         = rt.Nodes[i].Y.Value;
                            autoStep.PlugRegName = rt.Nodes[i].PlugRegName.Value;
                            steps.Add(nodeId, autoStep);
                            wfConfig.Steps.Add(autoStep);
                            stepConfig = autoStep;
                            break;

                        case NodeType.Route:
                            RouteStepConfig routeStep = new RouteStepConfig(wfConfig);
                            routeStep.Id          = rt.Nodes[i].ID.Value;
                            routeStep.Name        = rt.Nodes[i].Name.Value;
                            routeStep.DisplayName = rt.Nodes[i].Text.Value;
                            routeStep.Height      = rt.Nodes[i].Height.Value;
                            routeStep.Width       = rt.Nodes[i].Width.Value;
                            routeStep.Left        = rt.Nodes[i].X.Value;
                            routeStep.Top         = rt.Nodes[i].Y.Value;
                            if (index == 0)
                            {
                                ConnectionConfig connection = new ConnectionConfig();
                                connection.DisplayName = line.Text;
                                connection.PlugName    = line.PlugName;
                                connection.Name        = line.Name;
                                routeStep.Connections.Add(connection);
                            }
                            steps.Add(nodeId, routeStep);
                            wfConfig.Steps.Add(routeStep);
                            stepConfig = routeStep;
                            break;

                        case NodeType.Manual:
                            ManualStepConfig manualStep = new ManualStepConfig(wfConfig);
                            manualStep.Id            = rt.Nodes[i].ID.Value;
                            manualStep.Name          = rt.Nodes[i].Name.Value;
                            manualStep.DisplayName   = rt.Nodes[i].Text.Value;
                            manualStep.Height        = rt.Nodes[i].Height.Value;
                            manualStep.Width         = rt.Nodes[i].Width.Value;
                            manualStep.Left          = rt.Nodes[i].X.Value;
                            manualStep.Top           = rt.Nodes[i].Y.Value;
                            manualStep.ActorRegName  = rt.Nodes[i].ActorRegName.Value;
                            manualStep.ContentXml    = rt.Nodes[i].ManualPageXml.Value;
                            manualStep.ContentChoice = rt.Nodes[i].ContentChoice.Value.Value <ConfigChoice>();
                            if (rt.Nodes[i].ControllActions != null)
                            {
                                manualStep.ControlActions = new Ataw.Framework.Core.RegNameList <ControlActionConfig>();
                                ControlActionConfig controlActionConfig;
                                for (int j = 0; j < rt.Nodes[i].ControllActions.Count; j++)
                                {
                                    controlActionConfig = new ControlActionConfig
                                    {
                                        ShowKind    = (ShowKind)rt.Nodes[i].ControllActions[j].ShowKind,
                                        Title       = rt.Nodes[i].ControllActions[j].Title,
                                        Order       = rt.Nodes[i].ControllActions[j].Order,
                                        AreaName    = rt.Nodes[i].ControllActions[j].AreaName,
                                        ControlName = rt.Nodes[i].ControllActions[j].ControllName,
                                        ActionName  = rt.Nodes[i].ControllActions[j].ActionName
                                    };
                                    manualStep.ControlActions.Add(controlActionConfig);
                                }
                            }
                            if (rt.Nodes[i].Process != null)
                            {
                                manualStep.Process = new ProcessConfig();
                                if (rt.Nodes[i].Process.UIOperationConfig != null)
                                {
                                    manualStep.Process.UIOperation               = new Ataw.Workflow.Core.UIOperationConfig();
                                    manualStep.Process.UIOperation.Name          = rt.Nodes[i].Process.UIOperationConfig.Name;
                                    manualStep.Process.UIOperation.DisplayName   = rt.Nodes[i].Process.UIOperationConfig.DisplayName;
                                    manualStep.Process.UIOperation.ButtonCaption = rt.Nodes[i].Process.UIOperationConfig.ButtonCaption;
                                    manualStep.Process.UIOperation.PlugIn        = rt.Nodes[i].Process.UIOperationConfig.Plugin;
                                }
                                if (rt.Nodes[i].Process.NonUIOperationConfigs != null)
                                {
                                    manualStep.Process.NonUIOperations = new Ataw.Framework.Core.RegNameList <Ataw.Workflow.Core.NonUIOperationConfig>();
                                    Ataw.Workflow.Core.NonUIOperationConfig nonUIOperationConfig;
                                    for (int j = 0; j < rt.Nodes[i].Process.NonUIOperationConfigs.Count; j++)
                                    {
                                        nonUIOperationConfig = new Ataw.Workflow.Core.NonUIOperationConfig
                                        {
                                            Name          = rt.Nodes[i].Process.NonUIOperationConfigs[j].Name,
                                            DisplayName   = rt.Nodes[i].Process.NonUIOperationConfigs[j].DisplayName,
                                            ButtonCaption = rt.Nodes[i].Process.NonUIOperationConfigs[j].ButtonCaption,
                                            PlugIn        = rt.Nodes[i].Process.NonUIOperationConfigs[j].Plugin,
                                            NeedPrompt    = rt.Nodes[i].Process.NonUIOperationConfigs[j].NeedPrompt == "1" ? true : false
                                        };
                                        manualStep.Process.NonUIOperations.Add(nonUIOperationConfig);
                                    }
                                }
                            }
                            steps.Add(nodeId, manualStep);
                            wfConfig.Steps.Add(manualStep);
                            stepConfig = manualStep;
                            break;
                        }
                        #endregion
                        if (index == 0)
                        {
                            fromStep = stepConfig;
                        }
                        else
                        {
                            toStep = stepConfig;
                        }
                    }
                }
            }
            #endregion
            if (fromStep != null && toStep != null)
            {
                //设置路由步骤的Connection 的下一步名称
                RouteStepConfig rsc = fromStep as RouteStepConfig;
                if (rsc != null)
                {
                    rsc.Connections[rsc.Connections.Count - 1].NextStepName = toStep.Name;
                }
                fromStep.AddNextConfig(toStep, fromStep.Left, fromStep.Top, toStep.Left, toStep.Top);
            }
        }