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