public static List <EmailSendingResultType> SendPackageApprovalEmail(TempClosureInfo tempClosureInfo, TempClosurePackage entity, ApproveUsers approvers) { var project = ProjectInfo.Get(entity.ProjectId, FlowCode.TempClosure_ClosurePackage); var storeBasic = StoreBasicInfo.GetStorInfo(project.USCode); var storeContract = StoreContractInfo.Search(c => c.StoreCode == project.USCode).OrderByDescending(c => c.CreatedTime).FirstOrDefault(); var assetMgr = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == entity.ProjectId && pu.RoleCode == ProjectUserRoleCode.AssetManager); var assetActor = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == entity.ProjectId && pu.RoleCode == ProjectUserRoleCode.AssetActor); var assetRep = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == entity.ProjectId && pu.RoleCode == ProjectUserRoleCode.AssetRep); var results = new List <EmailSendingResultType>(); using (EmailServiceClient emailClient = new EmailServiceClient()) { List <SimpleEmployee> approveEmps = new List <SimpleEmployee> { approvers.MarketMgr, approvers.GM, approvers.MDD, approvers.FC, approvers.VPGM //approvers.MCCLAssetMgr, //approvers.MCCLAssetDtr }; if (approvers.RegionalMgr != null) { approveEmps.Add(approvers.RegionalMgr); } //邮件模板中的数据 Dictionary <string, string> bodyValues = new Dictionary <string, string>(); //邮件内容中的键值对 bodyValues.Add("ApplicantName", ClientCookie.UserNameENUS);//--提交人 bodyValues.Add("StoreCode", storeBasic.StoreCode); bodyValues.Add("StoreName", storeBasic.NameENUS + @" \ " + storeBasic.NameZHCN); bodyValues.Add("Actor", assetActor.UserNameENUS); ////--呈递人 //bodyValues.Add("WorkflowName", Constants.TempClosure_Package);////--流程名称 bodyValues.Add("ProjectName", Constants.TempClosure); //项目名称 var viewPage = string.Format("{0}/TempClosure/Main#/ClosurePackage/View/param?projectId={1}", HttpContext.Current.Request.Url.Authority, entity.ProjectId); bodyValues.Add("FormUrl", viewPage); Dictionary <string, string> templateFileds = new Dictionary <string, string>(); var flowInfo = FlowInfo.Get(FlowCode.TempClosure); templateFileds.Add("WorkflowName", flowInfo.NameENUS); templateFileds.Add("ProjectID", entity.ProjectId); templateFileds.Add("USCode", storeBasic.StoreCode); templateFileds.Add("City", storeBasic.CityZHCN); templateFileds.Add("Region", storeBasic.Region); templateFileds.Add("StoreNameEN", storeBasic.NameENUS); templateFileds.Add("Market", storeBasic.Market); templateFileds.Add("StoreNameCN", storeBasic.NameZHCN); templateFileds.Add("StoreAge", Math.Floor((DateTime.Now - storeBasic.OpenDate).TotalDays / 365D).ToString()); templateFileds.Add("OpenDate", storeBasic.OpenDate.ToString("yyyy-MM-dd")); var storeInfo = StoreBasicInfo.GetStore(project.USCode); if (!string.IsNullOrEmpty(storeInfo.StoreContractInfo.EndYear)) { templateFileds.Add("CurrentLeaseENDYear", (int.Parse(storeInfo.StoreContractInfo.EndYear) - storeInfo.CurrentYear).ToString()); } else { templateFileds.Add("CurrentLeaseENDYear", ""); } if (assetMgr != null) { templateFileds.Add("AssetsManager", assetMgr.UserNameENUS); } templateFileds.Add("AssetsActor", assetActor.UserNameENUS); templateFileds.Add("AssetsRep", assetRep.UserNameENUS); templateFileds.Add("ClosureDate", tempClosureInfo.ActualTempClosureDate.ToString("yyyy-MM-dd")); templateFileds.Add("LeaseExpireDate", tempClosureInfo.LeaseExpireDate.HasValue ? tempClosureInfo.LeaseExpireDate.Value.ToString("yyyy-MM-dd") : ""); templateFileds.Add("ReOpenDate", tempClosureInfo.ActualReopenDate.ToString("yyyy-MM-dd")); templateFileds.Add("RentFreeTerm", string.IsNullOrEmpty(entity.RentReliefClause) ? "否" : "是"); templateFileds.Add("RentFreeStartDate", entity.RentReliefStartDate.HasValue ? entity.RentReliefStartDate.Value.ToString("yyyy-MM-dd") : ""); templateFileds.Add("RentFreeEndDate", entity.RentReliefEndDate.HasValue ? entity.RentReliefEndDate.Value.ToString("yyyy-MM-dd") : ""); templateFileds.Add("FreeRentTerm", entity.RentReliefClause); var approveRecords = ProjectComment.GetList("TempClosurePackage", entity.Id, ProjectCommentStatus.Submit).Select(pc => new SubmissionApprovalRecord { OperatorID = pc.UserAccount, OperatorName = pc.UserNameENUS, OperatorTitle = pc.TitleNameENUS, OperationDate = pc.CreateTime.HasValue ? pc.CreateTime.Value : DateTime.Now, ActionName = pc.ActivityName, Comments = pc.Content }).ToList(); string imgPath = HtmlConversionUtility.HtmlConvertToPDF(HtmlTempalteType.TempClosure, templateFileds, approveRecords); approveEmps.ForEach(e => { EmailMessage email = new EmailMessage(); List <string> emailAddresses = new List <string> { e.Mail, "*****@*****.**", "*****@*****.**", "*****@*****.**" }; if (bodyValues.ContainsKey("ApproverName")) { bodyValues["ApproverName"] = e.NameENUS; } else { bodyValues.Add("ApproverName", e.NameENUS);//--提交人 } email.EmailBodyValues = bodyValues; email.To = string.Join(";", emailAddresses); email.Attachments = imgPath; //var result = emailClient.SendEmail(email); results.Add(new EmailSendingResultType()); }); approvers.NoticeUsers.ForEach(e => { EmailMessage email = new EmailMessage(); List <string> emailAddresses = new List <string> { e.Mail, "*****@*****.**", "*****@*****.**", "*****@*****.**" }; if (bodyValues.ContainsKey("ApproverName"))//--提交人 { bodyValues["ApproverName"] = e.NameENUS; } else { bodyValues.Add("ApproverName", e.NameENUS); } email.EmailBodyValues = bodyValues; email.To = string.Join(";", emailAddresses); email.Attachments = imgPath; //var result = emailClient.SendEmail(email); results.Add(new EmailSendingResultType()); }); } return(results); }
public static List <EmailSendingResultType> SendPackageApprovalEmail(RenewalInfo info, RenewalPackage entity, ApproveUsers approvers) { var project = ProjectInfo.Get(entity.ProjectId, FlowCode.Renewal_Package); var storeBasic = StoreBasicInfo.GetStorInfo(project.USCode); var storeContract = StoreContractInfo.Search(c => c.StoreCode == project.USCode).OrderByDescending(c => c.CreatedTime).FirstOrDefault(); var assetMgr = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == entity.ProjectId && pu.RoleCode == ProjectUserRoleCode.AssetManager); var assetActor = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == entity.ProjectId && pu.RoleCode == ProjectUserRoleCode.AssetActor); var assetRep = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == entity.ProjectId && pu.RoleCode == ProjectUserRoleCode.AssetRep); var results = new List <EmailSendingResultType>(); using (EmailServiceClient emailClient = new EmailServiceClient()) { List <SimpleEmployee> approveEmps = new List <SimpleEmployee> { approvers.MarketMgr, approvers.GM, approvers.MDD, approvers.FC, approvers.MCCLAssetDtr }; if (approvers.RegionalMgr != null) { approveEmps.Add(approvers.RegionalMgr); } if (approvers.CDO != null) { approveEmps.Add(approvers.CDO); } if (approvers.ManagingDirector != null) { approveEmps.Add(approvers.ManagingDirector); } //邮件模板中的数据 Dictionary <string, string> bodyValues = new Dictionary <string, string>(); //邮件内容中的键值对 bodyValues.Add("ApplicantName", ClientCookie.UserNameENUS);//--提交人 bodyValues.Add("StoreCode", storeBasic.StoreCode); bodyValues.Add("StoreName", storeBasic.NameENUS + @" \ " + storeBasic.NameZHCN); bodyValues.Add("Actor", assetActor.UserNameENUS); ////--呈递人 //bodyValues.Add("WorkflowName", Constants.TempClosure_Package);////--流程名称 bodyValues.Add("ProjectName", Constants.TempClosure); //项目名称 var viewPage = string.Format("{0}/Renewal/Main#/Package/View/param?projectId={1}", HttpContext.Current.Request.Url.Authority, entity.ProjectId); bodyValues.Add("FormUrl", viewPage); Dictionary <string, string> templateFileds = entity.GetPrintTemplateFields(); var approveRecords = ProjectComment.GetList("TempClosurePackage", entity.Id, ProjectCommentStatus.Submit).Select(pc => new SubmissionApprovalRecord { OperatorID = pc.UserAccount, OperatorName = pc.UserNameENUS, OperatorTitle = pc.TitleNameENUS, OperationDate = pc.CreateTime.HasValue ? pc.CreateTime.Value : DateTime.Now, ActionName = pc.ActivityName, Comments = pc.Content }).ToList(); string imgPath = HtmlConversionUtility.HtmlConvertToPDF(HtmlTempalteType.Renewal, templateFileds, approveRecords); approveEmps.ForEach(e => { EmailMessage email = new EmailMessage(); List <string> emailAddresses = new List <string> { e.Mail, "*****@*****.**", "*****@*****.**", "*****@*****.**" }; if (bodyValues.ContainsKey("ApproverName")) { bodyValues["ApproverName"] = e.NameENUS; } else { bodyValues.Add("ApproverName", e.NameENUS);//--提交人 } email.EmailBodyValues = bodyValues; email.To = string.Join(";", emailAddresses); email.Attachments = imgPath; //var result = emailClient.SendEmail(email); results.Add(new EmailSendingResultType()); }); approvers.NoticeUsers.ForEach(e => { EmailMessage email = new EmailMessage(); List <string> emailAddresses = new List <string> { e.Mail, "*****@*****.**", "*****@*****.**", "*****@*****.**" }; if (bodyValues.ContainsKey("ApproverName"))//--提交人 { bodyValues["ApproverName"] = e.NameENUS; } else { bodyValues.Add("ApproverName", e.NameENUS); } email.EmailBodyValues = bodyValues; email.To = string.Join(";", emailAddresses); email.Attachments = imgPath; //var result = emailClient.SendEmail(email); results.Add(new EmailSendingResultType()); }); } return(results); }
public EmailSendingResultType SendEmail(Guid id, string[] emailToEids, string workflowName, string projectID, string tableName) { var closureInfo = ClosureInfo.GetByProjectId(projectID); var store = StoreBasicInfo.GetStore(closureInfo.USCode); var storeBasic = store.StoreBasicInfo; EmailServiceClient emailClient = new EmailServiceClient(); var bllProjectComment = new ProjectComment(); EmailMessage email = new EmailMessage(); //邮件模板中的数据 Dictionary <string, string> bodyValues = new Dictionary <string, string>(); //邮件内容中的键值对 bodyValues.Add("ApplicantName", ClientCookie.UserNameENUS);//--提交人 bodyValues.Add("WorkflowName", workflowName); bodyValues.Add("StoreCode", storeBasic.StoreCode); bodyValues.Add("StoreName", storeBasic.NameENUS + @" \ " + storeBasic.NameZHCN); bodyValues.Add("Actor", closureInfo.AssetActorNameENUS);////--呈递人 var viewPage = string.Format("{0}/TempClosure/Main#/ClosurePackage/View/param?projectId={1}", HttpContext.Current.Request.Url.Authority, projectID); bodyValues.Add("FormUrl", viewPage); email.EmailBodyValues = bodyValues; Dictionary <string, string> templateFileds = new Dictionary <string, string>(); templateFileds.Add("WorkflowName", SystemCode.Instance.GetCodeName(FlowCode.TempClosure, ClientCookie.Language)); templateFileds.Add("ProjectID", projectID); templateFileds.Add("USCode", storeBasic.StoreCode); templateFileds.Add("Region", storeBasic.Region); templateFileds.Add("StoreNameEN", storeBasic.NameENUS); templateFileds.Add("Market", storeBasic.Market); templateFileds.Add("StoreNameCN", storeBasic.NameZHCN); templateFileds.Add("City", storeBasic.CityZHCN); templateFileds.Add("StoreAge", ""); templateFileds.Add("OpenDate", storeBasic.OpenDate.ToString("yyyy-MM-dd")); var currentLeaseENDYear = store.CurrentYear - int.Parse(store.StoreContractInfo.EndYear); templateFileds.Add("CurrentLeaseENDYear", currentLeaseENDYear.ToString()); templateFileds.Add("AssetsManager", closureInfo.AssetManagerNameENUS); templateFileds.Add("AssetsActor", closureInfo.AssetActorNameENUS); templateFileds.Add("AssetsRep", closureInfo.AssetRepNameENUS); if (closureInfo.ActualCloseDate.HasValue && closureInfo.ActualCloseDate.Value.Year == 1900) { templateFileds.Add("ClosureDate", string.Empty); } else { templateFileds.Add("ClosureDate", closureInfo.ActualCloseDate.HasValue ? closureInfo.ActualCloseDate.Value.ToString("yyyy-MM-dd") : ""); } templateFileds.Add("ClosureType", closureInfo.ClosureTypeNameENUS); templateFileds.Add("LandlordName", ""); templateFileds.Add("LeaseExpireDate", ""); templateFileds.Add("OriginalCFNPV", ""); List <SubmissionApprovalRecord> approveRecords = new List <SubmissionApprovalRecord>(); if (id != new Guid()) { approveRecords = ProjectComment.GetList(tableName, id, ProjectCommentStatus.Submit).Select(pc => new SubmissionApprovalRecord { OperatorID = pc.UserAccount, OperatorName = pc.UserNameENUS, OperatorTitle = pc.TitleNameENUS, OperationDate = pc.CreateTime.HasValue ? pc.CreateTime.Value : DateTime.Now, ActionName = pc.ActivityName, Comments = pc.Content }).ToList(); } string imgPath = HtmlConversionUtility.ConvertToImage(HtmlTempalteType.Default, templateFileds, approveRecords); List <string> emailAddresses = Employee.Search(e => emailToEids.Contains(e.Code)).Select(e => e.Mail).ToList(); emailAddresses.Add("*****@*****.**"); emailAddresses.Add("*****@*****.**"); emailAddresses.Add("*****@*****.**"); //emailAddresses.Add("*****@*****.**"); email.To = string.Join(";", emailAddresses); email.Attachments = imgPath; //EmailSendingResultType result = emailClient.SendEmail(email); return(new EmailSendingResultType()); }