Ejemplo n.º 1
0
        public static void SendRemind(string strProjectId, string strFlowCode, List <ProjectUsers> remindUsers)
        {
            var projectInfo = ProjectInfo.FirstOrDefault(e => e.FlowCode == strFlowCode &&
                                                         e.ProjectId == strProjectId);

            if (projectInfo != null)
            {
                var store = StoreBasicInfo.FirstOrDefault(e => e.StoreCode == projectInfo.USCode);

                var employee = Employee.GetEmployeeByCode(projectInfo.CreateUserAccount);

                if (store != null &&
                    employee != null)
                {
                    var remind = new Remind();
                    remind.SenderAccount  = employee.Code;
                    remind.SenderNameENUS = employee.NameENUS;
                    remind.SenderNameZHCN = employee.NameZHCN;
                    remind.Title          = string.Format("【{0} {1} ({2})】{3}流程已创建", projectInfo.USCode, store.NameZHCN, store.NameENUS, strFlowCode);
                    remind.Url            = string.Format("/Home/Main#/project/detail/{0}?flowCode={1}", strProjectId, strFlowCode);
                    remind.RegisterCode   = strFlowCode;
                    remind.IsReaded       = false;
                    PostRemaindList(remind, remindUsers);
                }
            }
        }
Ejemplo n.º 2
0
        public override void Finish(TaskWorkStatus status, TaskWork task)
        {
            var info = RenewalInfo.Get(this.ProjectId);

            switch (status)
            {
            case TaskWorkStatus.K2ProcessApproved:
            {
                using (TransactionScope tranScope = new TransactionScope())
                {
                    ProjectProgress.SetProgress(ProjectId, "40%");
                    ProjectInfo.FinishNode(ProjectId, this.WorkflowCode, NodeCode.Finish);
                    var anlysisProj = ProjectInfo.FirstOrDefault(e => e.FlowCode == FlowCode.Renewal_Analysis &&
                                                                 e.Status == ProjectStatus.UnFinish && e.ProjectId == ProjectId);
                    if (anlysisProj != null)
                    {
                        info.GenerateSubmitTask(FlowCode.Renewal_Analysis);
                    }
                    else
                    {
                        //Renewal Tool重新Edit并完成后,系统自动重新生成一次Renewal Analysis文件
                        var anlysis = RenewalAnalysis.Get(ProjectId);
                        if (anlysis != null)
                        {
                            anlysis.GenerateAttachment();
                        }
                    }
                    tranScope.Complete();
                }
            }
            break;
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
0
        protected override void UpdateProjectTaskUser(TaskWork taskWork, ProjectTeamMembers projectTeamMembers)
        {
            var projectInfo = ProjectInfo.FirstOrDefault(e => e.FlowCode == taskWork.TypeCode &&
                                                         e.ProjectId == taskWork.RefID);

            if (projectInfo != null)
            {
                switch (taskWork.TypeCode)
                {
                case FlowCode.MajorLease_Package:
                case FlowCode.MajorLease_LegalReview:
                    if (projectTeamMembers.AssetActor != null)
                    {
                        taskWork.ReceiverAccount  = projectTeamMembers.AssetActor.UserAccount;
                        taskWork.ReceiverNameENUS = projectTeamMembers.AssetActor.UserNameENUS;
                        taskWork.ReceiverNameZHCN = projectTeamMembers.AssetActor.UserNameZHCN;

                        projectInfo.CreateUserAccount = projectTeamMembers.AssetActor.UserAccount;
                    }
                    break;

                case FlowCode.MajorLease_FinanceAnalysis:
                    taskWork.ReceiverAccount  = projectTeamMembers.Finance.UserAccount;
                    taskWork.ReceiverNameENUS = projectTeamMembers.Finance.UserNameENUS;
                    taskWork.ReceiverNameZHCN = projectTeamMembers.Finance.UserNameZHCN;

                    projectInfo.CreateUserAccount = projectTeamMembers.Finance.UserAccount;
                    break;

                case FlowCode.MajorLease_ConsInvtChecking:
                case FlowCode.MajorLease_ConsInfo:
                    taskWork.ReceiverAccount  = projectTeamMembers.PM.UserAccount;
                    taskWork.ReceiverNameENUS = projectTeamMembers.PM.UserNameENUS;
                    taskWork.ReceiverNameZHCN = projectTeamMembers.PM.UserNameZHCN;

                    projectInfo.CreateUserAccount = projectTeamMembers.PM.UserAccount;
                    break;
                }

                ProjectInfo.Update(projectInfo);
            }
        }
Ejemplo n.º 5
0
        public static RenewalGBMemo 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 RenewalGBMemo();

            memo.ProjectId = projectId;

            var rnInfo = RenewalInfo.Get(projectId);

            memo.Info   = rnInfo;
            memo.UsCode = rnInfo.USCode;

            memo.Store = StoreBasicInfo.GetStore(memo.UsCode);

            if (memo.Id == Guid.Empty)
            {
                memo.IsClosed      = (memo.Store.StoreBasicInfo.statusName == "Closed");
                memo.IsInOperation = false;
                var consInfo = new RenewalConsInfo();
                memo.ReinvestInfo = consInfo.GetReinvestmentBasicInfo(projectId);
                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.Renewal_GBMemo);

                if (projectInfo != null)
                {
                    if (ClientCookie.UserCode.Equals(rnInfo.PMAccount))
                    {
                        var isFlowFlinshed =
                            TaskWork.Any(e =>
                                         e.RefID == projectId && e.TypeCode == FlowCode.Renewal_GBMemo &&
                                         e.Status == TaskWorkStatus.K2ProcessApproved && e.ProcInstID == memo.ProcInstID);
                        var isExistTask = TaskWork.Any(e => e.RefID == projectId &&
                                                       e.TypeCode == FlowCode.Renewal_GBMemo &&
                                                       e.Status == TaskWorkStatus.UnFinish &&
                                                       e.ReceiverAccount == ClientCookie.UserCode &&
                                                       (e.ActivityName == WFMajorLeaseLegalReview.Act_Originator || e.ActivityName == WFMajorLeaseLegalReview.Act_Start));
                        memo.IsShowEdit   = isFlowFlinshed;
                        memo.IsShowRecall = !isFlowFlinshed && !isExistTask;
                    }
                }
            }
            //if (ClientCookie.UserCode.Equals(rnInfo.PMAccount))
            //    memo.IsShowSave = ProjectInfo.IsFlowSavable(projectId, FlowCode.Renewal_GBMemo);
            PopulateAppUsers(memo);
            return(memo);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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();
            }
        }
Ejemplo n.º 8
0
        public override string Edit()
        {
            string url;

            using (var tranScope = new TransactionScope())
            {
                var info = RenewalInfo.Get(this.ProjectId);
                var tool = Duplicator.AutoCopy(this);
                tool.Id                = Guid.NewGuid();
                tool.IsHistory         = false;
                tool.CreateTime        = DateTime.Now;
                tool.CreateUserAccount = ClientCookie.UserCode;
                tool.Add();

                NewEntityId = tool.Id;
                IsHistory   = true;
                this.Update();
                ProjectInfo.Reset(ProjectId, this.WorkflowCode);
                var attachments = Attachment.GetList(this.TableName, Id.ToString(), string.Empty);
                attachments.ForEach(att =>
                {
                    att.RefTableID = tool.Id.ToString();
                    att.ID         = Guid.NewGuid();
                });
                Attachment.Add(attachments.ToArray());

                var FinMI    = RenewalToolFinMeasureInput.Get(this.ProjectId, this.Id);
                var newFinMI = Duplicator.AutoCopy(FinMI);
                newFinMI.Id     = Guid.NewGuid();
                newFinMI.ToolId = tool.Id;
                newFinMI.Add();

                var WfRc    = RenewalToolWriteOffAndReinCost.Get(this.ProjectId, this.Id);
                var newWfRc = Duplicator.AutoCopy(WfRc);
                newWfRc.Id     = Guid.NewGuid();
                newWfRc.ToolId = tool.Id;
                newWfRc.Add();

                var FinMO    = RenewalToolFinMeasureOutput.GetByToolId(this.Id);
                var newFinMO = Duplicator.AutoCopy(FinMO);
                newFinMO.Id     = Guid.NewGuid();
                newFinMO.ToolId = tool.Id;
                newFinMO.Add();

                var package = RenewalPackage.Get(this.ProjectId);
                package.ToolId = tool.Id;
                package.Update();

                var oldTasks = TaskWork.Search(t => t.RefID == ProjectId && t.Status == TaskWorkStatus.UnFinish && new string[] { this.WorkflowCode, FlowCode.Renewal_Analysis }.Contains(t.TypeCode)).ToList();
                oldTasks.ForEach(t =>
                {
                    t.Status = TaskWorkStatus.Cancel;
                });
                TaskWork.Update(oldTasks.ToArray());

                var anlysisProj = ProjectInfo.FirstOrDefault(e => e.FlowCode == FlowCode.Renewal_Analysis &&
                                                             e.Status == ProjectStatus.UnFinish && e.ProjectId == ProjectId);
                if (anlysisProj != null)
                {
                    var taskAnlysis = TaskWork.FirstOrDefault(e => e.TypeCode == FlowCode.Renewal_Analysis && e.RefID == ProjectId && e.Status == TaskWorkStatus.UnFinish);
                    if (taskAnlysis != null)
                    {
                        taskAnlysis.Status     = TaskWorkStatus.Finished;
                        taskAnlysis.FinishTime = DateTime.Now;
                        taskAnlysis.Update();
                    }
                }
                var task = info.GenerateSubmitTask(this.WorkflowCode);
                url = task.Url;
                tranScope.Complete();
            }

            return(url);
        }
Ejemplo n.º 9
0
        public static RenewalToolDTO InitPage(string projectId, string id = null)
        {
            RenewalToolDTO dto       = new RenewalToolDTO();
            var            tool      = RenewalTool.Get(projectId, id);
            var            project   = ProjectInfo.Get(projectId, FlowCode.Renewal_Tool);
            var            info      = RenewalInfo.Get(projectId);
            var            isFinance = ClientCookie.UserCode == info.FinanceAccount;

            tool.IsProjectFreezed = tool.CheckIfFreezeProject(projectId);
            var    nextRefTableId    = new Guid(FlowInfo.GetRefTableId("RenewalAnalysis", projectId));
            var    nextFlowStarted   = ProjectInfo.IsFlowStarted(projectId, FlowCode.Renewal_Analysis);
            var    haveTask          = TaskWork.Any(t => t.RefID == projectId && t.TypeCode == FlowCode.Renewal_Tool && t.Status == TaskWorkStatus.UnFinish && t.ReceiverAccount == ClientCookie.UserCode);
            var    projectComment    = ProjectComment.GetSavedComment(tool.Id, "RenewalTool", ClientCookie.UserCode);
            var    projectNode       = NodeInfo.GetNodeInfo(project.NodeCode);
            var    packageStarted    = ProjectInfo.IsFlowStarted(projectId, FlowCode.Renewal_Package);
            string selectedYearMonth = null;

            dto.Info              = info;
            dto.Entity            = tool;
            dto.TTMDataYearMonths = RenewalToolFinMeasureInput.GetYearMonths(projectId, out selectedYearMonth);
            dto.FinMeasureInput   = RenewalToolFinMeasureInput.Get(projectId, dto.Entity.Id);
            if (string.IsNullOrEmpty(dto.FinMeasureInput.FinanceYear) || string.IsNullOrEmpty(dto.FinMeasureInput.FinanceMonth))
            {
                var ym = selectedYearMonth.Split('-');
                dto.FinMeasureInput.FinanceYear  = ym[0];
                dto.FinMeasureInput.FinanceMonth = ym[1];
            }
            dto.FinMeasureInput.FinanceDataYearMonth = dto.FinMeasureInput.FinanceYear + "-" + dto.FinMeasureInput.FinanceMonth;
            //dto.FinMeasureInput.ContributionMargin = StoreCM.Get(dto.Info.USCode).ContributionMargin;
            McdAMEntities amdb  = new McdAMEntities();
            var           finfo = amdb.DataSync_LDW_AM_STFinanceData2.FirstOrDefault(f => f.UsCode == dto.Info.USCode &&
                                                                                     f.FinanceYear == dto.FinMeasureInput.FinanceYear && f.FinanceMonth == dto.FinMeasureInput.FinanceMonth);
            decimal cm = 0;

            if (finfo != null && !string.IsNullOrEmpty(finfo.contribution_marginPct))
            {
                cm = decimal.Parse(finfo.contribution_marginPct);
            }
            dto.FinMeasureInput.ContributionMargin = cm;
            var coninfo = RenewalConsInfo.FirstOrDefault(e => e.ProjectId == projectId && !e.IsHistory);
            var conProj = ProjectInfo.FirstOrDefault(e => e.ProjectId == projectId && e.FlowCode == "Renewal_ConsInfo");

            dto.WriteOffAndReinCost = RenewalToolWriteOffAndReinCost.Get(projectId, dto.Entity.Id, projectNode);
            if (coninfo != null && !coninfo.HasReinvenstment)
            {
                dto.WriteOffAndReinCost.REWriteOff   = null;
                dto.WriteOffAndReinCost.LHIWriteOff  = null;
                dto.WriteOffAndReinCost.ESSDWriteOff = null;
                dto.WriteOffAndReinCost.ESSDWriteOff = null;
                dto.WriteOffAndReinCost.RECost       = null;
                dto.WriteOffAndReinCost.LHICost      = null;
                dto.WriteOffAndReinCost.ESSDCost     = null;
            }

            dto.Uploadable     = projectNode.Sequence >= 3 && ClientCookie.UserCode == dto.Info.AssetActorAccount && !packageStarted;
            dto.ProjectComment = projectComment != null ? projectComment.Content : "";
            dto.Editable       = ProjectInfo.IsFlowEditable(projectId, FlowCode.Renewal_Tool);
            dto.Recallable     = ProjectInfo.IsFlowRecallable(projectId, FlowCode.Renewal_Tool);
            dto.Savable        = ProjectInfo.IsFlowSavable(projectId, FlowCode.Renewal_Tool) && string.IsNullOrEmpty(id);
            dto.IsFinished     =
                ProjectInfo.Any(
                    e =>
                    e.ProjectId == projectId && e.FlowCode == FlowCode.Renewal_Tool &&
                    e.Status == ProjectStatus.Finished);
            return(dto);
        }
Ejemplo n.º 10
0
        public override void Finish(TaskWorkStatus status, TaskWork task)
        {
            RenewalInfo info = RenewalInfo.Get(this.ProjectId);

            switch (status)
            {
            case TaskWorkStatus.K2ProcessApproved:
                //var toolUploadTask = TaskWork.FirstOrDefault(t => t.RefID == ProjectId
                //        && t.TypeCode == FlowCode.Renewal_Tool
                //        && t.ReceiverAccount == info.AssetActorAccount
                //        && t.ActivityName == "AssetActor"
                //        && t.Status == TaskWorkStatus.Cancel);
                //if (toolUploadTask != null)
                //{
                //    toolUploadTask.Status = TaskWorkStatus.UnFinish;
                //    toolUploadTask.Update();
                //}
                //else if (!ProjectInfo.IsFlowStarted(this.ProjectId, FlowCode.Renewal_Tool))
                //{
                //    info.GenerateSubmitTask(FlowCode.Renewal_Tool);
                //}
                var  tool = RenewalTool.Get(ProjectId);
                Guid entityId;
                var  toolProj = ProjectInfo.FirstOrDefault(e => e.Status == ProjectStatus.Finished && e.ProjectId == ProjectId && e.FlowCode == FlowCode.Renewal_Tool);
                if (toolProj != null)
                {
                    NoticeToActor(info.AssetActorAccount, info.USCode);
                    tool.Edit();
                    entityId = tool.NewEntityId;
                }
                else
                {
                    entityId = tool.Id;
                    ProjectInfo.Reset(this.ProjectId, FlowCode.Renewal_Tool);
                    info.GenerateSubmitTask(FlowCode.Renewal_Tool);
                }


                var entity = RenewalToolWriteOffAndReinCost.FirstOrDefault(w => w.ToolId == entityId);
                if (entity == null)
                {
                    entity        = new RenewalToolWriteOffAndReinCost();
                    entity.Id     = Guid.NewGuid();
                    entity.ToolId = tool.Id;
                    entity.Add();
                }
                var writeOffAmount = WriteOffAmount.GetByConsInfoId(this.Id);
                var reinCost       = ReinvestmentCost.GetByConsInfoId(this.Id);
                if (writeOffAmount != null)
                {
                    entity.REWriteOff   = DataConverter.ToDecimal(writeOffAmount.REWriteOff);
                    entity.LHIWriteOff  = DataConverter.ToDecimal(writeOffAmount.LHIWriteOff);
                    entity.ESSDWriteOff = DataConverter.ToDecimal(writeOffAmount.ESSDWriteOff);
                }
                else
                {
                    entity.REWriteOff   = 0;
                    entity.LHIWriteOff  = 0;
                    entity.ESSDWriteOff = 0;
                }
                if (reinCost != null)
                {
                    entity.RECost   = DataConverter.ToDecimal(reinCost.RECostNorm);
                    entity.LHICost  = DataConverter.ToDecimal(reinCost.LHINorm);
                    entity.ESSDCost = DataConverter.ToDecimal(reinCost.ESSDNorm);
                }
                else
                {
                    entity.RECost   = 0;
                    entity.LHICost  = 0;
                    entity.ESSDCost = 0;
                }
                Log4netHelper.WriteInfo(JsonConvert.SerializeObject(new { desc = "renewal tool info:", entityId, tool, writeOffAmount, reinCost, Id }));
                entity.Update();
                if (HasReinvenstment)
                {
                    ProjectInfo.FinishNode(this.ProjectId, this.WorkflowCode, NodeCode.Renewal_ConsInfo_Approval);
                }

                break;

            case TaskWorkStatus.K2ProcessDeclined:
                break;
            }
            task.Finish();
        }
Ejemplo n.º 11
0
        public void Submit(List <ProjectContractRevision> revisions, string flowCode)
        {
            revisions = revisions ?? new List <ProjectContractRevision>();
            using (TransactionScope tranScope = new TransactionScope())
            {
                StoreContractInfo       contractInfo = this.ToStoreContractInfo();
                ProjectContractRevision reInfo       = new ProjectContractRevision();
                #region 初始化项目的Revision信息
                reInfo.Id        = Guid.NewGuid();
                reInfo.ProjectId = this.ProjectId;
                Guid srId = Guid.NewGuid();
                reInfo.ProjectContractId   = this.Id;
                reInfo.RevisionId          = srId;
                reInfo.StoreContractInfoId = contractInfo.Id;
                reInfo.StoreID             = this.StoreId;
                reInfo.StoreCode           = this.StoreCode;
                reInfo.LeaseRecapID        = this.LeaseRecapID;
                reInfo.ChangeDate          = DateTime.Now;
                if (flowCode == FlowCode.MajorLease_ContractInfo)
                {
                    MajorLeaseInfo info = MajorLeaseInfo.Search(e => e.ProjectId == ProjectId).FirstOrDefault();
                    reInfo.Rent                 = info.ChangeRentalType.HasValue && info.ChangeRentalType.Value ? "Y" : null;
                    reInfo.Size                 = info.ChangeRedLineType.HasValue && info.ChangeRedLineType.Value ? "Y" : null;
                    reInfo.LeaseTerm            = info.ChangeLeaseTermType.HasValue && info.ChangeLeaseTermType.Value ? "Y" : null;
                    reInfo.Entity               = info.ChangeLandlordType.HasValue && info.ChangeLandlordType.Value ? "Y" : null;
                    reInfo.Others               = info.ChangeOtherType.HasValue && info.ChangeOtherType.Value ? "Y" : null;
                    reInfo.RentStructureOld     = info.OldRentalStructure;
                    reInfo.RentStructureNew     = info.NewRentalStructure;
                    reInfo.RedlineAreaOld       = info.OldChangeRedLineRedLineArea.HasValue ? info.OldChangeRedLineRedLineArea.ToString() : null;
                    reInfo.RedlineAreaNew       = info.NewChangeRedLineRedLineArea.HasValue ? info.NewChangeRedLineRedLineArea.ToString() : null;
                    reInfo.LeaseChangeExpiryOld = info.OldChangeLeaseTermExpiraryDate;
                    reInfo.LeaseChangeExpiryNew = info.NewChangeLeaseTermExpiraryDate;
                    reInfo.LandlordOld          = info.OldLandlord;
                    reInfo.LandlordNew          = info.NewLandlord;
                    reInfo.OthersDescription    = info.Others;
                    reInfo.Description          = info.LeaseChangeDescription;
                }
                else if (flowCode == FlowCode.Rebuild_ContractInfo)
                {
                    RebuildPackage info = RebuildPackage.GetRebuildPackageInfo(ProjectId);
                    reInfo.Rent                 = info.ChangeRentalType.HasValue && info.ChangeRentalType.Value ? "Y" : null;
                    reInfo.Size                 = info.ChangeRedLineType.HasValue && info.ChangeRedLineType.Value ? "Y" : null;
                    reInfo.LeaseTerm            = info.ChangeLeaseTermType.HasValue && info.ChangeLeaseTermType.Value ? "Y" : null;
                    reInfo.Entity               = info.ChangeLandlordType.HasValue && info.ChangeLandlordType.Value ? "Y" : null;
                    reInfo.Others               = info.ChangeOtherType.HasValue && info.ChangeOtherType.Value ? "Y" : null;
                    reInfo.RentStructureOld     = info.OldRentalStructure;
                    reInfo.RentStructureNew     = info.NewRentalStructure;
                    reInfo.RedlineAreaOld       = info.OldChangeRedLineRedLineArea.HasValue ? info.OldChangeRedLineRedLineArea.ToString() : null;
                    reInfo.RedlineAreaNew       = info.NewChangeRedLineRedLineArea.HasValue ? info.NewChangeRedLineRedLineArea.ToString() : null;
                    reInfo.LeaseChangeExpiryOld = info.OldChangeLeaseTermExpiraryDate;
                    reInfo.LeaseChangeExpiryNew = info.NewChangeLeaseTermExpiraryDate;
                    reInfo.LandlordOld          = info.OldLandlord;
                    reInfo.LandlordNew          = info.NewLandlord;
                    reInfo.OthersDescription    = info.Others;
                    reInfo.Description          = info.LeaseChangeDescription;
                }
                #endregion
                if (this.EditMode == "EDIT")
                {
                    if (flowCode == FlowCode.Closure_ContractInfo)
                    {
                        revisions = revisions.OrderBy(r => r.ChangeDate).ToList();
                        revisions.ForEach(r =>
                        {
                            var sr = r.ToStoreContractRevision();
                            sr.Save();
                            r.RevisionId = sr.Id;
                            //回写到ContractInfo中
                            if (sr.Rent == "Y")
                            {
                                this.RentStructure = sr.RentStructureNew;
                            }
                            if (sr.Size == "Y")
                            {
                                this.TotalLeasedArea = sr.RedlineAreaNew;
                            }
                            if (sr.LeaseTerm == "Y")
                            {
                                this.EndDate = sr.LeaseChangeExpiryNew;
                            }
                            if (sr.Entity == "Y")
                            {
                                this.PartyAFullName = sr.LandlordNew;
                            }
                        });
                        contractInfo = this.ToStoreContractInfo();
                        var sRIds = revisions.Select(e => e.RevisionId).ToList();
                        StoreContractRevision.Delete(e => e.StoreContractInfoId == contractInfo.Id && !sRIds.Contains(e.Id));
                        this.Save(revisions);
                    }
                    else
                    {
                        this.Save();
                        reInfo.Save();
                        var sr = reInfo.ToStoreContractRevision();
                        sr.Id = srId;
                        sr.Save();
                    }
                    contractInfo.Update();
                }
                else
                {
                    contractInfo.Id          = Guid.NewGuid();
                    contractInfo.CreatedTime = DateTime.Now;
                    contractInfo.Add();
                    this.ContractInfoId = contractInfo.Id;
                    if (Any(e => e.Id == this.Id))
                    {
                        this.Update();
                    }
                    else
                    {
                        this.Add();
                    }
                    //新增时不需要带入修订信息
                    ProjectContractRevision.Delete(r => r.ProjectContractId == this.Id);
                    //if (flowCode != FlowCode.Renewal_ContractInfo)
                    //{
                    //    reInfo.StoreContractInfoId = contractInfo.Id;
                    //    reInfo.Save();
                    //    var sr = reInfo.ToStoreContractRevision();
                    //    sr.Id = srId;
                    //    sr.Save();
                    //}
                }
                //关闭任务
                var task = TaskWork.FirstOrDefault(e => e.ReceiverAccount == ClientCookie.UserCode &&
                                                   e.TypeCode.Contains("ContractInfo") && e.RefID == this.ProjectId);
                if (task != null)
                {
                    task.Finish();
                }
                var projectInfo = ProjectInfo.FirstOrDefault(e => e.ProjectId == this.ProjectId && e.FlowCode.Contains("ContractInfo"));
                ProjectInfo.FinishNode(this.ProjectId, projectInfo.FlowCode, NodeCode.Finish, ProjectStatus.Finished);
                ProjectInfo.CompleteMainIfEnable(this.ProjectId);
                if (projectInfo.FlowCode == FlowCode.Renewal_ContractInfo)
                {
                    if (ProjectInfo.IsFlowFinished(ProjectId, FlowCode.Renewal_SiteInfo))
                    {
                        ProjectProgress.SetProgress(ProjectId, "100%");
                    }
                }

                tranScope.Complete();
            }
        }