Ejemplo n.º 1
0
        public IHttpActionResult InitPage(string projectId)
        {
            var info            = RenewalInfo.Get(projectId);
            var siteInfoProject = ProjectInfo.Get(projectId, FlowCode.Renewal_SiteInfo);

            var estimatedVsActualConstruction = EstimatedVsActualConstruction.FirstOrDefault(e => e.RefId == siteInfoProject.Id);

            if (estimatedVsActualConstruction == null)
            {
                var consInfo      = RenewalConsInfo.Get(projectId);
                var reinBasicInfo = ReinvestmentBasicInfo.GetByConsInfoId(consInfo.Id);
                var storeInfo     = StoreSTLocation.FirstOrDefault(e => e.StoreCode == info.USCode);
                estimatedVsActualConstruction = new EstimatedVsActualConstruction
                {
                    RefId                 = siteInfoProject.Id,
                    GBDate                = reinBasicInfo != null ? reinBasicInfo.GBDate : null,
                    CompletionDate        = reinBasicInfo != null ? reinBasicInfo.ConsCompletionDate : null,
                    ARDC                  = reinBasicInfo != null ? reinBasicInfo.NewDesignType : null,
                    OriginalOperationSize = storeInfo.TotalArea,
                    OriginalSeatNumber    = storeInfo.TotalSeatsNo,
                    ClosureDays           = reinBasicInfo != null ? (reinBasicInfo.ConsCompletionDate.Value - reinBasicInfo.GBDate.Value).TotalDays.ToString() : ""
                };
            }
            var result = new
            {
                Info    = info,
                Savable = ProjectInfo.IsFlowSavable(projectId, FlowCode.Renewal_SiteInfo),
                EstimatedVsActualConstruction = estimatedVsActualConstruction
            };

            return(Ok(result));
        }
Ejemplo n.º 2
0
        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());
        }