Esempio n. 1
0
 public static void CopyWorkflowToStepHis(WorkflowDbContext wfContext, WF_WORKFLOW_INST workflowRow,
                                          WF_STEP_INST_HIS stepRow, FlowAction flowAction)
 {
     // stepRow.SI_INDEX = workflowRow.WI_INDEX;
     stepRow.SI_INDEX = workflowRow.WI_INDEX;
     //步骤标识 0 -- 有效初始值  1 -- 无效的
     stepRow.SI_VALID_FLAG = 0;
     stepRow.SI_VALID_FLAG = 0;
     //流转方式
     stepRow.SI_FLOW_TYPE = (int?)flowAction;
     ////步骤基本信息
     stepRow.SI_ID    = wfContext.GetUniId();
     stepRow.SI_WI_ID = workflowRow.WI_ID;
     ////上一步骤信息
     stepRow.SI_LAST_STEP        = workflowRow.WI_LAST_STEP;
     stepRow.SI_LAST_STEP_NAME   = workflowRow.WI_LAST_STEP_NAME;
     stepRow.SI_LAST_MANUAL      = workflowRow.WI_LAST_MANUAL;
     stepRow.SI_LAST_MANUAL_NAME = workflowRow.WI_LAST_MANUAL_NAME;
     ////当前步骤
     stepRow.SI_CURRENT_STEP      = workflowRow.WI_CURRENT_STEP;
     stepRow.SI_CURRENT_STEP_NAME = workflowRow.WI_CURRENT_STEP_NAME;
     stepRow.SI_STEP_TYPE         = workflowRow.WI_STEP_TYPE;
     stepRow.SI_PRIORITY          = workflowRow.WI_PRIORITY;
     stepRow.SI_STATUS            = workflowRow.WI_STATUS ?? 0;
     ////当前步骤 时间信息:开始时间 结束时间 步骤用时
     stepRow.SI_START_DATE = workflowRow.WI_CURRENT_CREATE_DATE;
     stepRow.SI_END_DATE   = wfContext.Now;
     stepRow.SI_TIME_SPAN  = (double)((wfContext.Now - stepRow.SI_START_DATE.Value <DateTime>()).Ticks)
                             / TimeSpan.TicksPerDay;
     ////发送时间
     stepRow.SI_SEND_DATE = workflowRow.WI_SEND_DATE;
 }
        public void BeginStepExecute(StepConfig stepConfig, int priority, string workflowName, WorkflowContent content, IUnitOfData context)
        {
            StringBuilder sb = new StringBuilder();

            content.SaveStringBuilder(sb);
            // throw new System.NotImplementedException();

            WorkflowDbContext wfContent = context as WorkflowDbContext;

            //ATAW_WORKFLOWContext wfContent = context as ATAW_WORKFLOWContext;
            WF_WORKFLOW_INST inst = new WF_WORKFLOW_INST();

            inst.WI_ID          = wfContent.GetUniId();
            inst.WI_CONTENT_XML = sb.ToString();
            inst.WI_NAME        = workflowName;
            wfContent.WF_WORKFLOW_INST.Add(inst);

            //步骤基本信息
            StepUtil.SetWorkflowByStep(inst, stepConfig.Name, stepConfig.DisplayName, wfContent.Now,
                                       (int)stepConfig.StepType, (int)StepState.ProcessNotSend);
            inst.WI_INDEX    = 1;
            inst.WI_PRIORITY = priority;
            //扩展信息
            //父子流程
            //主表控制
            content.SetAllMainRow(wfContent, stepConfig, inst.WI_ID);
        }
Esempio n. 3
0
        public override void Execute(WF_WORKFLOW_INST workflowRow)
        {
            // throw new NotImplementedException();
            if (UIData != null && UIData.Tables["WF_APPROVE_HISTORY"] != null)
            {
                var approveRow = UIData.Tables["WF_APPROVE_HISTORY"].Rows[0];

                var yes = approveRow["AH_APPROVE"].ToString();

                var note = approveRow["AH_NOTE"].ToString();

                WorkflowDbContext db = Source as WorkflowDbContext;
                SetApproveYes(yes.Value <bool>(), db);
                string sql = "INSERT INTO [WF_APPROVE_HISTORY] " +
                             "([AH_ID] " +
                             ",[AH_WORKFLOW_ID] " +
                             ",[AH_STEP_NAME] " +
                             ",[AH_STEP_DISPLAY_NAME] " +
                             ",[AH_OPERATOR] " +
                             " ,[AH_APPROVE] " +
                             " ,[AH_NOTE] " +
                             " ,[AH_CREATE_ID] " +
                             " ,[AH_CREATE_DATE]) " +
                             "VALUES(@AH_ID,@AH_WORKFLOW_ID,@AH_STEP_NAME,@AH_STEP_DISPLAY_NAME,@AH_OPERATOR,@AH_APPROVE,@AH_NOTE,@AH_CREATE_ID,@AH_CREATE_DATE) ";
                // "('" + db.GetUniId() + "' " +
                // ",'" + workflowRow.WI_ID + "' " +
                //" ,'" + workflowRow.WI_CURRENT_STEP + "' " +
                // ",'" + workflowRow.WI_CURRENT_STEP_NAME + "' " +
                //" ,'" + GlobalVariable.UserId.ToString() + "' " +
                //" ," + yes +
                //" ,'" + note + "' " +
                // " ,'" + GlobalVariable.UserId.ToString() + "' " +
                //" ,'" + db.Now.ToString() + "') ";

                List <SqlParameter> dblist = new List <SqlParameter>();

                dblist.Add(new SqlParameter("@AH_ID", db.GetUniId()));
                dblist.Add(new SqlParameter("@AH_WORKFLOW_ID", workflowRow.WI_ID));
                dblist.Add(new SqlParameter("@AH_STEP_NAME", workflowRow.WI_CURRENT_STEP));
                dblist.Add(new SqlParameter("@AH_STEP_DISPLAY_NAME", workflowRow.WI_CURRENT_STEP_NAME));
                dblist.Add(new SqlParameter("@AH_OPERATOR", GlobalVariable.UserId.ToString()));
                dblist.Add(new SqlParameter("@AH_APPROVE", yes));
                dblist.Add(new SqlParameter("@AH_NOTE", note));
                dblist.Add(new SqlParameter("@AH_CREATE_ID", GlobalVariable.UserId.ToString()));
                dblist.Add(new SqlParameter("@AH_CREATE_DATE", db.Now.ToString()));
                db.RegisterSqlCommand(sql, dblist.ToArray());

                workflowRow.WI_CUSTOM_DATA = yes;
            }
        }
Esempio n. 4
0
        //-1重名,-2 异常,返回其他(id)正常成功
        public string AddOrEditWorkflowDefine(WorkflowConfig config)
        {
            try
            {
                var workflow = context.WF_WORKFLOW_DEF.FirstOrDefault <WF_WORKFLOW_DEF>(m => m.WD_ID == config.Id);
                if (workflow != null)
                {
                    workflow.WD_DESCRIPTION = config.Description;
                    workflow.WD_CONTENT     = config.SaveString();
                    workflow.WD_DESCRIPTION = config.Description;
                    workflow.WD_NAME        = config.DisplayName;
                    workflow.WD_UPDATE_DATE = context.Now;
                    workflow.WD_UPDATE_ID   = GlobalVariable.UserId.ToString();
                    context.SaveChanges();
                    return(workflow.WD_ID);
                }
                else
                {
                    WF_WORKFLOW_DEF def = new WF_WORKFLOW_DEF();
                    //如重名,返回-1
                    if (context.WF_WORKFLOW_DEF.FirstOrDefault <WF_WORKFLOW_DEF>(m => m.WD_SHORT_NAME == config.Name) != null)
                    {
                        return("-1");
                    }
                    def.WD_ID          = context.GetUniId();
                    config.Id          = def.WD_ID;
                    def.WD_CONTENT     = config.SaveString();
                    def.WD_CREATE_DATE = context.Now;
                    def.WD_CREATE_ID   = GlobalVariable.UserId.ToString();
                    def.WD_DESCRIPTION = config.Description;
                    def.WD_IS_USED     = 1;
                    def.WD_NAME        = config.DisplayName;
                    def.WD_SHORT_NAME  = config.Name;
                    def.WD_UPDATE_DATE = context.Now;
                    def.FControlUnitID = GlobalVariable.FControlUnitID;
                    def.WD_UPDATE_ID   = GlobalVariable.UserId.ToString();

                    context.WF_WORKFLOW_DEF.Add(def);
                    context.SaveChanges();
                    return(def.WD_ID);
                }
            }
            catch
            {
                return("-2");
            }
        }
Esempio n. 5
0
        public Workflow(IUnitOfData source, string name, RegNameList <KeyValueItem> parameter, string createUser,
                        int?parentId)
            : this(source)
        {
            //  Source = source;
            WorkflowDbContext dbContext = source as WorkflowDbContext;
            Config      = WorkflowConfig.GetByName(name, source);
            WorkflowRow = new WF_WORKFLOW_INST();
            //WorkflowRow.BeginEdit();
            WorkflowRow.WI_ID = dbContext.GetUniId();
            //WorkflowRow["WI_ID"] = id;
            WorkflowId                 = WorkflowRow.WI_ID;
            WorkflowRow.WI_WD_NAME     = name;
            WorkflowRow.WI_CREATE_USER = createUser;
            // WorkflowRow["WI_RETRIEVABLE"] = Config.Retrievable;
            ////初始化参与人列表
            WorkflowRow.WI_REF_LIST    = QuoteIdList.GetQuoteId(createUser);
            WorkflowRow.WI_CREATE_DATE = dbContext.Now;

            BeginStep step = Config.Steps.BeginStep.CreateStep(this) as BeginStep;
            step.Parameter = parameter;
            CurrentStep    = step;
            CurrentState   = BeginNRState.Instance;
        }
        public Root WorkflowConfig2Root(WorkflowConfig workflowConfig)
        {
            Root root = new Root();

            root.ID            = workflowConfig.Id;
            root.Description   = workflowConfig.Description;
            root.DisplayName   = workflowConfig.DisplayName;
            root.IsSave        = workflowConfig.IsSaveContent.ToString();
            root.Name          = workflowConfig.Name;
            root.Priority      = ((int)workflowConfig.Priority).ToString();
            root.ContentChoice = ((int)workflowConfig.ContentChoice).ToString();
            root.ManualPageXml = workflowConfig.ContentXml ?? "";
            if (workflowConfig.ControlActions != null)
            {
                root.ControllActions = new List <ControllAction>();
                ControllAction controllAction;
                foreach (ControlActionConfig caConfig in workflowConfig.ControlActions)
                {
                    controllAction              = new ControllAction();
                    controllAction.ActionName   = caConfig.ActionName;
                    controllAction.AreaName     = caConfig.AreaName;
                    controllAction.ControllName = caConfig.ControlName;
                    controllAction.Order        = caConfig.Order;
                    controllAction.Title        = caConfig.Title == null ? "" : caConfig.Title;
                    controllAction.ShowKind     = (int)caConfig.ShowKind;
                    root.ControllActions.Add(controllAction);
                }
            }
            root.Nodes    = new List <Node>();
            root.LineList = new List <Line>();
            Node node;

            for (int i = 0; i < workflowConfig.Steps.Count; i++)
            {
                node = new Node();
                Line             line       = new Line();
                StepConfig       stepConfig = workflowConfig.Steps[i];
                BeginStepConfig  beginStep  = workflowConfig.Steps[i] as BeginStepConfig;
                EndStepConfig    endStep    = workflowConfig.Steps[i] as EndStepConfig;
                AutoStepConfig   autoStep   = workflowConfig.Steps[i] as AutoStepConfig;
                ManualStepConfig manualStep = workflowConfig.Steps[i] as ManualStepConfig;
                RouteStepConfig  routeStep  = workflowConfig.Steps[i] as RouteStepConfig;
                node.ObjectIndex = new BaseIntElement {
                    Type = "number", Value = 0
                };
                node.TypeIndex = new BaseIntElement {
                    Type = "number", Value = 0
                };
                stepConfig.Id = string.IsNullOrEmpty(stepConfig.Id) ? context.GetUniId() : stepConfig.Id;
                node.ID       = new BaseStringElement {
                    Type = "string", Value = stepConfig.Id
                };
                node.Text = new BaseStringElement {
                    Type = "string", Value = stepConfig.DisplayName
                };
                node.Name = new BaseStringElement {
                    Type = "string", Value = stepConfig.Name
                };
                node.Height = new BaseIntElement {
                    Type = "number", Value = stepConfig.Height == 0 ? 51 : stepConfig.Height
                };
                node.Width = new BaseIntElement {
                    Type = "number", Value = stepConfig.Width == 0 ? 130 : stepConfig.Width
                };
                node.X = new BaseIntElement {
                    Type = "number", Value = stepConfig.Left
                };
                node.Y = new BaseIntElement {
                    Type = "number", Value = stepConfig.Top
                };
                node.ParentList = new List <Parent>();
                node.ChildList  = new List <Child>();
                if (stepConfig.HasInStep)
                {
                    Parent parent;
                    ////输入节点数量 0:无输入 1:1输入 2:多输入
                    //switch (stepConfig.PrevSteps.Count())
                    //{
                    //    case 0:
                    //        node.InputType = new BaseIntElement { Type = "number", Value = 0 };
                    //        break;
                    //    case 1:
                    //        node.InputType = new BaseIntElement { Type = "number", Value = 1 };
                    //        break;
                    //    default:
                    //        node.InputType = new BaseIntElement { Type = "number", Value = 2 };
                    //        break;
                    //}
                    foreach (StepConfig sc in stepConfig.PrevSteps)
                    {
                        sc.Id        = string.IsNullOrEmpty(sc.Id) ? context.GetUniId() : sc.Id;
                        parent       = new Parent();
                        parent.Value = sc.Id;
                        node.ParentList.Add(parent);
                    }
                }
                if (stepConfig.HasOutStep)
                {
                    Child child;
                    //switch (stepConfig.NextStepCount)
                    //{
                    //    case 0:
                    //        node.OutputType = new BaseIntElement { Type = "number", Value = 0 };
                    //        break;
                    //    case 1:
                    //        node.OutputType = new BaseIntElement { Type = "number", Value = 1 };
                    //        break;
                    //    default:
                    //        node.OutputType = new BaseIntElement { Type = "number", Value = 2 };
                    //        break;
                    //}
                    foreach (StepConfig sc in stepConfig.NextSteps)
                    {
                        sc.Id       = string.IsNullOrEmpty(sc.Id) ? context.GetUniId() : sc.Id;
                        child       = new Child();
                        child.Value = sc.Id;
                        node.ChildList.Add(child);
                        line    = new Line();
                        line.ID = stepConfig.Id + "_" + sc.Id;
                        if (routeStep != null)
                        {
                            for (int k = 0; k < routeStep.Connections.Count; k++)
                            {
                                if (routeStep.Connections[k].NextStepName == sc.Name)
                                {
                                    line.Name     = routeStep.Connections[k].Name;
                                    line.PlugName = routeStep.Connections[k].PlugName;
                                    line.Text     = routeStep.Connections[k].DisplayName;
                                    break;
                                }
                            }
                        }
                        root.LineList.Add(line);
                    }
                }
                if (beginStep != null)
                {
                    node.Icon = new BaseStringElement {
                        Type = "string", Value = "nodeicon1"
                    };
                    node.NodeType = new BaseIntElement {
                        Type = "number", Value = (int)NodeType.Begin
                    };
                    node.CreatorRegName = new BaseStringElement {
                        Type = "string", Value = beginStep.CreatorRegName
                    };
                    node.InputType = new BaseIntElement {
                        Type = "number", Value = 0
                    };
                    node.OutputType = new BaseIntElement {
                        Type = "number", Value = 1
                    };
                }
                else if (endStep != null)
                {
                    node.Icon = new BaseStringElement {
                        Type = "string", Value = "nodeicon2"
                    };
                    node.NodeType = new BaseIntElement {
                        Type = "number", Value = (int)NodeType.End
                    };
                    node.PlugRegName = new BaseStringElement {
                        Type = "string", Value = endStep.PlugRegName
                    };
                    node.InputType = new BaseIntElement {
                        Type = "number", Value = 2
                    };
                    node.OutputType = new BaseIntElement {
                        Type = "number", Value = 0
                    };
                }
                else if (routeStep != null)
                {
                    node.Icon = new BaseStringElement {
                        Type = "string", Value = "nodeicon3"
                    };
                    node.NodeType = new BaseIntElement {
                        Type = "number", Value = (int)NodeType.Route
                    };
                    node.InputType = new BaseIntElement {
                        Type = "number", Value = 2
                    };
                    node.OutputType = new BaseIntElement {
                        Type = "number", Value = 2
                    };
                }
                else if (autoStep != null)
                {
                    node.Icon = new BaseStringElement {
                        Type = "string", Value = "nodeicon-auto"
                    };
                    node.NodeType = new BaseIntElement {
                        Type = "number", Value = (int)NodeType.Auto
                    };
                    node.PlugRegName = new BaseStringElement {
                        Type = "string", Value = autoStep.PlugRegName
                    };
                    node.InputType = new BaseIntElement {
                        Type = "number", Value = 2
                    };
                    node.OutputType = new BaseIntElement {
                        Type = "number", Value = 1
                    };
                }
                else if (manualStep != null)
                {
                    node.Icon = new BaseStringElement {
                        Type = "string", Value = "nodeicon5"
                    };
                    node.NodeType = new BaseIntElement {
                        Type = "number", Value = (int)NodeType.Manual
                    };
                    node.ActorRegName = new BaseStringElement {
                        Type = "string", Value = manualStep.ActorRegName
                    };
                    node.InputType = new BaseIntElement {
                        Type = "number", Value = 2
                    };
                    node.OutputType = new BaseIntElement {
                        Type = "number", Value = 1
                    };
                    node.ManualPageXml = new BaseStringElement {
                        Type = "string", Value = manualStep.ContentXml
                    };
                    node.ContentChoice = new BaseIntElement {
                        Type = "number", Value = (int)manualStep.ContentChoice
                    };

                    if (manualStep.ControlActions != null)
                    {
                        node.ControllActions = new List <ControllAction>();
                        ControllAction controllAction;
                        foreach (ControlActionConfig caConfig in manualStep.ControlActions)
                        {
                            controllAction              = new ControllAction();
                            controllAction.ActionName   = caConfig.ActionName;
                            controllAction.AreaName     = caConfig.AreaName;
                            controllAction.ControllName = caConfig.ControlName;
                            controllAction.Order        = caConfig.Order;
                            controllAction.Title        = caConfig.Title == null ? "" : caConfig.Title;
                            controllAction.ShowKind     = (int)caConfig.ShowKind;
                            node.ControllActions.Add(controllAction);
                        }
                    }

                    if (manualStep.Process != null)
                    {
                        node.Process = new Process();
                        node.Process.UIOperationConfig = new WorkFlowDesigner.Models.UIOperationConfig();
                        if (manualStep.Process.UIOperation != null)
                        {
                            node.Process.UIOperationConfig.ButtonCaption = manualStep.Process.UIOperation.ButtonCaption;
                            node.Process.UIOperationConfig.DisplayName   = manualStep.Process.UIOperation.DisplayName;
                            node.Process.UIOperationConfig.Name          = manualStep.Process.UIOperation.Name;
                            node.Process.UIOperationConfig.Plugin        = manualStep.Process.UIOperation.PlugIn;
                        }
                        node.Process.NonUIOperationConfigs = new List <WorkFlowDesigner.Models.NonUIOperationConfig>();
                        WorkFlowDesigner.Models.NonUIOperationConfig nonUiConfig;
                        if (manualStep.Process.NonUIOperations != null)
                        {
                            foreach (var nonUi in manualStep.Process.NonUIOperations)
                            {
                                nonUiConfig = new WorkFlowDesigner.Models.NonUIOperationConfig();
                                nonUiConfig.ButtonCaption = nonUi.ButtonCaption;
                                nonUiConfig.DisplayName   = nonUi.DisplayName;
                                nonUiConfig.Name          = nonUi.Name;
                                nonUiConfig.NeedPrompt    = nonUi.NeedPrompt.ToString();
                                nonUiConfig.Plugin        = nonUi.PlugIn;
                                node.Process.NonUIOperationConfigs.Add(nonUiConfig);
                            }
                        }
                    }
                }
                root.Nodes.Add(node);
            }
            return(root);
        }