예제 #1
0
        public void GenerateSiteInfoTask()
        {
            var taskWork = new TaskWork();

            taskWork.SourceCode     = FlowCode.Reimage;
            taskWork.SourceNameENUS = FlowCode.Reimage;
            taskWork.SourceNameZHCN = FlowCode.Reimage;
            taskWork.Status         = TaskWorkStatus.UnFinish;
            taskWork.StatusNameZHCN = "任务";
            taskWork.StatusNameENUS = "任务";
            taskWork.RefID          = ProjectId;
            taskWork.Id             = Guid.NewGuid();
            taskWork.CreateTime     = DateTime.Now;

            var reimageInfo = ReimageInfo.FirstOrDefault(e => e.ProjectId == ProjectId);

            if (reimageInfo == null)
            {
                throw new Exception("Cannot find the relative reimage info!");
            }

            taskWork.Title            = TaskWork.BuildTitle(ProjectId, reimageInfo.StoreNameZHCN, reimageInfo.StoreNameENUS);
            taskWork.TypeCode         = FlowCode.Reimage_SiteInfo;
            taskWork.TypeNameENUS     = FlowCode.Reimage_SiteInfo;
            taskWork.TypeNameZHCN     = FlowCode.Reimage_SiteInfo;
            taskWork.ReceiverAccount  = reimageInfo.PMAccount;
            taskWork.ReceiverNameENUS = reimageInfo.PMNameENUS;
            taskWork.ReceiverNameZHCN = reimageInfo.PMNameZHCN;
            taskWork.Url          = string.Format(@"/Reimage/Main#/SiteInfo/Process/Approval?projectId={0}&action={1}", ProjectId, "Confirm");
            taskWork.StoreCode    = reimageInfo.USCode;
            taskWork.ActivityName = NodeCode.Start;
            taskWork.ActionName   = SetTaskActionName(ProjectId);
            TaskWork.Add(taskWork);
        }
예제 #2
0
        public void GenerateConsInvtCheckingTask(bool isScheduled = false)
        {
            var rmgInfo = ReimageInfo.Search(e => e.ProjectId.Equals(ProjectId)).AsNoTracking().FirstOrDefault();

            if (rmgInfo == null)
            {
                throw new Exception("Could not find the Reimage Info, please check it!");
            }
            var taskUrl = string.Format(@"/Reimage/Main#/ConsInvtChecking?projectId={0}", ProjectId);
            var task    = rmgInfo.GenerateTaskWork(WorkflowCode, WorkflowCode, WorkflowCode, taskUrl);

            task.ActivityName = NodeCode.Start;
            task.ActionName   = SetTaskActionName(ProjectId);

            if (!isScheduled)
            {
                TaskWork.Add(task);
            }
            else
            {
                var gbMemo = ReimageGBMemo.GetGBMemo(ProjectId);
                if (gbMemo != null && gbMemo.ConstCompletionDate.HasValue)
                {
                    ScheduleLog.GenerateTaskSchedule(gbMemo.ConstCompletionDate.Value.AddDays(60), task, ClientCookie.UserCode, ProjectId, FlowCode.Reimage_ConsInvtChecking, rmgInfo.USCode);
                }
            }
        }
예제 #3
0
        public ReimageConsInvtChecking GetConsInvtChecking(string strProjectId, string entityId = "")
        {
            ProjectId = strProjectId;
            ReimageConsInvtChecking entity = null;

            if (string.IsNullOrEmpty(entityId))
            {
                entity = Search(e => e.ProjectId.Equals(strProjectId) && !e.IsHistory).FirstOrDefault();
            }
            else
            {
                entity = Search(e => e.Id.ToString().Equals(entityId)).FirstOrDefault();
            }

            if (entity != null)
            {
                entity.IsProjectFreezed = CheckIfFreezeProject(strProjectId);
                entity.ApprovalType     = entity.GetApprovalType();
                var projectInfo = ProjectInfo.FirstOrDefault(e => e.ProjectId == strProjectId &&
                                                             e.FlowCode == WorkflowCode);

                if (projectInfo != null)
                {
                    var reimageInfo = ReimageInfo.FirstOrDefault(e => e.ProjectId == strProjectId);

                    if (reimageInfo != null &&
                        ClientCookie.UserCode.Equals(reimageInfo.PMAccount))
                    {
                        var isExistTask = TaskWork.Search(e => e.RefID == strProjectId
                                                          &&
                                                          e.TypeCode == WorkflowCode &&
                                                          e.Status == TaskWorkStatus.UnFinish &&
                                                          e.ReceiverAccount == ClientCookie.UserCode
                                                          &&
                                                          e.ActivityName ==
                                                          WFReimageConsInvtChecking.Act_Originator).Any();

                        entity.IsShowEdit   = projectInfo.Status == ProjectStatus.Finished && !isExistTask;
                        entity.IsShowRecall = projectInfo.Status != ProjectStatus.Finished && !isExistTask;
                    }
                }
            }
            else
            {
                entity = new ReimageConsInvtChecking();
                entity.IsProjectFreezed = CheckIfFreezeProject(strProjectId);
            }
            entity.IsShowSave = ProjectInfo.IsFlowSavable(strProjectId, FlowCode.Reimage_ConsInvtChecking);
            PopulateAppUsers(entity);
            return(entity);
        }
예제 #4
0
        public void Save(string action = "")
        {
            using (var scope = new TransactionScope())
            {
                if (Id == Guid.Empty)
                {
                    Id                = Guid.NewGuid();
                    CreateTime        = DateTime.Now;
                    LastUpdateTime    = DateTime.Now;
                    CreateUserAccount = ClientCookie.UserCode;

                    IsHistory = false;

                    Add(this);
                }
                else
                {
                    LastUpdateTime = DateTime.Now;
                    Update(this);
                }
                if (ReinBasicInfo != null)
                {
                    ReinBasicInfo.ConsInfoID = Id;
                    ReinBasicInfo.Save();

                    //同步更新GBDate与ReopenDate
                    var reimageInfo = ReimageInfo.GetReimageInfo(ProjectId);
                    reimageInfo.ReopenDate = ReinBasicInfo.ReopenDate;
                    reimageInfo.GBDate     = ReinBasicInfo.GBDate;
                    reimageInfo.Update();
                }

                if (ReinCost != null)
                {
                    ReinCost.ConsInfoID = Id;
                    ReinCost.Save();
                }

                if (WriteOff != null)
                {
                    WriteOff.ConsInfoID = Id;
                    WriteOff.Save();
                }
                SaveApproveUsers(action);
                if (string.Compare(action, "edit", true) != 0)
                {
                    SaveComments(action);
                }
                scope.Complete();
            }
        }
예제 #5
0
        private int StartProcess(TaskWork task)
        {
            var reimageInfo = ReimageInfo.FirstOrDefault(e => e.ProjectId.Equals(ProjectId));

            if (reimageInfo == null)
            {
                throw new Exception("Could not find the Reimage Info, please check it!");
            }

            var processDataFields = SetWorkflowDataFields(task);

            return(K2FxContext.Current.StartProcess(WorkflowProcessCode, ClientCookie.UserCode,
                                                    processDataFields));
        }
예제 #6
0
        private void PopulateAppUsers(ReimageConsInvtChecking entity)
        {
            var approvedUsers = ApproveDialogUser.GetApproveDialogUser(entity.Id.ToString());

            entity.AppUsers = new ApproveUsers();
            if (approvedUsers != null)
            {
                var simp = new SimpleEmployee
                {
                    Code = approvedUsers.ConstructionManagerCode
                };
                entity.AppUsers.ConstructionManager = simp;

                entity.AppUsers = new ApproveUsers();
                simp            = new SimpleEmployee
                {
                    Code = approvedUsers.FMCode
                };
                entity.AppUsers.FM = simp;

                entity.AppUsers = new ApproveUsers();
                simp            = new SimpleEmployee
                {
                    Code = approvedUsers.FinanceControllerCode
                };
                entity.AppUsers.FinanceController = simp;

                entity.AppUsers = new ApproveUsers();
                simp            = new SimpleEmployee
                {
                    Code = approvedUsers.VPGMCode
                };
                entity.AppUsers.VPGM = simp;
            }
            else
            {
                var reimageInfo = ReimageInfo.FirstOrDefault(e => e.ProjectId == ProjectId);
                if (reimageInfo != null)
                {
                    entity.AppUsers.ConstructionManager = new SimpleEmployee
                    {
                        Code = reimageInfo.CMAccount
                    };
                }
            }
        }
예제 #7
0
        public override void Finish(TaskWorkStatus status, TaskWork task)
        {
            using (var scope = new TransactionScope())
            {
                switch (status)
                {
                case TaskWorkStatus.K2ProcessApproved:
                    ProjectInfo.FinishNode(ProjectId, FlowCode.Reimage_ConsInfo, NodeCode.Reimage_ConsInfo_Confirm, ProjectStatus.Finished);

                    var reimagePackage = ReimagePackage.Get(ProjectId);
                    reimagePackage.GeneratePackageTask(ProjectId);

                    var reimageInfo = ReimageInfo.FirstOrDefault(e => e.ProjectId == ProjectId);

                    if (reimageInfo != null)
                    {
                        if (!TaskWork.Any(e => e.RefID == ProjectId &&
                                          e.TypeCode == FlowCode.Reimage_Summary &&
                                          e.Status == TaskWorkStatus.UnFinish &&
                                          e.ActivityName == NodeCode.Start))
                        {
                            var    reimageSummary = ReimageSummary.GetReimageSummaryInfo(ProjectId);
                            string filePath;
                            reimageSummary.GenerateExcel(out filePath);

                            if (!ProjectInfo.Any(e => e.ProjectId == ProjectId &&
                                                 e.FlowCode == FlowCode.Reimage_Summary &&
                                                 e.Status == ProjectStatus.Finished))
                            {
                                var summaryTask = reimageInfo.GenerateTaskWork(
                                    FlowCode.Reimage_Summary,
                                    FlowCode.Reimage_Summary,
                                    FlowCode.Reimage_Summary,
                                    string.Format(@"/Reimage/Main#/Summary?projectId={0}", ProjectId));

                                summaryTask.Add();
                            }
                        }
                    }
                    break;
                }

                scope.Complete();
            }
        }
예제 #8
0
        public override string Edit()
        {
            var taskUrl = string.Format("/Reimage/Main#/GBMemo?projectId={0}", ProjectId);

            using (var scope = new TransactionScope())
            {
                var rmgInfo = ReimageInfo.Search(e => e.ProjectId.Equals(ProjectId)).FirstOrDefault();
                if (rmgInfo == null)
                {
                    throw new Exception("Could not find the Reimage Info, please check it!");
                }
                var task = rmgInfo.GenerateTaskWork(WorkflowCode, "Reimage_GBMemo", "Reimage_GBMemo", taskUrl);
                task.ActivityName = NodeCode.Start;
                task.ActionName   = SetTaskActionName(ProjectId);
                TaskWork.Add(task);
                ProjectInfo.Reset(ProjectId, WorkflowCode);

                if (IsInOperation)
                {
                    ProjectInfo.Reset(ProjectId, FlowCode.Reimage_ReopenMemo);
                    ProjectInfo.Reset(ProjectId, FlowCode.Reimage_TempClosureMemo);
                }
                else
                {
                    CompleteNotFinishTask();
                }
                CompleteNotifyTask(ProjectId);
                IsHistory = true;
                Update(this);

                Mapper.CreateMap <ReimageGBMemo, ReimageGBMemo>();
                var entity = Mapper.Map <ReimageGBMemo>(this);
                entity.Id         = Guid.Empty;
                entity.ProcInstID = null;
                entity.IsHistory  = false;
                entity.Comments   = null;
                entity.CreateTime = DateTime.Now;
                entity.Save();

                CopyAppUsers(Id.ToString(), entity.Id.ToString());
                scope.Complete();
            }

            return(taskUrl);
        }
예제 #9
0
        private void PopulateAppUsers()
        {
            var approvedUsers = ApproveDialogUser.GetApproveDialogUser(this.Id.ToString());

            this.AppUsers = new ApproveUsers();
            if (approvedUsers != null)
            {
                var simp = new SimpleEmployee
                {
                    Code = approvedUsers.ConstructionManagerCode
                };
                this.AppUsers.ConstructionManager = simp;

                simp = new SimpleEmployee
                {
                    Code = approvedUsers.MCCLConsManagerCode
                };
                this.AppUsers.MCCLConsManager = simp;

                //simp = new SimpleEmployee
                //{
                //    Code = approvedUsers.MCCLAssetMgrCode
                //};
                //entity.AppUsers.MCCLAssetMgr = simp;

                //simp = new SimpleEmployee
                //{
                //    Code = approvedUsers.MCCLAssetDtrCode
                //};
                //entity.AppUsers.MCCLAssetDtr = simp;
            }
            else
            {
                var reimageInfo = ReimageInfo.FirstOrDefault(e => e.ProjectId == ProjectId);
                if (reimageInfo != null)
                {
                    this.AppUsers.ConstructionManager = new SimpleEmployee
                    {
                        Code = reimageInfo.CMAccount
                    };
                }
            }
        }
예제 #10
0
        public void GenerateConsInvertTask(string projectId)
        {
            if (CheckIfUnfreezePackageWorkflow(projectId))
            {
                if (!TaskWork.Any(e => e.RefID == projectId &&
                                  e.TypeCode == WorkflowCode &&
                                  e.Status == TaskWorkStatus.UnFinish))
                {
                    var taskWork = new TaskWork();
                    taskWork.SourceCode     = FlowCode.Reimage;
                    taskWork.SourceNameENUS = FlowCode.Reimage;
                    taskWork.SourceNameZHCN = FlowCode.Reimage;
                    taskWork.Status         = TaskWorkStatus.UnFinish;
                    taskWork.StatusNameZHCN = "任务";
                    taskWork.StatusNameENUS = "任务";
                    taskWork.RefID          = projectId;
                    taskWork.Id             = Guid.NewGuid();
                    taskWork.CreateTime     = DateTime.Now;
                    var reimageInfo = ReimageInfo.FirstOrDefault(e => e.ProjectId == projectId);

                    if (reimageInfo == null)
                    {
                        throw new Exception("Cannot find the relative reimage info!");
                    }

                    taskWork.Title            = TaskWork.BuildTitle(projectId, reimageInfo.StoreNameZHCN, reimageInfo.StoreNameENUS);
                    taskWork.TypeCode         = WorkflowCode;
                    taskWork.TypeNameENUS     = WorkflowCode;
                    taskWork.TypeNameZHCN     = WorkflowCode;
                    taskWork.ReceiverAccount  = reimageInfo.PMAccount;
                    taskWork.ReceiverNameENUS = reimageInfo.PMNameENUS;
                    taskWork.ReceiverNameZHCN = reimageInfo.PMNameZHCN;
                    taskWork.Url          = string.Format(@"/Reimage/Main#/ConsInvtChecking?projectId={0}", projectId);
                    taskWork.StoreCode    = reimageInfo.USCode;
                    taskWork.ActivityName = NodeCode.Start;
                    taskWork.ActionName   = SetTaskActionName(projectId);
                    TaskWork.Add(taskWork);
                }
            }
        }
예제 #11
0
        public override void GenerateDefaultWorkflowInfo(string projectId)
        {
            var entity = new ReimageConsInfo();

            entity.ProjectId         = projectId;
            entity.Id                = Guid.NewGuid();
            entity.CreateTime        = DateTime.Now;
            entity.CreateUserAccount = ClientCookie.UserCode;
            entity.IsHistory         = false;

            var rbdInfo = ReimageInfo.FirstOrDefault(e => e.ProjectId == projectId);

            if (rbdInfo != null)
            {
                entity.ReinBasicInfo = new ReinvestmentBasicInfo
                {
                    GBDate     = rbdInfo.GBDate,
                    ReopenDate = rbdInfo.ReopenDate,
                    // ConsCompletionDate = rbdInfo.ConstCompletionDate
                };
            }
            Add(entity);
        }
예제 #12
0
파일: GBMemo.cs 프로젝트: XiaoYaTech/Demo
        public static GBMemo GetGBMemo(string projectId)
        {
            var memo = FirstOrDefault(e => e.ProjectId.Equals(projectId) && !e.IsHistory);

            if (memo == null)
            {
                memo = new GBMemo();
            }

            memo.ProjectId = projectId;
            string usCode = "";

            if (projectId.ToLower().IndexOf("rebuild") >= 0)
            {
                var rbdInfo = new RebuildInfo();
                rbdInfo   = rbdInfo.GetRebuildInfo(projectId);
                memo.Info = rbdInfo;
                usCode    = rbdInfo.USCode;
            }
            if (projectId.ToLower().IndexOf("reimage") >= 0)
            {
                var reimageInfo = ReimageInfo.GetReimageInfo(projectId);
                memo.rmgInfo = reimageInfo;
                usCode       = reimageInfo.USCode;
            }
            memo.Store = StoreBasicInfo.GetStore(usCode);

            if (memo.Store.Hour24Count == 24)
            {
                memo.Is24Hour = true;
            }
            else
            {
                memo.Is24Hour = false;
            }
            return(memo);
        }
예제 #13
0
        public override string Edit()
        {
            var taskUrl = string.Format("/Reimage/Main#/ConsInfo?projectId={0}", ProjectId);

            using (var scope = new TransactionScope())
            {
                var reimageInfo = ReimageInfo.FirstOrDefault(e => e.ProjectId.Equals(ProjectId));
                if (reimageInfo == null)
                {
                    throw new Exception("Could not find the Reimage Info, please check it!");
                }
                var task = reimageInfo.GenerateTaskWork(FlowCode.Reimage_ConsInfo,
                                                        "Reimage_ConsInfo",
                                                        "Reimage_ConsInfo",
                                                        taskUrl);
                task.ActivityName = NodeCode.Start;
                task.ActionName   = SetTaskActionName(ProjectId);
                TaskWork.Add(task);

                var package = ReimagePackage.GetReimagePackageInfo(ProjectId);
                if (package != null)
                {
                    package.CompleteActorPackageTask(reimageInfo.AssetActorAccount);
                }


                var attachments = Attachment.Search(e => e.RefTableID == Id.ToString() &&
                                                    e.RefTableName == WFReimageConsInfo.TableName).AsNoTracking().ToList();



                ProjectInfo.Reset(ProjectId, FlowCode.Reimage_ConsInfo);
                var wfEntity = GetWorkflowEntity(ProjectId, FlowCode.Reimage_Package);
                if (wfEntity != null)
                {
                    wfEntity.ChangePackageHoldingStatus(HoldingStatus.No);
                }



                var form = Duplicator.AutoCopy(this);
                form.Id         = Guid.Empty;
                form.ProcInstId = null;
                form.IsHistory  = false;
                form.Comments   = null;
                form.CreateTime = DateTime.Now;
                form.SaveEdit("edit");

                List <Attachment> listAttachment = new List <Attachment>();
                Mapper.CreateMap <Attachment, Attachment>();
                foreach (var attachment in attachments)
                {
                    var newAttachment = Duplicator.AutoCopy(attachment);
                    newAttachment.RefTableID = form.Id.ToString();
                    newAttachment.ID         = Guid.NewGuid();
                    listAttachment.Add(newAttachment);
                }
                Attachment.Add(listAttachment.ToArray());
                IsHistory = true;
                Update(this);
                scope.Complete();
            }

            return(taskUrl);
        }
예제 #14
0
        public static TempClosureMemo GetTempClosureMemo(string projectId)
        {
            var memo = FirstOrDefault(e => e.ProjectId.Equals(projectId));

            if (memo == null)
            {
                memo           = new TempClosureMemo();
                memo.ProjectId = projectId;
                var eac = new EstimatedVsActualConstruction();
                if (projectId.ToLower().IndexOf("rebuild") >= 0)
                {
                    var rbdInfo = new RebuildInfo();
                    rbdInfo = rbdInfo.GetRebuildInfo(projectId);
                    var store = StoreBasicInfo.GetStore(rbdInfo.USCode);
                    eac = eac.GetEAC(rbdInfo.Id);
                    if (rbdInfo != null)
                    {
                        memo.ClosureDate = rbdInfo.TempClosureDate;
                    }
                    if (store != null)
                    {
                        memo.RegionCode     = store.StoreBasicInfo.RegionCode;
                        memo.RegionNameENUS = store.StoreBasicInfo.RegionENUS;
                        memo.RegionNameZHCN = store.StoreBasicInfo.RegionZHCN;

                        memo.MarketCode     = store.StoreBasicInfo.MarketCode;
                        memo.MarketNameENUS = store.StoreBasicInfo.MarketENUS;
                        memo.MarketNameZHCN = store.StoreBasicInfo.MarketZHCN;

                        memo.ProvinceNameENUS = store.StoreBasicInfo.ProvinceENUS;
                        memo.ProvinceNameZHCN = store.StoreBasicInfo.ProvinceZHCN;

                        memo.CityCode     = store.StoreBasicInfo.CityCode;
                        memo.CityNameENUS = store.StoreBasicInfo.CityENUS;
                        memo.CityNameZHCN = store.StoreBasicInfo.CityZHCN;

                        memo.StoreNameENUS = store.StoreBasicInfo.NameENUS;
                        memo.StoreNameZHCN = store.StoreBasicInfo.NameZHCN;

                        memo.StoreAddressENUS = store.StoreBasicInfo.AddressENUS;
                        memo.StoreAddressZHCN = store.StoreBasicInfo.AddressZHCN;

                        memo.USCode   = store.StoreBasicInfo.StoreCode;
                        memo.OpenDate = store.StoreBasicInfo.OpenDate;
                    }
                }
                else if (projectId.ToLower().IndexOf("reimage") >= 0)
                {
                    var rmgInfo = ReimageInfo.GetReimageInfo(projectId);
                    var store   = StoreBasicInfo.GetStore(rmgInfo.USCode);
                    eac = eac.GetEAC(rmgInfo.Id);
                    memo.ClosureDate = DateTime.Now;
                    if (store != null)
                    {
                        memo.RegionCode     = store.StoreBasicInfo.RegionCode;
                        memo.RegionNameENUS = store.StoreBasicInfo.RegionENUS;
                        memo.RegionNameZHCN = store.StoreBasicInfo.RegionZHCN;

                        memo.MarketCode     = store.StoreBasicInfo.MarketCode;
                        memo.MarketNameENUS = store.StoreBasicInfo.MarketENUS;
                        memo.MarketNameZHCN = store.StoreBasicInfo.MarketZHCN;

                        memo.ProvinceNameENUS = store.StoreBasicInfo.ProvinceENUS;
                        memo.ProvinceNameZHCN = store.StoreBasicInfo.ProvinceZHCN;

                        memo.CityCode     = store.StoreBasicInfo.CityCode;
                        memo.CityNameENUS = store.StoreBasicInfo.CityENUS;
                        memo.CityNameZHCN = store.StoreBasicInfo.CityZHCN;

                        memo.StoreNameENUS = store.StoreBasicInfo.NameENUS;
                        memo.StoreNameZHCN = store.StoreBasicInfo.NameZHCN;

                        memo.StoreAddressENUS = store.StoreBasicInfo.AddressENUS;
                        memo.StoreAddressZHCN = store.StoreBasicInfo.AddressZHCN;

                        memo.USCode   = store.StoreBasicInfo.StoreCode;
                        memo.OpenDate = store.StoreBasicInfo.OpenDate;
                    }
                }
                memo.Save();
            }
            return(memo);
        }
예제 #15
0
        public StoreProfitabilityAndLeaseInfo GetStore(string projectId)
        {
            string pageType       = "";
            var    store          = new StoreProfitabilityAndLeaseInfo();
            var    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(store);
        }
예제 #16
0
        public void Save(bool pushOrNot)
        {
            using (TransactionScope tranScope = new TransactionScope())
            {
                var projectInfo = ProjectInfo.Get(Id);
                if (projectInfo == null)
                {
                    ProjectId = ProjectInfo.CreateDLProject(Id, FlowCode.Reimage, USCode, NodeCode.Start, ClientCookie.UserCode, pushOrNot);
                    var store = StoreBasicInfo.GetStorInfo(USCode);

                    var 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.AssetRepAccount    = "";
                    reimageInfo.AssetRepNameZHCN   = "";
                    reimageInfo.AssetRepNameENUS   = "";
                    reimageInfo.AssetActorAccount  = "";
                    reimageInfo.AssetActorNameZHCN = "";
                    reimageInfo.AssetActorNameENUS = "";
                    reimageInfo.FinanceAccount     = "";
                    reimageInfo.FinanceNameZHCN    = "";
                    reimageInfo.FinanceNameENUS    = "";
                    reimageInfo.PMAccount          = "";
                    reimageInfo.PMNameZHCN         = "";
                    reimageInfo.PMNameENUS         = "";
                    reimageInfo.LegalAccount       = "";
                    reimageInfo.LegalNameZHCN      = "";
                    reimageInfo.LegalNameENUS      = "";
                    reimageInfo.StoreNameENUS      = store.NameENUS;
                    reimageInfo.StoreNameZHCN      = store.NameZHCN;
                    reimageInfo.GBDate             = GBDate;
                    reimageInfo.ReopenDate         = ReopenDate;
                    reimageInfo.Add();

                    var reimageConsInfo = new ReimageConsInfo();
                    reimageConsInfo.Id                = Guid.NewGuid();
                    reimageConsInfo.ProjectId         = ProjectId;
                    reimageConsInfo.IsHistory         = false;
                    reimageConsInfo.CreateTime        = DateTime.Now;
                    reimageConsInfo.CreateUserAccount = ClientCookie.UserCode;
                    reimageConsInfo.Add();

                    var reinvestmentBasicInfo = new ReinvestmentBasicInfo();
                    reinvestmentBasicInfo.ConsInfoID        = reimageConsInfo.Id;
                    reinvestmentBasicInfo.RightSizingSeatNo = RightSizingSeatNO;
                    reinvestmentBasicInfo.NewDesignType     = AfterReimageDesignType;
                    reinvestmentBasicInfo.Add();

                    var reimageConsInvtChecking = new ReimageConsInvtChecking();
                    reimageConsInvtChecking.Id                = Guid.NewGuid();
                    reimageConsInvtChecking.ProjectId         = ProjectId;
                    reimageConsInvtChecking.IsHistory         = false;
                    reimageConsInvtChecking.CreateTime        = DateTime.Now;
                    reimageConsInvtChecking.CreateUserAccount = ClientCookie.UserCode;
                    reimageConsInvtChecking.Add();

                    var writeOffAmount = new WriteOffAmount();
                    writeOffAmount.Id            = Guid.NewGuid();
                    writeOffAmount.ConsInfoID    = reimageConsInvtChecking.Id;
                    writeOffAmount.TotalWriteOff = Reimage_Total_WO_Proj;
                    writeOffAmount.TotalActual   = Reimage_Total_WO_Act;
                    writeOffAmount.Add();

                    var reinvestmentCost = new ReinvestmentCost();
                    reinvestmentCost.Id         = Guid.NewGuid();
                    reinvestmentCost.ConsInfoID = reimageConsInvtChecking.Id;
                    reinvestmentCost.TotalReinvestmentBudget = Reimage_Total_Reinvestment_Proj;
                    reinvestmentCost.TotalReinvestmentPMAct  = Reimage_Total_Reinvestment_Act;
                    reinvestmentCost.Add();

                    var reopenMemo = new ReopenMemo();
                    reopenMemo.Id        = Guid.NewGuid();
                    reopenMemo.ProjectId = ProjectId;
                    reopenMemo.NewMcCafe = false;
                    reopenMemo.NewKiosk  = false;
                    reopenMemo.NewMDS    = false;
                    reopenMemo.Is24H     = false;
                    reopenMemo.AftARSN   = AfterReimageSeatNO;
                    reopenMemo.Add();
                }
                else
                {
                    ProjectId            = projectInfo.ProjectId;
                    projectInfo.IsPushed = pushOrNot;
                    projectInfo.Update();
                    var store = StoreBasicInfo.GetStorInfo(USCode);

                    var reimageInfo = ReimageInfo.FirstOrDefault(i => i.ProjectId == ProjectId);
                    if (reimageInfo != null)
                    {
                        reimageInfo.GBDate     = GBDate;
                        reimageInfo.ReopenDate = ReopenDate;
                        reimageInfo.Update();
                    }
                    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.AssetRepAccount    = "";
                        reimageInfo.AssetRepNameZHCN   = "";
                        reimageInfo.AssetRepNameENUS   = "";
                        reimageInfo.AssetActorAccount  = "";
                        reimageInfo.AssetActorNameZHCN = "";
                        reimageInfo.AssetActorNameENUS = "";
                        reimageInfo.FinanceAccount     = "";
                        reimageInfo.FinanceNameZHCN    = "";
                        reimageInfo.FinanceNameENUS    = "";
                        reimageInfo.PMAccount          = "";
                        reimageInfo.PMNameZHCN         = "";
                        reimageInfo.PMNameENUS         = "";
                        reimageInfo.LegalAccount       = "";
                        reimageInfo.LegalNameZHCN      = "";
                        reimageInfo.LegalNameENUS      = "";
                        reimageInfo.StoreNameENUS      = store.NameENUS;
                        reimageInfo.StoreNameZHCN      = store.NameZHCN;
                        reimageInfo.GBDate             = GBDate;
                        reimageInfo.ReopenDate         = ReopenDate;
                        reimageInfo.Add();
                    }

                    var reimageConsInfo = ReimageConsInfo.FirstOrDefault(i => i.ProjectId == ProjectId && i.IsHistory == false);
                    if (reimageConsInfo != null)
                    {
                        var reinvestmentBasicInfo = ReinvestmentBasicInfo.FirstOrDefault(i => i.ConsInfoID == reimageConsInfo.Id);
                        if (reinvestmentBasicInfo != null)
                        {
                            reinvestmentBasicInfo.RightSizingSeatNo = RightSizingSeatNO;
                            reinvestmentBasicInfo.NewDesignType     = AfterReimageDesignType;
                            reinvestmentBasicInfo.Update();
                        }
                        else
                        {
                            reinvestmentBasicInfo                   = new ReinvestmentBasicInfo();
                            reinvestmentBasicInfo.ConsInfoID        = reimageConsInfo.Id;
                            reinvestmentBasicInfo.RightSizingSeatNo = RightSizingSeatNO;
                            reinvestmentBasicInfo.NewDesignType     = AfterReimageDesignType;
                            reinvestmentBasicInfo.Add();
                        }
                    }
                    else
                    {
                        reimageConsInfo                   = new ReimageConsInfo();
                        reimageConsInfo.Id                = Guid.NewGuid();
                        reimageConsInfo.ProjectId         = ProjectId;
                        reimageConsInfo.IsHistory         = false;
                        reimageConsInfo.CreateTime        = DateTime.Now;
                        reimageConsInfo.CreateUserAccount = ClientCookie.UserCode;
                        reimageConsInfo.Add();

                        var reinvestmentBasicInfo = new ReinvestmentBasicInfo();
                        reinvestmentBasicInfo.ConsInfoID        = reimageConsInfo.Id;
                        reinvestmentBasicInfo.RightSizingSeatNo = RightSizingSeatNO;
                        reinvestmentBasicInfo.NewDesignType     = AfterReimageDesignType;
                        reinvestmentBasicInfo.Add();
                    }

                    var reimageConsInvtChecking = ReimageConsInvtChecking.FirstOrDefault(i => i.ProjectId == ProjectId && i.IsHistory == false);
                    if (reimageConsInvtChecking != null)
                    {
                        var writeOffAmount = WriteOffAmount.FirstOrDefault(i => i.ConsInfoID == reimageConsInvtChecking.Id);
                        if (writeOffAmount != null)
                        {
                            writeOffAmount.TotalWriteOff = Reimage_Total_WO_Proj;
                            writeOffAmount.TotalActual   = Reimage_Total_WO_Act;
                            writeOffAmount.Update();
                        }
                        else
                        {
                            writeOffAmount               = new WriteOffAmount();
                            writeOffAmount.Id            = Guid.NewGuid();
                            writeOffAmount.ConsInfoID    = reimageConsInvtChecking.Id;
                            writeOffAmount.TotalWriteOff = Reimage_Total_WO_Proj;
                            writeOffAmount.TotalActual   = Reimage_Total_WO_Act;
                            writeOffAmount.Add();
                        }

                        var reinvestmentCost = ReinvestmentCost.FirstOrDefault(i => i.ConsInfoID == reimageConsInvtChecking.Id);
                        if (reinvestmentCost != null)
                        {
                            reinvestmentCost.TotalReinvestmentBudget = Reimage_Total_Reinvestment_Proj;
                            reinvestmentCost.TotalReinvestmentPMAct  = Reimage_Total_Reinvestment_Act;
                            reinvestmentCost.Update();
                        }
                        else
                        {
                            reinvestmentCost            = new ReinvestmentCost();
                            reinvestmentCost.Id         = Guid.NewGuid();
                            reinvestmentCost.ConsInfoID = reimageConsInvtChecking.Id;
                            reinvestmentCost.TotalReinvestmentBudget = Reimage_Total_Reinvestment_Proj;
                            reinvestmentCost.TotalReinvestmentPMAct  = Reimage_Total_Reinvestment_Act;
                            reinvestmentCost.Add();
                        }
                    }
                    else
                    {
                        reimageConsInvtChecking                   = new ReimageConsInvtChecking();
                        reimageConsInvtChecking.Id                = Guid.NewGuid();
                        reimageConsInvtChecking.ProjectId         = ProjectId;
                        reimageConsInvtChecking.IsHistory         = false;
                        reimageConsInvtChecking.CreateTime        = DateTime.Now;
                        reimageConsInvtChecking.CreateUserAccount = ClientCookie.UserCode;
                        reimageConsInvtChecking.Add();

                        var writeOffAmount = new WriteOffAmount();
                        writeOffAmount.Id            = Guid.NewGuid();
                        writeOffAmount.ConsInfoID    = reimageConsInvtChecking.Id;
                        writeOffAmount.TotalWriteOff = Reimage_Total_WO_Proj;
                        writeOffAmount.TotalActual   = Reimage_Total_WO_Act;
                        writeOffAmount.Add();

                        var reinvestmentCost = new ReinvestmentCost();
                        reinvestmentCost.Id         = Guid.NewGuid();
                        reinvestmentCost.ConsInfoID = reimageConsInvtChecking.Id;
                        reinvestmentCost.TotalReinvestmentBudget = Reimage_Total_Reinvestment_Proj;
                        reinvestmentCost.TotalReinvestmentPMAct  = Reimage_Total_Reinvestment_Act;
                        reinvestmentCost.Add();
                    }

                    var reopenMemo = ReopenMemo.FirstOrDefault(i => i.ProjectId == ProjectId);
                    if (reopenMemo != null)
                    {
                        reopenMemo.AftARSN = AfterReimageSeatNO;
                        reopenMemo.Update();
                    }
                    else
                    {
                        reopenMemo           = new ReopenMemo();
                        reopenMemo.Id        = Guid.NewGuid();
                        reopenMemo.ProjectId = ProjectId;
                        reopenMemo.NewMcCafe = false;
                        reopenMemo.NewKiosk  = false;
                        reopenMemo.NewMDS    = false;
                        reopenMemo.Is24H     = false;
                        reopenMemo.AftARSN   = AfterReimageSeatNO;
                        reopenMemo.Add();
                    }
                }
                tranScope.Complete();
            }
        }
예제 #17
0
        public static ReimageSummary GetReimageSummaryInfo(string projectId, string id = "")
        {
            var entity = string.IsNullOrEmpty(id) ?
                         Search(e => e.ProjectId.Equals(projectId) && !e.IsHistory).FirstOrDefault()
                : Search(e => e.Id.ToString().Equals(id)).FirstOrDefault();
            var reimageInfo = ReimageInfo.FirstOrDefault(e => e.ProjectId == projectId);

            if (entity != null)
            {
                //entity.FinancialPreanalysis = FinancialPreanalysis.FirstOrDefault(e => e.RefId == entity.Id);
                //entity.StoreProfitabilityAndLeaseInfo =
                //    StoreProfitabilityAndLeaseInfo.FirstOrDefault(e => e.RefId == entity.Id);
                //var reimageSummary = ReimageSummary.FirstOrDefault(e => e.ProjectId == projectId && e.IsHistory == false);
                //var store = ReinvestmentBasicInfo.GetByConsInfoId(reimageSummary.Id);
                //var storelease =
                //  StoreProfitabilityAndLeaseInfo.FirstOrDefault(e => e.RefId == reimageSummary.Id);
                //var financial = FinancialPreanalysis.FirstOrDefault(e => e.RefId == reimageSummary.Id);
                //if (store != null || storelease != null || financial != null)
                //{
                //    entity.PageType = "save";
                //}



                entity.IsShowEdit   = ProjectInfo.IsFlowEditable(projectId, FlowCode.Reimage_Summary);
                entity.IsShowRecall = ProjectInfo.IsFlowRecallable(projectId, FlowCode.Reimage_Summary);



                //var condition = new ProjectCommentCondition();
                //condition.SourceCode = FlowCode.Reimage;
                //condition.UserAccount = ClientCookie.UserCode;

                //condition.RefTableId = entity.Id;
                //condition.RefTableName = "ReimageSummary";

                //var comments = ProjectComment.SearchList(condition);
                //if (comments != null && comments.Count > 0)
                //{
                //    entity.ProjectComments = comments;

                //    var saveComment =
                //        comments.OrderByDescending(e => e.CreateTime)
                //            .FirstOrDefault(e => e.Status == ProjectCommentStatus.Save);
                //    if (saveComment != null)
                //    {
                //        entity.Comments = saveComment.Content;
                //    }
                //}
            }
            else
            {
                entity = new ReimageSummary()
                {
                    ProjectId = projectId
                };
            }
            entity.FinancialPreanalysis           = entity.getFinan(projectId, reimageInfo.USCode);
            entity.StoreProfitabilityAndLeaseInfo = entity.GetStore(projectId) == null ? new StoreProfitabilityAndLeaseInfo() : entity.GetStore(projectId);

            entity.IsProjectFreezed = entity.CheckIfFreezeProject(projectId);

            if (ReimageConsInfo.CheckIfConsInfoFinished(projectId))
            {
                entity.ReimageConsInfo = ReimageConsInfo.GetConsInfo(projectId);

                entity.ReinvestmentBasicInfo = entity.ReimageConsInfo.ReinBasicInfo;
            }



            return(entity);
        }
예제 #18
0
        public Attachment GenerateAttachment(out string filePath)
        {
            var info = ReimageInfo.FirstOrDefault(e => e.ProjectId == this.ProjectId);

            _refId = GetRefId(this.ProjectId);
            var    storeInfo        = StoreBasicInfo.GetStorInfo(info.USCode);
            string templateFileName = string.Concat(SiteFilePath.Template_DIRECTORY, "/", SiteFilePath.Reimage_Summary_Template);
            string fileName         = HttpContext.Current.Server.MapPath(string.Format("~/UploadFiles/{0}.xlsx", Guid.NewGuid()));
            var    extetion         = Path.GetExtension(fileName);
            var    internalName     = Path.GetFileName(fileName);

            File.Copy(templateFileName, fileName);
            FileInfo fileInfo = new FileInfo(fileName);
            ExcelDataInputDirector excelDirector = new ExcelDataInputDirector(fileInfo, ExcelDataInputType.ReimageSummary);
            ExcelInputDTO          excelDto      = new ExcelInputDTO();

            excelDto.USCode    = info.USCode;
            excelDto.ProjectId = info.ProjectId;
            excelDirector.Input(excelDto);
            var  att       = Attachment.FirstOrDefault(e => e.RefTableID == this.Id.ToString() && e.TypeCode == "ReimageSummary");
            bool hasAttach = true;

            if (att == null)
            {
                hasAttach = false;
                att       = new Attachment();
                att.ID    = Guid.NewGuid();
            }

            att.TypeCode        = "ReimageSummary";
            att.RefTableID      = this.Id.ToString();
            att.RefTableName    = "ReimageSummary";
            att.Name            = "Reimage Summary";
            att.Extension       = extetion;
            att.RelativePath    = "/";
            att.InternalName    = internalName;
            att.ContentType     = "application/vnd.ms-excel";
            att.Length          = (int)fileInfo.Length;
            att.CreatorID       = ClientCookie.UserCode;
            att.CreatorNameENUS = ClientCookie.UserNameENUS;
            att.CreatorNameZHCN = ClientCookie.UserNameZHCN;
            att.CreateTime      = DateTime.Now;
            att.RequirementId   = new Guid("5647BDBB-5B5F-47CD-9AD2-3E35A16DD303");
            if (hasAttach)
            {
                att.Update();
            }
            else
            {
                att.Add();
            }
            //fileInfo = new FileInfo(fileName);
            //var importDirector = new ExcelDataImportDirector(fileInfo, ExcelDataImportType.FinancialPreAnalysis);
            //importDirector.FillEntityEvent += FillFinancialPreAnalysisEntity;
            //using (var scope = new TransactionScope())
            //{
            //    importDirector.ParseAndImport();
            //    scope.Complete();
            //}

            filePath = fileName;
            return(att);
        }
예제 #19
0
        public override void Finish(TaskWorkStatus status, TaskWork task)
        {
            using (var scope = new TransactionScope())
            {
                switch (status)
                {
                case TaskWorkStatus.K2ProcessApproved:
                    var imgInfo = ReimageInfo.Search(e => e.ProjectId.Equals(ProjectId)).FirstOrDefault();
                    ProjectInfo.FinishNode(ProjectId, FlowCode.Reimage_GBMemo, NodeCode.Finish, ProjectStatus.Finished);
                    if (IsInOperation)
                    {
                        ProjectInfo.FinishNode(ProjectId, FlowCode.Reimage_ReopenMemo, NodeCode.Finish, ProjectStatus.Finished);
                        ProjectInfo.FinishNode(ProjectId, FlowCode.Reimage_TempClosureMemo, NodeCode.Finish, ProjectStatus.Finished);
                    }
                    else
                    {
                        var taskUrlReopen = string.Format(@"/Reimage/Main#/ReopenMemo?projectId={0}", ProjectId);
                        var taskReopen    = imgInfo.GenerateTaskWork(FlowCode.Reimage_ReopenMemo, "Reopen Memo", "Reopen Memo", taskUrlReopen);
                        taskReopen.ActivityName = NodeCode.Start;
                        taskReopen.ActionName   = SetTaskActionName(ProjectId);
                        //TaskWork.Add(taskReopen);
                        if (rmgInfo.ReopenDate.HasValue)
                        {
                            ScheduleLog.GenerateTaskSchedule(rmgInfo.ReopenDate.Value.AddDays(-7), taskReopen, ClientCookie.UserCode, ProjectId, FlowCode.Reimage_ReopenMemo, rmgInfo.USCode);
                        }
                        ProjectInfo.Reset(ProjectId, FlowCode.Reimage_ReopenMemo);

                        var taskUrlClosure = string.Format(@"/Reimage/Main#/TempClosureMemo?projectId={0}", ProjectId);
                        var taskClosure    = imgInfo.GenerateTaskWork(FlowCode.Reimage_TempClosureMemo, "TempClosure Memo", "TempClosure Memo", taskUrlClosure);
                        taskClosure.ActivityName = NodeCode.Start;
                        taskClosure.ActionName   = SetTaskActionName(ProjectId);
                        TaskWork.Add(taskClosure);
                        ProjectInfo.Reset(ProjectId, FlowCode.Reimage_TempClosureMemo);
                    }

                    var consCheckingTask = TaskWork.FirstOrDefault(e => e.RefID == ProjectId && e.TypeCode == FlowCode.Reimage_ConsInvtChecking && e.Status == TaskWorkStatus.UnFinish);
                    var checkingProj     = ProjectInfo.FirstOrDefault(e => e.ProjectId == ProjectId && e.FlowCode == FlowCode.Reimage_ConsInvtChecking);
                    if (consCheckingTask == null && checkingProj != null &&
                        checkingProj.Status != ProjectStatus.Finished)
                    {
                        var consInvtChecking = new ReimageConsInvtChecking();
                        consInvtChecking.ProjectId = task.RefID;
                        consInvtChecking.GenerateConsInvtCheckingTask(true);
                    }

                    ProjectInfo.CompleteMainIfEnable(ProjectId);
                    var pmTaskUrl = string.Format(@"/Reimage/Main#/GBMemo/Process/Notify?projectId={0}", ProjectId);
                    var pmTask    = imgInfo.GenerateTaskWork(WorkflowCode, "Reimage GBMemo", "Reimage GBMemo", pmTaskUrl);
                    pmTask.ActivityName = "Notify";
                    pmTask.ActionName   = "Notify";
                    TaskWork.Add(pmTask);

                    GenerateSiteInfoTask();
                    break;

                case TaskWorkStatus.K2ProcessDeclined:
                    ProjectInfo.UpdateProjectStatus(ProjectId, FlowCode.Reimage, ProjectStatus.Rejected);
                    ProjectInfo.UpdateProjectStatus(ProjectId, FlowCode.Reimage_GBMemo, ProjectStatus.Rejected);
                    break;
                }
                scope.Complete();
            }
        }
예제 #20
0
        public static ReimageConsInfo GetConsInfo(string strProjectId, string entityId = "")
        {
            ReimageConsInfo entity = null;

            if (string.IsNullOrEmpty(entityId))
            {
                entity = Search(e => e.ProjectId.Equals(strProjectId) && !e.IsHistory).FirstOrDefault();
            }
            else
            {
                entity = Search(e => e.Id.ToString().Equals(entityId)).FirstOrDefault();
            }
            var reimageInfo = ReimageInfo.FirstOrDefault(e => e.ProjectId == strProjectId);

            if (entity != null)
            {
                entity.IsProjectFreezed = entity.CheckIfFreezeProject(strProjectId);
                entity.ReinCost         = ReinvestmentCost.GetByConsInfoId(entity.Id);
                entity.ReinBasicInfo    = ReinvestmentBasicInfo.GetByConsInfoId(entity.Id);
                if (entity.ReinBasicInfo != null)
                {
                    entity.ReinBasicInfo.GBDate     = reimageInfo.GBDate;
                    entity.ReinBasicInfo.ReopenDate = reimageInfo.ReopenDate;
                }
                else
                {
                    entity.ReinBasicInfo =
                        new ReinvestmentBasicInfo
                    {
                        GBDate     = reimageInfo.GBDate,
                        ReopenDate = reimageInfo.ReopenDate
                    };
                }
                entity.WriteOff = WriteOffAmount.GetByConsInfoId(entity.Id);
                var attachmentReinCost = Attachment.FirstOrDefault(e => e.RefTableID == entity.Id.ToString() && e.TypeCode == "ReinCost");
                if (attachmentReinCost != null && entity.ReinCost != null)
                {
                    entity.ReinCost.ReinCostUser = attachmentReinCost.CreatorNameENUS;
                    entity.ReinCost.ReinCostTime = attachmentReinCost.CreateTime;
                }
                var attachmentWriteOff = Attachment.FirstOrDefault(e => e.RefTableID == entity.Id.ToString() && e.TypeCode == "WriteOff");
                if (attachmentWriteOff != null)
                {
                    entity.WriteOff.WriteOffUser = attachmentWriteOff.CreatorNameENUS;
                    entity.WriteOff.WriteOffTime = attachmentWriteOff.CreateTime;
                }
                //entity.ProcInstID = entity.ProcInstId;
                entity.IsShowEdit   = ProjectInfo.IsFlowEditable(strProjectId, FlowCode.Reimage_ConsInfo);
                entity.IsShowRecall = ProjectInfo.IsFlowRecallable(strProjectId, FlowCode.Reimage_ConsInfo);
            }
            else
            {
                //var reimage = ReimageInfo.FirstOrDefault(e => e.ProjectId == strProjectId);
                //if (reimage != null)
                //{
                //    entity = new ReimageConsInfo
                //    {
                //        ReinBasicInfo =
                //            new ReinvestmentBasicInfo
                //            {
                //                GBDate = reimage.GBDate,
                //                ReopenDate = reimage.ReopenDate
                //            },
                //        IsProjectFreezed =entity.CheckIfFreezeProject(strProjectId),
                //        ReinvenstmentType = 1
                //    };
                //}
                entity.IsProjectFreezed = entity.CheckIfFreezeProject(strProjectId);
                entity.ReinBasicInfo    = ReinvestmentBasicInfo.GetByConsInfoId(entity.Id);
                if (entity.ReinBasicInfo != null)
                {
                    entity.ReinBasicInfo.GBDate     = reimageInfo.GBDate;
                    entity.ReinBasicInfo.ReopenDate = reimageInfo.ReopenDate;
                }
                else
                {
                    entity.ReinBasicInfo =
                        new ReinvestmentBasicInfo
                    {
                        GBDate     = reimageInfo.GBDate,
                        ReopenDate = reimageInfo.ReopenDate
                    };
                }
            }
            entity.IsShowSave = ProjectInfo.IsFlowSavable(strProjectId, FlowCode.Reimage_ConsInfo);
            entity.PopulateAppUsers();
            return(entity);
        }
예제 #21
0
        public static ReimageGBMemo GetGBMemo(string projectId, string entityId = "")
        {
            var memo = (string.IsNullOrEmpty(entityId) ?
                        FirstOrDefault(e => e.ProjectId.Equals(projectId) && !e.IsHistory)
                : FirstOrDefault(e => e.Id.ToString().Equals(entityId))) ?? new ReimageGBMemo();

            memo.ProjectId = projectId;

            string usCode  = "";
            var    rmgInfo = ReimageInfo.GetReimageInfo(projectId);

            memo.rmgInfo = rmgInfo;
            usCode       = rmgInfo.USCode;

            memo.Store = StoreBasicInfo.GetStore(usCode);
            var consInfo = new ReimageConsInfo();

            memo.ReinvestInfo = consInfo.GetReinvestmentBasicInfo(projectId);

            if (memo.Id == Guid.Empty)
            {
                memo.IsClosed      = (memo.Store.StoreBasicInfo.statusName == "Closed");
                memo.IsInOperation = false;

                if (memo.ReinvestInfo != null)
                {
                    if ((memo.ReinvestInfo.NewAttachedKiosk.HasValue && memo.ReinvestInfo.NewAttachedKiosk.Value) ||
                        (memo.ReinvestInfo.NewRemoteKiosk.HasValue && memo.ReinvestInfo.NewRemoteKiosk.Value))
                    {
                        memo.IsKiosk = true;
                    }
                    memo.IsMcCafe = memo.ReinvestInfo.NewMcCafe.HasValue && memo.ReinvestInfo.NewMcCafe.Value;
                    memo.IsMDS    = memo.ReinvestInfo.NewMDS.HasValue && memo.ReinvestInfo.NewMDS.Value;
                    memo.Is24Hour = memo.ReinvestInfo.NewTwientyFourHour.HasValue &&
                                    memo.ReinvestInfo.NewTwientyFourHour.Value;
                    memo.GBDate = memo.ReinvestInfo.GBDate;
                    memo.ConstCompletionDate = memo.ReinvestInfo.ConsCompletionDate;
                    memo.ReopenDate          = memo.ReinvestInfo.ReopenDate;
                }
                memo.Save();
            }
            else
            {
                var projectInfo = ProjectInfo.FirstOrDefault(e => e.ProjectId == projectId &&
                                                             e.FlowCode == FlowCode.Reimage_GBMemo);

                if (projectInfo != null)
                {
                    if (ClientCookie.UserCode.Equals(rmgInfo.PMAccount))
                    //if (reimageInfo != null)
                    {
                        var isExistTask = TaskWork.Any(e => e.RefID == projectId &&
                                                       e.TypeCode == FlowCode.Reimage_GBMemo &&
                                                       e.Status == TaskWorkStatus.UnFinish &&
                                                       e.ReceiverAccount == ClientCookie.UserCode
                                                       &&
                                                       e.ActivityName ==
                                                       WorkflowActOriginator);
                        memo.IsShowEdit   = projectInfo.Status == ProjectStatus.Finished && !isExistTask;
                        memo.IsShowRecall = CheckIfShowRecallByPojectStatus(projectInfo.Status) && !isExistTask;
                    }
                }
            }
            if (ClientCookie.UserCode.Equals(rmgInfo.PMAccount))
            {
                memo.IsShowSave = ProjectInfo.IsFlowSavable(projectId, FlowCode.Reimage_GBMemo);
            }
            PopulateAppUsers(memo);
            return(memo);
        }
예제 #22
0
        public static ReopenMemo GetReopenMemo(string projectId)
        {
            var  memo        = FirstOrDefault(e => e.ProjectId.Equals(projectId));
            bool isEmptyMemo = false;

            if (memo == null)
            {
                memo        = new ReopenMemo();
                isEmptyMemo = true;
            }

            memo.ProjectId = projectId;
            if (projectId.ToLower().IndexOf("rebuild") >= 0)
            {
                var rbdInfo = new RebuildInfo();
                memo.RbdInfo = rbdInfo.GetRebuildInfo(projectId);
                memo.Store   = StoreBasicInfo.GetStore(memo.RbdInfo.USCode);
                var consInfo = new RebuildConsInfo();
                consInfo = consInfo.GetConsInfo(projectId);
                var rein = ReinvestmentBasicInfo.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentBasicInfo();
                memo.ReinvestInfo = rein;
                var recos = ReinvestmentCost.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentCost();
                memo.TotalReinvestmentBudget = recos.TotalReinvestmentBudget;
                if (!memo.ReopenDate.HasValue)
                {
                    memo.ReopenDate = memo.ReinvestInfo.ReopenDate;
                }
                if (!memo.GBDate.HasValue)
                {
                    memo.GBDate = memo.ReinvestInfo.GBDate;
                }
                var gbMemo = GBMemo.GetGBMemo(projectId);
                if (!memo.CompletionDate.HasValue && gbMemo != null)
                {
                    memo.CompletionDate = gbMemo.ConstCompletionDate;
                }
                //if (string.IsNullOrEmpty(memo.DesignConcept))
                //    memo.DesignConcept = memo.ReinvestInfo.NewDesignType;

                var writeoff = WriteOffAmount.GetByConsInfoId(consInfo.Id) ?? new WriteOffAmount();
                memo.WriteOff = writeoff;
            }
            else if (projectId.ToLower().IndexOf("reimage") >= 0)
            {
                memo.RmgInfo = ReimageInfo.GetReimageInfo(projectId);
                memo.Store   = StoreBasicInfo.GetStore(memo.RmgInfo.USCode);
                var consInfo = ReimageConsInfo.GetConsInfo(projectId);
                var rein     = ReinvestmentBasicInfo.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentBasicInfo();
                memo.ReinvestInfo = rein;
                var recos = ReinvestmentCost.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentCost();
                memo.TotalReinvestmentBudget = recos.TotalReinvestmentBudget;
                if (!memo.ReopenDate.HasValue)
                {
                    memo.ReopenDate = memo.ReinvestInfo.ReopenDate;
                }
                if (!memo.GBDate.HasValue)
                {
                    memo.GBDate = memo.ReinvestInfo.GBDate;
                }
                var gbMemo = ReimageGBMemo.GetGBMemo(projectId);
                if (!memo.CompletionDate.HasValue && gbMemo != null)
                {
                    memo.CompletionDate = gbMemo.ConstCompletionDate;
                }
                //if (string.IsNullOrEmpty(memo.DesignConcept))
                //    memo.DesignConcept = memo.ReinvestInfo.NewDesignType;
                var writeoff = WriteOffAmount.GetByConsInfoId(consInfo.Id) ?? new WriteOffAmount();
                memo.WriteOff = writeoff;
            }
            else if (projectId.ToLower().IndexOf("majorlease") >= 0)
            {
                var mjrInfo = new MajorLeaseInfo().GetMajorLeaseInfo(projectId);
                memo.ReopenDate = mjrInfo.ReopenDate;
                memo.Store      = StoreBasicInfo.GetStore(mjrInfo.USCode);
                var consInfo = new MajorLeaseConsInfo().GetConsInfo(projectId);
                var rein     = ReinvestmentBasicInfo.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentBasicInfo();
                memo.ReinvestInfo = rein;
                var recos = ReinvestmentCost.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentCost();
                memo.TotalReinvestmentBudget = recos.TotalReinvestmentBudget;
                if (!memo.ReopenDate.HasValue)
                {
                    memo.ReopenDate = memo.ReinvestInfo.ReopenDate;
                }
                if (!memo.GBDate.HasValue)
                {
                    memo.GBDate = memo.ReinvestInfo.GBDate;
                }
                var gbMemo = MajorLeaseGBMemo.GetGBMemo(projectId);
                if (!memo.CompletionDate.HasValue && gbMemo != null)
                {
                    memo.CompletionDate = gbMemo.ConstCompletionDate;
                }
                //if (string.IsNullOrEmpty(memo.DesignConcept))
                //    memo.DesignConcept = memo.ReinvestInfo.NewDesignType;
                var writeoff = WriteOffAmount.GetByConsInfoId(consInfo.Id) ?? new WriteOffAmount();
                memo.WriteOff = writeoff;
            }
            else if (projectId.ToLower().IndexOf("renewal") >= 0)
            {
                var renewalInfo = RenewalInfo.Get(projectId);
                memo.ReopenDate = renewalInfo.NewLeaseStartDate;
                memo.Store      = StoreBasicInfo.GetStore(renewalInfo.USCode);
                var consInfo = RenewalConsInfo.Get(projectId);
                var rein     = ReinvestmentBasicInfo.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentBasicInfo();
                memo.ReinvestInfo = rein;
                var recos = ReinvestmentCost.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentCost();
                memo.TotalReinvestmentBudget = recos.TotalReinvestmentBudget;
                if (!memo.ReopenDate.HasValue)
                {
                    memo.ReopenDate = memo.ReinvestInfo.ReopenDate;
                }
                if (!memo.GBDate.HasValue)
                {
                    memo.GBDate = memo.ReinvestInfo.GBDate;
                }
                var gbMemo = RenewalGBMemo.GetGBMemo(projectId);
                if (!memo.CompletionDate.HasValue && gbMemo != null)
                {
                    memo.CompletionDate = gbMemo.ConstCompletionDate;
                }
                //if (string.IsNullOrEmpty(memo.DesignConcept))
                //    memo.DesignConcept = memo.ReinvestInfo.NewDesignType;
                var writeoff = WriteOffAmount.GetByConsInfoId(consInfo.Id) ?? new WriteOffAmount();
                memo.WriteOff = writeoff;
            }
            if (isEmptyMemo)
            {
                if (memo.ReinvestInfo != null)
                {
                    if (memo.ReinvestInfo.NewMcCafe.HasValue && memo.ReinvestInfo.NewMcCafe.Value)
                    {
                        memo.NewMcCafe = true;
                    }
                    if ((memo.ReinvestInfo.NewAttachedKiosk.HasValue && memo.ReinvestInfo.NewAttachedKiosk.Value) ||
                        (memo.ReinvestInfo.NewRemoteKiosk.HasValue && memo.ReinvestInfo.NewRemoteKiosk.Value))
                    {
                        memo.NewKiosk = true;
                    }
                    if (memo.ReinvestInfo.NewMDS.HasValue && memo.ReinvestInfo.NewMDS.Value)
                    {
                        memo.NewMDS = true;
                    }
                    if (memo.ReinvestInfo.NewTwientyFourHour.HasValue && memo.ReinvestInfo.NewTwientyFourHour.Value)
                    {
                        memo.Is24H = true;
                    }
                    //if (!string.IsNullOrEmpty(memo.ReinvestInfo.NewOperationSize))
                    //{
                    //    memo.AftOperationSize = memo.ReinvestInfo.NewOperationSize;
                    //}
                    //if (!string.IsNullOrEmpty(memo.ReinvestInfo.EstimatedSeatNo))
                    //{
                    //    memo.AftARSN = memo.ReinvestInfo.EstimatedSeatNo;
                    //}
                }
                memo.TTMNetSales = GetTTFinanceData(memo.Store.StoreBasicInfo.StoreCode);
            }
            memo.PriceTiter = GetPriceTier(memo.Store.StoreBasicInfo.StoreCode);
            //if (string.IsNullOrEmpty(memo.AftARPT))
            //{
            //    memo.AftARPT = memo.PriceTiter;
            //}
            //if (memo.Store != null)
            //{
            //    memo.OriginalOperationSize = memo.Store.StoreSTLocation.TotalArea;
            //    memo.OriginalSeatNumber = memo.Store.StoreSTLocation.TotalSeatsNo;
            //}
            memo.YearMonthList = GetSelectYearMonth(memo.Store.StoreBasicInfo.StoreCode);
            if (isEmptyMemo)
            {
                SaveReopenMemo(memo);
            }
            return(memo);
        }