Beispiel #1
0
        public string GeneratePackageTask(string projectId)
        {
            if (!TaskWork.Any(i => i.RefID == projectId && i.TypeCode == FlowCode.Closure_ClosurePackage && i.Status == TaskWorkStatus.UnFinish))
            {
                var taskWork = new TaskWork();
                taskWork.SourceCode        = FlowCode.Closure;
                taskWork.SourceNameENUS    = taskWork.SourceCode;
                taskWork.SourceNameZHCN    = "关店流程";
                taskWork.Status            = TaskWorkStatus.UnFinish;
                taskWork.StatusNameZHCN    = "任务";
                taskWork.StatusNameENUS    = "任务";
                taskWork.RefID             = projectId;
                taskWork.Id                = Guid.NewGuid();
                taskWork.CreateTime        = DateTime.Now;
                taskWork.CreateUserAccount = ClientCookie.UserCode;

                var closureInfo = ClosureInfo.GetByProjectId(projectId);

                taskWork.Title            = TaskWork.BuildTitle(projectId, closureInfo.StoreNameZHCN, closureInfo.StoreNameENUS);
                taskWork.TypeCode         = WorkflowCode;
                taskWork.TypeNameENUS     = "ClosurePackage";
                taskWork.TypeNameZHCN     = "ClosurePackage";
                taskWork.ReceiverAccount  = closureInfo.AssetActorAccount;
                taskWork.ReceiverNameENUS = closureInfo.AssetActorNameENUS;
                taskWork.ReceiverNameZHCN = closureInfo.AssetActorNameZHCN;
                taskWork.ActivityName     = "Start";
                taskWork.Url       = string.Format(@"/Closure/Main#/ClosurePackage?projectId={0}", projectId);
                taskWork.StoreCode = closureInfo.USCode;

                TaskWork.Add(taskWork);
                return(taskWork.Url);
            }
            return("");
        }
Beispiel #2
0
        public static RenewalPackageDTO InitPage(string projectId, string id = null)
        {
            RenewalPackageDTO dto = new RenewalPackageDTO();
            var entity            = RenewalPackage.Get(projectId, id);
            var project           = ProjectInfo.Get(projectId, FlowCode.Renewal_Package);
            var info = RenewalInfo.Get(projectId);

            entity.IsProjectFreezed = entity.CheckIfFreezeProject(projectId);
            entity.GenerateCover();
            var haveTask       = TaskWork.Any(t => t.RefID == projectId && t.TypeCode == FlowCode.Renewal_Package && t.Status == TaskWorkStatus.UnFinish && t.ReceiverAccount == ClientCookie.UserCode);
            var projectComment = ProjectComment.GetSavedComment(entity.Id, "RenewalPackage", ClientCookie.UserCode);
            var projectNode    = NodeInfo.GetNodeInfo(project.NodeCode);

            dto.Info             = info;
            dto.Entity           = entity;
            dto.Analysis         = RenewalAnalysis.Get(entity.AnalysisId.Value);
            dto.FinMeasureOutput = RenewalToolFinMeasureOutput.GetByToolId(entity.ToolId.Value);
            dto.Uploadable       = projectNode.Sequence >= 4 && ClientCookie.UserCode == dto.Info.AssetActorAccount;
            var editStatuses = new[] { ProjectStatus.Finished, ProjectStatus.Rejected };

            dto.ProjectComment = projectComment != null ? projectComment.Content : "";
            dto.Editable       = ProjectInfo.IsFlowEditable(projectId, FlowCode.Renewal_Package);
            dto.Recallable     = ProjectInfo.IsFlowRecallable(projectId, FlowCode.Renewal_Package);
            dto.Savable        = ProjectInfo.IsFlowSavable(projectId, FlowCode.Renewal_Package) && string.IsNullOrEmpty(id);
            if (entity.ProcInstId.HasValue)
            {
                var currentActivityName = K2FxContext.Current.GetCurrentActivityName(entity.ProcInstId.Value);
                dto.Rejectable = !entity.WorkflowNormalActors.Contains(currentActivityName);
            }
            dto.IsLindaLu = string.Compare(ClientCookie.UserCode, ConfigurationManager.AppSettings["AssetMgrCode"], true) == 0;
            return(dto);
        }
Beispiel #3
0
        public static ConsInfoDTO <RenewalInfo, RenewalConsInfo> InitPage(string projectId, string id = "")
        {
            RenewalInfo info     = RenewalInfo.Get(projectId);
            var         consInfo = RenewalConsInfo.Get(projectId, id);

            if (consInfo == null)
            {
                consInfo           = new RenewalConsInfo();
                consInfo.ProjectId = projectId;
            }
            var isOriginator = ClientCookie.UserCode == info.PMAccount;

            consInfo.IsProjectFreezed = consInfo.CheckIfFreezeProject(projectId);
            var nextRefTableId  = new Guid(FlowInfo.GetRefTableId("RenewalTool", projectId));
            var nextFlowStarted = ProjectInfo.IsFlowStarted(projectId, FlowCode.Renewal_Tool);
            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(consInfo.Id, "RenewalConsInfo", ClientCookie.UserCode);

            if (string.IsNullOrEmpty(id))
            {
                consInfo.HasReinvenstment = info.NeedProjectCostEst;
            }
            ConsInfoDTO <RenewalInfo, RenewalConsInfo> dto = new ConsInfoDTO <RenewalInfo, RenewalConsInfo>();

            dto.Entity         = consInfo;
            dto.Info           = info;
            dto.ReinBasicInfo  = ReinvestmentBasicInfo.GetByConsInfoId(consInfo.Id);
            dto.ReinCost       = ReinvestmentCost.GetByConsInfoId(consInfo.Id);
            dto.WriteOff       = WriteOffAmount.GetByConsInfoId(consInfo.Id);
            dto.ProjectComment = projectComment != null ? projectComment.Content : "";
            dto.Editable       = ProjectInfo.IsFlowEditable(projectId, FlowCode.Renewal_ConsInfo);
            dto.Recallable     = ProjectInfo.IsFlowRecallable(projectId, FlowCode.Renewal_ConsInfo);
            dto.Savable        = ProjectInfo.IsFlowSavable(projectId, FlowCode.Renewal_ConsInfo) && string.IsNullOrEmpty(id);
            return(dto);
        }
Beispiel #4
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();
            }
        }
Beispiel #5
0
        public static bool IsFlowSavable(string projectId, string flowCode)
        {
            switch (flowCode)
            {
            /*客户需求以及不进流程的Renwal子项目在只读页面是否能保存*/
            case FlowCodeRef.Renewal_LLNegotiation:    //客户需求
                //case FlowCodeRef.Renewal_Analysis:
                //case FlowCodeRef.Renewal_ClearanceReport:
                //case FlowCodeRef.Renewal_ConfirmLetter:
                return(!ProjectInfo.IsFlowStarted(projectId, FlowCodeRef.Renewal_Package) &&
                       ProjectInfo.IsOriginator(projectId, flowCode, ClientCookie.UserCode));

            /*进流程的子项目在只读页面是否能保存*/
            default:
                return(!TaskWork.Any(t => t.RefID == projectId && t.TypeCode == flowCode) &&
                       !ProjectInfo.IsFlowFinished(projectId, flowCode) &&
                       ProjectInfo.IsOriginator(projectId, flowCode, ClientCookie.UserCode));
            }
        }
        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);
                }
            }
        }
        public static RenewalLegalApprovalDTO InitPage(string projectId, string id = null)
        {
            RenewalLegalApprovalDTO dto = new RenewalLegalApprovalDTO();
            var entity  = Get(projectId, id);
            var info    = RenewalInfo.Get(projectId);
            var isActor = ClientCookie.UserCode == info.AssetActorAccount;

            entity.IsProjectFreezed = entity.CheckIfFreezeProject(projectId);
            var nextRefTableId  = new Guid(FlowInfo.GetRefTableId(entity.TableName, projectId));
            var nextFlowStarted = ProjectInfo.IsFlowStarted(projectId, FlowCode.Renewal_Package);
            var haveTask        = TaskWork.Any(t => t.RefID == projectId && t.TypeCode == FlowCode.Renewal_LegalApproval && t.Status == TaskWorkStatus.UnFinish && t.ReceiverAccount == ClientCookie.UserCode);
            var projectComment  = ProjectComment.GetSavedComment(entity.Id, entity.TableName, ClientCookie.UserCode);
            var appUser         = ApproveDialogUser.GetApproveDialogUser(entity.Id.ToString());

            dto.Info             = info;
            dto.Entity           = entity;
            dto.ProjectComment   = projectComment != null ? projectComment.Content : "";
            dto.IsGeneralCounsel = appUser != null && appUser.GeneralCounselCode == ClientCookie.UserCode;
            dto.Editable         = ProjectInfo.IsFlowEditable(projectId, FlowCode.Renewal_LegalApproval);
            dto.Recallable       = ProjectInfo.IsFlowRecallable(projectId, FlowCode.Renewal_LegalApproval);
            dto.Savable          = ProjectInfo.IsFlowSavable(projectId, FlowCode.Renewal_LegalApproval) && string.IsNullOrEmpty(id);
            return(dto);
        }
Beispiel #8
0
        public void GenerateClourseMemoTask(string projectId)
        {
            if (!TaskWork.Any(t => t.RefID == projectId && t.TypeCode == FlowCode.Closure_Memo))
            {
                var taskWork = new TaskWork();
                taskWork.SourceCode     = FlowCode.Closure;
                taskWork.SourceNameENUS = taskWork.SourceCode;
                taskWork.SourceNameZHCN = "关店流程";
                taskWork.Status         = TaskWorkStatus.UnFinish;
                taskWork.StatusNameZHCN = "任务";
                taskWork.StatusNameENUS = "任务";
                taskWork.RefID          = projectId;
                taskWork.Id             = Guid.NewGuid();
                taskWork.CreateTime     = DateTime.Now;

                var closureInfo = ClosureInfo.GetByProjectId(projectId);

                taskWork.Title            = TaskWork.BuildTitle(projectId, closureInfo.StoreNameZHCN, closureInfo.StoreNameENUS);
                taskWork.TypeCode         = FlowCode.Closure_Memo;
                taskWork.TypeNameENUS     = "Closure Memo";
                taskWork.TypeNameZHCN     = "Closure Memo";
                taskWork.ReceiverAccount  = closureInfo.AssetActorAccount;
                taskWork.ReceiverNameENUS = closureInfo.AssetActorNameENUS;
                taskWork.ReceiverNameZHCN = closureInfo.AssetActorNameZHCN;
                taskWork.Url          = string.Format(@"/Closure/Main#/ClosureMemo?projectId={0}", projectId);
                taskWork.ActivityName = "Start";
                taskWork.StoreCode    = closureInfo.USCode;

                //TaskWork.Add(taskWork);
                //关店前7天发起Memo流程
                if (closureInfo.ActualCloseDate.HasValue)
                {
                    ScheduleLog.GenerateTaskSchedule(closureInfo.ActualCloseDate.Value.AddDays(-7), taskWork, ClientCookie.UserCode, projectId, FlowCode.Closure_Memo, closureInfo.USCode);
                }
            }
        }
Beispiel #9
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);
        }
Beispiel #10
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);
        }
Beispiel #11
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);
        }
Beispiel #12
0
 public static bool IsFlowRecallable(string projectId, string flowCode)
 {
     return(Any(p => p.ProjectId == projectId && p.FlowCode == flowCode && p.NodeCode != Constants.NodeCode.Start && p.Status != ProjectStatus.Rejected && p.Status != ProjectStatus.Finished) &&
            TaskWork.Any(e => e.ActivityName != "Start" && e.RefID == projectId && e.TypeCode == flowCode) &&
            ProjectInfo.IsOriginator(projectId, flowCode, ClientCookie.UserCode));
 }
Beispiel #13
0
 public static bool IsFlowHasStarted(string strProjectId, string strFlowCode)
 {
     return(Any(p => p.ProjectId == strProjectId && p.FlowCode == strFlowCode && p.NodeCode != Constants.NodeCode.Start) &&
            TaskWork.Any(e => e.ActivityName != "Start" && e.RefID == strProjectId && e.TypeCode == strFlowCode));
 }
Beispiel #14
0
        public void UpdateFromProjectList()
        {
            using (TransactionScope tranScope = new TransactionScope())
            {
                var oldInfo  = RenewalInfo.Get(this.ProjectId);
                var consInfo = RenewalConsInfo.Get(this.ProjectId);
                var analysis = RenewalAnalysis.Get(this.ProjectId);
                analysis.LeaseTenureAndTerm = string.Format("{0} years,from {1:yyyy-MM-dd} to {2:yyyy-MM-dd}", this.RenewalYears, this.NewLeaseStartDate, this.NewLeaseEndDate);
                analysis.Update();
                if (oldInfo.NeedProjectCostEst != this.NeedProjectCostEst)
                {
                    consInfo.HasReinvenstment = this.NeedProjectCostEst;
                    consInfo.Update();
                    if (ProjectInfo.IsFlowFinished(this.ProjectId, FlowCode.Renewal_Letter) &&
                        ProjectInfo.IsFlowFinished(this.ProjectId, FlowCode.Renewal_LLNegotiation))
                    {
                        if (!this.NeedProjectCostEst)
                        {
                            TaskWork.Cancel(e => e.RefID == this.ProjectId && e.Status == TaskWorkStatus.UnFinish && e.TypeCode == FlowCode.Renewal_ConsInfo);
                            ProjectInfo.FinishProject(this.ProjectId, FlowCode.Renewal_ConsInfo);
                            if (!ProjectInfo.IsFlowFinished(this.ProjectId, FlowCode.Renewal_Tool))
                            {
                                if (!TaskWork.Any(e => e.RefID == this.ProjectId && e.Status == TaskWorkStatus.UnFinish && e.TypeCode == FlowCode.Renewal_Tool))
                                {
                                    GenerateSubmitTask(FlowCode.Renewal_Tool);
                                }
                            }
                        }
                        else
                        {
                            ProjectInfo.Reset(this.ProjectId, FlowCode.Renewal_ConsInfo);

                            GenerateSubmitTask(FlowCode.Renewal_ConsInfo);
                            if (!ProjectInfo.IsFlowFinished(this.ProjectId, FlowCode.Renewal_Tool))
                            {
                                TaskWork.Cancel(e => e.RefID == this.ProjectId && e.TypeCode == FlowCode.Renewal_Tool && e.Status == TaskWorkStatus.UnFinish);
                                ProjectInfo.Reset(this.ProjectId, FlowCode.Renewal_Tool);
                            }
                        }
                    }
                }

                if (oldInfo.RenewalYears != this.RenewalYears)
                {
                    if (ProjectInfo.IsFlowFinished(ProjectId, FlowCode.Renewal_Analysis))
                    {
                        if (this.RenewalYears <= 2)
                        {
                            TaskWork.Finish(e => e.RefID == this.ProjectId && e.Status == TaskWorkStatus.UnFinish && e.TypeCode == FlowCode.Renewal_ClearanceReport);
                            ProjectInfo.FinishProject(this.ProjectId, FlowCode.Renewal_ClearanceReport);
                        }
                        else
                        {
                            if (!TaskWork.Any(e => e.RefID == ProjectId && e.TypeCode == FlowCode.Renewal_ClearanceReport && e.Status == TaskWorkStatus.UnFinish))
                            {
                                GenerateSubmitTask(FlowCode.Renewal_ClearanceReport);
                            }
                        }
                    }
                }
                this.Update();
                tranScope.Complete();
            }
        }
Beispiel #15
0
        public override void Finish(TaskWorkStatus status, TaskWork task)
        {
            switch (status)
            {
            case TaskWorkStatus.K2ProcessDeclined:
                ProjectInfo.UpdateProjectStatus(ProjectId, FlowCode.Closure, ProjectStatus.Rejected);
                //删除未处理完成的任务
                var oldTask = TaskWork.Search(i => i.SourceCode == FlowCode.Closure && i.RefID == this.ProjectId && i.Status == TaskWorkStatus.UnFinish).ToArray();
                foreach (var taskItem in oldTask)
                {
                    taskItem.Status = TaskWorkStatus.Cancel;
                }
                TaskWork.Update(oldTask);
                ProjectInfo.UpdateProjectStatus(ProjectId, FlowCode.Closure_ClosurePackage, ProjectStatus.Rejected);
                break;

            case TaskWorkStatus.K2ProcessApproved:
                //ClosurePackage的最后一步在K2中,但不属于审批
                task.ActionName = "";
                task.Update();

                ProjectInfo.FinishNode(this.ProjectId, FlowCode.Closure_ClosurePackage, NodeCode.Closure_ClosurePackage_ResourceUpload, ProjectStatus.Finished);
                //Package流程走完后,在Actor处生成一条任务,供Actor上传Signed Termination Agreement与Signed Package
                //GenerateSignedPackageTask(ProjectId);

                if (!TaskWork.Any(i => i.RefID == this.ProjectId && i.SourceCode == FlowCode.Closure && i.TypeCode == FlowCode.Closure_ContractInfo && i.Status != TaskWorkStatus.Cancel))
                {
                    TaskWork taskWorkContractInfo = new TaskWork();
                    taskWorkContractInfo.SourceCode     = FlowCode.Closure;
                    taskWorkContractInfo.SourceNameENUS = FlowCode.Closure;
                    taskWorkContractInfo.SourceNameZHCN = "关店流程";
                    taskWorkContractInfo.Status         = TaskWorkStatus.UnFinish;
                    taskWorkContractInfo.StatusNameZHCN = "任务";
                    taskWorkContractInfo.StatusNameENUS = "任务";
                    taskWorkContractInfo.RefID          = ProjectId;
                    taskWorkContractInfo.Id             = Guid.NewGuid();
                    taskWorkContractInfo.CreateTime     = DateTime.Now;

                    //ClosureInfo closure = new ClosureInfo();
                    var closureInfo = ClosureInfo.GetByProjectId(ProjectId);

                    taskWorkContractInfo.Title            = TaskWork.BuildTitle(ProjectId, closureInfo.StoreNameZHCN, closureInfo.StoreNameENUS);
                    taskWorkContractInfo.TypeCode         = FlowCode.Closure_ContractInfo;
                    taskWorkContractInfo.TypeNameENUS     = "ContractInfo";
                    taskWorkContractInfo.TypeNameZHCN     = "ContractInfo";
                    taskWorkContractInfo.ReceiverAccount  = closureInfo.AssetActorAccount;
                    taskWorkContractInfo.ReceiverNameENUS = closureInfo.AssetActorNameENUS;
                    taskWorkContractInfo.ReceiverNameZHCN = closureInfo.AssetActorNameZHCN;
                    taskWorkContractInfo.Url          = SiteInfo.GetProjectHandlerPageUrl(FlowCode.Closure_ContractInfo, closureInfo.ProjectId);
                    taskWorkContractInfo.StoreCode    = closureInfo.USCode;
                    taskWorkContractInfo.ActivityName = "Start";
                    taskWorkContractInfo.Add();
                }

                //为了方便测试,暂时做成Package走完立刻生成ConsInvtChecking和ClourseMemo
                //var consInvtChecking = new ClosureConsInvtChecking();
                //consInvtChecking.GenerateConsInvtCheckingTask(ProjectId);
                var memo = new ClosureMemo();
                memo.GenerateClourseMemoTask(ProjectId);

                //如果是Complete了的流程,Edit后流程走完需要重新把主流程状态改成Complete
                ProjectInfo.CompleteMainIfEnable(ProjectId);
                break;
            }
        }