public bool IsNodeAllAgree(string InstanceID, string NodeID) { try { int ApprovalNum = CApprovalManager.GetLastApprovalNum(InstanceID, NodeID); if (ApprovalNum == 0) { return(false); } string strUnCompleteNum = CDataHelper.GetData("select count(*) from " + CTableName.FlowChartReceiver + " where instance_id='" + InstanceID + "' and node_id='" + NodeID + "' and approval_num='" + ApprovalNum + "' and approval_status<>'" + EApprovalStatus.Complete.ToString() + "'"); if (strUnCompleteNum != "0") { return(false); } string strUnAgreeNum = CDataHelper.GetData("select count(*) from " + CTableName.FlowChartReceiver + " where instance_id='" + InstanceID + "' and node_id='" + NodeID + "' and approval_num='" + ApprovalNum + "' and approval_opinion<>'" + EApprovalStatus.Complete.ToString() + "' and approval_opinion<>NULL and approval_opinion<>''"); if (strUnAgreeNum != "0") { return(false); } return(true); } catch (Exception ex) { CLog.PutDownErrInfo("判断节点审批人是否都同意操作异常。实例ID:" + InstanceID + ",节点ID:" + NodeID + ",异常信息:" + ex.Message.ToString()); throw ex; } }
/// <summary> /// 通过工作流实例ID和分支节点ID,获取当前分支节点所选的分支的名称 /// </summary> /// <param name="InstanceID">工作流实例ID</param> /// <param name="NodeID">节点ID</param> /// <returns></returns> public static string[] GetSwitchName(string InstanceID, string NodeID) { try { string[] SwitchNames = null; string SwitchScript = CDataHelper.GetData("select switchscript from " + CTableName.FlowChartNode + " where [node_id]='" + NodeID + "'"); if (SwitchScript == null || SwitchScript == "") { return(null); } else { object SwitchNameObj = CScriptOpe.ScriptExec(SwitchScript, InstanceID); if (SwitchNameObj == null || SwitchNameObj == "") { return(null); } else { SwitchNames = SwitchNameDecode(SwitchNameObj); return(SwitchNames); } } } catch (Exception ex) { CLog.PutDownErrInfo("获取节点流转分支操作异常。实例ID:" + InstanceID + ",节点ID:" + NodeID + ",异常信息:" + ex.Message.ToString()); throw ex; } }
/// <summary> /// 根据不同的审批意见获取不同的下一级节点 /// </summary> /// <param name="NodeID">当前节点ID</param> /// <param name="Apo"></param> /// <returns></returns> public static string GetNextNodeIDByCurrentNodeID(string NodeID, EApprovalOpinion Apo) { try { string WFID = CWFManager.GetWFIDByNodeID(NodeID); if (Apo == EApprovalOpinion.意) { return(CDataHelper.GetData("select next_node_id from " + CTableName.FlowChartLine + " where node_id='" + NodeID + "'")); } else if (Apo == EApprovalOpinion.意) { return(CDataHelper.GetData("select [node_id] from " + CTableName.FlowChartNode + " where [flowchart_id]='" + WFID + "' and [nodetype]='" + CNodeType.EndType + "'")); } else if (Apo == EApprovalOpinion.驳回上级) { return(GetUpApprovalNodeID(NodeID)); } else { return(GetStartNodeID(WFID)); } } catch (Exception ex) { CLog.PutDownErrInfo("通过节点ID获取下一个节点ID操作异常。节点ID:" + NodeID + ",异常信息:" + ex.Message.ToString()); throw ex; } }
/// <summary> /// 获取活动未完成审批的活动节点 /// </summary> /// <returns></returns> public static string GetActiveNode(string InstanceID) { try { string ActiveNodeStr = ""; DataTable dtActiveNode = CDataHelper.GetDataTable("select distinct node_id from " + CTableName.FlowChartReceiver + " where instance_id='" + InstanceID + "' and approval_status='" + EApprovalStatus.Active.ToString() + "'"); if (dtActiveNode != null) { for (int i = 0; i < dtActiveNode.Rows.Count; i++) { ActiveNodeStr += dtActiveNode.Rows[i][0].ToString() + ";"; } if (ActiveNodeStr.Length > 0) { ActiveNodeStr = ActiveNodeStr.Substring(0, ActiveNodeStr.Length - 1); } } return(ActiveNodeStr); } catch (Exception ex) { CLog.PutDownErrInfo("获取活动节点操作异常。实例ID:" + InstanceID + ",异常信息:" + ex.Message.ToString()); throw ex; } }
/// <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); } }
/// <summary> /// 获取各个审批意见对应的处理脚本 /// </summary> /// <param name="NodeID"></param> /// <param name="ApprovalOpinion"></param> /// <returns></returns> public static string GetApprovalScript(string NodeID, EApprovalOpinion ApprovalOpinion) { try { return(CDataHelper.GetData("select [approvescript] from " + CTableName.FlowChartNodeApproveItem + " where node_id='" + NodeID + "' and [approvename]='" + ApprovalOpinion.ToString() + "'")); } catch (Exception ex) { throw ex; } }
public DataTable getDataTable(string strSql) { try { return(CDataHelper.GetDataTable(strSql)); } catch (Exception ex) { CLog.PutDownErrInfo("通过SQL语句获取人员信息操作异常。SQL语句:" + strSql + ",异常信息:" + ex.Message.ToString()); throw ex; } }
/// <summary> /// 获取最后一个版本号 /// </summary> /// <param name="WFName"></param> /// <returns></returns> public static string GetLastVersion(string WFName) { try { return(CDataHelper.GetData("select top 1 isnull(flowchart_version,'') as flowchart_version from " + CTableName.FlowChart + " where flowchart_name='" + WFName + "' order by id desc")); } catch (Exception ex) { CLog.PutDownErrInfo("获取工作流" + WFName + "的最后一个版本号操作异常,异常信息:" + ex.Message.ToString()); throw ex; } }
/// <summary> /// 获取工作流实例的发起人ID /// </summary> /// <param name="InstanceID"></param> /// <returns></returns> public static string GetInstanceStartManID(string InstanceID) { try { return(CDataHelper.GetData("select cre_man from " + CTableName.FlowChartInstance + " where instance_id='" + InstanceID + "'")); } catch (Exception ex) { CLog.PutDownErrInfo("获取工作流实例发起人ID操作异常。实例ID:" + InstanceID + ",异常信息:" + ex.Message.ToString()); throw ex; } }
public static string GetWFIDByNodeID(string NodeID) { try { return(CDataHelper.GetData("select flowchart_id from " + CTableName.FlowChartNode + " where node_id='" + NodeID + "'")); } catch (Exception ex) { CLog.PutDownErrInfo("获取节点所属工作流ID操作异常,异常信息:" + ex.Message.ToString()); throw ex; } }
/// <summary> /// 获取节点类型 /// </summary> /// <param name="NodeID"></param> /// <returns></returns> public static string GetNodeType(string NodeID) { try { return(CDataHelper.GetData("select [nodetype] from " + CTableName.FlowChartNode + " where [node_id]='" + NodeID + "'")); } catch (Exception ex) { CLog.PutDownErrInfo("获取节点类型操作异常。节点ID:" + NodeID + ",异常信息:" + ex.Message.ToString()); throw ex; } }
/// <summary> /// 通过Switch名称获取SwitchID /// </summary> /// <param name="SwitchNodeID"></param> /// <param name="SwitchName"></param> /// <returns></returns> public static string GetSwitchIDBySwitchName(string SwitchNodeID, string SwitchName) { try { return(CDataHelper.GetData("select [switchid] from " + CTableName.FlowChartSwitchitem + " where [node_id]='" + SwitchNodeID + "' and [switchname]='" + SwitchName + "'")); } catch (Exception ex) { CLog.PutDownErrInfo("通过SwitchName获取SwitchID操作异常。节点ID:" + SwitchNodeID + ",SwitchName:" + SwitchName + ",异常信息:" + ex.Message.ToString()); throw ex; } }
public static string GetNodeScript(string NodeID, EScriptType ScriptType) { try { return(CDataHelper.GetData("select " + ScriptType.ToString() + " from " + CTableName.FlowChartNode + " where node_id='" + NodeID + "'")); } catch (Exception ex) { CLog.PutDownErrInfo("获取节点脚本操作异常。节点ID:" + NodeID + ",脚本类型:" + ScriptType.ToString() + ",异常信息:" + ex.Message.ToString()); throw ex; } }
/// <summary> /// 获取上一级节点 /// </summary> /// <param name="NodeID">当前节点ID</param> /// <returns></returns> public static string GetUpNodeID(string NodeID) { try { return(CDataHelper.GetData("select node_id from " + CTableName.FlowChartLine + " where next_node_id='" + NodeID + "'")); } catch (Exception ex) { CLog.PutDownErrInfo("通过节点ID获取上一个节点ID操作异常。节点ID:" + NodeID + ",异常信息:" + ex.Message.ToString()); throw ex; } }
/// <summary> /// 获取开始节点 /// </summary> /// <param name="WFID"></param> /// <returns></returns> public static string GetStartNodeID(string WFID) { try { return(CDataHelper.GetData("select [node_id] from " + CTableName.FlowChartNode + " where [flowchart_id]='" + WFID + "' and [nodetype]='" + CNodeType.StartType + "'")); } catch (Exception ex) { CLog.PutDownErrInfo("获取工作流的开始节点操作异常。工作流ID:" + WFID + ",异常信息:" + ex.Message.ToString()); throw ex; } }
/// <summary> /// 通过SwitchID获取下一个节点ID /// </summary> /// <param name="SwitchID"></param> /// <returns></returns> public static string GetNextNodeIDBySwitchID(string SwitchID) { try { return(CDataHelper.GetData("select next_node_id from " + CTableName.FlowChartLine + " where [sourcepoint]='" + SwitchID + "-out'"));; } catch (Exception ex) { CLog.PutDownErrInfo("通过SwitchID获取下一个节点ID操作异常。SwitchID:" + SwitchID + ",异常信息:" + ex.Message.ToString()); throw ex; } }
/// <summary> /// 获取审批人最后一次审批意见 /// </summary> /// <param name="InstanceID"></param> /// <param name="NodeID"></param> /// <param name="ApproverID"></param> /// <returns></returns> public static string GetNodeApprovalOpinion(string InstanceID, string NodeID, string ApproverID) { try { return(CDataHelper.GetData("select top 1 approval_opinion from " + CTableName.FlowChartReceiver + " where instance_id='" + InstanceID + "' and node_id='" + NodeID + "' and user_id='" + ApproverID + "' order by approval_num desc")); } catch (Exception ex) { CLog.PutDownErrInfo("获取节点审批意见操作异常。实例ID:,节点ID:,审批人:,异常信息:" + ex.Message.ToString()); throw ex; } }
public DataTable GetInstanceAllDataTable() { try { string strsql = "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) "; return(CDataHelper.GetDataTable(strsql)); } catch (Exception ex) { CLog.PutDownErrInfo("获取工作流实例操作异常。异常信息:" + ex.Message.ToString()); throw ex; } }
/// <summary> /// 获取审批人 /// </summary> /// <param name="InstanceID"></param> /// <param name="NodeID"></param> /// <returns></returns> public static DataTable GetApprover(string InstanceID, string NodeID) { try { string ApproverScript = CDataHelper.GetData("select [operatorscript] from " + CTableName.FlowChartNode + " where [node_id]='" + NodeID + "'"); DataTable dtApprover = (DataTable)CScriptOpe.ScriptExec(ApproverScript, InstanceID); return(dtApprover); } catch (Exception ex) { CLog.PutDownErrInfo("获取审批人操作异常。实例ID:,节点ID:,异常信息:" + ex.Message.ToString()); throw ex; } }
public DataTable getroleuser(string strRoleNameList) { try { string strRoles = GetItemArray(strRoleNameList); string strSql = @"select user_id,user_name,'" + GetUserType.ByRole + "' as GetUserType from view_workflow_role_users where role_name in (" + strRoles + ")"; DataTable dtUser = CDataHelper.GetDataTable(strSql); return(dtUser); } catch (Exception ex) { CLog.PutDownErrInfo("通过角色获取人员信息操作异常。角色名称列表:" + strRoleNameList + ",异常信息:" + ex.Message.ToString()); throw ex; } }
public DataTable getdepartmentuser(string strDepartmenNameList) { try { string strDepartments = GetItemArray(strDepartmenNameList); string strSql = @"select user_id,user_name,'" + GetUserType.ByDepartment + "' as GetUserType from view_workflow_department_users where department_name in (" + strDepartments + ")"; DataTable dtUser = CDataHelper.GetDataTable(strSql); return(dtUser); } catch (Exception ex) { CLog.PutDownErrInfo("通过部门获取人员信息操作异常。部门名称列表:" + strDepartmenNameList + ",异常信息:" + ex.Message.ToString()); throw ex; } }
public DataTable getuser(string strUserList) { try { string strUsers = GetItemArray(strUserList); string strSql = "select user_id,user_name,'" + GetUserType.ByID + "' as GetUserType from view_workflow_users where user_id in (" + strUsers + ")"; DataTable dtUser = CDataHelper.GetDataTable(strSql); return(dtUser); } catch (Exception ex) { CLog.PutDownErrInfo("通过人员ID获取人员信息操作异常。人员ID列表:" + strUserList + ",异常信息:" + ex.Message.ToString()); throw ex; } }
public static string UpdateInstanceStatus(string InstanceID, EInstanceStatus InsStu) { try { if (CDataHelper.ExecuteNonQuery("update " + CTableName.FlowChartInstance + " set [instance_status]='" + InsStu.ToString() + "' where instance_id='" + InstanceID + "'") < 0) { WFGlobal.ErrInfo = CLog.PutDownErrInfo("更新实例状态操作失败。实例ID:" + InstanceID); return(WFGlobal.ErrInfo); } return(WFGlobal.success); } catch (Exception ex) { WFGlobal.ErrInfo = CLog.PutDownErrInfo("更新实例状态操作异常。实例ID:" + InstanceID + ",异常信息:" + ex.Message.ToString()); return(WFGlobal.ErrInfo); } }
public static string UpdateInstanceMessage(string InstanceID, string ErrorMessage) { try { if (CDataHelper.ExecuteNonQuery("update " + CTableName.FlowChartInstance + " set [instance_message]='" + ErrorMessage + "' where instance_id='" + InstanceID + "'") < 0) { WFGlobal.ErrInfo = CLog.PutDownErrInfo("更新工作流实例信息操作失败。实例ID:" + InstanceID); return(WFGlobal.ErrInfo); } return(WFGlobal.success); } catch (Exception ex) { WFGlobal.ErrInfo = CLog.PutDownErrInfo("更新工作流实例信息操作失异常。实例ID:" + InstanceID + ",异常信息:" + ex.Message.ToString()); return(WFGlobal.ErrInfo); } }
/// <summary> /// 更新审批意见 /// </summary> /// <param name="InstanceID"></param> /// <param name="NodeID"></param> /// <param name="ApprovalOpinion"></param> /// <param name="OpeManID"></param> /// <param name="ApprovalReason"></param> public static string UpdateApprovalOpinion(string InstanceID, string NodeID, EApprovalOpinion ApprovalOpinion, string OpeManID, string ApprovalReason) { try { if (CDataHelper.ExecuteNonQuery("update " + CTableName.FlowChartReceiver + " set [approval_opinion]='" + ApprovalOpinion + "',operate_time='" + DateTime.Now.ToString() + "',approval_status='" + EApprovalStatus.Complete.ToString() + "',approval_reason='" + ApprovalReason + "' where [instance_id]='" + InstanceID + "' and [node_id]='" + NodeID + "' and [user_id]='" + OpeManID + "' and [approval_status]='" + EApprovalStatus.Active.ToString() + "'") < 0) { WFGlobal.ErrInfo = CLog.PutDownErrInfo("记录实例" + InstanceID + "审批意见异常。审批节点:" + NodeID + ",审批人:" + OpeManID); return(WFGlobal.ErrInfo); } return(WFGlobal.success); } catch (Exception ex) { WFGlobal.ErrInfo = CLog.PutDownErrInfo("记录实例" + InstanceID + "审批意见异常。审批节点:" + NodeID + ",审批人:" + OpeManID + ",异常信息:" + ex.Message.ToString()); return(WFGlobal.ErrInfo); } }
/// <summary> /// 更新审批人的审批状态 /// </summary> /// <param name="InstanceID"></param> /// <param name="NodeID"></param> /// <param name="AppStu">审批状态</param> public static string UpdateApprovalStatus(string InstanceID, string NodeID, string ApproverID, EApprovalStatus AppStu) { try { if (CDataHelper.ExecuteNonQuery("update " + CTableName.FlowChartReceiver + " set [approval_status]='" + AppStu.ToString() + "' where instance_id='" + InstanceID + "' and node_id='" + NodeID + "' and user_id='" + ApproverID + "'") < 0) { WFGlobal.ErrInfo = CLog.PutDownErrInfo("更新审批状态操作失败。实例ID:" + InstanceID + ",节点ID:" + NodeID + ",审批人ID:" + ApproverID); return(WFGlobal.ErrInfo); } return(WFGlobal.success); } catch (Exception ex) { WFGlobal.ErrInfo = CLog.PutDownErrInfo("更新审批状态操作失败。实例ID:" + InstanceID + ",节点ID:" + NodeID + ",审批人ID:" + ApproverID + ",异常信息:" + ex.Message.ToString()); return(WFGlobal.ErrInfo); } }
/// <summary> /// 记录节点的审批人 /// </summary> /// <param name="InstanceID"></param> /// <param name="NodeID"></param> /// <param name="OpeManID"></param> /// <param name="ApprovalNum">表示该节点第几次审批</param> public static string PutDownApprover(string InstanceID, string NodeID, string OpeManID, int ApprovalNum, string ApprovalNote) { try { if (CDataHelper.ExecuteNonQuery("insert into " + CTableName.FlowChartReceiver + "(instance_id,node_id,user_id,operate_time,approval_status,approval_num,approval_note) values('" + InstanceID + "','" + NodeID + "','" + OpeManID + "','" + DateTime.Now.ToString() + "','" + EApprovalStatus.Active.ToString() + "','" + ApprovalNum.ToString() + "','" + ApprovalNote + "')") < 0) { WFGlobal.ErrInfo = CLog.PutDownErrInfo("记录审批人操作失败。工作流实例ID:" + InstanceID + ",节点ID:" + NodeID + ",操作人ID:" + OpeManID + ",操作次数:" + ApprovalNum.ToString()); return(WFGlobal.ErrInfo); } return(WFGlobal.success); } catch (Exception ex) { WFGlobal.ErrInfo = CLog.PutDownErrInfo("记录审批人操作异常。工作流实例ID:" + InstanceID + ",节点ID:" + NodeID + ",操作人ID:" + OpeManID + ",操作次数:" + ApprovalNum.ToString() + ",异常信息:" + ex.Message.ToString()); return(WFGlobal.ErrInfo); } }
/// <summary> /// 获取审批提示信息 /// </summary> /// <param name="InstanceID"></param> /// <param name="NodeID"></param> /// <returns></returns> public static string GetApprovalNote(string InstanceID, string NodeID) { try { string strApprovalNote = null; string ApprovalNoteScript = CDataHelper.GetData("select [approvalnotescript] from " + CTableName.FlowChartNode + " where [node_id]='" + NodeID + "'"); if (ApprovalNoteScript != null && ApprovalNoteScript != "") { strApprovalNote = (string)CScriptOpe.ScriptExec(ApprovalNoteScript, InstanceID); } return(strApprovalNote); } catch (Exception ex) { CLog.PutDownErrInfo("获取审批提示操作异常。实例ID:,节点ID:,异常信息:" + ex.Message.ToString()); throw ex; } }
/// <summary> /// 获取该节点最后一次审批是第几次审批 /// </summary> /// <param name="InstanceID"></param> /// <param name="NodeID"></param> /// <returns></returns> public static int GetLastApprovalNum(string InstanceID, string NodeID) { try { string strApprovalNum = CDataHelper.GetData("select top 1 approval_num from " + CTableName.FlowChartReceiver + " where instance_id='" + InstanceID + "' and node_id='" + NodeID + "' order by approval_num desc"); int ApprovalNum = 0; if (strApprovalNum != null && strApprovalNum != "") { ApprovalNum = Convert.ToInt32(strApprovalNum); } return(ApprovalNum); } catch (Exception ex) { CLog.PutDownErrInfo("获取最后的审批次数操作异常。实例ID:" + InstanceID + ",节点ID:" + NodeID + ",异常信息:" + ex.Message.ToString()); throw ex; } }
/// <summary> /// 获取非分支节点的下一级节点ID /// </summary> /// <param name="WFID"></param> /// <param name="InstanceID"></param> /// <param name="NodeID"></param> /// <returns></returns> public static string GoNextNodesFromOtherNode(string InstanceID, string NodeID) { try { string NextNodeID = CDataHelper.GetData("select next_node_id from " + CTableName.FlowChartLine + " where node_id='" + NodeID + "'"); if (NextNodeID == null || NextNodeID == "") { WFGlobal.ErrInfo = CLog.PutDownErrInfo("找不到节点" + NodeID + "的下一个节点。"); return(WFGlobal.ErrInfo); } return(NodeTransfer(InstanceID, NodeID, NextNodeID)); } catch (Exception ex) { WFGlobal.ErrInfo = CLog.PutDownErrInfo("获取节点的下一个节点操作失败。工作流实例ID:" + InstanceID + ",节点ID:" + NodeID + ",异常信息:" + ex.Message.ToString()); return(WFGlobal.ErrInfo); } }