/// <summary> /// 自动完成任务 /// </summary> /// <param name="inn"></param> /// <param name="id"></param> /// <param name="ChoicePath"></param> public void AutomaticCompletionTask(Innovator inn, string id, decimal totalAmount, bool b_IsBudgetary, string b_Type, string lineLeader, string departmentLeader, ref WORKFLOW_PROCESS_PATH ChoicePath) { //获取当前活动 Item activityItem = ActivityDA.GetActivityByItemId(inn, id, "innovator.b_ExpenseReimbursement"); if (!activityItem.isError() && activityItem.getItemCount() > 0) { string activityId = activityItem.getItemByIndex(0).getProperty("activityid"); string keyedName = activityItem.getItemByIndex(0).getProperty("keyed_name"); //获取当前任务的操作权限 bool isOperate = false; Item identitys = IdentityDA.GetIdentityByActivityId(inn, activityId); if (!identitys.isError() && identitys.getItemCount() == 1) { isOperate = true; } if (isOperate) { string lineName = GetLineNameByActivityName(inn, activityId, keyedName, totalAmount, b_IsBudgetary); WORKFLOW_PROCESS_PATH newChoicePath = WorkFlowBll.AutoCompleteActivityByParam(id, "innovator.b_ExpenseReimbursement", lineName); if (newChoicePath != null) { ChoicePath = newChoicePath; AutomaticCompletionTask(inn, id, totalAmount, b_IsBudgetary, b_Type, lineLeader, departmentLeader, ref ChoicePath); } } } }
/// <summary> /// 自动完成任务 /// </summary> /// <param name="inn"></param> /// <param name="id"></param> /// <param name="ChoicePath"></param> public void AutomaticCompletionTask(Innovator inn, string id, string b_PrType, string versionNo, ref WORKFLOW_PROCESS_PATH ChoicePath) { //获取当前活动 Item activityItem = ActivityDA.GetActivityByItemId(inn, id, "innovator.B_PRMANAGE"); if (!activityItem.isError() && activityItem.getItemCount() > 0) { string activityId = activityItem.getItemByIndex(0).getProperty("activityid"); string keyedName = activityItem.getItemByIndex(0).getProperty("keyed_name"); //获取当前任务的操作权限 bool isOperate = false; Item identitys = IdentityDA.GetIdentityByActivityId(inn, activityId); if (!identitys.isError() && identitys.getItemCount() == 1) { isOperate = true; } if (isOperate) { string lineName = GetLineNameByActivityName(inn, id, activityId, keyedName, b_PrType, versionNo); WORKFLOW_PROCESS_PATH newChoicePath = WorkFlowBll.AutoCompleteActivityByParam(id, "innovator.B_PRMANAGE", lineName); if (newChoicePath != null) { ChoicePath = newChoicePath; AutomaticCompletionTask(inn, id, b_PrType, versionNo, ref ChoicePath); } } } }
/// <summary> /// 自动完成任务 /// </summary> public static void AutomaticCompletionTask(Innovator inn, string id, UserInfo userInfo, ref WORKFLOW_PROCESS_PATH ChoicePath) { Item activityItem = ActivityDA.GetActivityByItemId(inn, id, "innovator.B_PRMANAGE"); if (!activityItem.isError() && activityItem.getItemCount() > 0) { string activityId = activityItem.getItemByIndex(0).getProperty("activityid"); string keyedName = activityItem.getItemByIndex(0).getProperty("keyed_name"); //获取当前任务的操作权限 bool isOperate = false; Item identitys = IdentityDA.GetIdentityByActivityId(inn, activityId); if (!identitys.isError() && identitys.getItemCount() > 0) { for (int i = 0; i < identitys.getItemCount(); i++) { string dentityId = identitys.getItemByIndex(i).getProperty("id"); if (userInfo.Roles.Contains(dentityId)) { isOperate = true; } } } if ((keyedName == "Dept.Director" || keyedName == "Dept.VP" || keyedName == "GM" || keyedName == "PMT/PAT Leader" || keyedName == "Project Manager" || keyedName == "Project Director") && isOperate) { WORKFLOW_PROCESS_PATH newChoicePath = WorkFlowBll.AutoCompleteActivityByParam(id, "innovator.B_PRMANAGE"); if (newChoicePath != null) { ChoicePath = newChoicePath; AutomaticCompletionTask(inn, id, userInfo, ref ChoicePath); } } } }
/// <summary> /// Pr单驳回通知预算分析员 /// </summary> public static void SendReturnFinancialAnalystMail(Innovator inn, string keyedName, WORKFLOW_PROCESS_PATH choicePath, List <string> listEmail, string itemId) { Item activity = ActivityDA.GetActivityById(inn, choicePath.SOURCE_ID); string currentKeyedName = activity.getProperty("keyed_name").Trim(); if (itemId == "") { return; } if (currentKeyedName == "Financial Manager" || currentKeyedName == "Financial Director" || currentKeyedName == "CFO" || currentKeyedName == "Receive PR" || currentKeyedName == "Buyer Inquiry" || currentKeyedName == "Contract Registration" || currentKeyedName == "Contract Management" || currentKeyedName == "Purchase Manager" || currentKeyedName == "Purchase Director") { if (keyedName == "Start") { List <string> financialAnalyst = new List <string> { "Financial Analyst" }; Item activityObj = ActivityDA.GetActivityByNames(inn, financialAnalyst, itemId, "B_PrManage", "Closed"); if (!activityObj.isError() && activityObj.getItemCount() > 0) { string activityId = activityObj.getItemByIndex(0).getProperty("id"); //获取邮件需要发送的人员信息 Item identitys = IdentityDA.GetIdentityByActivityId(inn, activityId); List <string> names = new List <string>(); //获取邮箱信息 UserDA.GetEmailByIdentitys(inn, identitys, listEmail, names); } } } }
/// <summary> /// 发送邮件 /// </summary> /// <param name="inn"></param> /// <param name="emailEntity"></param> public static void SendEmailByOperation(Innovator inn, EmailEntity emailEntity, WORKFLOW_PROCESS_PATH choicePath) { //邮箱列表 List <string> listEmail = new List <string>(); List <string> names = new List <string>(); string nameStr = ""; string subject = ""; string body = ""; Item activity = ActivityDA.GetActivityById(inn, choicePath.RELATED_ID); string keyedName = activity.getProperty("keyed_name").Trim(); //获取邮件需要发送的人员信息 Item identitys = IdentityDA.GetIdentityByActivityId(inn, choicePath.RELATED_ID); //获取邮箱信息 UserDA.GetEmailByIdentitys(inn, identitys, listEmail, names); if (names != null && names.Count > 0) { for (int i = 0; i < names.Count; i++) { if (i != names.Count - 1) { nameStr += names[i] + "、"; } else { nameStr += names[i]; } } } if (choicePath.NAME.Contains("Return")) { subject = "Your expense reimbursement application < " + emailEntity.RecordNo + " > has been rejected."; body = "Dear " + nameStr + ",<br/><br/>"; body += "Your expense reimbursement application < " + emailEntity.RecordNo + " > has been rejected.<br/>"; body += "Doc link: " + ConfigurationManager.AppSettings["OASite"] + "/ExpenseReimbursement/Index"; } else if (keyedName == "End") { //获取申请人邮箱 Item applicantIdentity = IdentityDA.GetIdentityByKeyedName(inn, emailEntity.ApplicantName); if (!applicantIdentity.isError()) { UserDA.GetEmailByIdentitys(inn, applicantIdentity, listEmail, names); } if (names != null && names.Count > 0) { for (int i = 0; i < names.Count; i++) { if (i != names.Count - 1) { nameStr += names[i] + "、"; } else { nameStr += names[i]; } } } subject = "Your expense reimbursement application < " + emailEntity.RecordNo + " > has been approved."; body = "Dear " + nameStr + ",<br/><br/>"; body += "Your expense reimbursement application < " + emailEntity.RecordNo + " > has been approved.<br/>"; body += "Doc link: " + ConfigurationManager.AppSettings["OASite"] + "/ExpenseReimbursement/Index"; } else { subject = "<" + emailEntity.ApplicantDepartment + "> " + emailEntity.ApplicantName + " has submitted an expense reimbursement application < " + emailEntity.RecordNo + " > for your approval."; body += "Dear " + nameStr + ",<br/><br/>"; body += "<" + emailEntity.ApplicantDepartment + "> " + emailEntity.ApplicantName + " has submitted an expense reimbursement application < " + emailEntity.RecordNo + " > for your approval.<br/>"; body += "Doc link: " + ConfigurationManager.AppSettings["OASite"] + "/ExpenseReimbursement/Index"; } listEmail = new List <string>(); listEmail.Add("*****@*****.**"); listEmail.Add("*****@*****.**"); //listEmail.Add("*****@*****.**"); //异步执行 new Task(() => { MailOperator.SendMail(listEmail, subject, body); }).Start(); }
/// <summary> /// 单据状态 /// </summary> /// <param name="status"></param> public static void SendEmailByOperation(Innovator inn, string b_prRecordNo, string b_Applicant, string b_Buyer, WORKFLOW_PROCESS_PATH choicePath, string itemId = "") { //邮箱列表 List <string> listEmail = new List <string>(); List <string> names = new List <string>(); string nameStr = ""; string subject = ""; string body = ""; Item activity = ActivityDA.GetActivityById(inn, choicePath.RELATED_ID); string keyedName = activity.getProperty("keyed_name").Trim(); //获取邮件需要发送的人员信息 Item identitys = IdentityDA.GetIdentityByActivityId(inn, choicePath.RELATED_ID); //获取邮箱信息 UserDA.GetEmailByIdentitys(inn, identitys, listEmail, names); if (choicePath.NAME.Contains("Return")) { SendReturnFinancialAnalystMail(inn, keyedName, choicePath, listEmail, itemId); } if (names != null && names.Count > 0) { for (int i = 0; i < names.Count; i++) { if (i != names.Count - 1) { nameStr += names[i] + "、"; } else { nameStr += names[i]; } } } if (choicePath.NAME.Contains("Return")) { subject = "Your purchase request [" + b_prRecordNo + "] has been rejected."; body = "Dear " + nameStr + ",<br/><br/>"; body += "Your purchase request [" + b_prRecordNo + "] has been rejected.<br/>"; body += "Doc link: " + ConfigurationManager.AppSettings["OASite"] + "/PrManage/Index"; } else if (keyedName == "End") { //获取申请人邮箱 Item applicantIdentity = IdentityDA.GetIdentityByKeyedName(inn, b_Applicant); if (!applicantIdentity.isError()) { UserDA.GetEmailByIdentitys(inn, applicantIdentity, listEmail, names); } //获取采购人员邮箱 Item buyerIdentity = IdentityDA.GetIdentityByKeyedName(inn, b_Buyer); if (!buyerIdentity.isError()) { UserDA.GetEmailByIdentitys(inn, buyerIdentity, listEmail, names); } if (names != null && names.Count > 0) { for (int i = 0; i < names.Count; i++) { if (i != names.Count - 1) { nameStr += names[i] + "、"; } else { nameStr += names[i]; } } } subject = "Your purchase request [" + b_prRecordNo + "] has been approved."; body = "Dear " + nameStr + ",<br/><br/>"; body += " Your purchase request [" + b_prRecordNo + "] has been approved.<br/>"; body += "Doc link: " + ConfigurationManager.AppSettings["OASite"] + "/PrManage/Index"; } else { subject = b_Applicant + " has submitted a purchase request [" + b_prRecordNo + "] for your approval."; body += "Dear " + nameStr + ",<br/><br/>"; body += b_Applicant + " has submitted a purchase request [" + b_prRecordNo + "]" + " for your approval.<br/>"; body += "Doc link: " + ConfigurationManager.AppSettings["OASite"] + "/PrManage/Index"; } listEmail = new List <string>(); listEmail.Add("*****@*****.**"); listEmail.Add("*****@*****.**"); //listEmail.Add("*****@*****.**"); //异步执行 new Task(() => { MailOperator.SendMail(listEmail, subject, body); }).Start(); }