/// <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="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); } }