Beispiel #1
0
 public IHttpActionResult EditClosurePackage(TempClosurePackage entity)
 {
     return(Ok(new ProjectEditResult
     {
         TaskUrl = entity.Edit()
     }));
 }
        public IHttpActionResult ReturnTask(WorkflowStepInfo info)
        {
            var task = TaskWork.GetTaskBySN(info.SN);

            if (task == null || task.Status != TaskWorkStatus.UnFinish)
            {
                return(Ok());
            }

            var    entityId  = new Guid(info.EntityID);
            string projectId = string.Empty;

            switch (info.WorkflowName)
            {
            case FlowCode.Closure_ClosurePackage:
                var closurePackage = ClosurePackage.Get(entityId);
                projectId = closurePackage.ProjectId;
                break;

            case FlowCode.TempClosure_ClosurePackage:
                var tempClosurePackage = TempClosurePackage.Get(entityId);
                projectId = tempClosurePackage.ProjectId;
                break;

            case FlowCode.MajorLease_Package:
                var majorLeasePackage = MajorLeaseChangePackage.Get(entityId);
                projectId = majorLeasePackage.ProjectId;
                break;

            case FlowCode.Rebuild_Package:
                var rebuildPackage = RebuildPackage.Get(entityId);
                projectId = rebuildPackage.ProjectId;
                break;

            case FlowCode.Renewal_Package:
                var renewalPackage = RenewalPackage.Get(entityId);
                projectId = renewalPackage.ProjectId;
                break;

            case FlowCode.Reimage_Package:
                var reimagePackage = RenewalPackage.Get(entityId);
                projectId = reimagePackage.ProjectId;
                break;

            default:
                break;
            }
            if (!string.IsNullOrEmpty(projectId))
            {
                TaskWork.Finish(e => e.RefID == projectId && e.TypeCode == info.WorkflowName && e.Status == TaskWorkStatus.UnFinish && e.ActivityName != "Originator");
            }
            return(Ok());
        }
Beispiel #3
0
        public IHttpActionResult Get(string projectId, Guid?Id = null)
        {
            var project     = ProjectInfo.Get(projectId, FlowCode.TempClosure_ClosurePackage);
            var tempClosure = TempClosureInfo.FirstOrDefault(tc => tc.ProjectId == projectId);
            var isActor     = ProjectUsers.IsRole(projectId, ClientCookie.UserCode, ProjectUserRoleCode.AssetActor);
            TempClosurePackage entity;

            if (Id != null)
            {
                entity = TempClosurePackage.Get(Id.Value);
            }
            else
            {
                entity = TempClosurePackage.Get(projectId);
            }
            if (entity != null)
            {
                entity.IsProjectFreezed = entity.CheckIfFreezeProject(projectId);
                var SavedComment = ProjectComment.GetSavedComment(entity.Id, "TempClosurePackage", ClientCookie.UserCode);
                var hasValidTask = TaskWork.Any(t => t.RefID == projectId && t.Status == TaskWorkStatus.UnFinish && t.ReceiverAccount != ClientCookie.UserCode);
                return(Ok(new
                {
                    Info = tempClosure,
                    ClosurePackage = entity,
                    Approver = ApproveDialogUser.GetApproveDialogUser(projectId, FlowCode.TempClosure_ClosurePackage),
                    ProjectComment = SavedComment != null ? SavedComment.Content : "",
                    Editable = ProjectInfo.IsFlowEditable(projectId, FlowCode.TempClosure_ClosurePackage),
                    Recallable = ProjectInfo.IsFlowRecallable(projectId, FlowCode.TempClosure_ClosurePackage),
                    Rejectable = ApproveDialogUser.Any(u => u.ProjectId == projectId && u.FlowCode == FlowCode.TempClosure_ClosurePackage && u.VPGMCode == ClientCookie.UserCode),
                    Savable = ProjectInfo.IsFlowSavable(projectId, FlowCode.TempClosure_ClosurePackage)
                }));
            }
            else
            {
                entity = TempClosurePackage.Create(projectId);
                return(Ok(new
                {
                    Info = tempClosure,
                    ClosurePackage = entity,
                    Approver = ApproveDialogUser.GetApproveDialogUser(projectId, FlowCode.TempClosure_ClosurePackage),
                    ProjectComment = "",
                    Editable = (project.Status == ProjectStatus.Finished || project.Status == ProjectStatus.Rejected) && isActor && !entity.IsHistory,
                    Recallable = project.Status == ProjectStatus.UnFinish && isActor && project.NodeCode != NodeCode.Start,
                    Rejectable = ApproveDialogUser.Any(u => u.ProjectId == projectId && u.FlowCode == FlowCode.TempClosure_ClosurePackage && u.VPGMCode == ClientCookie.UserCode),
                    Savable = ProjectInfo.IsFlowSavable(projectId, FlowCode.TempClosure_ClosurePackage)
                }));
            }
        }
Beispiel #4
0
        public IHttpActionResult getApprovers(string projectId)
        {
            var project = ProjectInfo.Get(projectId, FlowCode.TempClosure_ClosurePackage);

            return(Ok(new
            {
                MarketMgrs = Employee.GetStoreEmployeesByRole(project.USCode, RoleCode.Market_Asset_Mgr),
                RegionalMgrs = Employee.GetStoreEmployeesByRole(project.USCode, RoleCode.Regional_Asset_Mgr),
                MDDs = Employee.GetStoreEmployeesByRole(project.USCode, RoleCode.Market_DD),
                GMs = Employee.GetStoreEmployeesByRole(project.USCode, RoleCode.GM),
                FCs = Employee.GetStoreEmployeesByRole(project.USCode, RoleCode.Finance_Controller),
                VPGMs = Employee.GetStoreEmployeesByRole(project.USCode, RoleCode.VPGM),
                MCCLAssetMgrs = Employee.GetStoreEmployeesByRole(project.USCode, RoleCode.MCCL_Asset_Mgr),
                MCCLAssetDirs = Employee.GetStoreEmployeesByRole(project.USCode, RoleCode.MCCL_Asset_Director),
                ProjectDto = TempClosurePackage.GetApproverAndNoticeUsers(projectId)
            }));
        }
        public IHttpActionResult AddComments(WorkflowStepInfo comments)
        {
            var entityQuid = new Guid(comments.EntityID);

            switch (comments.WorkflowName)
            {
            case FlowCode.Closure_ClosurePackage:
                var closurePackage = ClosurePackage.Get(entityQuid);
                AddComments(comments, closurePackage.Id, ClosurePackage.TableName, closurePackage.ProcInstID, closurePackage.ProjectId, FlowCode.Closure, EmailTemplateCode.Closure_Package);
                break;

            case FlowCode.TempClosure_ClosurePackage:
                var tempClosurePackage = TempClosurePackage.Get(entityQuid);
                AddComments(comments, tempClosurePackage.Id, tempClosurePackage.TableName, tempClosurePackage.ProcInstId, tempClosurePackage.ProjectId, FlowCode.TempClosure, EmailTemplateCode.TempClosure_Package);
                break;

            case FlowCode.MajorLease_Package:
                var majorLeasePackage = MajorLeaseChangePackage.Get(entityQuid);
                AddComments(comments, majorLeasePackage.Id, majorLeasePackage.TableName, majorLeasePackage.ProcInstID, majorLeasePackage.ProjectId, FlowCode.MajorLease, EmailTemplateCode.MajorLease_Package);
                break;

            case FlowCode.Rebuild_Package:
                var rebuildPackage = RebuildPackage.Get(entityQuid);
                AddComments(comments, rebuildPackage.Id, RebuildPackage.TableName, rebuildPackage.ProcInstID, rebuildPackage.ProjectId, FlowCode.Rebuild, EmailTemplateCode.Rebuild_Package);
                break;

            case FlowCode.Renewal_Package:
                var renewalPackage = RenewalPackage.Get(entityQuid);
                AddComments(comments, renewalPackage.Id, renewalPackage.TableName, renewalPackage.ProcInstId, renewalPackage.ProjectId, FlowCode.Renewal, EmailTemplateCode.Renewal_Package);
                break;

            case FlowCode.Reimage_Package:
                var reimagePackage = ReimagePackage.Get(entityQuid);
                AddComments(comments, reimagePackage.Id, ReimagePackage.TableName, reimagePackage.ProcInstID, reimagePackage.ProjectId, FlowCode.Reimage, EmailTemplateCode.Reimage_Package);
                break;

            default:
                break;
            }
            return(Ok(true));
        }
Beispiel #6
0
        protected static BaseWFEntity GetEmptyWorkflowEntity(string flowCode)
        {
            BaseWFEntity wfEntity = null;

            switch (flowCode)
            {
            case FlowCode.MajorLease:
                wfEntity = new MajorLeaseInfo();
                wfEntity.IsMainProject = true;
                break;

            case FlowCode.MajorLease_LegalReview:
                wfEntity = new MajorLeaseLegalReview();
                break;

            case FlowCode.MajorLease_FinanceAnalysis:
                wfEntity = new MajorLeaseFinancAnalysis();
                break;

            case FlowCode.MajorLease_ConsInfo:
                wfEntity = new MajorLeaseConsInfo();
                break;

            case FlowCode.MajorLease_Package:
                wfEntity = new MajorLeaseChangePackage();
                break;

            case FlowCode.MajorLease_ConsInvtChecking:
                wfEntity = new MajorLeaseConsInvtChecking();
                break;

            case FlowCode.MajorLease_GBMemo:
                wfEntity = new MajorLeaseGBMemo();
                break;

            case FlowCode.Closure:
                wfEntity = new ClosureInfo();
                wfEntity.IsMainProject = true;
                break;

            case FlowCode.Closure_ClosurePackage:
                wfEntity = new ClosurePackage();
                break;

            case FlowCode.Closure_ClosureTool:
                wfEntity = new ClosureTool();
                break;

            case FlowCode.Closure_ConsInvtChecking:
                wfEntity = new ClosureConsInvtChecking();
                break;

            case FlowCode.Closure_LegalReview:
                wfEntity = new ClosureLegalReview();
                break;

            case FlowCode.Closure_WOCheckList:
                wfEntity = new ClosureWOCheckList();
                break;

            case FlowCode.Closure_ExecutiveSummary:
                wfEntity = new ClosureExecutiveSummary();
                break;

            case FlowCode.TempClosure:
                wfEntity = new TempClosureInfo();
                wfEntity.IsMainProject = true;
                break;

            case FlowCode.TempClosure_LegalReview:
                wfEntity = new TempClosureLegalReview();
                break;

            case FlowCode.TempClosure_ClosurePackage:
                wfEntity = new TempClosurePackage();
                break;

            case FlowCode.Rebuild:
                wfEntity = new RebuildInfo();
                wfEntity.IsMainProject = true;
                break;

            case FlowCode.Rebuild_LegalReview:
                wfEntity = new RebuildLegalReview();
                break;

            case FlowCode.Rebuild_FinanceAnalysis:
                wfEntity = new RebuildFinancAnalysis();
                break;

            case FlowCode.Rebuild_ConsInfo:
                wfEntity = new RebuildConsInfo();
                break;

            case FlowCode.Rebuild_Package:
                wfEntity = new RebuildPackage();
                break;

            case FlowCode.Rebuild_ConsInvtChecking:
                wfEntity = new RebuildConsInvtChecking();
                break;

            case FlowCode.Rebuild_GBMemo:
                wfEntity = new GBMemo();
                break;

            case FlowCode.Renewal:
                wfEntity = new RenewalInfo();
                wfEntity.IsMainProject = true;
                break;

            case FlowCode.Renewal_Letter:
                wfEntity = new RenewalLetter();
                break;

            case FlowCode.Renewal_LLNegotiation:
                wfEntity = new RenewalLLNegotiation();
                break;

            case FlowCode.Renewal_ConsInfo:
                wfEntity = new RenewalConsInfo();
                break;

            case FlowCode.Renewal_Tool:
                wfEntity = new RenewalTool();
                break;

            case FlowCode.Renewal_Analysis:
                wfEntity = new RenewalAnalysis();
                break;

            case FlowCode.Renewal_ClearanceReport:
                wfEntity = new RenewalClearanceReport();
                break;

            case FlowCode.Renewal_ConfirmLetter:
                wfEntity = new RenewalConfirmLetter();
                break;

            case FlowCode.Renewal_LegalApproval:
                wfEntity = new RenewalLegalApproval();
                break;

            case FlowCode.Renewal_Package:
                wfEntity = new RenewalPackage();
                break;

            case FlowCode.Renewal_GBMemo:
                wfEntity = new RenewalGBMemo();
                break;

            case FlowCode.Reimage:
                wfEntity = new ReimageInfo();
                wfEntity.IsMainProject = true;
                break;

            case FlowCode.Reimage_ConsInfo:
                wfEntity = new ReimageConsInfo();
                break;

            case FlowCode.Reimage_Summary:
                wfEntity = new ReimageSummary();
                break;

            case FlowCode.Reimage_Package:
                wfEntity = new ReimagePackage();
                break;

            case FlowCode.Reimage_ConsInvtChecking:
                wfEntity = new ReimageConsInvtChecking();
                break;

            case FlowCode.Reimage_GBMemo:
                wfEntity = new ReimageGBMemo();
                break;
            }
            return(wfEntity);
        }
        public IHttpActionResult PreparePackDownload(string refTableName, string projectId)
        {
            string pdfPath    = string.Empty;
            string refTableId = ProjectInfo.GetRefTableId(refTableName, projectId);
            Dictionary <string, string> templateFileds = new Dictionary <string, string>();
            HtmlTempalteType            templateType   = HtmlTempalteType.Default;
            string flowName = string.Empty;
            string flowCode = string.Empty;

            switch (refTableName)
            {
            case "MajorLeaseChangePackage":
            {
                templateType = HtmlTempalteType.MajorLease;
                flowName     = FlowCode.MajorLease;
                flowCode     = FlowCode.MajorLease_Package;
                var majorLeaseChangePkg = MajorLeaseChangePackage.GetMajorPackageInfo(projectId);
                templateFileds = majorLeaseChangePkg.GetPrintTemplateFields();
            }
            break;

            case "TempClosurePackage":
            {
                templateType = HtmlTempalteType.TempClosure;
                flowName     = FlowCode.TempClosure;
                flowCode     = FlowCode.TempClosure_ClosurePackage;
                var tempClosurePackage = TempClosurePackage.Get(projectId);
                if (tempClosurePackage == null)
                {
                    tempClosurePackage           = new TempClosurePackage();
                    tempClosurePackage.ProjectId = projectId;
                }
                templateFileds = tempClosurePackage.GetPrintTemplateFields();
            }
            break;

            case "ReimagePackage":
            {
                var entity = ReimagePackage.GetReimagePackageInfo(projectId);
                templateType = HtmlTempalteType.Reimage;
                flowName     = FlowCode.Reimage;
                flowCode     = FlowCode.Reimage_Package;
                if (entity == null || entity.Id == Guid.Parse("00000000-0000-0000-0000-000000000000"))
                {
                    entity           = new ReimagePackage();
                    entity.ProjectId = projectId;
                }
                templateFileds = entity.GetPrintTemplateFields();
            }
            break;

            case "RenewalLegalApproval":
            {
                templateType = HtmlTempalteType.RenewalLegalApproval;
                flowName     = FlowCode.Renewal;
                flowCode     = FlowCode.Renewal_LegalApproval;
                var legal = RenewalLegalApproval.Get(projectId);
                if (legal == null)
                {
                    legal           = new RenewalLegalApproval();
                    legal.ProjectId = projectId;
                }
                templateFileds = legal.GetPrintTemplateFields();
            }
            break;

            case "RenewalPackage":
            {
                templateType = HtmlTempalteType.Renewal;
                flowName     = FlowCode.Renewal;
                flowCode     = FlowCode.Renewal_Package;
                var package = RenewalPackage.Get(projectId);
                if (package == null)
                {
                    package           = new RenewalPackage();
                    package.ProjectId = projectId;
                }
                templateFileds = package.GetPrintTemplateFields();
            }
            break;

            case "ClosurePackage":
            {
                templateType = HtmlTempalteType.Default;
                flowName     = FlowCode.Closure;
                flowCode     = FlowCode.Closure_ClosurePackage;
                var closurePackage = ClosurePackage.Get(projectId);
                if (closurePackage == null)
                {
                    closurePackage           = new ClosurePackage();
                    closurePackage.ProjectId = projectId;
                }
                templateFileds = closurePackage.GetPrintTemplateFields();
            }
            break;

            default:
                break;
            }
            List <Attachment> attachments = Attachment.GetAllAttachmentsIncludeRequire(refTableName, projectId, flowCode).Where(att => att.ID != Guid.Empty &&
                                                                                                                                (att.RequirementId.HasValue || att.TypeCode == "Cover")).ToList();
            //Submission and Approval Records - 只显示通过意见
            List <SubmissionApprovalRecord> recordList = new List <SubmissionApprovalRecord>();
            //Submission and Approval Records Details — 所有意见
            List <SubmissionApprovalRecord> recordDetailList = new List <SubmissionApprovalRecord>();
            ProjectCommentCondition         condition        = new ProjectCommentCondition();

            condition.RefTableName = refTableName;
            condition.RefTableId   = Guid.Parse(refTableId);
            condition.Status       = ProjectCommentStatus.Submit;

            var commentList       = condition.RefTableId == Guid.Empty ? new List <VProjectComment>() : VProjectComment.SearchVListForPDF(condition);
            var commentDetailList = condition.RefTableId == Guid.Empty ? new List <VProjectComment>() : VProjectComment.SearchVList(condition);

            SubmissionApprovalRecord record = null;

            foreach (var item in commentList)
            {
                record            = new SubmissionApprovalRecord();
                record.ActionName = item.ActionDesc;
                if (item.CreateTime != null)
                {
                    record.OperationDate = item.CreateTime.Value;
                }
                record.OperatorID    = item.UserAccount;
                record.OperatorName  = item.UserNameENUS;
                record.OperatorTitle = item.PositionName;
                record.Comments      = item.Content;
                recordList.Add(record);
            }
            recordList = recordList.OrderBy(i => i.OperationDate).ToList();

            foreach (var item in commentDetailList)
            {
                record            = new SubmissionApprovalRecord();
                record.ActionName = item.ActionDesc;
                if (item.CreateTime != null)
                {
                    record.OperationDate = item.CreateTime.Value;
                }
                record.OperatorID    = item.UserAccount;
                record.OperatorName  = item.UserNameENUS;
                record.OperatorTitle = item.PositionName;
                record.Comments      = item.Content;
                recordDetailList.Add(record);
            }
            recordDetailList = recordDetailList.OrderBy(i => i.OperationDate).ToList();

            pdfPath = HtmlConversionUtility.HtmlConvertToPDF(templateType, templateFileds, recordList, recordDetailList);
            var pdfFileName  = Path.GetFileName(pdfPath);
            var pdfExtension = Path.GetExtension(pdfPath);

            attachments.Add(new Attachment {
                InternalName = pdfFileName, Name = flowName + " Print", Extension = pdfExtension
            });

            if (refTableName == "RenewalLegalApproval")
            {
                SaveRenewalLegalApprovalPDF("RenewalLegalApproval", projectId,
                                            new Guid("870BD738-A512-4B27-9FDB-C18058BFA817"), pdfPath);
                return(Ok());
            }
            string packFileUrl = ZipHandle.ExeFiles(attachments);

            return(Ok(new
            {
                PackUrl = string.Concat("~/", "Temp/", Path.GetFileName(packFileUrl))
            }));
        }
        private void GenerateCover(string projectId, string refTableName)
        {
            string coverPath      = string.Empty;
            string coverName      = "Cover";
            string coverTempPath  = SiteFilePath.UploadFiles_DIRECTORY + "\\" + Guid.NewGuid() + ".xlsx";
            string coverExtention = Path.GetExtension(coverTempPath);

            switch (refTableName)
            {
            case "MajorLeaseChangePackage":
                coverPath = SiteFilePath.Template_DIRECTORY + "\\" + SiteFilePath.MajorLeaseChangeCove_Template;
                var majorLeaseChangePackage = MajorLeaseChangePackage.GetMajorPackageInfo(projectId);
                majorLeaseChangePackage.GenerateCoverEexcel(coverPath, coverTempPath);
                break;

            case "ReimagePackage":
                var rmgPackage = ReimagePackage.Get(projectId);
                if (rmgPackage == null)
                {
                    return;
                }
                if (!Attachment.Any(i => i.TypeCode == "Cover" && i.RefTableName == ReimagePackage.TableName && i.RefTableID.ToString() == rmgPackage.Id.ToString()))
                {
                    var reimageInfoEntity = ReimageInfo.GetReimageInfo(projectId);
                    //生成cover文件
                    coverPath = SiteFilePath.Template_DIRECTORY + "\\" + SiteFilePath.Store_Reimage_Cover_Template;
                    var store = StoreBasicInfo.FirstOrDefault(e => e.StoreCode == reimageInfoEntity.USCode);

                    File.Copy(coverPath, coverTempPath);
                    var excelOutputDirector = new ExcelDataInputDirector(new FileInfo(coverTempPath), ExcelDataInputType.ReimageCover);
                    var inputInfo           = new ExcelInputDTO
                    {
                        Region    = store.Region,
                        Province  = store.ProvinceENUS,
                        City      = store.CityENUS,
                        StoreName = store.NameENUS,
                        USCode    = reimageInfoEntity.USCode,
                        OpenDate  = store.OpenDate
                    };
                    excelOutputDirector.Input(inputInfo);

                    var coverItem = new Attachment();
                    coverItem.Name         = coverName + coverExtention;
                    coverItem.InternalName = Path.GetFileName(coverTempPath);
                    coverItem.RefTableName = ReimagePackage.TableName;
                    coverItem.RefTableID   = rmgPackage.Id.ToString();
                    coverItem.RelativePath = "//";
                    coverItem.Extension    = coverExtention;
                    coverItem.CreateTime   = DateTime.Now;

                    coverItem.TypeCode        = coverName;
                    coverItem.CreatorID       = ClientCookie.UserCode;
                    coverItem.RequirementId   = AttachmentRequirement.FirstOrDefault(e => e.FlowCode == FlowCode.Reimage_Package && e.NameENUS == "Cover").Id;
                    coverItem.CreatorNameENUS = ClientCookie.UserNameENUS;
                    coverItem.CreatorNameZHCN = ClientCookie.UserNameZHCN;

                    using (FileStream stream = new FileStream(coverTempPath, FileMode.Open))
                    {
                        coverItem.Length = (int)stream.Length;
                    }
                    Attachment.SaveSigleFile(coverItem);
                }
                break;

            case "TempClosurePackage":
                var tempClosurePackage = TempClosurePackage.Get(projectId);
                if (tempClosurePackage == null)
                {
                    return;
                }
                if (!Attachment.Any(i => i.TypeCode == "Cover" && i.RefTableName == tempClosurePackage.TableName && i.RefTableID.ToString() == tempClosurePackage.Id.ToString()))
                {
                    var tempClosureInfoEntity = TempClosureInfo.Get(projectId);
                    //生成cover文件
                    coverPath = SiteFilePath.Template_DIRECTORY + "\\" + SiteFilePath.Store_TempClosure_Cover_Template;
                    var store = StoreBasicInfo.FirstOrDefault(e => e.StoreCode == tempClosureInfoEntity.USCode);

                    File.Copy(coverPath, coverTempPath);
                    var excelOutputDirector = new ExcelDataInputDirector(new FileInfo(coverTempPath), ExcelDataInputType.TempClosureCover);
                    var inputInfo           = new ExcelInputDTO
                    {
                        StoreNameEN     = store.NameENUS,
                        USCode          = tempClosureInfoEntity.USCode,
                        City            = store.CityENUS,
                        Market          = store.MarketENUS,
                        ActualCloseDate = tempClosureInfoEntity.ActualTempClosureDate.ToString("yyyy-MM-dd")
                    };
                    excelOutputDirector.Input(inputInfo);

                    var coverItem = new Attachment();
                    coverItem.Name         = coverName + coverExtention;
                    coverItem.InternalName = Path.GetFileName(coverTempPath);
                    coverItem.RefTableName = tempClosurePackage.TableName;
                    coverItem.RefTableID   = tempClosurePackage.Id.ToString();
                    coverItem.RelativePath = "//";
                    coverItem.Extension    = coverExtention;
                    coverItem.CreateTime   = DateTime.Now;

                    coverItem.TypeCode  = coverName;
                    coverItem.CreatorID = ClientCookie.UserCode;
                    //coverItem.RequirementId = AttachmentRequirement.FirstOrDefault(e => e.FlowCode == FlowCode.TempClosure_ClosurePackage && e.NameENUS == "Cover").Id;
                    coverItem.CreatorNameENUS = ClientCookie.UserNameENUS;
                    coverItem.CreatorNameZHCN = ClientCookie.UserNameZHCN;

                    using (FileStream stream = new FileStream(coverTempPath, FileMode.Open))
                    {
                        coverItem.Length = (int)stream.Length;
                    }
                    Attachment.SaveSigleFile(coverItem);
                }
                break;

            case "ClosurePackage":
                var closurePackage = ClosurePackage.Get(projectId);
                if (closurePackage == null)
                {
                    return;
                }
                if (!Attachment.Any(i => i.TypeCode == "Cover" && i.RefTableName == ClosurePackage.TableName && i.RefTableID.ToString() == closurePackage.Id.ToString()))
                {
                    var closureInfoEntity = ClosureInfo.GetByProjectId(projectId);
                    //生成cover文件
                    coverPath = SiteFilePath.Template_DIRECTORY + "\\" + SiteFilePath.Store_Closure_Cover_Template;
                    var store = StoreBasicInfo.FirstOrDefault(e => e.StoreCode == closureInfoEntity.USCode);

                    File.Copy(coverPath, coverTempPath);
                    var excelOutputDirector = new ExcelDataInputDirector(new FileInfo(coverTempPath), ExcelDataInputType.ClosureCover);
                    var inputInfo           = new ExcelInputDTO
                    {
                        StoreNameEN     = store.NameENUS,
                        USCode          = closureInfoEntity.USCode,
                        City            = store.CityENUS,
                        Market          = store.MarketENUS,
                        ActualCloseDate = closureInfoEntity.ActualCloseDate.Value.ToString("yyyy-MM-dd")
                    };
                    excelOutputDirector.Input(inputInfo);

                    var coverItem = new Attachment();
                    coverItem.Name         = coverName + coverExtention;
                    coverItem.InternalName = Path.GetFileName(coverTempPath);
                    coverItem.RefTableName = ClosurePackage.TableName;
                    coverItem.RefTableID   = closurePackage.Id.ToString();
                    coverItem.RelativePath = "//";
                    coverItem.Extension    = coverExtention;
                    coverItem.CreateTime   = DateTime.Now;

                    coverItem.TypeCode  = coverName;
                    coverItem.CreatorID = ClientCookie.UserCode;
                    //coverItem.RequirementId = AttachmentRequirement.FirstOrDefault(e => e.FlowCode == FlowCode.TempClosure_ClosurePackage && e.NameENUS == "Cover").Id;
                    coverItem.CreatorNameENUS = ClientCookie.UserNameENUS;
                    coverItem.CreatorNameZHCN = ClientCookie.UserNameZHCN;

                    using (FileStream stream = new FileStream(coverTempPath, FileMode.Open))
                    {
                        coverItem.Length = (int)stream.Length;
                    }
                    Attachment.SaveSigleFile(coverItem);
                }
                break;
            }
        }
Beispiel #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);
        }
Beispiel #10
0
 public IHttpActionResult ConfirmClosurePackage(TempClosurePackage entity)
 {
     entity.Confirm();
     return(Ok());
 }