public IHttpActionResult GetMemo(string flowCode, string projectId) { var memoList = AttachmentsMemo.GetAttachmentsMemoList(flowCode); if (memoList == null || memoList.Count == 0) { return(Ok()); } var navs = memoList.Select(e => { string url = ""; DateTime?date = null; ProjectUsers user = null; switch (e.MemoCode) { case "GBMemo": user = ProjectUsers.GetProjectUser(projectId, ProjectUserRoleCode.PM); var gbEntity = AttachmentsMemoProcessInfo.Get(projectId, FlowCode.GBMemo); if (gbEntity != null) { date = gbEntity.NotifyDate; } break; case "ClosureMemo": user = ProjectUsers.GetProjectUser(projectId, ProjectUserRoleCode.AssetActor); var tmpEntity = AttachmentsMemoProcessInfo.Get(projectId, FlowCode.ClosureMemo); if (tmpEntity != null) { date = tmpEntity.NotifyDate; } break; case "ReopenMemo": user = ProjectUsers.GetProjectUser(projectId, ProjectUserRoleCode.AssetActor); var entity = AttachmentsMemoProcessInfo.Get(projectId, FlowCode.ReopenMemo); date = entity.NotifyDate; break; } if (e.MemoCode == "GBMemo") { var flowcode = e.FlowCode + "_" + e.MemoCode; var task = TaskWork.Search(t => t.RefID == projectId && t.Status == TaskWorkStatus.UnFinish && t.TypeCode == flowcode).FirstOrDefault(); if (task != null) { if ((task.Url.IndexOf("Approval", StringComparison.OrdinalIgnoreCase) != -1 || task.Url.IndexOf("Resubmit", StringComparison.OrdinalIgnoreCase) != -1 || task.Url.IndexOf("Notify", StringComparison.OrdinalIgnoreCase) != -1 || task.Url.IndexOf("View", StringComparison.OrdinalIgnoreCase) == -1) && task.ReceiverAccount == ClientCookie.UserCode) { if (task.Url.IndexOf(task.RefID, StringComparison.OrdinalIgnoreCase) < 0) { if (task.Url.IndexOf("?") >= 0) { task.Url += "&"; } else { task.Url += "?"; } task.Url += "projectId=" + task.RefID; } url = task.Url; } else { url = string.Format("/{0}/Main#/{1}/Process/View?projectId={2}", flowCode, e.MemoCode, projectId); } } else { if (user.UserAccount == ClientCookie.UserCode && date == null) { url = string.Format("/{0}/Main#/{1}?projectId={2}", flowCode, e.MemoCode, projectId); } else { url = string.Format("/{0}/Main#/{1}/Process/View?projectId={2}", flowCode, e.MemoCode, projectId); } } } else { if (user.UserAccount == ClientCookie.UserCode) { url = string.Format("/{0}/Main#/{1}?projectId={2}", flowCode, e.MemoCode, projectId); } else { url = string.Format("/{0}/Main#/{1}/Process/View?projectId={2}", flowCode, e.MemoCode, projectId); } } return(new { NotifyDate = date, Name = e.MemoNameENUS, Url = url }); }).ToList(); return(Ok(navs)); }
public IHttpActionResult NotifyGBMemo(PostMemo <RenewalGBMemo> 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.Rebuild); 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"); pdfData.Add("GBDate", postData.Entity.GBDate.HasValue ? postData.Entity.GBDate.Value.ToString("yyyy-MM-dd") : ""); pdfData.Add("ConstCompletionDate", postData.Entity.ConstCompletionDate.HasValue ? postData.Entity.ConstCompletionDate.Value.ToString("yyyy-MM-dd") : ""); pdfData.Add("ReopenDate", postData.Entity.ReopenDate.HasValue ? postData.Entity.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", FlowCode.Renewal_GBMemo); ////--流程名称 bodyValues.Add("ProjectName", "Renewal"); //项目名称 string viewPage = string.Format("{0}/Renewal/Main#/GBMemo/Process/View?projectId={1}", HttpContext.Current.Request.Url.Authority, 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.Renewal_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); ProjectInfo.FinishNode(postData.Entity.ProjectId, FlowCode.Renewal_GBMemo, NodeCode.Finish); AttachmentsMemoProcessInfo.UpdateNotifyDate(postData.Entity.ProjectId, FlowCode.GBMemo); tranScope.Complete(); } return(Ok()); }