/// <summary>
        /// 记录新发起的工作流实例
        /// </summary>
        /// <param name="WFName">工作流名称</param>
        /// <param name="WFDataID">工作流实例对应的数据的ID</param>
        /// <param name="OpeManID">操作人</param>
        /// <param name="WFID">工作流ID</param>
        /// <param name="NewInstanceID">新工作流实例ID</param>
        public static string PutDownNewInstance(string WFName, string WFDataID, string OpeManID, string WFID, string NewInstanceID)
        {
            try
            {
                string WFVersion = CWFManager.GetLastVersion(WFName);
                if (WFVersion == null || WFVersion == "")
                {
                    CInstanceManager.SetInstanceError(NewInstanceID, "缺少工作流版本号");
                    WFGlobal.ErrInfo = CLog.PutDownErrInfo("工作流实例" + NewInstanceID + "缺少工作流版本号");
                    return(WFGlobal.ErrInfo);
                }

                if (CDataHelper.ExecuteNonQuery("insert into " + CTableName.FlowChartInstance + "(flowchart_id,flowchart_version,instance_id,cre_date,cre_man,instance_status) values('" + WFID + "','" + WFVersion + "','" + NewInstanceID + "','" + DateTime.Now.ToString() + "','" + OpeManID + "','" + EInstanceStatus.Active.ToString() + "')") < 0)
                {
                    WFGlobal.ErrInfo = CLog.PutDownErrInfo("记录工作流实例信息失败。");
                    return(WFGlobal.ErrInfo);
                }

                if (CDataHelper.ExecuteNonQuery("insert into " + CTableName.FlowChartPars + "(instance_id,keyvalue) values('" + NewInstanceID + "','" + WFDataID + "')") < 0)
                {
                    WFGlobal.ErrInfo = CLog.PutDownErrInfo("记录工作流数据信息失败。");
                    return(WFGlobal.ErrInfo);
                }
                return(WFGlobal.success);
            }
            catch (Exception ex)
            {
                WFGlobal.ErrInfo = CLog.PutDownErrInfo("记录工作流实例操作异常。工作流名称:" + WFName + ",数据ID:" + WFDataID + ",发起人ID:" + OpeManID + ",工作流ID:" + WFID + ",异常信息:" + ex.Message.ToString());
                return(WFGlobal.ErrInfo);
            }
        }
Exemplo n.º 2
0
 public string GetInstanceAll()
 {
     try
     {
         return(CInstanceManager.GetInstance("SELECT f.flowchart_name,i.[flowchart_id],i.[flowchart_version],i.[instance_id],i.[cre_date] ,u.user_name,i.[cre_man],i.[instance_status],i.[instance_message] FROM [kailifon].[dbo].[a_flowchart_instance] as i left join " + CTableName.FlowChart + " as f on(f.flowchart_id=i.flowchart_id) left join a_user as u on (i.cre_man=u.user_id) "));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 3
0
 public string GetInstanceFlowHistory(string InstanceID)
 {
     try
     {
         return(CInstanceManager.GetInstanceFlowHistory(InstanceID));
     }
     catch (Exception ex)
     {
         CLog.PutDownErrInfo("获取工作流实例流转历史操作异常。实例ID:" + InstanceID + ",异常信息:" + ex.Message.ToString());
         throw ex;
     }
 }
Exemplo n.º 4
0
 public string TerminateInstance(string InstanceID)
 {
     try
     {
         if (WFGlobal.ServerStarted == true)
         {
             return(CInstanceManager.SetInstanceComplete(InstanceID));
         }
         WFGlobal.ErrInfo = CLog.PutDownErrInfo("停止工作流实例操作失败,工作流服务未启动。工作流实例ID:" + InstanceID);
         return(WFGlobal.ErrInfo);
     }
     catch (Exception ex)
     {
         WFGlobal.ErrInfo = CLog.PutDownErrInfo("停止工作流实例操作失败,工作流服务未启动。工作流实例ID:" + InstanceID + ",异常信息:" + ex.Message.ToString());
         return(WFGlobal.ErrInfo);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// 发起流程命令处理
        /// </summary>
        /// <param name="WFName">流程名称</param>
        /// <param name="WFDataID">数据表相对应数据ID</param>
        /// <param name="OpeManID">发起人ID</param>
        private string WFStartDeal(string WFName, string WFDataID, string OpeManID)
        {
            try
            {
                string WFID = CWFManager.GetLastVersionWFID(WFName);

                if (WFID == null || WFID == "")
                {
                    WFGlobal.ErrInfo = CLog.PutDownErrInfo("工作流" + WFName + "不存在。");
                    return(WFGlobal.ErrInfo);
                }

                string StartNodeID = CNodeManager.GetStartNodeID(WFID);
                if (StartNodeID == null || StartNodeID == "")
                {
                    WFGlobal.ErrInfo = CLog.PutDownErrInfo("工作流" + WFID + "没有起始节点。");
                    return(WFGlobal.ErrInfo);
                }

                string NewInstanceID = Guid.NewGuid().ToString();

                //记录工作流实例
                string PutDownInstanceResult = CInstanceManager.PutDownNewInstance(WFName, WFDataID, OpeManID, WFID, NewInstanceID);
                if (PutDownInstanceResult != WFGlobal.success)
                {
                    return(PutDownInstanceResult);
                }

                //将工作流实例的审批人设定为发起人
                string PutDownApproverResult = CApprovalManager.PutDownApprover(NewInstanceID, StartNodeID, OpeManID, 1, "");
                if (PutDownApproverResult != WFGlobal.success)
                {
                    return(PutDownApproverResult);
                }

                //流程流转
                return(WFTransmitDeal(NewInstanceID, StartNodeID, EApprovalOpinion.意, OpeManID, ""));
            }
            catch (Exception ex)
            {
                WFGlobal.ErrInfo = CLog.PutDownErrInfo("发起工作流操作异常。工作流名称:" + WFName + ",发起人ID:" + OpeManID + ",数据ID" + WFDataID + ",异常信息:" + ex.Message.ToString());
                return(WFGlobal.ErrInfo);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 节点转移,从当前节点进入下一节点
        /// </summary>
        /// <param name="WFID"></param>
        /// <param name="InstanceID"></param>
        /// <param name="NodeID"></param>
        /// <param name="NextNodeID"></param>
        public static string NodeTransfer(string InstanceID, string NodeID, string NextNodeID)
        {
            try
            {
                if (CNodeManager.IsNodeThroughEnable(InstanceID, NextNodeID))
                {
                    //记录流转历史
                    if (CDataHelper.ExecuteNonQuery("insert into " + CTableName.FlowChartHistory + "(instance_id,node_id,next_node_id) values('" + InstanceID + "','" + NodeID + "','" + NextNodeID + "')") < 0)
                    {
                        WFGlobal.ErrInfo = CLog.PutDownErrInfo("记录工作流实例流转节点失败,工作流实例ID:" + InstanceID + ",开始节点ID:" + NodeID + ",结束节点ID:" + NextNodeID);
                        return(WFGlobal.ErrInfo);
                    }

                    string NodeType = CNodeManager.GetNodeType(NextNodeID);
                    if (NodeType == CNodeType.SwitchType)
                    {
                        return(GoNextNodesFromSwitchNode(InstanceID, NextNodeID));
                    }
                    else if (NodeType == CNodeType.ProcessType)
                    {
                        RunProcessScript(InstanceID, NextNodeID);
                        return(CNodeManager.GoNextNodesFromOtherNode(InstanceID, NextNodeID));
                    }
                    else if (NodeType == CNodeType.ApproveType || NodeType == CNodeType.StartType)
                    {
                        return(CNodeManager.PutDownNodeApprover(InstanceID, NextNodeID));
                    }
                    else if (NodeType == CNodeType.EndType)
                    {
                        return(CInstanceManager.SetInstanceComplete(InstanceID));
                    }
                }
                return(WFGlobal.success);
            }
            catch (Exception ex)
            {
                WFGlobal.ErrInfo = CLog.PutDownErrInfo("节点流转异常,工作流实例ID:" + InstanceID + ",开始节点ID:" + NodeID + ",结束节点ID:" + NextNodeID);
                return(WFGlobal.ErrInfo);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 记录节点的审批人
        /// </summary>
        /// <param name="InstanceID"></param>
        /// <param name="NodeID"></param>
        public static string PutDownNodeApprover(string InstanceID, string NodeID)
        {
            try
            {
                string nodetype = CNodeManager.GetNodeType(NodeID);
                if (nodetype == null)
                {
                    WFGlobal.ErrInfo = CLog.PutDownErrInfo("获取节点" + NodeID + "的节点类型失败,工作流实例ID:" + InstanceID);
                    CInstanceManager.SetInstanceError(InstanceID, WFGlobal.ErrInfo);
                    return(WFGlobal.ErrInfo);
                }

                int ApprovalNum = CApprovalManager.GetLastApprovalNum(InstanceID, NodeID);
                //判断是否开始流程
                if (nodetype == CNodeType.StartType)
                {
                    string StartManID = CInstanceManager.GetInstanceStartManID(InstanceID);
                    if (StartManID == null)
                    {
                        WFGlobal.ErrInfo = CLog.PutDownErrInfo("获取流程实例的发起人失败,工作流实例ID:" + InstanceID);
                        CInstanceManager.SetInstanceError(InstanceID, WFGlobal.ErrInfo);
                        return(WFGlobal.ErrInfo);
                    }

                    string ApprovalNote = CApprovalManager.GetApprovalNote(InstanceID, NodeID);

                    string PutDownApproverResult = CApprovalManager.PutDownApprover(InstanceID, NodeID, StartManID, ApprovalNum + 1, ApprovalNote);
                    if (PutDownApproverResult != WFGlobal.success)
                    {
                        return(PutDownApproverResult);
                    }
                }
                //判断流程是否结束
                else if (nodetype != CNodeType.EndType)
                {
                    DataTable dtReceiver   = CApprovalManager.GetApprover(InstanceID, NodeID);
                    string    ApprovalNote = CApprovalManager.GetApprovalNote(InstanceID, NodeID);
                    if (dtReceiver != null)
                    {
                        if (dtReceiver.Rows.Count > 0)
                        {
                            for (int i = 0; i < dtReceiver.Rows.Count; i++)
                            {
                                string ReceiverID            = dtReceiver.Rows[i][WFGlobal.UserID].ToString();
                                string PutDownApproverResult = CApprovalManager.PutDownApprover(InstanceID, NodeID, ReceiverID, ApprovalNum + 1, ApprovalNote);
                                if (PutDownApproverResult != WFGlobal.success)
                                {
                                    return(PutDownApproverResult);
                                }
                            }
                        }
                    }
                }
                return(WFGlobal.success);
            }
            catch (Exception ex)
            {
                WFGlobal.ErrInfo = CLog.PutDownErrInfo("记录节点审批人操作异常。工作流实例ID:" + InstanceID + ",节点ID:" + NodeID + ",异常信息:" + ex.Message.ToString());
                return(WFGlobal.ErrInfo);
            }
        }