public IHttpActionResult GetCreateFlowInfo(string projectId, string flowCode)
        {
            Object entity = null;

            if (flowCode.ToLower() == "rebuild")
            {
                entity = new RebuildInfo().GetRebuildInfo(projectId);
            }
            else if (flowCode.ToLower() == "reimage")
            {
                entity = ReimageInfo.GetReimageInfo(projectId);
            }
            else if (flowCode.ToLower() == "renewal")
            {
                entity = RenewalInfo.Get(projectId);
            }
            else if (flowCode.ToLower() == "tempclosure")
            {
                entity = TempClosureInfo.Get(projectId);
            }
            else if (flowCode.ToLower() == "closure")
            {
                entity = ClosureInfo.GetByProjectId(projectId);
            }
            else if (flowCode.ToLower() == "majorlease")
            {
                entity = new MajorLeaseInfo().GetMajorLeaseInfo(projectId);
            }
            return(Ok(entity));
        }
        public void FinishTest1()
        {
            var reimageInfo = ReimageInfo.FirstOrDefault(e => e.ProjectId == "Reimage15012901");

            if (reimageInfo != null)
            {
                reimageInfo.GenerateTaskWork(
                    FlowCode.Reimage_Summary,
                    FlowCode.Reimage_Summary,
                    FlowCode.Reimage_Summary,
                    string.Format(@"/Reimage/Main#/Summary?projectId={0}", "Reimage15012901"));
            }
        }
Exemple #3
0
        public IHttpActionResult GetReimageInfo(string projectId)
        {
            var reimageInfo = ReimageInfo.FirstOrDefault(e => e.ProjectId.Equals(projectId));

            if (reimageInfo != null)
            {
                reimageInfo.IsSiteInfoSaveable = ProjectInfo.IsFlowSavable(projectId, FlowCode.Reimage_SiteInfo);

                var siteInfo = ProjectInfo.FirstOrDefault(e => e.ProjectId.Equals(projectId) &&
                                                          e.FlowCode == FlowCode.Reimage_SiteInfo);

                if (siteInfo != null)
                {
                    reimageInfo.SiteInfoId = siteInfo.Id;

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

                    if (estimatedVsActualConstruction == null)
                    {
                        var consInfo      = ReimageConsInfo.GetConsInfo(projectId);
                        var reinBasicInfo = consInfo.ReinBasicInfo;
                        var gbMemo        = ReimageGBMemo.GetGBMemo(projectId);
                        var storeInfo     = StoreSTLocation.FirstOrDefault(e => e.StoreCode == siteInfo.USCode);

                        var summary = ReimageSummary.GetReimageSummaryInfo(projectId);
                        var afterReimagePriceTier = summary.FinancialPreanalysis != null
                            ? summary.FinancialPreanalysis.PriceTierafterReimage
                            : null;


                        estimatedVsActualConstruction = new EstimatedVsActualConstruction
                        {
                            RefId                 = siteInfo.Id,
                            GBDate                = gbMemo.GBDate,
                            CompletionDate        = gbMemo.ConstCompletionDate,
                            ARDC                  = reinBasicInfo.NewDesignType,
                            OriginalOperationSize = storeInfo.TotalArea,
                            OriginalSeatNumber    = storeInfo.TotalSeatsNo,
                            ARPT                  = afterReimagePriceTier
                        };
                    }

                    reimageInfo.EstimatedVsActualConstruction = estimatedVsActualConstruction;
                }
            }

            return(Ok(reimageInfo));
        }
        public ActionResult StoreProjectRowsCount(string _USCode)
        {
            var resultData = new
            {
                ClosureRowsCount     = ClosureInfo.Search(o => o.USCode == _USCode).ToList <ClosureInfo>().Count,
                RenewalRowsCount     = RenewalInfo.Search(o => o.USCode == _USCode).ToList <RenewalInfo>().Count,
                RebuildRowsCount     = RebuildInfo.Search(o => o.USCode == _USCode).ToList <RebuildInfo>().Count,
                MajorLeaseRowsCount  = MajorLeaseInfo.Search(o => o.USCode == _USCode).ToList <MajorLeaseInfo>().Count,
                ReimageRowsCount     = ReimageInfo.Search(o => o.USCode == _USCode).ToList <ReimageInfo>().Count,
                TempClosureRowsCount = TempClosureInfo.Search(o => o.USCode == _USCode).ToList <TempClosureInfo>().Count
            };

            string result = Newtonsoft.Json.JsonConvert.SerializeObject(resultData);

            return(Content(result));
        }
Exemple #5
0
        public IHttpActionResult CreateProject(ReimageInfo entity)
        {
            using (var tran = new TransactionScope())
            {
                entity.Id         = Guid.NewGuid();
                entity.ProjectId  = ProjectInfo.CreateMainProject(FlowCode.Reimage, entity.USCode, NodeCode.Start, entity.CreateUserAccount);
                entity.CreateDate = DateTime.Now;
                entity.Add();
                entity.AddProjectUsers();
                entity.SendRemind();
                entity.SendWorkTask();
                entity.CreateSubProject();
                entity.CreateAttachmentsMemo();
                ProjectNode.GenerateOnCreate(FlowCode.Reimage, entity.ProjectId);
                tran.Complete();
            }

            return(Ok(entity));
        }
Exemple #6
0
        public IHttpActionResult GetSelectYearMonth(string projectId)
        {
            using (var amdb = new McdAMEntities())
            {
                var selectItemList = new List <SelectItem>();
                var uscode         = ReimageInfo.FirstOrDefault(e => e.ProjectId == projectId).USCode;

                var reimageSummary = ReimageSummary.GetReimageSummaryInfo(projectId);
                if (reimageSummary != null)
                {
                    var refId = reimageSummary.Id;
                    var storeProfitabilityAndLeaseInfo =
                        StoreProfitabilityAndLeaseInfo.FirstOrDefault(e => e.RefId == refId);

                    var asOf            = storeProfitabilityAndLeaseInfo != null ? storeProfitabilityAndLeaseInfo.AsOf : string.Empty;
                    var yearMonthList   = amdb.DataSync_LDW_AM_STFinanceData2.Where(f => f.UsCode == uscode).Select(i => new { financeYearMonth = i.FinanceYear + "-" + i.FinanceMonth }).Distinct().OrderByDescending(i => i.financeYearMonth).Take(12).ToList();
                    var ldw_financeData = LDW_FinanceData.Get(projectId);
                    foreach (var _yearMonth in yearMonthList)
                    {
                        var selectItem = new SelectItem();
                        selectItem.name  = _yearMonth.financeYearMonth;
                        selectItem.value = _yearMonth.financeYearMonth;
                        if (ldw_financeData != null)
                        {
                            selectItem.selected = _yearMonth.financeYearMonth == ldw_financeData.FinanceYear + "-" + ldw_financeData.FinanceMonth;
                        }
                        else
                        {
                            // selectItem.selected = false;
                            selectItem.selected = _yearMonth.financeYearMonth == asOf;
                        }
                        selectItemList.Add(selectItem);
                    }
                    if (string.IsNullOrEmpty(asOf) && selectItemList.Count > 0)
                    {
                        selectItemList[0].selected = true;
                    }
                }

                return(Ok(new { data = selectItemList }));
            }
        }
Exemple #7
0
        public IHttpActionResult GetEstimatedVsActualConstruction(string projectId, Guid identifier)
        {
            var reimageInfo = ReimageInfo.FirstOrDefault(e => e.ProjectId.Equals(projectId));

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

            if (estimatedVsActualConstruction == null)
            {
                var reimageConsInfo = ReimageConsInfo.GetConsInfo(projectId);
                var storeInfo       = StoreSTLocation.FirstOrDefault(e => e.StoreCode == reimageInfo.USCode);
                estimatedVsActualConstruction = new EstimatedVsActualConstruction
                {
                    GBDate                = reimageConsInfo.ReinBasicInfo != null ? reimageConsInfo.ReinBasicInfo.GBDate : null,
                    CompletionDate        = reimageConsInfo.ReinBasicInfo != null ? reimageConsInfo.ReinBasicInfo.ConsCompletionDate : null,
                    ARDC                  = reimageConsInfo.ReinBasicInfo != null ? reimageConsInfo.ReinBasicInfo.NewDesignType : null,
                    OriginalOperationSize = storeInfo.TotalArea,
                    OriginalSeatNumber    = storeInfo.TotalSeatsNo
                };
            }

            return(Ok(estimatedVsActualConstruction));
        }
        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;
            }
        }
Exemple #9
0
        public IHttpActionResult GetStoreProfitabilityAndLeaseInfo(string projectId, string pageType = "")
        {
            StoreProfitabilityAndLeaseInfo store = new StoreProfitabilityAndLeaseInfo();
            var reimageSummary = ReimageSummary.FirstOrDefault(e => e.ProjectId == projectId && e.IsHistory == false);

            if (reimageSummary != null)
            {
                store =
                    StoreProfitabilityAndLeaseInfo.FirstOrDefault(e => e.RefId == reimageSummary.Id);
            }
            if (store != null)
            {
                if (store.Id != 0)
                {
                    pageType = "save";
                }
            }
            if (pageType == "")
            {
                //var resultStoreAllInfo = storeBll.GetStoreDetailsByEID(eid, usCode);

                var reimageInfo       = ReimageInfo.FirstOrDefault(e => e.ProjectId == projectId);
                var storeBasicInfo    = StoreBasicInfo.FirstOrDefault(e => e.StoreCode == reimageInfo.USCode);
                var storeContractInfo = StoreContractInfo.FirstOrDefault(e => e.StoreCode == reimageInfo.USCode);
                int Year = 0;
                if (storeContractInfo != null)
                {
                    if (storeContractInfo.EndDate != null)
                    {
                        DateTime dtNow = DateTime.Now;
                        Year = int.Parse(storeContractInfo.EndDate.ToString().Split('/')[2].Substring(0, 4)) - dtNow.Year;
                    }
                }
                //var stFinanceData =
                //   Mcdonalds.AM.DataAccess.DataSync_LDW_AM_STFinanceData.OrderByDescending(e => e.FinanceYear == DateTime.Now.Year.ToString(),
                //       e => e.FinanceMonth).FirstOrDefault();
                //if (stFinanceData == null)
                //{
                //    throw new Exception("Could not get the latest finance month data!");
                //}
                //var latestMonth = stFinanceData.FinanceMonth;
                //var data = Mcdonalds.AM.DataAccess.DataSync_LDW_AM_STFinanceData.FirstOrDefault(e => e.FinanceYear == DateTime.Now.Year.ToString() && e.FinanceMonth == latestMonth && e.UsCode == stFinanceData.UsCode);

                //store.AsOf =DateTime.Parse(DateTime.Now.Year + "/" + latestMonth + "/01");
                //store.TTMSales = data.Total_Sales_TTM.As<decimal>();
                //store.TTMSOIPercent = data.SOIPct_TTM.As<decimal>();
                if (store == null)
                {
                    store = new StoreProfitabilityAndLeaseInfo();
                }
                DateTime?dt = storeBasicInfo.ReImageDate;
                if (dt != null)
                {
                    if (dt.ToString().Substring(0, 8) == "1/1/1900")
                    {
                        dt = null;
                    }
                }
                store.LastRemodelDate     = dt;
                store.RemainingLeaseYears = Year;
            }
            return(Ok(store));
        }
Exemple #10
0
        public IHttpActionResult UploadAttachment(string flowCode, string typeCode, string usCode, Guid Id)
        {
            var refTableId   = string.Empty;
            var refTableName = string.Empty;
            var projectInfo  = ProjectInfo.Get(Id);
            var projectId    = string.Empty;

            if (projectInfo == null)
            {
                projectId = ProjectInfo.CreateDLProject(Id, flowCode, usCode, NodeCode.Start, ClientCookie.UserCode, false);
            }
            else
            {
                projectId = projectInfo.ProjectId;
            }
            using (TransactionScope tranScope = new TransactionScope())
            {
                switch (flowCode)
                {
                case FlowCode.Closure:
                    refTableName = "ClosureInfo";
                    var closureInfo = ClosureInfo.FirstOrDefault(i => i.ProjectId == projectId);
                    if (closureInfo != null)
                    {
                        refTableId = closureInfo.Id.ToString();
                    }
                    else
                    {
                        closureInfo                    = new ClosureInfo();
                        closureInfo.Id                 = Guid.NewGuid();
                        closureInfo.ProjectId          = projectId;
                        closureInfo.USCode             = usCode;
                        closureInfo.CreateDate         = DateTime.Now;
                        closureInfo.CreateUserAccount  = ClientCookie.UserCode;
                        closureInfo.CreateUserNameENUS = ClientCookie.UserNameENUS;
                        closureInfo.CreateUserNameZHCN = ClientCookie.UserNameZHCN;
                        closureInfo.Add();
                        refTableId = closureInfo.Id.ToString();
                    }
                    break;

                case FlowCode.Rebuild:
                    refTableName = "RebuildInfo";
                    var rebuildInfo = RebuildInfo.FirstOrDefault(i => i.ProjectId == projectId);
                    if (rebuildInfo != null)
                    {
                        refTableId = rebuildInfo.Id.ToString();
                    }
                    else
                    {
                        rebuildInfo                    = new RebuildInfo();
                        rebuildInfo.Id                 = Guid.NewGuid();
                        rebuildInfo.ProjectId          = projectId;
                        rebuildInfo.USCode             = usCode;
                        rebuildInfo.CreateTime         = DateTime.Now;
                        rebuildInfo.CreateUserAccount  = ClientCookie.UserCode;
                        rebuildInfo.CreateUserNameENUS = ClientCookie.UserNameENUS;
                        rebuildInfo.CreateUserNameZHCN = ClientCookie.UserNameZHCN;
                        rebuildInfo.Add();
                        refTableId = rebuildInfo.Id.ToString();
                    }
                    break;

                case FlowCode.MajorLease:
                    refTableName = "MajorLeaseInfo";
                    var majorLeaseInfo = MajorLeaseInfo.FirstOrDefault(i => i.ProjectId == projectId);
                    if (majorLeaseInfo != null)
                    {
                        refTableId = majorLeaseInfo.Id.ToString();
                    }
                    else
                    {
                        majorLeaseInfo                    = new MajorLeaseInfo();
                        majorLeaseInfo.Id                 = Guid.NewGuid();
                        majorLeaseInfo.ProjectId          = projectId;
                        majorLeaseInfo.USCode             = usCode;
                        majorLeaseInfo.CreateTime         = DateTime.Now;
                        majorLeaseInfo.CreateUserAccount  = ClientCookie.UserCode;
                        majorLeaseInfo.CreateUserNameENUS = ClientCookie.UserNameENUS;
                        majorLeaseInfo.CreateUserNameZHCN = ClientCookie.UserNameZHCN;
                        majorLeaseInfo.Add();
                        refTableId = majorLeaseInfo.Id.ToString();
                    }
                    break;

                case FlowCode.Renewal:
                    refTableName = "RenewalInfo";
                    var renewalInfo = RenewalInfo.Get(projectId);
                    if (renewalInfo != null)
                    {
                        refTableId = renewalInfo.Id.ToString();
                    }
                    else
                    {
                        renewalInfo                   = new RenewalInfo();
                        renewalInfo.Id                = Guid.NewGuid();
                        renewalInfo.ProjectId         = projectId;
                        renewalInfo.USCode            = usCode;
                        renewalInfo.CreateTime        = DateTime.Now;
                        renewalInfo.CreateUserAccount = ClientCookie.UserCode;
                        renewalInfo.Add();
                        refTableId = renewalInfo.Id.ToString();
                    }
                    break;

                case FlowCode.Reimage:
                    refTableName = "ReimageInfo";
                    var reimageInfo = ReimageInfo.GetReimageInfo(projectId);
                    if (reimageInfo != null)
                    {
                        refTableId = reimageInfo.Id.ToString();
                    }
                    else
                    {
                        reimageInfo                    = new ReimageInfo();
                        reimageInfo.Id                 = Guid.NewGuid();
                        reimageInfo.ProjectId          = projectId;
                        reimageInfo.USCode             = usCode;
                        reimageInfo.CreateDate         = DateTime.Now;
                        reimageInfo.CreateUserAccount  = ClientCookie.UserCode;
                        reimageInfo.CreateUserNameENUS = ClientCookie.UserNameENUS;
                        reimageInfo.CreateUserNameZHCN = ClientCookie.UserNameZHCN;
                        reimageInfo.Add();
                        refTableId = reimageInfo.Id.ToString();
                    }
                    break;
                }

                if (!string.IsNullOrEmpty(refTableId))
                {
                    var    files         = HttpContext.Current.Request.Files;
                    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.FirstOrDefault(i => i.RefTableID == refTableId && i.RefTableName == refTableName && i.TypeCode == typeCode);
                    if (att != null)
                    {
                        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);
                    }
                    else
                    {
                        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.TypeCode = typeCode;
                        Attachment.Add(att);
                    }
                }
                tranScope.Complete();
                return(Ok());
            }
        }
Exemple #11
0
 public IHttpActionResult UpdateReimageInfo(ReimageInfo entity)
 {
     entity.Update();
     return(Ok());
 }
Exemple #12
0
        public IHttpActionResult GetReimageApprovers(string flowCode, string projectId = "")
        {
            if (string.IsNullOrEmpty(flowCode))
            {
                throw new Exception("flowCode is NULL");
            }

            ReimageInfo reimageInfo = null;

            if (!string.IsNullOrEmpty(projectId))
            {
                reimageInfo = ReimageInfo.Search(e => e.ProjectId.Equals(projectId)).FirstOrDefault();
            }
            if (reimageInfo == null)
            {
                throw new Exception("Could not find the Reimage Info, please check it!");
            }
            var dicUsers = new Dictionary <string, List <SimpleEmployee> >();

            switch (flowCode)
            {
            case FlowCode.Reimage_Summary:
                dicUsers.Add("FMs", Employee.GetStoreEmployeesByRole(reimageInfo.USCode, RoleCode.Finance_Manager));
                break;

            case FlowCode.Reimage_ConsInfo:
                dicUsers.Add("ConstructionManagers", Employee.GetStoreEmployeesByRole(reimageInfo.USCode, RoleCode.Cons_Mgr));
                dicUsers.Add("MCCLConsManagers", Employee.GetStoreEmployeesByRole(reimageInfo.USCode, RoleCode.MCCL_Cons_Manager));
                break;

            case FlowCode.Reimage_Package:
                dicUsers.Add("MarketMgrs", Employee.GetStoreEmployeesByRole(reimageInfo.USCode, RoleCode.Market_Asset_Mgr));
                dicUsers.Add("RegionalMgrs", Employee.GetStoreEmployeesByRole(reimageInfo.USCode, RoleCode.Regional_Asset_Mgr));
                dicUsers.Add("MDDs", Employee.GetStoreEmployeesByRole(reimageInfo.USCode, RoleCode.Market_DD));
                dicUsers.Add("GMs", Employee.GetStoreEmployeesByRole(reimageInfo.USCode, RoleCode.GM));
                dicUsers.Add("FCs", Employee.GetStoreEmployeesByRole(reimageInfo.USCode, RoleCode.Finance_Controller));
                dicUsers.Add("DOs", Employee.GetStoreEmployeesByRole(reimageInfo.USCode, RoleCode.DO));
                dicUsers.Add("RDDs", Employee.GetStoreEmployeesByRole(reimageInfo.USCode, RoleCode.Regional_DD));
                dicUsers.Add("VPGMs", Employee.GetStoreEmployeesByRole(reimageInfo.USCode, RoleCode.VPGM));
                dicUsers.Add("CDOs", Employee.GetEmployeesByRole(RoleCode.CDO));
                dicUsers.Add("CFOs", Employee.GetEmployeesByRole(RoleCode.CFO));
                dicUsers.Add("MngDirectors", Employee.GetEmployeesByRole(RoleCode.MD));
                break;

            case FlowCode.Reimage_ConsInvtChecking:
                //dicUsers.Add("FMs", new List<SimpleEmployee>()
                //{
                //    new SimpleEmployee()
                //    {
                //        Code = reimageInfo.FinanceAccount,
                //        NameENUS = reimageInfo.FinanceNameENUS,
                //        NameZHCN = reimageInfo.FinanceNameZHCN
                //    }
                //});
                dicUsers.Add("FMs", Employee.GetStoreEmployeesByRole(reimageInfo.USCode, RoleCode.Finance_Manager));
                dicUsers.Add("ConstructionManagers", Employee.GetStoreEmployeesByRole(reimageInfo.USCode, RoleCode.Cons_Mgr));
                dicUsers.Add("FinanceControllers", Employee.GetStoreEmployeesByRole(reimageInfo.USCode, RoleCode.Finance_Controller));
                dicUsers.Add("VPGMs", Employee.GetStoreEmployeesByRole(reimageInfo.USCode, RoleCode.VPGM));
                break;

            case FlowCode.Reimage_GBMemo:
                dicUsers.Add("ConstructionManagers", Employee.GetStoreEmployeesByRole(reimageInfo.USCode, RoleCode.Cons_Mgr));
                break;
            }
            dicUsers.Add("MCCLAssetMgrs", Employee.GetStoreEmployeesByRole(reimageInfo.USCode, RoleCode.MCCL_Asset_Mgr));
            dicUsers.Add("MCCLAssetDtrs", Employee.GetStoreEmployeesByRole(reimageInfo.USCode, RoleCode.MCCL_Asset_Director));
            return(Ok(dicUsers));
        }
        public IHttpActionResult DownLoadTemplate(string templateType, string projectId, string consInfoID = "", string NormType = "", string flowCode = "")
        {
            var current = HttpContext.Current;
            ExcelDataInputType outputType;

            if (!Enum.TryParse(templateType, out outputType))
            {
                throw new Exception("Cannot find the specific template type!");
            }

            if (string.IsNullOrEmpty(projectId))
            {
                throw new Exception("Porject Id is Empty !");
            }
            var siteFilePath = default(string);

            switch (outputType)
            {
            case ExcelDataInputType.WriteOffAmount:
                siteFilePath = SiteFilePath.FAWrite_offTool_Template_X;
                break;

            case ExcelDataInputType.ReinvestmentCost:
                siteFilePath = SiteFilePath.FATool_Update_Template;
                break;

            case ExcelDataInputType.ClosureWOCheckList:
                siteFilePath = SiteFilePath.Closure_FAWrite_offTool_Template;
                break;
            }
            var path = string.Format(@"{0}\{1}", SiteFilePath.Template_DIRECTORY, siteFilePath);

            var tempFilePath = current.Server.MapPath("~/") + "Temp\\" + Guid.NewGuid() + ".xlsx";

            bool isNotUploadExcel = false;

            if (!string.IsNullOrEmpty(consInfoID))
            {
                string refTableName = "MajorLeaseConsInfo";
                if (projectId.ToLower().IndexOf("rebuild") != -1)
                {
                    refTableName = "RebuildConsInfo";
                }
                if (projectId.ToLower().IndexOf("reimage") != -1)
                {
                    refTableName = "ReimageConsInfo";
                }

                var strFileName = GetAttatchFile(refTableName, templateType, consInfoID);//download consifno upload file
                if (string.IsNullOrEmpty(strFileName))
                {
                    isNotUploadExcel = true;
                    tempFilePath     = current.Server.MapPath("~/") + "UploadFiles\\" + Guid.NewGuid() + ".xlsx";
                }
                else
                {
                    tempFilePath = current.Server.MapPath("~/") + "UploadFiles\\" + strFileName;
                }
            }

            if (isNotUploadExcel)
            {
                consInfoID = null;// if not upload file in consinfo flow,then we get empty template
            }
            var projectInfo = ProjectInfo.FirstOrDefault(e => e.ProjectId == projectId);

            if (projectInfo == null)
            {
                throw new Exception("Cannot find the project info!");
            }
            if (string.IsNullOrEmpty(consInfoID))
            {
                File.Copy(path, tempFilePath);

                var excelOutputDirector = new ExcelDataInputDirector(new FileInfo(tempFilePath), outputType);
                var store = StoreBasicInfo.Search(e => e.StoreCode == projectInfo.USCode).FirstOrDefault();
                if (store == null)
                {
                    throw new Exception("Cannot find Store info!");
                }

                var inputInfo = new ExcelInputDTO
                {
                    Region        = store.RegionENUS,
                    Market        = store.MarketENUS,
                    City          = store.CityENUS,
                    StoreNameCN   = store.NameZHCN,
                    StoreNameEN   = store.NameENUS,
                    StoreName     = store.NameZHCN,
                    USCode        = store.StoreCode,
                    StoreType     = store.StoreType,
                    StoreTypeName = store.StoreTypeName,
                    OpenDate      = store.OpenDate,
                    ClosureDate   = store.CloseDate.HasValue ? store.CloseDate.Value : default(DateTime)
                };

                switch (outputType)
                {
                case ExcelDataInputType.ReinvestmentCost:
                    Guid consInfoId = Guid.Empty;
                    if (projectId.ToLower().IndexOf("rebuild") != -1)
                    {
                        var rbdInfo = new RebuildConsInfo();
                        consInfoId = rbdInfo.GetConsInfo(projectId).Id;
                    }
                    else if (projectId.ToLower().IndexOf("majorlease") != -1)
                    {
                        var mjInfo = new MajorLeaseConsInfo();
                        consInfoId = mjInfo.GetConsInfo(projectId).Id;
                    }
                    else if (projectId.ToLower().IndexOf("reimage") != -1)
                    {
                        consInfoId = ReimageConsInfo.GetConsInfo(projectId).Id;
                    }
                    var reinvestmentBasicInfo = ReinvestmentBasicInfo.FirstOrDefault(e => e.ConsInfoID == consInfoId);
                    if (reinvestmentBasicInfo != null)
                    {
                        inputInfo.NewDesignType      = reinvestmentBasicInfo.NewDesignType;
                        inputInfo.NormType           = MappingNormType(NormType);
                        inputInfo.GBDate             = reinvestmentBasicInfo.GBDate;
                        inputInfo.ConsCompletionDate = reinvestmentBasicInfo.ConsCompletionDate;
                        inputInfo.EstimatedSeatNO    = reinvestmentBasicInfo.EstimatedSeatNo;
                        inputInfo.NewDTSiteArea      = reinvestmentBasicInfo.NewDTSiteArea;
                        inputInfo.NewOperationArea   = reinvestmentBasicInfo.NewOperationSize;
                        inputInfo.NewDiningArea      = reinvestmentBasicInfo.NewDiningArea;
                        inputInfo.WallPanelArea      = reinvestmentBasicInfo.WallPanelArea;
                        inputInfo.WallGraphicArea    = reinvestmentBasicInfo.WallGraphicArea;
                        inputInfo.FacadeACMArea      = reinvestmentBasicInfo.FacadeACMArea;
                        inputInfo.NewRemoteKiosk     = reinvestmentBasicInfo.NewRemoteKiosk;
                        inputInfo.NewAttachedKiosk   = reinvestmentBasicInfo.NewAttachedKiosk;
                        inputInfo.NewMcCafe          = reinvestmentBasicInfo.NewMcCafe;
                        inputInfo.NewMDS             = reinvestmentBasicInfo.NewMDS;
                    }

                    break;

                case ExcelDataInputType.WriteOffAmount:
                    string pmName = string.Empty;
                    if (projectId.ToLower().IndexOf("rebuild") != -1)
                    {
                        var rbdInfo = new RebuildInfo();
                        pmName = rbdInfo.GetRebuildInfo(projectId).PMNameENUS;
                    }
                    else if (projectId.ToLower().IndexOf("majorlease") != -1)
                    {
                        var mjInfo = new MajorLeaseInfo();
                        pmName = mjInfo.GetMajorLeaseInfo(projectId).PMNameENUS;
                    }
                    else if (projectId.ToLower().IndexOf("reimage") != -1)
                    {
                        pmName = ReimageInfo.GetReimageInfo(projectId).PMNameENUS;
                    }
                    inputInfo.PMNameENUS = pmName;
                    break;

                case ExcelDataInputType.ClosureWOCheckList:
                    var closure = ClosureInfo.GetByProjectId(projectId);
                    if (closure != null)
                    {
                        inputInfo.ActualCloseDate = closure.ActualCloseDate.HasValue ? closure.ActualCloseDate.Value.ToString("yyyy-MM-dd") : "";
                        inputInfo.PMNameENUS      = closure.PMNameENUS;
                    }
                    break;
                }

                excelOutputDirector.Input(inputInfo);
            }

            current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + SiteFilePath.GetTemplateFileName(projectInfo.USCode, flowCode, siteFilePath));
            current.Response.ContentType = "application/octet-stream";
            current.Response.WriteFile("" + tempFilePath + "");
            current.Response.End();

            return(Ok());
        }
Exemple #14
0
        public override void Input(ExcelWorksheet worksheet, ExcelInputDTO inputInfo)
        {
            var projectInfo = ProjectInfo.FirstOrDefault(e => e.ProjectId == inputInfo.ProjectId);

            if (projectInfo == null)
            {
                throw new Exception("Cannot find the project info!");
            }
            var store = StoreBasicInfo.Search(e => e.StoreCode == projectInfo.USCode).FirstOrDefault();

            if (store == null)
            {
                throw new Exception("Cannot find Store info!");
            }

            var reimageSummary = BaseWFEntity.GetWorkflowEntity(inputInfo.ProjectId, FlowCode.Reimage_Summary) as ReimageSummary;

            if (reimageSummary == null)
            {
                throw new Exception("Cannot find Reimage Summary Info!");
            }
            var storeSTLocation = StoreSTLocation.GetStoreSTLocation(projectInfo.USCode);
            var storeLeaseInfo  = new StoreProfitabilityAndLeaseInfo();
            var reimageConsInfo = ReimageConsInfo.GetConsInfo(inputInfo.ProjectId);
            var reinvestment    = ReinvestmentBasicInfo.FirstOrDefault(e => e.ConsInfoID == reimageConsInfo.Id);

            if (reimageSummary != null)
            {
                storeLeaseInfo =
                    StoreProfitabilityAndLeaseInfo.FirstOrDefault(e => e.RefId == reimageSummary.Id);
                if (storeLeaseInfo != null)
                {
                    if (storeLeaseInfo.LastRemodelDate.HasValue && storeLeaseInfo.LastRemodelDate.Value.ToString("yyyy-MM-dd") != "1900-01-01")
                    {
                        worksheet.Cells["B43"].Value = storeLeaseInfo.LastRemodelDate;
                    }
                    worksheet.Cells["B44"].Value = storeLeaseInfo.RemainingLeaseYears;

                    worksheet.Cells["B46"].Value = storeLeaseInfo.TTMSOIPercent / 100;
                    worksheet.Cells["B47"].Value = storeLeaseInfo.AsOf;
                    worksheet.Cells["B48"].Value = reimageSummary.OperationRequirements;
                    var financial = FinancialPreanalysis.FirstOrDefault(e => e.RefId == reimageSummary.Id);
                    worksheet.Cells["B49"].Value = TryParseDecimal(financial.TotalSalesInc);
                    worksheet.Cells["B45"].Value = financial.TTMSales;
                    worksheet.Cells["B50"].Value = TryParseDecimal(financial.StoreCM) * 100 + "%";
                    worksheet.Cells["B51"].Value = financial.CurrentPriceTier;
                    worksheet.Cells["B52"].Value = string.IsNullOrEmpty(financial.SPTAR) ? 0 : financial.SPTAR.As <decimal>();
                    worksheet.Cells["B53"].Value = financial.PriceTierafterReimage;
                }
                //worksheet.Cells["E4"].Value = financial.MarginInc;
            }
            else
            {
                var reimageInfo       = ReimageInfo.FirstOrDefault(e => e.ProjectId == inputInfo.ProjectId);
                var storeBasicInfo    = StoreBasicInfo.FirstOrDefault(e => e.StoreCode == reimageInfo.USCode);
                var storeContractInfo = StoreContractInfo.FirstOrDefault(e => e.StoreCode == reimageInfo.USCode);
                int Year = 0;
                if (storeContractInfo != null)
                {
                    if (storeContractInfo.EndDate != null)
                    {
                        DateTime dtNow = DateTime.Now;
                        Year = int.Parse(storeContractInfo.EndDate.ToString().Split('/')[2].Substring(0, 4)) - dtNow.Year;
                    }
                }

                DateTime?dt = storeBasicInfo.ReImageDate;
                if (dt != null)
                {
                    if (dt.ToString().Substring(0, 8) == "1/1/1900")
                    {
                        dt = null;
                    }
                }
                worksheet.Cells["B43"].Value = dt;
                worksheet.Cells["B44"].Value = Year;
                //storeLeaseInfo.LastRemodelDate = dt;
                //storeLeaseInfo.RemainingLeaseYears = Year;
            }
            ReinvestmentCost cost = ReinvestmentCost.FirstOrDefault(e => e.ConsInfoID == reimageConsInfo.Id);

            worksheet.Cells["B2"].Value = store.Region;
            worksheet.Cells["B3"].Value = store.StoreCode;
            if (reinvestment != null)
            {
                worksheet.Cells["B8"].Value  = TryParseDecimal(reinvestment.RightSizingSeatNo);
                worksheet.Cells["B11"].Value = TryParseDecimal(reinvestment.EstimatedSeatNo);
                worksheet.Cells["B41"].Value = reinvestment.GBDate;
                worksheet.Cells["B42"].Value = reinvestment.ConsCompletionDate;
            }
            if (cost != null)
            {
                worksheet.Cells["B13"].Value = TryParseDecimal(cost.DesignFee);
                worksheet.Cells["B14"].Value = TryParseDecimal(cost.PublicBudget);
                worksheet.Cells["B15"].Value = TryParseDecimal(cost.BuildingFacade);
                worksheet.Cells["B16"].Value = TryParseDecimal(cost.SiteBudget);
                worksheet.Cells["B17"].Value = TryParseDecimal(cost.BuildingWork);
                worksheet.Cells["B18"].Value = TryParseDecimal(cost.PlumbingSystem);
                worksheet.Cells["B19"].Value = TryParseDecimal(cost.ElectricalSystem);
                worksheet.Cells["B20"].Value = TryParseDecimal(cost.HVACDuctSystem);
                worksheet.Cells["B21"].Value = TryParseDecimal(cost.Signage);
                worksheet.Cells["B22"].Value = TryParseDecimal(cost.Seating);
                worksheet.Cells["B23"].Value = TryParseDecimal(cost.Decor);
                worksheet.Cells["B24"].Value = TryParseDecimal(cost.Kiosk);
                worksheet.Cells["B25"].Value = TryParseDecimal(cost.McCafe);
                worksheet.Cells["B26"].Value = TryParseDecimal(cost.MDS);
                worksheet.Cells["B27"].Value = TryParseDecimal(cost.Playland);
                worksheet.Cells["B28"].Value = TryParseDecimal(cost.KitchenCapacityUpgrade);
                worksheet.Cells["B29"].Value = TryParseDecimal(cost.BuildingWorks);
                worksheet.Cells["B30"].Value = TryParseDecimal(cost.KitchenEquipment);
                worksheet.Cells["B31"].Value = TryParseDecimal(cost.HVAC);
                worksheet.Cells["B32"].Value = TryParseDecimal(cost.Plumbing);
                worksheet.Cells["B33"].Value = TryParseDecimal(cost.ElectricDistribution);
                worksheet.Cells["B34"].Value = TryParseDecimal(cost.Structure);
                worksheet.Cells["B35"].Value = TryParseDecimal(cost.Others);
                worksheet.Cells["B36"].Value = TryParseDecimal(cost.LHIPMAct);
                worksheet.Cells["B37"].Value = TryParseDecimal(cost.SignagePMAct);
                worksheet.Cells["B38"].Value = TryParseDecimal(cost.EquipmentPMAct);
                worksheet.Cells["B39"].Value = TryParseDecimal(cost.SeatingPackagePMAct);
                worksheet.Cells["B40"].Value = TryParseDecimal(cost.DecorPMAct);
            }
            worksheet.Cells["B5"].Value = storeSTLocation.TotalArea.As <decimal>();
            worksheet.Cells["B6"].Value = store.ProvinceZHCN;
            worksheet.Cells["B7"].Value = store.NameZHCN;

            worksheet.Cells["B4"].Value  = TryParseDecimal(storeSTLocation.TotalSeatsNo);
            worksheet.Cells["B9"].Value  = TryParseDecimal(storeSTLocation.KitchenArea);
            worksheet.Cells["B10"].Value = store.CityZHCN;

            if (!string.IsNullOrEmpty(storeSTLocation.DesignStyle))
            {
                var dict = Dictionary.FirstOrDefault(i => i.Code == storeSTLocation.DesignStyle);
                if (dict != null)
                {
                    worksheet.Cells["B12"].Value = dict.NameZHCN;
                }
                else
                {
                    worksheet.Cells["B12"].Value = storeSTLocation.DesignStyle;
                }
            }
            //worksheet.Cells["B24"].Value = reimageSummary.ReinvestmentBasicInfo.NewKiosk;
            //worksheet.Cells["B25"].Value = reimageSummary.ReinvestmentBasicInfo.NewMcCafe;
            //worksheet.Cells["B26"].Value = reimageSummary.ReinvestmentBasicInfo.NewMDS;
            //worksheet.Cells["B41"].Value = reimageSummary.ReinvestmentBasicInfo.GBDate;
            //worksheet.Cells["B42"].Value = reimageSummary.ReinvestmentBasicInfo.ConsCompletionDate;


            worksheet.Cells["B10"].Value = store.CityZHCN;
            //worksheet.Cells["B11"].Value = inputInfo.StoreType;
            //worksheet.Cells["B12"].Value = inputInfo.StoreType;
            //worksheet.Cells["B13"].Value = inputInfo.StoreType;
            //worksheet.Cells["B14"].Value = inputInfo.StoreType;
            //worksheet.Cells["B15"].Value = inputInfo.StoreType;
            //worksheet.Cells["B16"].Value = inputInfo.StoreType;
            //worksheet.Cells["B17"].Value = inputInfo.StoreType;
            //worksheet.Cells["B18"].Value = inputInfo.StoreType;
            //worksheet.Cells["B19"].Value = inputInfo.StoreType;
            //worksheet.Cells["B20"].Value = inputInfo.StoreType;
            //worksheet.Cells["B21"].Value = inputInfo.StoreType;
            //worksheet.Cells["B22"].Value = inputInfo.StoreType;
            //worksheet.Cells["B23"].Value = inputInfo.StoreType;

            //worksheet.Cells["B27"].Value = inputInfo.StoreType;
            //worksheet.Cells["B28"].Value = inputInfo.StoreType;
            //worksheet.Cells["B29"].Value = inputInfo.StoreType;
            //worksheet.Cells["B30"].Value = inputInfo.StoreType;
            //worksheet.Cells["B31"].Value = inputInfo.StoreType;
            //worksheet.Cells["B32"].Value = inputInfo.StoreType;
            //worksheet.Cells["B33"].Value = inputInfo.StoreType;
            //worksheet.Cells["B34"].Value = inputInfo.StoreType;
            //worksheet.Cells["B35"].Value = inputInfo.StoreType;
            //worksheet.Cells["B36"].Value = inputInfo.StoreType;
            //worksheet.Cells["B37"].Value = inputInfo.StoreType;
            //worksheet.Cells["B38"].Value = inputInfo.StoreType;
            //worksheet.Cells["B39"].Value = inputInfo.StoreType;
            //worksheet.Cells["B40"].Value = inputInfo.StoreType;

            //if (reimageSummary.StoreProfitabilityAndLeaseInfo != null)
            //{
            //    worksheet.Cells["B43"].Value = reimageSummary.StoreProfitabilityAndLeaseInfo.LastRemodelDate;
            //    worksheet.Cells["B44"].Value = reimageSummary.StoreProfitabilityAndLeaseInfo.RemainingLeaseYears;
            //    worksheet.Cells["B45"].Value = reimageSummary.StoreProfitabilityAndLeaseInfo.TTMSales;
            //    worksheet.Cells["B46"].Value = reimageSummary.StoreProfitabilityAndLeaseInfo.TTMSOIPercent;
            //    worksheet.Cells["B47"].Value = reimageSummary.StoreProfitabilityAndLeaseInfo.AsOf;
            //}

            ////worksheet.Cells["B48"].Value = reimageSummary.OperationRequirements;
            //if (reimageSummary.FinancialPreanalysis != null)
            //{
            //    worksheet.Cells["B49"].Value = reimageSummary.FinancialPreanalysis.TotalSalesInc;
            //    worksheet.Cells["B50"].Value = reimageSummary.FinancialPreanalysis.StoreCM;
            //    worksheet.Cells["B51"].Value = reimageSummary.FinancialPreanalysis.CurrentPriceTier;
            //    worksheet.Cells["B52"].Value = reimageSummary.FinancialPreanalysis.ISDWIP;
            //    worksheet.Cells["B53"].Value = reimageSummary.FinancialPreanalysis.SPTAR;

            //}
        }
        private string GenPrintReimageAttachment(ReimageInfo reimageInfo, ReimagePackage entity, PrintFileType fileType)
        {
            var            storeInfo = StoreBasicInfo.GetStore(reimageInfo.USCode);
            StoreBasicInfo store     = storeInfo.StoreBasicInfo;

            //生成Print文件
            var printDic = new Dictionary <string, string>();

            printDic.Add("WorkflowName", FlowCode.Reimage);
            printDic.Add("ProjectID", entity.ProjectId);
            printDic.Add("USCode", reimageInfo.USCode);
            printDic.Add("Region", store.RegionENUS);
            printDic.Add("Market", store.MarketENUS);
            printDic.Add("City", store.CityENUS);
            printDic.Add("AddressZHCN", store.AddressZHCN);
            printDic.Add("OpenDate", store.OpenDate.ToString("yyyy-MM-dd"));
            if (store.CloseDate.HasValue && store.CloseDate.Value.Year == 1900)
            {
                printDic.Add("ClosureDate", string.Empty);
            }
            else
            {
                printDic.Add("ClosureDate", store.CloseDate.HasValue ? (store.CloseDate.Value.ToString("yyyy-MM-dd")) : "");
            }
            printDic.Add("AssetsManager", storeInfo.StoreDevelop.AssetMgrName);
            printDic.Add("AssetsRep", storeInfo.StoreDevelop.AssetRepName);
            printDic.Add("StoreAge", (DateTime.Now.Year - store.OpenDate.Year).ToString());
            var currentLeaseENDYear = storeInfo.CurrentYear - int.Parse(storeInfo.StoreContractInfo.EndYear);

            printDic.Add("CurrentLeaseENDYear", currentLeaseENDYear.ToString());
            printDic.Add("StoreNameEN", store.NameENUS);
            printDic.Add("StoreNameCN", store.NameENUS);
            var RmgSummaryentity     = ReimageSummary.FirstOrDefault(e => e.ProjectId.Equals(entity.ProjectId) && e.IsHistory == false);
            var financialPreanalysis = FinancialPreanalysis.FirstOrDefault(e => e.RefId.Equals(RmgSummaryentity.Id));

            printDic.Add("SalesBuildingInvestment", financialPreanalysis.SalesBuildingInvestment);
            printDic.Add("NoneSalesBuildingInvst", financialPreanalysis.NoneSalesBuildingInvst);
            printDic.Add("TTMSales", financialPreanalysis.TTMSales.HasValue ? Math.Round(financialPreanalysis.TTMSales.Value, 2).ToString() : string.Empty);
            var reimage = ReimageConsInfo.GetConsInfo(entity.ProjectId, "");
            ReinvestmentCost reinCost = ReinvestmentCost.FirstOrDefault(e => e.ConsInfoID == reimage.Id);

            printDic.Add("TotalReinvestmentNorm", reinCost.TotalReinvestmentNorm);
            printDic.Add("TotalSalesInc", financialPreanalysis.TotalSalesInc);
            printDic.Add("ROI", financialPreanalysis.ROI);
            ////printDic.Add("SalesInc", financialPreanalysis.ROI);
            printDic.Add("PaybackYears", financialPreanalysis.PaybackYears);
            printDic.Add("StoreCM", financialPreanalysis.StoreCM);
            printDic.Add("EstimatedWriteOffCost", financialPreanalysis.EstimatedWriteOffCost);
            printDic.Add("MarginInc", financialPreanalysis.MarginInc);
            printDic.Add("ISDWIP", financialPreanalysis.ISDWIP);
            printDic.Add("CurrStorePricingTier", financialPreanalysis.CurrentPriceTier);
            printDic.Add("SPTAR", financialPreanalysis.SPTAR);

            //Submission and Approval Records - 只显示通过意见
            List <SubmissionApprovalRecord> recordList = new List <SubmissionApprovalRecord>();
            //Submission and Approval Records Details — 所有意见
            List <SubmissionApprovalRecord> recordDetailList = new List <SubmissionApprovalRecord>();

            ProjectComment          projectCommentBll = new ProjectComment();
            ProjectCommentCondition condition         = new ProjectCommentCondition();
            var package = ReimagePackage.Get(entity.ProjectId);

            condition.RefTableName = ReimagePackage.TableName;
            condition.RefTableId   = entity.Id;
            condition.SourceCode   = FlowCode.Reimage;

            var commentList       = VProjectComment.SearchVListForPDF(condition);
            var commentDetailList = 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);
            }
            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);
            }



            string result = string.Empty;

            if (fileType == PrintFileType.Pdf)
            {
                result = HtmlConversionUtility.HtmlConvertToPDF(HtmlTempalteType.Reimage, printDic, recordList, recordDetailList);
            }
            else
            {
                result = HtmlConversionUtility.ConvertToImage(HtmlTempalteType.Reimage, printDic, recordList, recordDetailList);
            }
            return(result);
        }
Exemple #16
0
 public IHttpActionResult Get(string projectId)
 {
     return(Ok(ReimageInfo.FirstOrDefault(c => c.ProjectId == projectId)));
 }
Exemple #17
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);
        }
Exemple #18
0
        public IHttpActionResult GetAttachments(Guid Id, string flowCode)
        {
            var refTableId   = string.Empty;
            var refTableName = string.Empty;
            var projectInfo  = ProjectInfo.Get(Id);

            if (projectInfo != null)
            {
                switch (flowCode)
                {
                case FlowCode.Closure:
                    refTableName = "ClosureInfo";
                    var closureInfo = ClosureInfo.GetByProjectId(projectInfo.ProjectId);
                    if (closureInfo != null)
                    {
                        refTableId = closureInfo.Id.ToString();
                    }
                    break;

                case FlowCode.Rebuild:
                    refTableName = "RebuildInfo";
                    var rebuildInfo = RebuildInfo.FirstOrDefault(i => i.ProjectId == projectInfo.ProjectId);
                    if (rebuildInfo != null)
                    {
                        refTableId = rebuildInfo.Id.ToString();
                    }
                    break;

                case FlowCode.MajorLease:
                    refTableName = "MajorLeaseInfo";
                    var majorLeaseInfo = MajorLeaseInfo.FirstOrDefault(i => i.ProjectId == projectInfo.ProjectId);
                    if (majorLeaseInfo != null)
                    {
                        refTableId = majorLeaseInfo.Id.ToString();
                    }
                    break;

                case FlowCode.Renewal:
                    refTableName = "RenewalInfo";
                    var renewalInfo = RenewalInfo.Get(projectInfo.ProjectId);
                    if (renewalInfo != null)
                    {
                        refTableId = renewalInfo.Id.ToString();
                    }
                    break;

                case FlowCode.Reimage:
                    refTableName = "ReimageInfo";
                    var reimageInfo = ReimageInfo.GetReimageInfo(projectInfo.ProjectId);
                    if (reimageInfo != null)
                    {
                        refTableId = reimageInfo.Id.ToString();
                    }
                    break;
                }
                if (!string.IsNullOrEmpty(refTableId))
                {
                    var list = Attachment.Search(i => i.RefTableName == refTableName && i.RefTableID == refTableId).ToList();
                    foreach (var item in list)
                    {
                        item.FileURL = SiteInfo.ServiceUrl + "api/attachment/download?id=" + item.ID;
                    }
                    return(Ok(list));
                }
            }
            return(Ok());
        }