public string GetStartProcessXML(string requestor, string operate, string processName, string groupName, string keyXml, string data, string infoSource) { try { DataSet dsr, osr; if (requestor.ToLower() == operate.ToLower()) { dsr = K2DBHelper.GetEmployeeInfoByUserAd(requestor); osr = dsr; } else { dsr = K2DBHelper.GetEmployeeInfoByUserAd(requestor); osr = K2DBHelper.GetEmployeeInfoByUserAd(operate); } if (dsr.Tables.Count == 0 || osr.Tables.Count == 0) { throw new Exception("未取得申请人或操作人信息!"); //return string.Empty; } if (dsr.Tables[0].Rows.Count == 0 || osr.Tables[0].Rows.Count == 0) { throw new Exception("未取得申请人或操作人信息!"); //return string.Empty; } RequestDefinition.Request request = new RequestDefinition.Request(); request.RequestorAD = requestor; request.OperatorAD = operate; request.Department = dsr.Tables[0].Rows[0]["DepartCode"].ToString(); request.DepartmentName = dsr.Tables[0].Rows[0]["DepartName"].ToString(); request.RequestorEmail = dsr.Tables[0].Rows[0]["Email"].ToString(); request.RequestorTel = dsr.Tables[0].Rows[0]["OfficePhone"].ToString(); request.WorkSpace = "ALL"; //由于PWorld没有Based地点概念,故此处写为ALL request.Operator = osr.Tables[0].Rows[0]["EmployeeName"].ToString(); request.Requestor = dsr.Tables[0].Rows[0]["EmployeeName"].ToString(); request.OperatorEmail = osr.Tables[0].Rows[0]["Email"].ToString(); request.OperatorTel = osr.Tables[0].Rows[0]["OfficePhone"].ToString(); string xml = SerializationHelper.Serialize(request); xml = xml.Insert(xml.IndexOf("</Request>"), keyXml + data); string approveNodeXml = WS.K2.K2Rule.GetApproveNodeXML(processName, groupName, xml); string retXml = WS.K2.K2Rule.GetApproveXML(requestor, approveNodeXml, xml, infoSource); //取得最终的xml //记录日志 K2DBHelper.RecordGetApproveXML(requestor, operate, processName, groupName, keyXml, data, retXml); return(retXml); } catch (Exception ex) { K2DBHelper.RecoreErrorProfile(ex, "K2HelperWS.GetStartProcessXML", requestor); return(ex.Message); } }
/// <summary> /// 通过节点与人员对应关系生成审批XML /// </summary> /// <param name="pairList"></param> /// <returns></returns> private static string CreateApproveXML(string requestor, List <Triplet> pairList, string xml, string infoSource) { ApprovalChainProcess process = new ApprovalChainProcess("自定义流程", ""); process.DefinitionType = infoSource; ApprovalChainData data = new ApprovalChainData(); process.AddData(data); //发起人节点 ApprovalChainActivity activity = new ApprovalChainActivity(Guid.NewGuid().ToString(), "发起人", true, "http://localhost:3373/Resubmit.aspx?SN=", EnumActivityType.SP.ToString()); activity.Status = EnumStatus.Completed.ToString(); activity.ActionWeightType = EnumActionWeightType.N.ToString(); ApprovalChainDestination originator = new ApprovalChainDestination("", requestor, "", "", EnumDestinationUserType.User.ToString()); originator.Status = EnumStatus.Completed.ToString(); activity.AddDestination(originator); process.AddActivity(activity); foreach (Triplet tl in pairList) { //string nodeName = K2DBHelper.GetProcessNodeName(tl.First.ToString()); DataSet ds = K2DBHelper.GetProcessNodeByNodeID(tl.First.ToString()); if (ds != null) { string nodeName = ds.Tables[0].Rows[0]["NodeName"].ToString(); string weightedType = ds.Tables[0].Rows[0]["WeightedType"].ToString(); string samplingRate = string.Empty; if (ds.Tables[0].Rows[0]["SamplingRate"] != DBNull.Value) { samplingRate = ds.Tables[0].Rows[0]["SamplingRate"].ToString(); } activity = new ApprovalChainActivity(tl.First.ToString(), nodeName, true, tl.Third.ToString(), EnumActivityType.SP.ToString()); string[] users = tl.Second.ToString().Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); ApprovalChainDestination des = new ApprovalChainDestination(); if (weightedType == EnumActionWeightType.P.ToString()) { activity.ActionWeightType = weightedType; activity.ActionWeight = samplingRate; foreach (string user in users) { ds = K2DBHelper.GetEmployeeInfoByUserAd(user); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { string Id = ds.Tables[0].Rows[0]["EmployeeCode"].ToString(); string email = ds.Tables[0].Rows[0]["Email"].ToString(); string name = ds.Tables[0].Rows[0]["EmployeeName"].ToString(); des.AddDestinationUser(new ApprovalChainDestinationUser(Id, user, name, email, EnumDestinationUserType.User.ToString())); } } activity.AddDestination(des); } else if (weightedType == EnumActionWeightType.R.ToString()) { activity.ActionWeightType = weightedType; activity.ActionWeight = "1"; foreach (string user in users) { ds = K2DBHelper.GetEmployeeInfoByUserAd(user); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { string Id = ds.Tables[0].Rows[0]["EmployeeCode"].ToString(); string email = ds.Tables[0].Rows[0]["Email"].ToString(); string name = ds.Tables[0].Rows[0]["EmployeeName"].ToString(); des.AddDestinationUser(new ApprovalChainDestinationUser(Id, user, name, email, EnumDestinationUserType.User.ToString())); } } activity.AddDestination(des); } else { activity.ActionWeightType = weightedType; foreach (string user in users) { ds = K2DBHelper.GetEmployeeInfoByUserAd(user); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { string Id = ds.Tables[0].Rows[0]["EmployeeCode"].ToString(); string email = ds.Tables[0].Rows[0]["Email"].ToString(); string name = ds.Tables[0].Rows[0]["EmployeeName"].ToString(); activity.AddDestination(new ApprovalChainDestination(Id, user, name, email, EnumDestinationUserType.User.ToString())); } } } process.AddActivity(activity); } } string processApprovalChain = SerializationHelper.Serialize(process); return(processApprovalChain); }