Esempio n. 1
0
        public IHttpActionResult GetNotifyUser(string usCode, string projectId, string roleCodes)
        {
            Dictionary <string, string> dictNotify = new Dictionary <string, string>();

            foreach (string roleCode in roleCodes.Split(','))
            {
                if (!string.IsNullOrEmpty(roleCode))
                {
                    if (roleCode == "Actor")
                    {
                        var actor = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == projectId && pu.RoleCode == ProjectUserRoleCode.AssetActor);
                        dictNotify.Add(roleCode, actor.UserNameENUS);
                    }
                    else
                    {
                        RoleCode enumRole;
                        if (Enum.TryParse(roleCode, out enumRole))
                        {
                            var employeeList = Employee.GetStoreEmployeesByRole(usCode, enumRole);
                            dictNotify.Add(roleCode, BuildNoticeUserNameStr(employeeList));
                        }
                    }
                }
            }
            return(Ok(dictNotify));
        }
Esempio n. 2
0
        public Project FindProjectById(Guid projectId, bool validateCPS = true)
        {
            if (Projects == null)
            {
                Projects = new List <Project>();
            }

            Project project = Projects.FirstOrDefault(x => x.ProjectId == projectId);

            if (project == null)
            {
                project = ProjectUsers.FirstOrDefault(x => x.ProjectId == projectId)?.Project;
            }

            if (validateCPS)
            {
                if (project.OrganizationCPS == null)
                {
                    project.OrganizationCPS = new OrganizationCPS {
                        Type = CloudProviderService.None
                    };
                }
            }

            return(project);
        }
Esempio n. 3
0
        public IHttpActionResult GetByProjectId(string projectId)
        {
            var entity = ClosureConsInvtChecking.FirstOrDefault(e => e.ProjectId == projectId && e.IsHistory == false);

            if (entity != null)
            {
                var closureInfo = ClosureInfo.GetByProjectId(projectId);
                entity.USCode = closureInfo.USCode;
                ProjectCommentCondition condition = new ProjectCommentCondition();
                condition.RefTableId   = entity.Id;
                condition.RefTableName = ClosureWOCheckList.TableName;
                condition.UserAccount  = ClientCookie.UserCode;
                condition.Status       = ProjectCommentStatus.Save;
                var commentList = ProjectComment.SearchList(condition);
                if (commentList != null && commentList.Count > 0)
                {
                    entity.Comments = commentList[0].Content;
                }

                if (string.IsNullOrEmpty(entity.PMSupervisor))
                {
                    var puser = ProjectUsers.FirstOrDefault(i => i.ProjectId == entity.ProjectId && i.RoleCode == ProjectUserRoleCode.CM);
                    if (puser != null)
                    {
                        entity.PMSupervisor = puser.UserAccount;
                    }
                }
            }

            return(Ok(entity));
        }
        public WFTempClosureLegalReview(TempClosureLegalReview entity)
            : base(entity)
        {
            var legal = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == entity.ProjectId && pu.RoleCode == ProjectUserRoleCode.Legal);
            var task  = TaskWork.GetTaskWork(entity.ProjectId, ClientCookie.UserCode, TaskWorkStatus.UnFinish,
                                             FlowCode.TempClosure, FlowCode.TempClosure_LegalReview);

            K2Param.Task = task;
            K2Param.AddDataField("dest_Creator", Entity.CreateUserAccount);
            K2Param.AddDataField("dest_Legal", legal.UserAccount);
            K2Param.AddDataField("ProcessCode", ProcessCode);
            K2Param.AddDataField("ProjectTaskInfo", JsonConvert.SerializeObject(task));
        }
Esempio n. 5
0
        public bool Add(MaterTrack materTrack)
        {
            using (TransactionScope tranScope = new TransactionScope())
            {
                materTrack.Id         = Guid.NewGuid();
                materTrack.CreateTime = DateTime.Now;
                MaterTrack.Add(materTrack);
                var project = ProjectInfo.Get(materTrack.WorkflowId, materTrack.WorkflowType);
                var store   = StoreBasicInfo.FirstOrDefault(s => s.StoreCode == project.USCode);
                var Codes   = materTrack.NodeType.Split('_');
                var url     = string.Format("/{0}/Main#/{1}/Process/View?projectId={2}", Codes[0], Codes[1], materTrack.WorkflowId);
                //if (Codes[0] == "Closure") //临时改动 只针对Closure,因为Closure 用的还是老的URL
                //{
                //    url = string.Format("/{0}/Main#/{0}/{1}/Process/View?projectId={2}", Codes[0], Codes[1], materTrack.WorkflowId);
                //}
                var title = TaskWork.BuildTitle(materTrack.WorkflowId, store.NameZHCN, store.NameENUS);
                switch (materTrack.TrackType)
                {
                case MaterTrackType.Rep:
                {
                    var actor = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == materTrack.WorkflowId && pu.RoleCode == ProjectUserRoleCode.AssetActor);
                    TaskWork.SendTask(materTrack.WorkflowId, title, project.USCode, url, actor, materTrack.WorkflowType, materTrack.NodeType, "Start_MaterTrack_Rep");
                }
                break;

                case MaterTrackType.Feedback:
                {
                    var legal = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == materTrack.WorkflowId && pu.RoleCode == ProjectUserRoleCode.Legal);
                    TaskWork.Finish(t => t.RefID == materTrack.WorkflowId && t.SourceCode == materTrack.WorkflowType && t.TypeCode == materTrack.NodeType && t.ActivityName == "Start_MaterTrack_Rep" && t.Status == TaskWorkStatus.UnFinish);
                    if (TaskWork.Count(t => t.RefID == materTrack.WorkflowId && t.SourceCode == materTrack.WorkflowType && t.TypeCode == materTrack.NodeType && t.ActivityName == "Start_MaterTrack_Feedback" && t.Status == TaskWorkStatus.UnFinish) == 0)
                    {
                        TaskWork.SendTask(materTrack.WorkflowId, title, project.USCode, url, legal, materTrack.WorkflowType, materTrack.NodeType, "Start_MaterTrack_Feedback");
                    }
                }
                break;

                case MaterTrackType.Reply:
                {
                    var actor = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == materTrack.WorkflowId && pu.RoleCode == ProjectUserRoleCode.AssetActor);
                    TaskWork.Finish(t => t.RefID == materTrack.WorkflowId && t.SourceCode == materTrack.WorkflowType && t.TypeCode == materTrack.NodeType && t.ActivityName == "Start_MaterTrack_Feedback" && t.Status == TaskWorkStatus.UnFinish);
                    if (TaskWork.Count(t => t.RefID == materTrack.WorkflowId && t.SourceCode == materTrack.WorkflowType && t.TypeCode == materTrack.NodeType && t.ActivityName == "Start_MaterTrack_Rep" && t.Status == TaskWorkStatus.UnFinish) == 0)
                    {
                        TaskWork.SendTask(materTrack.WorkflowId, title, project.USCode, url, actor, materTrack.WorkflowType, materTrack.NodeType, "Start_MaterTrack_Rep");
                    }
                }
                break;
                }
                tranScope.Complete();
                return(true);
            }
        }
Esempio n. 6
0
        public PipelineRole GetRoleInProject(Guid projectId)
        {
            if (ProjectUsers == null)
            {
                ProjectUsers = new List <ProjectUser>();
            }

            ProjectUser projectUser = ProjectUsers.FirstOrDefault(x => x.ProjectId == projectId);

            if (projectUser == null)
            {
                return(PipelineRole.None);
            }

            return(projectUser.Role);
        }
        public IHttpActionResult GetByProjectId(string projectId)
        {
            var entity = ClosureWOCheckList.Get(projectId);

            if (entity != null)
            {
                ProjectCommentCondition condition = new ProjectCommentCondition();
                condition.RefTableId   = entity.Id;
                condition.RefTableName = ClosureWOCheckList.TableName;
                condition.UserAccount  = ClientCookie.UserCode;
                condition.Status       = ProjectCommentStatus.Save;
                var commentList = ProjectComment.SearchList(condition);
                if (commentList != null && commentList.Count > 0)
                {
                    entity.Comments = commentList[0].Content;
                }
                var closureEntity = ClosureInfo.GetByProjectId(entity.ProjectId);
                entity.USCode      = closureEntity.USCode;
                entity.UserAccount = ClientCookie.UserCode;

                if (string.IsNullOrEmpty(entity.PMSupervisorAccount))
                {
                    var puser = ProjectUsers.FirstOrDefault(i => i.ProjectId == entity.ProjectId && i.RoleCode == ProjectUserRoleCode.CM);
                    if (puser != null)
                    {
                        entity.PMSupervisorAccount = puser.UserAccount;
                    }
                }
                // entity.Comments = GetCommers(entity);
                //string pmAccount = closureEntity.PMAccount;
                //entity.PMSupervisorAccount = userPositionHandler.GetReportToAccounts(pmAccount);
                //string[] accounts = {UserPositionHandler.IT,UserPositionHandler.MCCL_Construction_Mgr};



                //var positionlist = userPositionHandler.SearchUserPosition(closureEntity.USCode,accounts);
                //string mcclApprover = userPositionHandler.GetAccounts(positionlist);
                //entity.MCCLApproverAccount = mcclApprover;
            }
            return(Ok(entity));
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
 public string GetUserRoleInProject(string userCode, string projectId)
 {
     return(ProjectUsers.FirstOrDefault(pu => pu.UserAccount == userCode && pu.ProjectId == projectId).RoleCode);
 }
Esempio n. 11
0
        public IHttpActionResult Send(PostMemo <TempClosureMemo> postData)
        {
            var actor = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == postData.Entity.ProjectId && pu.RoleCode == ProjectUserRoleCode.AssetActor);
            Dictionary <string, string> pdfData = new Dictionary <string, string>();

            if (postData.Entity.ProjectId.ToLower().IndexOf("rebuild") != -1)
            {
                pdfData.Add("WorkflowName", "Rebuild");
                pdfData.Add("ClosureNature", "Temporary");
            }
            else if (postData.Entity.ProjectId.ToLower().IndexOf("majorlease") != -1)
            {
                pdfData.Add("WorkflowName", "MajorLease");
                pdfData.Add("ClosureNature", "Temporary");
            }
            else if (postData.Entity.ProjectId.ToLower().IndexOf("reimage") != -1)
            {
                pdfData.Add("WorkflowName", "Reimage");
                pdfData.Add("ClosureNature", "Temporary");
            }
            else if (postData.Entity.ProjectId.ToLower().IndexOf("renewal") != -1)
            {
                pdfData.Add("WorkflowName", "Renewal");
                pdfData.Add("ClosureNature", "Temporary");
            }
            else
            {
                pdfData.Add("WorkflowName", "TempClosure");
                pdfData.Add("ClosureNature", postData.Entity.ClosureNature.ToString());
            }
            pdfData.Add("ProjectID", postData.Entity.ProjectId);
            pdfData.Add("RegionNameENUS", postData.Entity.RegionNameENUS);
            pdfData.Add("RegionNameZHCN", postData.Entity.RegionNameZHCN);
            pdfData.Add("MarketNameENUS", postData.Entity.MarketNameENUS);
            pdfData.Add("MarketNameZHCN", postData.Entity.MarketNameZHCN);
            pdfData.Add("ProvinceNameENUS", postData.Entity.ProvinceNameENUS);
            pdfData.Add("ProvinceNameZHCN", postData.Entity.ProvinceNameZHCN);
            pdfData.Add("CityNameENUS", postData.Entity.CityNameENUS);
            pdfData.Add("CityNameZHCN", postData.Entity.CityNameZHCN);
            pdfData.Add("StoreNameENUS", postData.Entity.StoreNameENUS);
            pdfData.Add("StoreNameZHCN", postData.Entity.StoreNameZHCN);
            pdfData.Add("StoreAddressENUS", postData.Entity.StoreAddressENUS);
            pdfData.Add("StoreAddressZHCN", postData.Entity.StoreAddressZHCN);
            pdfData.Add("USCode", postData.Entity.USCode);
            pdfData.Add("OpenDate", postData.Entity.OpenDate.HasValue ? postData.Entity.OpenDate.Value.ToString("yyyy-MM-dd") : "");
            pdfData.Add("ClosureDate", postData.Entity.ClosureDate.HasValue ? postData.Entity.ClosureDate.Value.ToString("yyyy-MM-dd") : "");

            pdfData.Add("BecauseOfReimaging", postData.Entity.BecauseOfReimaging ? "Yes" : "No");
            pdfData.Add("BecauseOfRemodel", postData.Entity.BecauseOfRemodel ? "Yes" : "No");
            pdfData.Add("BecauseOfDespute", postData.Entity.BecauseOfDespute ? "Yes" : "No");
            pdfData.Add("BecauseOfRedevelopment", postData.Entity.BecauseOfRedevelopment ? "Yes" : "No");
            pdfData.Add("BecauseOfPlanedClosure", postData.Entity.BecauseOfPlanedClosure ? "Yes" : "No");
            pdfData.Add("BecauseOfRebuild", postData.Entity.BecauseOfRebuild ? "Yes" : "No");
            pdfData.Add("BecauseOfOthers", postData.Entity.BecauseOfOthers);
            pdfData.Add("PermanentCloseOpportunity", postData.Entity.PermanentCloseOpportunity ? "Yes" : "No");
            pdfData.Add("HasRelocationPlan", postData.Entity.HasRelocationPlan ? "Yes" : "No");
            pdfData.Add("PipelineName", postData.Entity.PipelineName);
            pdfData.Add("CompensationAwarded", postData.Entity.CompensationAwarded ? "Yes" : "No");
            pdfData.Add("Compensation", postData.Entity.Compensation.HasValue ? postData.Entity.Compensation.Value.ToString("N") : "");
            string pdfPath = HtmlConversionUtility.HtmlConvertToPDF(HtmlTempalteType.ClosureMemo, pdfData, null);
            EmailSendingResultType result;
            //邮件模板中的数据
            Dictionary <string, string> bodyValues = new Dictionary <string, string>();

            //邮件内容中的键值对
            bodyValues.Add("ApplicantName", ClientCookie.UserNameENUS);//--提交人
            bodyValues.Add("StoreCode", postData.Entity.USCode);
            bodyValues.Add("StoreName", postData.Entity.StoreNameENUS);
            bodyValues.Add("Actor", actor.UserNameENUS);////--呈递人


            string viewPage = string.Format("{0}/TempClosure/Main#/ClosureMemo/Process/View?projectId={1}",
                                            ConfigurationManager.AppSettings["webHost"], postData.Entity.ProjectId);

            if (postData.Entity.ProjectId.ToLower().IndexOf("rebuild") != -1)
            {
                bodyValues.Add("WorkflowName", Constants.TempClosure_Memo); ////--流程名称
                bodyValues.Add("ProjectName", Constants.Rebuild);           //项目名称
                viewPage = string.Format("{0}/Rebuild/Main#/TempClosureMemo/View?projectId={1}",
                                         ConfigurationManager.AppSettings["webHost"], postData.Entity.ProjectId);
            }
            else if (postData.Entity.ProjectId.ToLower().IndexOf("majorlease") != -1)
            {
                bodyValues.Add("WorkflowName", Constants.Closure_Memo); ////--流程名称
                bodyValues.Add("ProjectName", Constants.MajorLease);    //项目名称
                viewPage = string.Format("{0}/MajorLease/Main#/ClosureMemo/View?projectId={1}",
                                         ConfigurationManager.AppSettings["webHost"], postData.Entity.ProjectId);
            }
            else if (postData.Entity.ProjectId.ToLower().IndexOf("reimage") != -1)
            {
                bodyValues.Add("WorkflowName", Constants.TempClosure_Memo); ////--流程名称
                bodyValues.Add("ProjectName", Constants.Reimage);           //项目名称
                viewPage = string.Format("{0}/Reimage/Main#/TempClosureMemo/View?projectId={1}",
                                         ConfigurationManager.AppSettings["webHost"], postData.Entity.ProjectId);
            }
            else if (postData.Entity.ProjectId.ToLower().IndexOf("renewal") != -1)
            {
                bodyValues.Add("WorkflowName", Constants.Closure_Memo); ////--流程名称
                bodyValues.Add("ProjectName", Constants.Renewal);       //项目名称
                viewPage = string.Format("{0}/Renewal/Main#/ClosureMemo/View?projectId={1}",
                                         ConfigurationManager.AppSettings["webHost"], postData.Entity.ProjectId);
            }
            else if (postData.Entity.ProjectId.ToLower().IndexOf("closure") != -1)
            {
                bodyValues.Add("WorkflowName", Constants.Closure_Memo); ////--流程名称
                bodyValues.Add("ProjectName", Constants.Closure);       //项目名称
            }
            else
            {
                bodyValues.Add("WorkflowName", Constants.Closure_Memo); ////--流程名称
                bodyValues.Add("ProjectName", Constants.TempClosure);   //项目名称
            }
            bodyValues.Add("FormUrl", viewPage);

            if (postData.Entity.ProjectId.ToLower().Contains("tpcls"))
            {
                //调用邮件服务发送邮件
                using (EmailServiceClient client = new EmailServiceClient())
                {
                    EmailMessage  message = new EmailMessage();
                    StringBuilder sbTo    = new StringBuilder();
                    StringBuilder sbCC    = new StringBuilder();
                    Dictionary <string, string> attachments = new Dictionary <string, string>();
                    //主送人
                    var actorEmployee = Employee.GetEmployeeByCode(actor.UserAccount);
                    if (actorEmployee != null)
                    {
                        sbTo.Append(actorEmployee.Mail + ";");
                    }
                    var cooList = Employee.GetStoreEmployeesByRole(postData.Entity.USCode, RoleCode.Coordinator);
                    foreach (var coo in cooList)
                    {
                        sbTo.Append(coo.Mail + ";");
                    }
                    var mamList = Employee.GetStoreEmployeesByRole(postData.Entity.USCode, RoleCode.Market_Asset_Mgr);
                    foreach (var mam in mamList)
                    {
                        sbTo.Append(mam.Mail + ";");
                    }
                    var ramList = Employee.GetStoreEmployeesByRole(postData.Entity.USCode, RoleCode.Regional_Asset_Mgr);
                    foreach (var ram in ramList)
                    {
                        sbTo.Append(ram.Mail + ";");
                    }
                    var mcamList = Employee.GetStoreEmployeesByRole(postData.Entity.USCode, RoleCode.MCCL_Asset_Mgr);
                    foreach (var mcam in mcamList)
                    {
                        sbTo.Append(mcam.Mail + ";");
                    }

                    //抄送人
                    if (postData.Receivers != null)
                    {
                        foreach (Employee emp in postData.Receivers)
                        {
                            if (sbCC.Length > 0)
                            {
                                sbCC.Append(";");
                            }
                            if (!string.IsNullOrEmpty(emp.Mail))
                            {
                                sbCC.Append(emp.Mail);
                            }
                        }
                    }
                    if (sbCC.Length > 0)
                    {
                        sbCC.Append(";");
                    }
                    message.EmailBodyValues = bodyValues;
                    attachments.Add(pdfPath, postData.Entity.USCode + " " + Constants.TempClosure_Memo + ".pdf");
                    message.AttachmentsDict = attachments;
                    message.To           = sbTo.ToString();
                    message.CC           = sbCC.ToString();
                    message.TemplateCode = EmailTemplateCode.GBMemoNotification;
                    result = client.SendNotificationEmail(message);
                }
            }
            else
            {
                using (EmailServiceClient client = new EmailServiceClient())
                {
                    EmailMessage  message = new EmailMessage();
                    StringBuilder sbTo    = new StringBuilder();
                    StringBuilder sbCC    = new StringBuilder();
                    Dictionary <string, string> attachments = new Dictionary <string, string>();

                    if (postData.Receivers != null)
                    {
                        foreach (Employee emp in postData.Receivers)
                        {
                            if (sbCC.Length > 0)
                            {
                                sbTo.Append(";");
                            }
                            if (!string.IsNullOrEmpty(emp.Mail))
                            {
                                sbTo.Append(emp.Mail);
                            }
                        }
                    }
                    if (sbCC.Length > 0)
                    {
                        sbCC.Append(";");
                    }
                    message.EmailBodyValues = bodyValues;
                    string strTitle = FlowCode.TempClosure_ClosureMemo;
                    if (postData.Entity.ProjectId.ToLower().IndexOf("rebuild") >= 0)
                    {
                        strTitle = FlowCode.Rebuild_TempClosureMemo;
                    }
                    else if (postData.Entity.ProjectId.ToLower().IndexOf("reimage") >= 0)
                    {
                        strTitle = FlowCode.Reimage_TempClosureMemo;
                    }
                    else if (postData.Entity.ProjectId.ToLower().IndexOf("majorlease") >= 0)
                    {
                        strTitle = "MajorLease_ClosureMemo";
                    }

                    attachments.Add(pdfPath, postData.Entity.USCode + " " + strTitle + ".pdf");
                    message.AttachmentsDict = attachments;
                    message.To           = sbTo.ToString();
                    message.TemplateCode = EmailTemplateCode.GBMemoNotification;
                    result = client.SendNotificationEmail(message);
                }
            }

            if (!result.Successful)
            {
                return(BadRequest(result.ErrorMessage + " " + pdfPath));
            }
            using (TransactionScope tranScope = new TransactionScope())
            {
                postData.Entity.Save();
                ProjectInfo projectInfo = null;
                if (postData.Entity.ProjectId.ToLower().IndexOf("rebuild") >= 0)
                {
                    projectInfo = ProjectInfo.Get(postData.Entity.ProjectId, FlowCode.Rebuild_TempClosureMemo);
                }
                else if (postData.Entity.ProjectId.ToLower().IndexOf("reimage") >= 0)
                {
                    projectInfo = ProjectInfo.Get(postData.Entity.ProjectId, FlowCode.Reimage_TempClosureMemo);
                }
                else if (postData.Entity.ProjectId.ToLower().IndexOf("majorlease") >= 0 ||
                         postData.Entity.ProjectId.ToLower().IndexOf("renewal") >= 0)
                {
                    postData.Entity.Submit();
                }
                else
                {
                    projectInfo = ProjectInfo.Get(postData.Entity.ProjectId, FlowCode.TempClosure_ClosureMemo);
                    var tempClosure = TempClosureInfo.Get(postData.Entity.ProjectId);
                    if (postData.Entity.ClosureDate != null)
                    {
                        tempClosure.ActualTempClosureDate = postData.Entity.ClosureDate.Value;
                    }
                    tempClosure.Update();
                }
                if (projectInfo != null && projectInfo.Status == ProjectStatus.UnFinish)
                {
                    postData.Entity.Submit();

                    if (postData.Entity.ProjectId.ToLower().Contains("tpcls"))
                    {
                        if (postData.Entity.ClosureDate.HasValue)
                        {
                            ScheduleLog.UpdateStoreStatusSchedule(postData.Entity.USCode, postData.Entity.ProjectId, postData.Entity.ClosureDate.Value, ClientCookie.UserCode);
                        }
                    }
                }
                tranScope.Complete();
            }
            return(Ok());
        }