示例#1
0
        public IHttpActionResult UploadAttachement(string projectId)
        {
            HttpRequest        request     = System.Web.HttpContext.Current.Request;
            HttpFileCollection FileCollect = request.Files;

            if (FileCollect.Count > 0) //如果集合的数量大于0
            {
                var entity = ClosureExecutiveSummary.FirstOrDefault(e => e.ProjectId == projectId && e.IsHistory == false);

                if (entity == null)
                {
                    entity                = new ClosureExecutiveSummary();
                    entity.Id             = Guid.NewGuid();
                    entity.CreateTime     = DateTime.Now;
                    entity.CreatorAccount = ClientCookie.UserCode;
                    entity.IsHistory      = false;
                    entity.ProjectId      = projectId;
                    ClosureExecutiveSummary.Add(entity);
                }

                for (int i = 0; i < FileCollect.Count; i++)
                {
                    var fileSave = FileCollect[i];
                    //用key获取单个文件对象HttpPostedFile

                    string fileName      = Path.GetFileName(fileSave.FileName);
                    string fileExtension = Path.GetExtension(fileSave.FileName);
                    var    current       = System.Web.HttpContext.Current;
                    string internalName  = Guid.NewGuid() + fileExtension;
                    string absolutePath  = current.Server.MapPath("~/") + "UploadFiles/" + internalName;

                    fileSave.SaveAs(absolutePath);

                    Attachment att = new Attachment();
                    att.InternalName    = internalName;
                    att.RefTableName    = "ClosureExecutiveSummary";
                    att.RefTableID      = entity.Id.ToString();
                    att.RelativePath    = "//";
                    att.Name            = fileName;
                    att.Extension       = fileExtension;
                    att.Length          = FileCollect[0].ContentLength;
                    att.CreateTime      = DateTime.Now;
                    att.ID              = Guid.NewGuid();
                    att.TypeCode        = "Attachment";
                    att.CreatorID       = ClientCookie.UserCode;
                    att.CreatorNameENUS = ClientCookie.UserNameENUS;
                    att.CreatorNameZHCN = ClientCookie.UserNameZHCN;
                    Attachment.Add(att);
                }
            }
            return(Ok());
        }
示例#2
0
        public IHttpActionResult SaveExcutiveSummary(ClosureExecutiveSummary entity)
        {
            if (!ClosureExecutiveSummary.Any(i => i.ProjectId == entity.ProjectId && i.IsHistory == false))
            {
                if (entity.Id == Guid.Empty || entity.Id == null)
                {
                    entity.Id = Guid.NewGuid();
                }
                entity.CreateTime     = DateTime.Now;
                entity.CreatorAccount = ClientCookie.UserCode;
                ClosureExecutiveSummary.Add(entity);
            }
            else
            {
                ClosureExecutiveSummary.Update(entity);
            }

            ProjectInfo.FinishNode(entity.ProjectId, FlowCode.Closure_ExecutiveSummary, NodeCode.Closure_ExecutiveSummary_Input);
            return(Ok());
        }
示例#3
0
        public IHttpActionResult Upload(string projectId, string refTableName, Guid?requirementId = null)
        {
            using (TransactionScope tranScope = new TransactionScope())
            {
                var refTableId = Attachment.GetRefTableId(refTableName, projectId);
                if (refTableId == Guid.Empty.ToString())
                {
                    var newId = Guid.NewGuid();
                    refTableId = newId.ToString();
                    switch (refTableName)
                    {
                    case "MajorLeaseChangePackage":
                    {
                        var entity = new MajorLeaseChangePackage();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;

                    case "ReimageSummary":
                    {
                        var entity = new ReimageSummary();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;

                    case "ReimageConsInfo":
                    {
                        var entity = new ReimageConsInfo();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;

                    case "ReimagePackage":
                    {
                        var entity = new ReimagePackage();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;

                    case "RebuildLegalReview":
                    {
                        var entity = new RebuildLegalReview();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;

                    case "ClosureLegalReview":
                    {
                        var entity = new ClosureLegalReview();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;

                    case "ClosureExecutiveSummary":
                    {
                        var entity = new ClosureExecutiveSummary();
                        entity.ProjectId      = projectId;
                        entity.Id             = newId;
                        entity.CreateTime     = DateTime.Now;
                        entity.CreatorAccount = ClientCookie.UserCode;
                        entity.IsHistory      = false;
                        entity.Add();
                    }
                    break;

                    case "ClosurePackage":
                    {
                        var entity = new ClosurePackage();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;
                    }
                }
                var userRole = ProjectUsers.Get(ClientCookie.UserCode, projectId);
                var files    = HttpContext.Current.Request.Files;
                if (requirementId.HasValue)
                {
                    var attReq      = AttachmentRequirement.Get(requirementId.Value);
                    var projectInfo = ProjectInfo.Get(projectId, attReq.FlowCode);
                    var store       = StoreBasicInfo.GetStorInfo(projectInfo.USCode);
                    var attachNode  = NodeInfo.FirstOrDefault(n => n.FlowCode == attReq.FlowCode && n.Code == attReq.NodeCode);
                    if (attachNode != null)
                    {
                        ProjectInfo.FinishNode(projectId, attReq.FlowCode, attReq.NodeCode);
                    }
                    var    file          = files[0];
                    string fileName      = Path.GetFileName(file.FileName);
                    string fileExtension = Path.GetExtension(file.FileName);
                    var    current       = System.Web.HttpContext.Current;
                    string internalName  = Guid.NewGuid() + fileExtension;
                    string absolutePath  = current.Server.MapPath("~/") + "UploadFiles/" + internalName;

                    file.SaveAs(absolutePath);

                    Attachment att = Attachment.Get(refTableId, requirementId.Value);

                    if (att == null)
                    {
                        att = new Attachment();
                        att.InternalName    = internalName;
                        att.RefTableName    = refTableName;
                        att.RefTableID      = refTableId;
                        att.RelativePath    = "//";
                        att.Name            = fileName;
                        att.Extension       = fileExtension;
                        att.Length          = file.ContentLength;
                        att.CreateTime      = DateTime.Now;
                        att.CreatorNameZHCN = ClientCookie.UserNameZHCN;
                        att.CreatorNameENUS = ClientCookie.UserNameENUS;
                        att.CreatorID       = ClientCookie.UserCode;
                        att.ID            = Guid.NewGuid();
                        att.RequirementId = requirementId;
                        att.TypeCode      = "";
                        Attachment.Add(att);
                    }
                    else
                    {
                        att.InternalName    = internalName;
                        att.RefTableName    = refTableName;
                        att.RefTableID      = refTableId;
                        att.RelativePath    = "//";
                        att.Name            = fileName;
                        att.Extension       = fileExtension;
                        att.Length          = file.ContentLength;
                        att.CreateTime      = DateTime.Now;
                        att.CreatorNameZHCN = ClientCookie.UserNameZHCN;
                        att.CreatorNameENUS = ClientCookie.UserNameENUS;
                        att.CreatorID       = ClientCookie.UserCode;
                        Attachment.Update(att);
                    }
                    //TempClosure上传SignAgreement
                    //if (requirementId.Value.Equals(new Guid("1E9B17AF-357A-4DC9-8A60-17766663FB75")))
                    //{
                    //    var url = "/TempClosure/Main#/ClosureMemo?projectId=" + projectId;
                    //    var actor = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == projectId && pu.RoleCode == ProjectUserRoleCode.AssetActor);
                    //    var title = string.Concat(projectId, " ", store.NameZHCN, " ", store.NameENUS);
                    //    TaskWork.Finish(t => t.ReceiverAccount == ClientCookie.UserCode && t.RefID == projectId && t.Status == TaskWorkStatus.UnFinish && t.TypeCode == FlowCode.TempClosure_ClosurePackage);
                    //    //TaskWork.SendTask(projectId, title, projectInfo.USCode, url, actor, FlowCode.TempClosure, FlowCode.TempClosure_ClosureMemo, "Start");
                    //}
                }
                else
                {
                    List <Attachment> attachments = new List <Attachment>();
                    string            typeCode    = "";
                    if (refTableName == "RebuildLegalReview")
                    {
                        typeCode = "Contract";
                    }
                    for (int i = 0; i < files.Count; i++)
                    {
                        var    file          = files[i];
                        string fileName      = Path.GetFileName(file.FileName);
                        string fileExtension = Path.GetExtension(file.FileName);
                        var    current       = System.Web.HttpContext.Current;
                        string internalName  = Guid.NewGuid() + fileExtension;
                        string absolutePath  = current.Server.MapPath("~/") + "UploadFiles/" + internalName;

                        file.SaveAs(absolutePath);

                        Attachment att = new Attachment();
                        att.InternalName    = internalName;
                        att.RefTableName    = refTableName;
                        att.RefTableID      = refTableId;
                        att.RelativePath    = "//";
                        att.Name            = fileName;
                        att.Extension       = fileExtension;
                        att.Length          = file.ContentLength;
                        att.CreateTime      = DateTime.Now;
                        att.CreatorNameZHCN = ClientCookie.UserNameZHCN;
                        att.CreatorNameENUS = ClientCookie.UserNameENUS;
                        att.CreatorID       = ClientCookie.UserCode;
                        att.ID            = Guid.NewGuid();
                        att.RequirementId = requirementId;
                        att.TypeCode      = typeCode;
                        attachments.Add(att);
                    }
                    Attachment.Add(attachments.ToArray());
                }
                tranScope.Complete();
                return(Ok());
            }
        }
示例#4
0
        public IHttpActionResult GenExecutiveSummaty(ClosureExecutiveSummary entity)
        {
            if (!ClosureExecutiveSummary.Any(i => i.ProjectId == entity.ProjectId && i.IsHistory == false))
            {
                if (entity.Id == Guid.Empty || entity.Id == null)
                {
                    entity.Id = Guid.NewGuid();
                }
                entity.CreateTime     = DateTime.Now;
                entity.CreatorAccount = ClientCookie.UserCode;
                ClosureExecutiveSummary.Add(entity);
            }
            else
            {
                ClosureExecutiveSummary.Update(entity);
            }

            var    current          = System.Web.HttpContext.Current;
            string path             = SiteFilePath.Template_DIRECTORY + "\\" + SiteFilePath.Executive_Summary_Template;
            string internalFileName = Guid.NewGuid() + ".xlsx";
            string filePath         = SiteFilePath.UploadFiles_DIRECTORY + "\\" + internalFileName;

            File.Copy(path, filePath);
            var fileInfo         = new FileInfo(filePath);
            var excelPMTDirector = new ExcelDataInputDirector(fileInfo, ExcelDataInputType.ClosureExecutiveSummary);

            var closure   = ClosureInfo.GetByProjectId(entity.ProjectId);
            var store     = StoreBasicInfo.GetStore(closure.USCode);
            var inputInfo = new ExcelInputDTO
            {
                StoreNameCN        = store.StoreBasicInfo.NameZHCN,
                USCode             = store.StoreBasicInfo.StoreCode,
                City               = store.StoreBasicInfo.CityENUS,
                Market             = store.StoreBasicInfo.MarketENUS,
                OpenDate           = store.StoreBasicInfo.OpenDate,
                Floor              = store.StoreSTLocation.Floor,
                TotalArea          = store.StoreSTLocation.TotalArea,
                TotalSeatsNo       = store.StoreSTLocation.TotalSeatsNo,
                BE                 = store.StoreBEInfoList.Count,
                RentType           = store.StoreContractInfo.RentType,
                RentStructure      = store.StoreContractInfo.RentStructure,
                MiniMarket         = entity.MiniMarket,
                StoreLocation      = entity.StoreLocation,
                CurrentSituation   = entity.CurrentSituation,
                NegotiationHistory = entity.NegotiationHistory,
                ProposedSolution   = entity.ProposedSolution,
                SalesTransfer      = entity.SalesTransfer
            };


            var leaseRecapID = StoreContractInfo.SearchByProject(entity.ProjectId).FirstOrDefault().LeaseRecapID ?? 0;
            var storeAtt     = StoreContractInfoAttached.Search(c => c.LeaseRecapID == leaseRecapID.ToString()).OrderByDescending(e => e.CreateDate).FirstOrDefault();

            if (storeAtt != null)
            {
                inputInfo.LeasingTerm = store.StoreContractInfo.LeasePurchaseTerm;
            }
            if (store.StoreContractInfo.RentCommencementDate.HasValue)
            {
                inputInfo.RentCommencementDate = store.StoreContractInfo.RentCommencementDate.Value;
            }

            if (store.StoreContractInfo.EndDate.HasValue)
            {
                inputInfo.LeaseExpirationDate = store.StoreContractInfo.EndDate.Value;
            }


            var toolEntity = ClosureTool.Get(closure.ProjectId);

            if (toolEntity != null)
            {
                if (toolEntity.TotalSales_Adjustment_RMB != null)
                {
                    inputInfo.TotalSales_TTM = string.Format("{0:f}", toolEntity.TotalSales_Adjustment_RMB);
                }
                if (toolEntity.CompSales_Adjustment != null)
                {
                    inputInfo.SalesComp_TTM = string.Format("{0:f}", toolEntity.CompSales_Adjustment);
                }
                if (toolEntity.CompCG_Adjustment != null)
                {
                    inputInfo.GCComp_TTM = string.Format("{0:f}", toolEntity.CompCG_Adjustment);
                }
                if (toolEntity.PAC_Adjustment != null)
                {
                    inputInfo.PAC_TTM = string.Format("{0:f}", toolEntity.PAC_Adjustment);
                }
                if (toolEntity.SOI_Adjustment != null)
                {
                    inputInfo.SOI_TTM = string.Format("{0:f}", toolEntity.SOI_Adjustment);
                }
                if (toolEntity.CashFlow_RMB_Adjustment != null)
                {
                    inputInfo.CASHFLOW_TTM = string.Format("{0:f}", toolEntity.CashFlow_RMB_Adjustment);
                }
                if (toolEntity.TotalSales_TTMY1 != null)
                {
                    inputInfo.TotalSales_TTMY1 = string.Format("{0:f}", toolEntity.TotalSales_TTMY1);
                }
                if (toolEntity.CompSales_TTMY1 != null)
                {
                    inputInfo.CompSales_TTMY1 = string.Format("{0:f}", toolEntity.CompSales_TTMY1);
                }
                if (toolEntity.CompGC_TTMY1 != null)
                {
                    inputInfo.CompGC_TTMY1 = string.Format("{0:f}", toolEntity.CompGC_TTMY1);
                }
                if (toolEntity.PAC_TTMY1 != null)
                {
                    inputInfo.PAC_TTMY1 = string.Format("{0:f}", toolEntity.PAC_TTMY1);
                }
                if (toolEntity.SOI_TTMY1 != null)
                {
                    inputInfo.SOI_TTMY1 = string.Format("{0:f}", toolEntity.SOI_TTMY1);
                }
                if (toolEntity.CashFlow_TTMY1 != null)
                {
                    inputInfo.CashFlow_TTMY1 = string.Format("{0:f}", toolEntity.CashFlow_TTMY1);
                }
                if (toolEntity.TotalSales_TTMY2 != null)
                {
                    inputInfo.TotalSales_TTMY2 = string.Format("{0:f}", toolEntity.TotalSales_TTMY2);
                }
                if (toolEntity.CompSales_TTMY2 != null)
                {
                    inputInfo.CompSales_TTMY2 = string.Format("{0:f}", toolEntity.CompSales_TTMY2);
                }
                if (toolEntity.CompGC_TTMY2 != null)
                {
                    inputInfo.CompGC_TTMY2 = string.Format("{0:f}", toolEntity.CompGC_TTMY2);
                }
                if (toolEntity.PAC_TTMY2 != null)
                {
                    inputInfo.PAC_TTMY2 = string.Format("{0:f}", toolEntity.PAC_TTMY2);
                }
                if (toolEntity.SOI_TTMY2 != null)
                {
                    inputInfo.SOI_TTMY2 = string.Format("{0:f}", toolEntity.SOI_TTMY2);
                }
                if (toolEntity.CashFlow_TTMY2 != null)
                {
                    inputInfo.CashFlow_TTMY2 = string.Format("{0:f}", toolEntity.CashFlow_TTMY2);
                }


                List <StoreBEInfo> remoteBeList   = new List <StoreBEInfo>();
                List <StoreBEInfo> attachedBeList = new List <StoreBEInfo>();
                StoreBEInfo        mds            = null;
                StoreBEInfo        mcCafe         = null;
                StoreBEInfo        hour24         = null;
                if (store.StoreBEInfoList.Count > 0)
                {
                    foreach (var beInfo in store.StoreBEInfoList)
                    {
                        switch (beInfo.BETypeName)
                        {
                        case "Remote Kiosk":
                            remoteBeList.Add(beInfo);
                            break;

                        case "Attach Kiosk":
                            attachedBeList.Add(beInfo);
                            break;

                        case "MDS":
                            mds = beInfo;
                            break;

                        case "McCafe":
                            mcCafe = beInfo;
                            break;

                        case "24 Hour":
                            hour24 = beInfo;
                            break;
                        }
                    }
                }
                inputInfo.RemoteKiosk1_Status   = "No";
                inputInfo.RemoteKiosk2_Status   = "No";
                inputInfo.RemoteKiosk3_Status   = "No";
                inputInfo.AttachedKiosk1_Status = "No";
                inputInfo.AttachedKiosk2_Status = "No";
                inputInfo.AttachedKiosk3_Status = "No";
                inputInfo.MDS_Status            = "No";
                inputInfo.McCafe_Status         = "No";
                inputInfo.TwentyFourHour_Status = "No";

                if (remoteBeList.Count > 0)
                {
                    inputInfo.RemoteKiosk1_Status   = "Yes";
                    inputInfo.RemoteKiosk1_OpenDate = remoteBeList[0].LaunchDate;
                    if (remoteBeList.Count > 1)
                    {
                        inputInfo.RemoteKiosk2_Status   = "Yes";
                        inputInfo.RemoteKiosk2_OpenDate = remoteBeList[1].LaunchDate;

                        if (remoteBeList.Count > 2)
                        {
                            inputInfo.RemoteKiosk3_Status   = "Yes";
                            inputInfo.RemoteKiosk3_OpenDate = remoteBeList[2].LaunchDate;
                        }
                    }
                }

                if (attachedBeList.Count > 0)
                {
                    inputInfo.AttachedKiosk1_Status   = "Yes";
                    inputInfo.AttachedKiosk1_OpenDate = attachedBeList[0].LaunchDate;
                    if (attachedBeList.Count > 1)
                    {
                        inputInfo.AttachedKiosk2_Status   = "Yes";
                        inputInfo.AttachedKiosk2_OpenDate = attachedBeList[1].LaunchDate;

                        if (attachedBeList.Count > 2)
                        {
                            inputInfo.AttachedKiosk3_Status   = "Yes";
                            inputInfo.AttachedKiosk3_OpenDate = attachedBeList[2].LaunchDate;
                        }
                    }
                }
                if (mds != null)
                {
                    inputInfo.MDS_Status   = "Yes";
                    inputInfo.MDS_OpenDate = mds.LaunchDate;
                }
                if (mcCafe != null)
                {
                    inputInfo.McCafe_Status   = "Yes";
                    inputInfo.McCafe_OpenDate = mcCafe.LaunchDate;
                }
                if (hour24 != null)
                {
                    inputInfo.TwentyFourHour_Status   = "Yes";
                    inputInfo.TwentyFourHour_OpenDate = hour24.LaunchDate;
                }


                var woEntity = ClosureWOCheckList.Get(closure.ProjectId);
                if (woEntity != null)
                {
                    if (woEntity.LHI_NBV != null)
                    {
                        inputInfo.LHI_NBV = string.Format("{0:f}", woEntity.LHI_NBV);
                    }
                    if (woEntity.ESSD_NBV != null)
                    {
                        inputInfo.ESSD_NBV = string.Format("{0:f}", woEntity.ESSD_NBV);
                    }
                    if (woEntity.TotalCost_NBV != null)
                    {
                        inputInfo.TotalCost_NBV = string.Format("{0:f}", woEntity.TotalCost_NBV);
                    }
                }
            }

            excelPMTDirector.Input(inputInfo);

            Attachment att = Attachment.GetAttachment("ClosureExecutiveSummary", entity.Id.ToString(), "Template");

            if (att == null)
            {
                att = new Attachment();
                att.RefTableName    = "ClosureExecutiveSummary";
                att.RefTableID      = entity.Id.ToString();
                att.CreateTime      = DateTime.Now;
                att.ID              = Guid.NewGuid();
                att.TypeCode        = "Template";
                att.CreatorID       = ClientCookie.UserCode;
                att.CreatorNameENUS = ClientCookie.UserNameENUS;
                att.CreatorNameZHCN = ClientCookie.UserNameZHCN;
                att.Name            = SiteFilePath.Executive_Summary_Template;
                att.InternalName    = internalFileName;
                att.Extension       = fileInfo.Extension;
                att.Length          = Convert.ToInt32(fileInfo.Length);
                att.RequirementId   = new Guid("79258ffb-c2ef-4eff-897d-ba8376c90071");
                Attachment.Add(att);
            }
            else
            {
                att.CreateTime      = DateTime.Now;
                att.CreatorID       = ClientCookie.UserCode;
                att.CreatorNameENUS = ClientCookie.UserNameENUS;
                att.CreatorNameZHCN = ClientCookie.UserNameZHCN;
                att.Name            = SiteFilePath.Executive_Summary_Template;
                att.InternalName    = internalFileName;
                att.Extension       = fileInfo.Extension;
                att.Length          = Convert.ToInt32(fileInfo.Length);
                att.RequirementId   = new Guid("79258ffb-c2ef-4eff-897d-ba8376c90071");
                Attachment.Update(att);
            }

            ProjectInfo.FinishNode(entity.ProjectId, FlowCode.Closure_ExecutiveSummary, NodeCode.Closure_ExecutiveSummary_Generate);

            return(Ok());
        }
示例#5
0
        public IHttpActionResult UploadTemplate(string projectid)
        {
            HttpRequest        request      = System.Web.HttpContext.Current.Request;
            HttpFileCollection FileCollect  = request.Files;
            string             internalName = string.Empty;

            if (FileCollect.Count > 0) //如果集合的数量大于0
            {
                ClosureWOCheckList entity = new ClosureWOCheckList();



                //用key获取单个文件对象HttpPostedFile
                HttpPostedFile fileSave      = FileCollect[0];
                string         fileName      = Path.GetFileName(fileSave.FileName);
                string         fileExtension = Path.GetExtension(fileSave.FileName);


                internalName = Guid.NewGuid() + fileExtension;
                string absolutePath = SiteFilePath.UploadFiles_DIRECTORY + "\\" + internalName;
                //通过此对象获取文件名

                fileSave.SaveAs(absolutePath);


                var woEntity = ClosureExecutiveSummary.FirstOrDefault(e => e.ProjectId == projectid && e.IsHistory == false);
                if (woEntity == null)
                {
                    woEntity                = new ClosureExecutiveSummary();
                    woEntity.ProjectId      = projectid;
                    woEntity.Id             = Guid.NewGuid();
                    woEntity.CreateTime     = DateTime.Now;
                    woEntity.CreatorAccount = ClientCookie.UserCode;

                    ClosureExecutiveSummary.Add(woEntity);
                }

                Attachment att = Attachment.GetAttachment("ClosureExecutiveSummary", woEntity.Id.ToString(), "Template");
                if (att == null)
                {
                    att = new Attachment();
                    att.RefTableName    = "ClosureExecutiveSummary";
                    att.RefTableID      = woEntity.Id.ToString();
                    att.CreateTime      = DateTime.Now;
                    att.ID              = Guid.NewGuid();
                    att.TypeCode        = "Template";
                    att.CreatorID       = ClientCookie.UserCode;
                    att.CreatorNameENUS = ClientCookie.UserNameENUS;
                    att.CreatorNameZHCN = ClientCookie.UserNameZHCN;
                    att.Name            = fileName;
                    att.InternalName    = internalName;
                    att.Name            = fileName;
                    att.Extension       = fileExtension;
                    att.Length          = FileCollect[0].ContentLength;
                    Attachment.Add(att);
                }
                else
                {
                    att.CreateTime      = DateTime.Now;
                    att.CreatorID       = ClientCookie.UserCode;
                    att.CreatorNameENUS = ClientCookie.UserNameENUS;
                    att.CreatorNameZHCN = ClientCookie.UserNameZHCN;
                    att.Name            = fileName;
                    att.InternalName    = internalName;
                    att.Extension       = fileExtension;
                    att.Length          = FileCollect[0].ContentLength;
                    Attachment.Update(att);
                }


                //var closureInfo = closureHandler.GetByProjectId(projectid);
                //Store store = new Store();
                //var storeInfo = store.GetStoreEntity(closureInfo.USCode);

                //string filePath = SiteFilePath.UploadFiles_DIRECTORY + "\\" + internalName;
                //Excel excel = new Excel();
                //excel.Open(filePath);
                //var sheet = excel.Sheets["PMT"];

                //sheet.Cells[1, 1].StrValue = closureInfo.StoreNameZHCN;
                //sheet.Cells[2, 1].StrValue = closureInfo.USCode;

                //if (storeInfo != null)
                //{
                //    sheet.Cells[3, 1].StrValue = storeInfo.CityName;
                //    sheet.Cells[4, 1].StrValue = storeInfo.MarketName;
                //    if (storeInfo.OpenDate != null)
                //    {
                //        sheet.Cells[5, 1].StrValue = storeInfo.OpenDate.Value.ToString("yyyy-MM-dd");
                //    }
                //    sheet.Cells[7, 1].StrValue = storeInfo.TotalLeasedArea;
                //    sheet.Cells[8, 1].StrValue = storeInfo.TotalSeatsNo;
                //    sheet.Cells[10, 1].StrValue = storeInfo.LeasePurchaseTerm;
                //    if (storeInfo.RentCommencementDate != null)
                //    {

                //        sheet.Cells[11, 1].StrValue = storeInfo.RentCommencementDate.Value.ToString("yyyy-MM-dd");
                //    }
                //    if (storeInfo.EndDate != null)
                //    {
                //        sheet.Cells[12, 1].StrValue = storeInfo.EndDate.Value.ToString("yyyy-MM-dd");
                //    }
                //    sheet.Cells[13, 1].StrValue = storeInfo.RentType;
                //    sheet.Cells[13, 1].StrValue = storeInfo.RentStructure;
                //}

                //excel.Save();
            }
            //return Ok(result);

            ProjectInfo.FinishNode(projectid, FlowCode.Closure_ExecutiveSummary,
                                   NodeCode.Finish);


            var resultStr = SiteInfo.WebUrl + "UploadFiles/" + internalName;

            return(Ok(resultStr));
        }
示例#6
0
        /// <summary>
        /// 提交Closure
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public IHttpActionResult PostClosure(ClosureInfo entity)
        {
            using (TransactionScope tranScope = new TransactionScope())
            {
                //    bll.BeginTransAction();
                //    try
                //    {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                if (entity.ClosureReasonCode != "Others")
                {
                    entity.ClosureReasonRemark = string.Empty;
                }

                if (entity.Id == new Guid())
                {
                    entity.Id = Guid.NewGuid();

                    entity.CreateDate = DateTime.Now;

                    entity.ProjectId = ProjectInfo.CreateMainProject(FlowCode.Closure, entity.USCode, NodeCode.Start, entity.CreateUserAccount);



                    ClosureInfo.Add(entity);
                }
                else
                {
                    ClosureInfo.Update(entity);
                }
                //    bll.Commit();
                //}
                //catch (Exception ex)
                //{
                //    bll.Rollback();
                //    return BadRequest(ex.Message);
                //}
                var usersList  = new List <ProjectUsers>();
                var assetActor = GetClosureUsers(ProjectUserRoleCode.AssetActor, ProjectUserRoleCode.AssetActor, ProjectUserRoleCode.AssetActor, entity.AssetActorAccount, entity.AssetActorNameENUS, entity.AssetActorNameZHCN, entity.ProjectId);
                usersList.Add(assetActor);
                var assetRep = GetClosureUsers(ProjectUserRoleCode.AssetRep, ProjectUserRoleCode.AssetRep, ProjectUserRoleCode.AssetRep, entity.AssetRepAccount, entity.AssetRepNameENUS, entity.AssetRepNameZHCN, entity.ProjectId);
                usersList.Add(assetRep);
                var finance = GetClosureUsers(ProjectUserRoleCode.Finance, ProjectUserRoleCode.Finance, ProjectUserRoleCode.Finance, entity.FinanceAccount, entity.FinanceNameENUS, entity.FinanceNameZHCN, entity.ProjectId);
                usersList.Add(finance);
                var Legal = GetClosureUsers(ProjectUserRoleCode.Legal, ProjectUserRoleCode.Legal, ProjectUserRoleCode.Legal, entity.LegalAccount, entity.LegalNameENUS, entity.LegalNameZHCN, entity.ProjectId);
                usersList.Add(Legal);
                var PM = GetClosureUsers(ProjectUserRoleCode.PM, ProjectUserRoleCode.PM, ProjectUserRoleCode.PM, entity.PMAccount, entity.PMNameZHCN, entity.PMNameENUS, entity.ProjectId);
                usersList.Add(PM);
                var assertMgr = GetClosureUsers(ProjectUserRoleCode.AssetManager, ProjectUserRoleCode.AssetManager, ProjectUserRoleCode.AssetManager, entity.AssetManagerAccount, entity.AssetManagerNameENUS,
                                                entity.AssetManagerNameZHCN, entity.ProjectId);
                usersList.Add(assertMgr);

                var cm = GetClosureUsers(ProjectUserRoleCode.CM, ProjectUserRoleCode.CM, ProjectUserRoleCode.CM, entity.CMAccount, entity.CMNameENUS,
                                         entity.CMNameZHCN, entity.ProjectId);
                usersList.Add(cm);
                if (entity.NecessaryNoticeUserList != null && entity.NecessaryNoticeUserList.Count > 0)
                {
                    usersList.AddRange(entity.NecessaryNoticeUserList.Select(
                                           user => GetClosureUsers(ProjectUserRoleCode.View, ProjectUserRoleCode.View, ProjectUserRoleCode.View, user.Code, user.NameENUS, user.NameZHCN,
                                                                   entity.ProjectId)));
                }
                if (entity.NoticeUserList != null && entity.NoticeUserList.Count > 0)
                {
                    usersList.AddRange(entity.NoticeUserList.Select(
                                           user => GetClosureUsers(ProjectUserRoleCode.View, ProjectUserRoleCode.View, ProjectUserRoleCode.View, user.Code, user.NameENUS, user.NameZHCN,
                                                                   entity.ProjectId)));
                }

                ProjectUsers.Add(usersList.ToArray());
                SendRemind(entity);
                SendWorkTaskAndEmail(entity);

                //初始化项目信息

                ProjectInfo.CreateSubProject(FlowCode.Closure_WOCheckList, entity.ProjectId, entity.USCode, NodeCode.Start, PM.UserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Closure_LegalReview, entity.ProjectId, entity.USCode, NodeCode.Start, assetActor.UserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Closure_ClosureTool, entity.ProjectId, entity.USCode, NodeCode.Start, finance.UserAccount);

                var store = StoreBasicInfo.GetStorInfo(entity.USCode);

                var closureTool = new ClosureTool();
                closureTool.Id                   = Guid.NewGuid();
                closureTool.ProjectId            = entity.ProjectId;
                closureTool.IsHistory            = false;
                closureTool.IsOptionOffered      = entity.IsRelocation();
                closureTool.PipelineName         = store.PipelineNameENUS;
                closureTool.RelocationPipelineID = store.PipelineID;
                closureTool.Add();

                var woCheckList = new ClosureWOCheckList
                {
                    Id                = Guid.NewGuid(),
                    ProjectId         = entity.ProjectId,
                    CreateTime        = DateTime.Now,
                    CreateUserAccount = ClientCookie.UserCode,
                    CreateUserName    = ClientCookie.UserNameENUS,
                    IsHistory         = false
                };
                woCheckList.Add();

                var legalReview = new ClosureLegalReview
                {
                    Id                = Guid.NewGuid(),
                    ProjectId         = entity.ProjectId,
                    CreateTime        = DateTime.Now,
                    CreateUserAccount = ClientCookie.UserCode,
                    CreateUserName    = ClientCookie.UserNameENUS,
                    IsHistory         = false
                };
                legalReview.Add();

                var executiveSummary = new ClosureExecutiveSummary
                {
                    Id             = Guid.NewGuid(),
                    ProjectId      = entity.ProjectId,
                    CreateTime     = DateTime.Now,
                    CreatorAccount = ClientCookie.UserCode,
                    CreatorName    = ClientCookie.UserNameENUS,
                    IsHistory      = false
                };
                executiveSummary.Add();

                //var package = new ClosurePackage
                //{
                //    Id = Guid.NewGuid(),
                //    ProjectId = entity.ProjectId,
                //    CreateTime = DateTime.Now,
                //    CreateUserAccount = ClientCookie.UserCode,
                //    IsHistory = false
                //};
                //package.Add();

                var projectContractInfo = ProjectContractInfo.GetContractWithHistory(entity.ProjectId).Current;
                projectContractInfo.Add();

                ProjectInfo.CreateSubProject(FlowCode.Closure_ExecutiveSummary, entity.ProjectId, entity.USCode, NodeCode.Start, assetActor.UserAccount);

                ProjectInfo.CreateSubProject(FlowCode.Closure_ClosurePackage, entity.ProjectId, entity.USCode, NodeCode.Start, assetActor.UserAccount);

                ProjectInfo.CreateSubProject(FlowCode.Closure_ConsInvtChecking, entity.ProjectId, entity.USCode, NodeCode.Start, entity.PMAccount);


                ProjectInfo.CreateSubProject(FlowCode.Closure_ContractInfo, entity.ProjectId, entity.USCode,
                                             NodeCode.Start, entity.CreateUserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Closure_Memo, entity.ProjectId, entity.USCode,
                                             NodeCode.Start, entity.CreateUserAccount);
                ProjectNode.GenerateOnCreate(FlowCode.Closure, entity.ProjectId);
                try
                {
                    //bllActionLog.Add(new ActionLog
                    //{
                    //    Id = Guid.NewGuid(),
                    //    ProjectId = entity.ProjectId,
                    //    Action = ActionType.Submit,
                    //    CreateTime = DateTime.Now,
                    //    Operator = entity.CreateUserAccount,
                    //    OperatorENUS = entity.CreateUserNameENUS,
                    //    OperatorZHCN = entity.CreateUserNameZHCN,
                    //    Remark = "",
                    //    OperatorTitle = "创建流程"
                    //});
                    tranScope.Complete();
                    //bll.GetDb().SaveChanges();
                }
                catch (DbEntityValidationException dbEx)
                {
                    tranScope.Dispose();
                }


                return(Ok(entity));
            }
        }