public IHttpActionResult NotifyGBMemo(PostMemo <ReimageGBMemo> postData) { var actor = ProjectUsers.GetProjectUser(postData.Entity.ProjectId, ProjectUserRoleCode.AssetActor); using (TransactionScope tranScope = new TransactionScope()) { Dictionary <string, string> pdfData = new Dictionary <string, string>(); pdfData.Add("WorkflowName", Constants.Reimage); pdfData.Add("ProjectID", postData.Entity.ProjectId); pdfData.Add("RegionNameENUS", postData.Entity.Store.StoreBasicInfo.RegionENUS); pdfData.Add("RegionNameZHCN", postData.Entity.Store.StoreBasicInfo.RegionZHCN); pdfData.Add("MarketNameENUS", postData.Entity.Store.StoreBasicInfo.MarketENUS); pdfData.Add("MarketNameZHCN", postData.Entity.Store.StoreBasicInfo.MarketZHCN); pdfData.Add("ProvinceNameENUS", postData.Entity.Store.StoreBasicInfo.ProvinceENUS); pdfData.Add("ProvinceNameZHCN", postData.Entity.Store.StoreBasicInfo.ProvinceZHCN); pdfData.Add("CityNameENUS", postData.Entity.Store.StoreBasicInfo.CityENUS); pdfData.Add("CityNameZHCN", postData.Entity.Store.StoreBasicInfo.CityZHCN); pdfData.Add("StoreNameENUS", postData.Entity.Store.StoreBasicInfo.NameENUS); pdfData.Add("StoreNameZHCN", postData.Entity.Store.StoreBasicInfo.NameZHCN); pdfData.Add("USCode", postData.Entity.Store.StoreBasicInfo.StoreCode); pdfData.Add("IsClosed", postData.Entity.IsClosed ? "Y" : "N"); pdfData.Add("IsInOperation", postData.Entity.IsInOperation ? "Y" : "N"); pdfData.Add("IsMcCafe", postData.Entity.IsMcCafe ? "Y" : "N"); pdfData.Add("IsKiosk", postData.Entity.IsKiosk ? "Y" : "N"); pdfData.Add("IsMDS", postData.Entity.IsMDS ? "Y" : "N"); pdfData.Add("Is24Hour", postData.Entity.Is24Hour ? "Y" : "N"); var consInfo = ReimageConsInfo.GetConsInfo(postData.Entity.ProjectId); postData.Entity.ReinvestInfo = ReinvestmentBasicInfo.GetByConsInfoId(consInfo.Id); pdfData.Add("GBDate", postData.Entity.rmgInfo.GBDate.HasValue ? postData.Entity.rmgInfo.GBDate.Value.ToString("yyyy-MM-dd") : ""); pdfData.Add("ConstCompletionDate", postData.Entity.ReinvestInfo.ConsCompletionDate.HasValue ? postData.Entity.ReinvestInfo.ConsCompletionDate.Value.ToString("yyyy-MM-dd") : ""); pdfData.Add("ReopenDate", postData.Entity.rmgInfo.ReopenDate.HasValue ? postData.Entity.rmgInfo.ReopenDate.Value.ToString("yyyy-MM-dd") : ""); string pdfPath = HtmlConversionUtility.HtmlConvertToPDF(HtmlTempalteType.GBMemo, pdfData, null); EmailSendingResultType result; //邮件模板中的数据 Dictionary <string, string> bodyValues = new Dictionary <string, string>(); //邮件内容中的键值对 bodyValues.Add("ApplicantName", ClientCookie.UserNameENUS);//--提交人 bodyValues.Add("StoreCode", postData.Entity.Store.StoreBasicInfo.StoreCode); bodyValues.Add("StoreName", postData.Entity.Store.StoreBasicInfo.NameENUS); bodyValues.Add("Actor", actor.RoleNameENUS); ////--呈递人 bodyValues.Add("WorkflowName", Constants.Reimage_GBMemo); ////--流程名称 bodyValues.Add("ProjectName", Constants.Reimage); //项目名称 string viewPage = string.Format("{0}/Reimage/Main#/GBMemo/Process/View?projectId={1}", ConfigurationManager.AppSettings["webHost"], postData.Entity.ProjectId); bodyValues.Add("FormUrl", viewPage); //调用邮件服务发送邮件 using (EmailServiceClient client = new EmailServiceClient()) { EmailMessage message = new EmailMessage(); StringBuilder sbTo = new StringBuilder(); Dictionary <string, string> attachments = new Dictionary <string, string>(); foreach (Employee emp in postData.Receivers) { if (sbTo.Length > 0) { sbTo.Append(";"); } if (!string.IsNullOrEmpty(emp.Mail)) { sbTo.Append(emp.Mail); } } if (sbTo.Length > 0) { sbTo.Append(";"); } message.EmailBodyValues = bodyValues; string strTitle = FlowCode.Reimage_GBMemo; attachments.Add(pdfPath, strTitle + "_" + postData.Entity.ProjectId + ".pdf"); message.AttachmentsDict = attachments; message.To = sbTo.ToString(); message.TemplateCode = EmailTemplateCode.GBMemoNotification; result = client.SendGBMemoNotificationEmail(message); } if (!result.Successful) { return(BadRequest(result.ErrorMessage + " " + pdfPath)); } postData.Entity.CompleteNotifyTask(postData.Entity.ProjectId); tranScope.Complete(); } return(Ok()); }