Exemple #1
0
        public override void Finish(TaskWorkStatus status, TaskWork task)
        {
            var info = RenewalInfo.Get(ProjectId);

            switch (status)
            {
            case TaskWorkStatus.K2ProcessApproved:
                ProjectProgress.SetProgress(ProjectId, "70%");
                ProjectInfo.FinishNode(ProjectId, FlowCode.Renewal_ConfirmLetter, NodeCode.Finish, ProjectStatus.Finished);
                if (!ProjectInfo.IsFlowStarted(ProjectId, FlowCode.Renewal_LegalApproval))
                {
                    info.GenerateSubmitTask(FlowCode.Renewal_LegalApproval);
                }
                break;

            case TaskWorkStatus.K2ProcessDeclined:
                break;
            }
        }
        public void Submit()
        {
            var task = TaskWork.GetTaskWork(ProjectId, ClientCookie.UserCode, TaskWorkStatus.UnFinish,
                                            FlowCode.MajorLease, FlowCode.MajorLease_LegalReview);
            string taskUrl = "/MajorLease/Main#/LegalReview/Process/View?projectId=" + ProjectId;

            task.Url   = taskUrl;
            ProcInstID = StartProcess(task);
            using (var scope = new TransactionScope())
            {
                task.Status     = TaskWorkStatus.Finished;
                task.FinishTime = DateTime.Now;

                TaskWork.Update(task);

                Save("Submit");
                ProjectInfo.FinishNode(ProjectId, FlowCode.MajorLease_LegalReview, NodeCode.MajorLease_LegalReview_Input);
                scope.Complete();
            }
        }
Exemple #3
0
 public void Resubmit(string comment, string SerialNumber)
 {
     K2FxContext.Current.ApprovalProcess(SerialNumber, ClientCookie.UserCode, "Resubmit", comment);
     using (TransactionScope tranScope = new TransactionScope())
     {
         this.CreateUserAccount = ClientCookie.UserCode;
         this.Update();
         ProjectInfo.FinishNode(this.ProjectId, this.WorkflowCode, NodeCode.TempClosure_LegalReview_Input);
         ProjectComment.AddComment(
             ProjectCommentAction.ReSubmit,
             comment,
             this.Id,
             this.TableName,
             FlowCode.TempClosure,
             this.ProcInstId,
             ProjectCommentStatus.Submit
             );
         tranScope.Complete();
     }
 }
Exemple #4
0
        public void ExecuteProcess(string employeeCode, string sn, string actionName, string comment, List <ProcessDataField> dataField = null)
        {
            using (var scope = new TransactionScope())
            {
                Save(actionName);
                switch (actionName)
                {
                case ProjectAction.ReSubmit:
                    ProjectInfo.FinishNode(ProjectId, FlowCode.Rebuild_ConsInvtChecking, NodeCode.Rebuild_ConsInvtChecking_Downlod);
                    ProjectInfo.FinishNode(ProjectId, FlowCode.Rebuild_ConsInvtChecking, NodeCode.Rebuild_ConsInvtChecking_Input);
                    ProjectInfo.FinishNode(ProjectId, FlowCode.Rebuild_ConsInvtChecking, NodeCode.Rebuild_ConsInvtChecking_Upload);
                    break;

                case ProjectAction.Return:
                case ProjectAction.Recall:
                    ProjectInfo.Reset(ProjectId, WorkflowCode, GetProjectStatus(actionName));
                    break;

                case ProjectAction.Decline:
                    ProjectInfo.Reject(ProjectId, WorkflowCode);
                    break;

                //case ProjectAction.Approve:
                //    ProjectInfo.FinishNode(ProjectId, WorkflowCode, NodeCode.Rebuild_ConsInvtChecking_Confirm, GetProjectStatus(actionName));
                //    break;
                default:
                    ProjectInfo.FinishNode(ProjectId, WorkflowCode, NodeCode.Rebuild_ConsInvtChecking_Upload, GetProjectStatus(actionName));
                    break;
                }

                if (actionName == ProjectAction.Return)
                {
                    TaskWork.Finish(e => e.RefID == ProjectId &&
                                    e.TypeCode == WorkflowCode &&
                                    e.Status == TaskWorkStatus.UnFinish &&
                                    e.K2SN != sn);
                }
                scope.Complete();
            }
            K2FxContext.Current.ApprovalProcess(sn, employeeCode, actionName, comment);
        }
Exemple #5
0
        public void Submit()
        {
            var task = TaskWork.GetTaskWork(ProjectId, LastUpdateUserAccount, TaskWorkStatus.UnFinish,
                                            FlowCode.MajorLease, WorkflowCode);

            task.Status     = TaskWorkStatus.Finished;
            task.FinishTime = DateTime.Now;
            string taskUrl = "/MajorLease/Main#/FinanceAnalysis/Process/View?projectId=" + ProjectId;

            task.Url   = taskUrl;
            ProcInstID = StartProcess(task);

            using (var scope = new TransactionScope())
            {
                TaskWork.Update(task);

                Save("Submit");
                ProjectInfo.FinishNode(ProjectId, WorkflowCode, NodeCode.MajorLease_FinanceAnalysis_Input);
                scope.Complete();
            }
        }
Exemple #6
0
        public override void Finish(TaskWorkStatus status, TaskWork task)
        {
            using (var scope = new TransactionScope())
            {
                switch (status)
                {
                case TaskWorkStatus.K2ProcessApproved:
                    ProjectInfo.FinishNode(this.ProjectId, FlowCode.Closure_ExecutiveSummary, NodeCode.Closure_ExecutiveSummary_Generate, ProjectStatus.Finished);
                    if (ProjectInfo.Any(e => e.ProjectId == ProjectId &&
                                        e.Status == ProjectStatus.Finished &&
                                        e.FlowCode == FlowCode.Closure_LegalReview))
                    {
                        var package = new ClosurePackage();
                        package.GeneratePackageTask(ProjectId);
                        package.GeneratePackage(ProjectId);
                    }
                    break;
                }

                scope.Complete();
            }
        }
        public void Submit()
        {
            var task = TaskWork.GetTaskWork(ProjectId, ClientCookie.UserCode, TaskWorkStatus.UnFinish,
                                            FlowCode.Reimage, FlowCode.Reimage_ConsInvtChecking);

            task.Status     = TaskWorkStatus.Finished;
            task.FinishTime = DateTime.Now;
            string taskUrl = "/Reimage/Main#/ConsInvtChecking/Process/View?projectId=" + ProjectId;

            task.Url   = taskUrl;
            ProcInstID = StartProcess(task);
            using (TransactionScope scope = new TransactionScope())
            {
                TaskWork.Update(task);

                Save("Submit");
                ProjectInfo.FinishNode(ProjectId, FlowCode.Reimage_ConsInvtChecking, NodeCode.Reimage_ConsInvtChecking_Downlod);
                ProjectInfo.FinishNode(ProjectId, FlowCode.Reimage_ConsInvtChecking, NodeCode.Reimage_ConsInvtChecking_Input);
                ProjectInfo.FinishNode(ProjectId, FlowCode.Reimage_ConsInvtChecking, NodeCode.Reimage_ConsInvtChecking_Upload);
                scope.Complete();
            }
        }
Exemple #8
0
        public void Resubmit(string serialNumber)
        {
            var comment    = "";
            var task       = TaskWork.FirstOrDefault(t => t.RefID == this.ProjectId && t.TypeCode == this.WorkflowCode && t.ReceiverAccount == ClientCookie.UserCode && t.Status == TaskWorkStatus.UnFinish);
            var dataFields = SetWorkflowDataFields(task);

            K2FxContext.Current.ApprovalProcess(serialNumber, ClientCookie.UserCode, "Resubmit", comment, dataFields);
            using (TransactionScope tranScope = new TransactionScope())
            {
                Save();
                ProjectComment.AddComment(
                    ProjectCommentAction.ReSubmit,
                    comment,
                    this.Id,
                    this.TableName,
                    FlowCode.Renewal,
                    this.ProcInstId,
                    ProjectCommentStatus.Submit
                    );
                ProjectInfo.FinishNode(ProjectId, WorkflowCode, NodeCode.Renewal_LLNegotiation_Input);
                tranScope.Complete();
            }
        }
Exemple #9
0
        public void Submit()
        {
            var task = TaskWork.GetTaskWork(ProjectId, ClientCookie.UserCode, TaskWorkStatus.UnFinish,
                                            FlowCode.MajorLease, FlowCode.MajorLease_ConsInfo);

            ProcInstID = StartProcess(task);
            //task.ProcInstID = ProcInstID;
            using (var scope = new TransactionScope())
            {
                task.Finish();

                Save("Submit");
                ProjectInfo.FinishNode(ProjectId, FlowCode.MajorLease_ConsInfo, NodeCode.MajorLease_ConsInfo_Input);

                //var majorLeasePackage = new MajorLeaseChangePackage();
                //majorLeasePackage.GeneratePackageTask(ProjectId);

                //var majorLeaseConsInvtChecking = new MajorLeaseConsInvtChecking();
                //majorLeaseConsInvtChecking.GenerateConsInvtCheckingTask(ProjectId);

                scope.Complete();
            }
        }
 public void Approve(string comment, string SerialNumber, bool isGeneralCouncel)
 {
     if (isGeneralCouncel)
     {
         K2FxContext.Current.ApprovalProcess(SerialNumber, ClientCookie.UserCode, "Approve", comment);
     }
     else
     {
         K2FxContext.Current.ApprovalProcess(SerialNumber, ClientCookie.UserCode, "Approve", comment, SetWorkflowDataFieldsByLegal());
     }
     using (TransactionScope tranScope = new TransactionScope())
     {
         if (!isGeneralCouncel)
         {
             var approveDialogUser = ApproveDialogUser.GetApproveDialogUser(this.Id.ToString());
             approveDialogUser.GeneralCounselCode = AppUsers.GeneralCounsel.Code;
             approveDialogUser.Update();
         }
         this.LastUpdateTime        = DateTime.Now;
         this.LastUpdateUserAccount = ClientCookie.UserCode;
         this.Update();
         ProjectComment.AddComment(
             ProjectCommentAction.Approve,
             comment,
             this.Id,
             this.TableName,
             FlowCode.Renewal,
             this.ProcInstId,
             ProjectCommentStatus.Submit
             );
         if (!isGeneralCouncel)
         {
             ProjectInfo.FinishNode(this.ProjectId, this.WorkflowCode, NodeCode.Renewal_LegalApproval_LegalReview);
         }
         tranScope.Complete();
     }
 }
Exemple #11
0
 public override void Finish(TaskWorkStatus status, TaskWork task)
 {
     switch (status)
     {
     case TaskWorkStatus.K2ProcessApproved:
     {
         ProjectInfo.FinishNode(ProjectId, this.WorkflowCode, NodeCode.Finish);
         ProjectInfo.FinishNode(ProjectId, FlowCode.Renewal_LLNegotiation, NodeCode.Renewal_LLNegotiation_ConfirmLetter);
         if (!ProjectInfo.IsFlowStarted(ProjectId, FlowCode.Renewal_ConsInfo))
         {
             var info = RenewalInfo.Get(task.RefID);
             if (ProjectInfo.IsFlowFinished(ProjectId, FlowCode.Renewal_LLNegotiation))
             {
                 ProjectProgress.SetProgress(ProjectId, "30%");
                 if (info.NeedProjectCostEst)
                 {
                     if (!ProjectInfo.IsFlowStarted(ProjectId, FlowCode.Renewal_ConsInfo))
                     {
                         info.GenerateSubmitTask(FlowCode.Renewal_ConsInfo);
                     }
                 }
                 else
                 {
                     ProjectInfo.FinishNode(ProjectId, FlowCode.Renewal_ConsInfo, NodeCode.Finish, ProjectStatus.Finished);
                     if (!ProjectInfo.IsFlowStarted(ProjectId, FlowCode.Renewal_Tool))
                     {
                         info.GenerateSubmitTask(FlowCode.Renewal_Tool);
                     }
                 }
             }
         }
         TaskWork.Finish(t => t.TypeCode == this.WorkflowCode && t.RefID == this.ProjectId && t.Status == TaskWorkStatus.UnFinish);
     }
     break;
     }
 }
Exemple #12
0
        public void ExecuteProcess(string employeeCode, string sn, string actionName, string comment, List <ProcessDataField> dataField = null)
        {
            using (var scope = new TransactionScope())
            {
                Save(actionName);
                switch (actionName)
                {
                case ProjectAction.Return:
                case ProjectAction.Recall:
                    ProjectInfo.Reset(ProjectId, WorkflowCode, ProjectStatus.Finished);
                    break;

                case ProjectAction.Decline:
                    ProjectInfo.Reject(ProjectId, WorkflowCode, ProjectStatus.Finished);
                    break;

                default:
                    ProjectInfo.FinishNode(ProjectId, WorkflowCode, NodeCode.Renewal_GBMemo_Input, ProjectStatus.Finished);
                    break;
                }
                scope.Complete();
            }
            K2FxContext.Current.ApprovalProcess(sn, employeeCode, actionName, comment, dataField);
        }
Exemple #13
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();
            }
        }
Exemple #14
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();
            }
        }
Exemple #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;
            }
        }
Exemple #16
0
        public void Submit()
        {
            string strFlowCode = FlowCode.TempClosure;
            string strNodeCode = NodeCode.Finish;
            string strTypeCode = FlowCode.TempClosure_ClosureMemo;

            if (ProjectId.ToLower().IndexOf("rebuild") != -1)
            {
                strFlowCode = FlowCode.Rebuild;
                //strNodeCode = NodeCode.Finish;
                strTypeCode = FlowCode.Rebuild_TempClosureMemo;
            }
            else if (ProjectId.ToLower().IndexOf("reimage") != -1)
            {
                strFlowCode = FlowCode.Reimage;
                //strNodeCode = NodeCode.Finish;
                strTypeCode = FlowCode.Reimage_TempClosureMemo;
            }
            using (var scope = new TransactionScope())
            {
                Save();
                if (ProjectId.ToLower().IndexOf("majorlease") != -1 ||
                    ProjectId.ToLower().IndexOf("renewal") != -1)
                {
                    AttachmentsMemoProcessInfo.UpdateNotifyDate(ProjectId, FlowCode.ClosureMemo);
                }
                else
                {
                    var task = TaskWork.GetTaskWork(ProjectId, ClientCookie.UserCode, TaskWorkStatus.UnFinish, strFlowCode, strTypeCode);
                    if (task != null)
                    {
                        task.Status       = TaskWorkStatus.K2ProcessApproved;
                        task.ActivityName = "Finish";
                        string taskUrl = "/" + strFlowCode + "/Main#/ClosureMemo/Process/View?projectId=" + ProjectId;
                        if (ProjectId.ToLower().IndexOf("rebuild") != -1 ||
                            ProjectId.ToLower().IndexOf("reimage") != -1)
                        {
                            taskUrl = "/" + strFlowCode + "/Main#/TempClosureMemo/Process/View?projectId=" + ProjectId;
                        }
                        task.Url        = taskUrl;
                        task.FinishTime = DateTime.Now;
                        TaskWork.Update(task);
                        if (ProjectId.ToLower().IndexOf("rebuild") != -1)
                        {
                            ProjectInfo.FinishNode(ProjectId, strTypeCode, NodeCode.Rebuild_TempClosureMemo_Input);
                            ProjectInfo.FinishNode(ProjectId, strTypeCode, NodeCode.Rebuild_TempClosureMemo_Send, ProjectStatus.Finished);
                        }
                        else if (ProjectId.ToLower().IndexOf("reimage") != -1)
                        {
                            ProjectInfo.FinishNode(ProjectId, strTypeCode, NodeCode.Reimage_TempClosureMemo_Input);
                            ProjectInfo.FinishNode(ProjectId, strTypeCode, NodeCode.Reimage_TempClosureMemo_Send, ProjectStatus.Finished);
                        }
                        else
                        {
                            //TempClosure
                            ProjectInfo.FinishNode(ProjectId, strTypeCode, NodeCode.TempClosure_ClosureMemo_Input);
                            ProjectInfo.FinishNode(ProjectId, strTypeCode, NodeCode.TempClosure_ClosureMemo_Send, ProjectStatus.Finished);
                        }
                        ProjectInfo.CompleteMainIfEnable(ProjectId);
                    }
                }
                scope.Complete();
            }
        }
Exemple #17
0
        public override string Edit()
        {
            var taskUrl = string.Format("/Reimage/Main#/Summary?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(WorkflowCode,
                                                        "Reimage_Summary",
                                                        "Reimage_Summary",
                                                        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 == TableName).AsNoTracking().ToList();


                ProjectInfo.Reset(ProjectId, WorkflowCode);
                ProjectInfo.FinishNode(ProjectId, WorkflowCode, NodeCode.Reimage_Summary_Input);
                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.CreateTime = DateTime.Now;
                form.Save("edit");

                var 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);
        }
Exemple #18
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();
        }
Exemple #19
0
        public void Submit()
        {
            var task = TaskWork.GetTaskWork(ProjectId, ClientCookie.UserCode, TaskWorkStatus.UnFinish,
                                            FlowCode.Reimage, FlowCode.Reimage_ConsInfo);

            task.Status     = TaskWorkStatus.Finished;
            task.FinishTime = DateTime.Now;
            string taskUrl = "/Reimage/Main#/ConsInfo/Process/View?projectId=" + ProjectId;

            task.Url = taskUrl;
            task.CreateUserAccount = ClientCookie.UserCode;
            ProcInstId             = StartProcess(task);
            task.ProcInstID        = ProcInstId;
            using (TransactionScope scope = new TransactionScope())
            {
                TaskWork.Update(task);

                Save("Submit");
                ProjectInfo.FinishNode(ProjectId, FlowCode.Reimage_ConsInfo, NodeCode.Reimage_ConsInfo_Input);

                //var majorLeasePackage = new MajorLeaseChangePackage();
                //majorLeasePackage.GeneratePackageTask(ProjectId);

                //var majorLeaseConsInvtChecking = new MajorLeaseConsInvtChecking();
                //majorLeaseConsInvtChecking.GenerateConsInvtCheckingTask(ProjectId);

                scope.Complete();
            }

            //var currTask = TaskWork.FirstOrDefault(e => e.ReceiverAccount == CreateUserAccount
            //                                            && e.Status == 0
            //                                            && e.SourceCode == FlowCode.Reimage
            //                                            && e.TypeCode == FlowCode.Reimage_ConsInfo
            //                                            && e.RefID == ProjectId);

            //if (currTask != null)
            //{
            //    using (var scope = new TransactionScope())
            //    {
            //        currTask.Url = string.Format("/Reimage/Main#/Reimage/ConsInfo/View/{0}", ProjectId);
            //        currTask.Finish();

            //        if (ProcInstId > 0)
            //        {
            //            SaveComment();
            //            Add();
            //        }
            //        else
            //        {
            //            throw new Exception("Could not get process instance id, please check it and try it again!");
            //        }

            //        scope.Complete();
            //    }

            //    ProcInstId = StartProcess(currTask);
            //    Update(this);
            //}
            //else
            //{
            //    throw new Exception("Can not find the task, please check it!");
            //}
        }
Exemple #20
0
        public void Submit(string comment, ApproveUsers approvers, Action onExecuting = null)
        {
            var legal = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == this.ProjectId && pu.RoleCode == ProjectUserRoleCode.Legal);
            var task  = TaskWork.GetTaskWork(this.ProjectId, ClientCookie.UserCode, TaskWorkStatus.UnFinish,
                                             FlowCode.TempClosure, this.WorkflowCode);

            task.Status     = TaskWorkStatus.Finished;
            task.FinishTime = DateTime.Now;
            string destMRMgrs = approvers.MarketMgr.Code;

            if (approvers.RegionalMgr != null)
            {
                destMRMgrs += ";" + approvers.RegionalMgr.Code;
            }
            List <ProcessDataField> dataFields = new List <ProcessDataField>
            {
                new ProcessDataField("dest_Creator", this.CreateUserAccount),
                new ProcessDataField("dest_MRMgrs", destMRMgrs),
                new ProcessDataField("dest_GMApprovers", string.Concat(approvers.MDD.Code, ";", approvers.GM.Code, ";", approvers.FC.Code)),
                new ProcessDataField("dest_VPGM", approvers.VPGM.Code),
                new ProcessDataField("ProcessCode", this.WorkflowProcessCode),
                new ProcessDataField("ProjectTaskInfo", JsonConvert.SerializeObject(task))
            };
            var procInstId = K2FxContext.Current.StartProcess(WorkflowProcessCode, ClientCookie.UserCode, dataFields);

            if (procInstId > 0)
            {
                using (TransactionScope tranScope = new TransactionScope())
                {
                    TaskWork.Update(task);
                    var project = ProjectInfo.Get(this.ProjectId, FlowCode.TempClosure_ClosurePackage);
                    project.CreateUserAccount = ClientCookie.UserCode;
                    project.Update();
                    this.CreateUserAccount = ClientCookie.UserCode;
                    this.ProcInstId        = procInstId;
                    Update(this);
                    var approver = ApproveDialogUser.GetApproveDialogUser(this.Id.ToString());
                    if (approver == null)
                    {
                        approver = new ApproveDialogUser();
                    }
                    approver.ProjectId     = this.ProjectId;
                    approver.RefTableID    = this.Id.ToString();
                    approver.FlowCode      = FlowCode.TempClosure_ClosurePackage;
                    approver.MarketMgrCode = approvers.MarketMgr.Code;
                    if (approvers.RegionalMgr != null)
                    {
                        approver.RegionalMgrCode = approvers.RegionalMgr.Code;
                    }
                    approver.MDDCode  = approvers.MDD.Code;
                    approver.GMCode   = approvers.GM.Code;
                    approver.FCCode   = approvers.FC.Code;
                    approver.VPGMCode = approvers.VPGM.Code;
                    //approver.MCCLAssetMgrCode = approvers.MCCLAssetMgr.Code;
                    //approver.MCCLAssetDtrCode = approvers.MCCLAssetDtr.Code;
                    approver.NecessaryNoticeUsers = string.Join(";", approvers.NecessaryNoticeUsers.Select(u => u.Code).ToArray());
                    approver.NoticeUsers          = string.Join(";", approvers.NoticeUsers.Select(u => u.Code).ToArray());
                    approver.Save();
                    ProjectInfo.FinishNode(this.ProjectId, FlowCode.TempClosure_ClosurePackage, NodeCode.TempClosure_ClosurePackage_Input);
                    var SavedComment = ProjectComment.GetSavedComment(this.Id, this.TableName, ClientCookie.UserCode);
                    if (SavedComment != null)
                    {
                        SavedComment.Status     = ProjectCommentStatus.Submit;
                        SavedComment.Content    = comment;
                        SavedComment.CreateTime = DateTime.Now;
                        SavedComment.Update();
                    }
                    else
                    {
                        ProjectComment.AddComment(
                            ProjectCommentAction.Submit,
                            comment,
                            this.Id,
                            "TempClosurePackage",
                            FlowCode.TempClosure,
                            this.ProcInstId,
                            ProjectCommentStatus.Submit
                            );
                    }
                    if (onExecuting != null)
                    {
                        onExecuting();
                    }
                    tranScope.Complete();
                }
            }
        }
Exemple #21
0
        public void Resubmit(string comment, string SerialNumber, ApproveUsers newApprover, Action onExecuting = null)
        {
            var    assetActor = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == this.ProjectId && pu.RoleCode == ProjectUserRoleCode.AssetActor);
            string destMRMgrs = newApprover.MarketMgr.Code;

            if (newApprover.RegionalMgr != null)
            {
                destMRMgrs += ";" + newApprover.RegionalMgr.Code;
            }
            List <ProcessDataField> dataFields = new List <ProcessDataField>
            {
                new ProcessDataField("dest_Creator", this.CreateUserAccount),
                new ProcessDataField("dest_MRMgrs", destMRMgrs),
                new ProcessDataField("dest_GMApprovers", string.Concat(newApprover.MDD.Code, ";", newApprover.GM.Code, ";", newApprover.FC.Code)),
                new ProcessDataField("dest_VPGM", newApprover.VPGM.Code),
                new ProcessDataField("ProcessCode", this.WorkflowProcessCode)
            };

            K2FxContext.Current.ApprovalProcess(SerialNumber, ClientCookie.UserCode, "Resubmit", comment, dataFields);
            using (TransactionScope tranScope = new TransactionScope())
            {
                var project = ProjectInfo.Get(this.ProjectId, FlowCode.TempClosure_ClosurePackage);
                project.CreateUserAccount = ClientCookie.UserCode;
                project.Update();
                this.CreateUserAccount = ClientCookie.UserCode;
                Update(this);
                var approver = ApproveDialogUser.GetApproveDialogUser(this.Id.ToString());
                if (approver == null)
                {
                    approver = new ApproveDialogUser();
                }
                approver.ProjectId     = this.ProjectId;
                approver.RefTableID    = this.Id.ToString();
                approver.FlowCode      = this.WorkflowCode;
                approver.MarketMgrCode = newApprover.MarketMgr.Code;
                if (newApprover.RegionalMgr != null)
                {
                    approver.RegionalMgrCode = newApprover.RegionalMgr.Code;
                }
                else
                {
                    approver.RegionalMgrCode = null;
                }
                approver.MDDCode          = newApprover.MDD.Code;
                approver.GMCode           = newApprover.GM.Code;
                approver.FCCode           = newApprover.FC.Code;
                approver.VPGMCode         = newApprover.VPGM.Code;
                approver.MCCLAssetMgrCode = newApprover.MCCLAssetMgr.Code;
                approver.MCCLAssetDtrCode = newApprover.MCCLAssetDtr.Code;
                approver.NoticeUsers      = string.Join(";", newApprover.NoticeUsers.Select(u => u.Code).ToArray());
                approver.Save();
                ProjectInfo.FinishNode(this.ProjectId, this.WorkflowCode, NodeCode.TempClosure_ClosurePackage_Input);
                var SavedComment = ProjectComment.GetSavedComment(this.Id, this.TableName, ClientCookie.UserCode);
                if (SavedComment != null)
                {
                    SavedComment.Status     = ProjectCommentStatus.Submit;
                    SavedComment.Action     = ProjectCommentAction.ReSubmit;
                    SavedComment.Content    = comment;
                    SavedComment.CreateTime = DateTime.Now;
                    SavedComment.Update();
                }
                else
                {
                    ProjectComment.AddComment(
                        ProjectCommentAction.ReSubmit,
                        comment,
                        this.Id,
                        this.TableName,
                        FlowCode.TempClosure,
                        this.ProcInstId,
                        ProjectCommentStatus.Submit
                        );
                }

                var task = TaskWork.FirstOrDefault(t => t.RefID == this.ProjectId && t.TypeCode == this.WorkflowCode && t.ReceiverAccount == assetActor.UserAccount);
                task.Finish();
                if (onExecuting != null)
                {
                    onExecuting();
                }
                tranScope.Complete();
            }
        }