Example #1
0
        public void Submit()
        {
            var task = TaskWork.GetTaskWork(ProjectId, LastUpdateUserAccount, TaskWorkStatus.UnFinish,
                                            FlowCode.Rebuild, FlowCode.Rebuild_ConsInfo);

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

            task.Url   = taskUrl;
            ProcInstID = StartProcess(task);
            using (var scope = new TransactionScope())
            {
                TaskWork.Update(task);
                Save("Submit");
                ProjectInfo.FinishNode(ProjectId, FlowCode.Rebuild_ConsInfo, NodeCode.Rebuild_ConsInfo_Input);

                //var rbdPackage = new RebuildChangePackage();
                //rbdPackage.GeneratePackageTask(ProjectId);

                //var rbdConsInvtChecking = new RebuildConsInvtChecking();
                //rbdConsInvtChecking.GenerateConsInvtCheckingTask(ProjectId);

                scope.Complete();
            }
        }
Example #2
0
        public void Submit()
        {
            var  task     = TaskWork.GetTaskWork(ProjectId, LastUpdateUserAccount, TaskWorkStatus.UnFinish, FlowCode.Renewal, FlowCode.Renewal_GBMemo);
            bool isNoTask = false;

            if (task == null)
            {
                string taskUrl = "/Renewal/Main#/GBMemo/Process/View?projectId=" + ProjectId;
                task     = Info.GenerateTaskWork(FlowCode.Renewal_GBMemo, "GBMemo", "GBMemo", taskUrl);
                isNoTask = true;
            }
            ProcInstID = StartProcess(task);
            using (var scope = new TransactionScope())
            {
                task.Status     = TaskWorkStatus.Finished;
                task.FinishTime = DateTime.Now;
                if (isNoTask)
                {
                    TaskWork.Add(task);
                }
                else
                {
                    TaskWork.Update(task);
                }
                Save("Submit");
                ProjectInfo.FinishNode(ProjectId, FlowCode.Renewal_GBMemo, NodeCode.Renewal_GBMemo_Input);
                scope.Complete();
            }
        }
Example #3
0
        public void Submit()
        {
            var task = TaskWork.GetTaskWork(ProjectId, ClientCookie.UserCode, TaskWorkStatus.UnFinish,
                                            FlowCode.Reimage, WorkflowCode);

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

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

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

                Save("Submit");

                ProjectInfo.FinishNode(ProjectId, WorkflowCode, NodeCode.Reimage_Summary_Input);

                //var reimagePackage = new ReimagePackage();
                //reimagePackage.GeneratePackageTask(ProjectId);

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

                scope.Complete();
            }
        }
Example #4
0
        public static void Submit(GBMemo memo)
        {
            string strFlowCode = "";
            string strNodeCode = "";
            string strTypeCode = "";

            if (memo.ProjectId.ToLower().IndexOf("rebuild") != -1)
            {
                strFlowCode = FlowCode.Rebuild;
                strNodeCode = NodeCode.Finish;
                strTypeCode = FlowCode.Rebuild_GBMemo;
            }
            else if (memo.ProjectId.ToLower().IndexOf("reimage") != -1)
            {
                strFlowCode = FlowCode.Reimage;
                strNodeCode = NodeCode.Finish;
                strTypeCode = FlowCode.Reimage_GBMemo;
            }
            var task = TaskWork.GetTaskWork(memo.ProjectId, ClientCookie.UserCode, TaskWorkStatus.UnFinish, strFlowCode, strTypeCode);

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

            task.Url = taskUrl;
            using (var scope = new TransactionScope())
            {
                TaskWork.Update(task);
                SaveGBMemo(memo);
                ProjectInfo.UpdateProjectNode(memo.ProjectId, strTypeCode, strNodeCode);
                scope.Complete();
            }
        }
Example #5
0
 public override string Edit()
 {
     using (var tranScope = new TransactionScope())
     {
         var letter = Duplicator.AutoCopy(this);
         letter.Id                = Guid.NewGuid();
         letter.IsHistory         = false;
         letter.CreateUserAccount = ClientCookie.UserCode;
         letter.Add();
         IsHistory = true;
         this.Update();
         ProjectInfo.Reset(ProjectId, this.WorkflowCode);
         var attachments = Attachment.GetList(this.TableName, Id.ToString(), string.Empty);
         attachments.ForEach(att =>
         {
             att.RefTableID = letter.Id.ToString();
             att.ID         = Guid.NewGuid();
         });
         Attachment.Add(attachments.ToArray());
         var assetActor = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == ProjectId && pu.RoleCode == ProjectUserRoleCode.AssetActor);
         var oldTasks   = TaskWork.Search(t => t.RefID == ProjectId && t.Status == TaskWorkStatus.UnFinish && (t.TypeCode == this.WorkflowCode || t.TypeCode == FlowCode.Renewal_ConsInfo)).ToList();
         oldTasks.ForEach(t =>
         {
             t.Status = TaskWorkStatus.Cancel;
         });
         TaskWork.Update(oldTasks.ToArray());
         var    latestTask = TaskWork.FirstOrDefault(t => t.RefID == ProjectId && t.TypeCode == this.WorkflowCode);
         string url        = "/Renewal/Main#/Letter?projectId=" + ProjectId;
         TaskWork.SendTask(ProjectId, latestTask.Title, latestTask.StoreCode, url, assetActor, FlowCode.Renewal, this.WorkflowCode, "Start");
         tranScope.Complete();
         return(url);
     }
 }
Example #6
0
        public void Submit()
        {
            string strFlowCode = FlowCode.TempClosure;
            string strNodeCode = NodeCode.Finish;
            string strTypeCode = FlowCode.TempClosure_ReopenMemo;

            using (var scope = new TransactionScope())
            {
                Save();
                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#/ReopenMemo/Process/View?projectId=" + ProjectId;
                    task.Url        = taskUrl;
                    task.FinishTime = DateTime.Now;
                    TaskWork.Update(task);
                    ProjectInfo.FinishNode(ProjectId, strTypeCode, NodeCode.TempClosure_ReopenMemo_Input);
                    ProjectInfo.FinishNode(ProjectId, strTypeCode, NodeCode.TempClosure_ReopenMemo_Send, ProjectStatus.Finished);
                    //ProjectInfo.FinishNode(ProjectId, strTypeCode, strNodeCode);
                    ProjectInfo.CompleteMainIfEnable(ProjectId);
                }
                scope.Complete();
            }
        }
Example #7
0
        public override void Recall(string comment)
        {
            using (TransactionScope tranScope = new TransactionScope())
            {
                ProjectInfo.Reset(this.ProjectId, this.WorkflowCode, ProjectStatus.Recalled);
                ProjectComment.AddComment(
                    ProjectCommentAction.Recall,
                    comment,
                    this.Id,
                    this.TableName,
                    FlowCode.TempClosure,
                    this.ProcInstId,
                    ProjectCommentStatus.Submit
                    );
                var actor            = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == this.ProjectId && pu.RoleCode == ProjectUserRoleCode.AssetActor);
                var legal            = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == this.ProjectId && pu.RoleCode == ProjectUserRoleCode.Legal);
                var oldUnfinishTasks = TaskWork.Search(t => t.RefID == this.ProjectId && t.TypeCode == FlowCode.TempClosure_LegalReview && t.Status == TaskWorkStatus.UnFinish).ToList();
                oldUnfinishTasks.ForEach(t =>
                {
                    t.Status = TaskWorkStatus.Cancel;
                });
                TaskWork.Update(oldUnfinishTasks.ToArray());
                tranScope.Complete();
            }
            string comments = ClientCookie.UserNameZHCN + "进行了流程撤回操作";

            K2FxContext.Current.GoToActivityAndRecord(
                this.ProcInstId.Value,
                this.WorkflowActOriginator,
                ClientCookie.UserCode,
                ProjectAction.Recall,
                comments
                );
            //ProjectInfo.Reset(this.ProjectId, WorkflowCode);
        }
Example #8
0
        public override void Finish(TaskWorkStatus status, TaskWork task)
        {
            using (var scope = new TransactionScope())
            {
                switch (status)
                {
                case TaskWorkStatus.K2ProcessApproved:

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

                    ProjectInfo.FinishNode(this.ProjectId, FlowCode.Closure_ClosureTool, NodeCode.Closure_ClosureTool_Generate, ProjectStatus.Finished);
                    if (!ClosureExecutiveSummary.Any(i => i.ProjectId == this.ProjectId && i.IsHistory == false))
                    {
                        var esEntity = new ClosureExecutiveSummary();
                        esEntity.ProjectId      = this.ProjectId;
                        esEntity.Id             = Guid.NewGuid();
                        esEntity.CreateTime     = DateTime.Now;
                        esEntity.CreatorAccount = ClientCookie.UserCode;
                        ClosureExecutiveSummary.Add(esEntity);
                    }
                    break;
                }

                scope.Complete();
            }
        }
Example #9
0
        public void Submit(string comment, 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;
            List <ProcessDataField> dataFields = new List <ProcessDataField>
            {
                new ProcessDataField("dest_Creator", this.CreateUserAccount),
                new ProcessDataField("dest_Legal", legal.UserAccount),
                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);
                    this.ProcInstId        = procInstId;
                    this.CreateTime        = DateTime.Now;
                    this.CreateUserAccount = ClientCookie.UserCode;
                    this.Update();
                    var project = ProjectInfo.Get(this.ProjectId, this.WorkflowCode);
                    project.CreateUserAccount = ClientCookie.UserCode;
                    project.Update();
                    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,
                            this.TableName,
                            FlowCode.TempClosure,
                            procInstId,
                            ProjectCommentStatus.Submit
                            );
                    }
                    ProjectInfo.FinishNode(this.ProjectId, this.WorkflowCode, NodeCode.TempClosure_LegalReview_Input);
                    if (onExecuting != null)
                    {
                        onExecuting();
                    }
                    tranScope.Complete();
                }
            }
        }
Example #10
0
        public static void Submit(ReopenMemo memo)
        {
            string strFlowCode      = "";
            string strInputNodeCode = "";
            string strSendNodeCode  = "";
            string strTypeCode      = "";

            if (memo.ProjectId.ToLower().IndexOf("rebuild") != -1)
            {
                strFlowCode      = FlowCode.Rebuild;
                strInputNodeCode = NodeCode.Rebuild_ReopenMemo_Input;
                strSendNodeCode  = NodeCode.Rebuild_ReopenMemo_Send;
                strTypeCode      = FlowCode.Rebuild_ReopenMemo;
            }
            else if (memo.ProjectId.ToLower().IndexOf("reimage") != -1)
            {
                strFlowCode      = FlowCode.Reimage;
                strInputNodeCode = NodeCode.Reimage_ReopenMemo_Input;
                strSendNodeCode  = NodeCode.Reimage_ReopenMemo_SendMemo;
                strTypeCode      = FlowCode.Reimage_ReopenMemo;
            }
            using (var scope = new TransactionScope())
            {
                SaveReopenMemo(memo);
                if (memo.ProjectId.ToLower().IndexOf("rebuild") != -1 ||
                    memo.ProjectId.ToLower().IndexOf("reimage") != -1)
                {
                    var task = TaskWork.GetTaskWork(memo.ProjectId, ClientCookie.UserCode, TaskWorkStatus.UnFinish, strFlowCode, strTypeCode);
                    if (task != null)
                    {
                        task.Status       = TaskWorkStatus.K2ProcessApproved;
                        task.ActivityName = "Finish";
                        task.FinishTime   = DateTime.Now;
                        string taskUrl = "/" + strFlowCode + "/Main#/ReopenMemo/Process/View?projectId=" + memo.ProjectId;
                        task.Url = taskUrl;
                        TaskWork.Update(task);
                        ProjectInfo.FinishNode(memo.ProjectId, strTypeCode, strInputNodeCode);
                        ProjectInfo.FinishNode(memo.ProjectId, strTypeCode, strSendNodeCode);
                        ProjectInfo.CompleteMainIfEnable(memo.ProjectId);
                    }
                }
                else
                {
                    AttachmentsMemoProcessInfo.UpdateNotifyDate(memo.ProjectId, FlowCode.ReopenMemo);
                }
                scope.Complete();
            }
        }
Example #11
0
        public void Submit()
        {
            var    task    = TaskWork.GetTaskWork(ProjectId, LastUpdateUserAccount, TaskWorkStatus.UnFinish, FlowCode.Reimage, FlowCode.Reimage_GBMemo);
            string taskUrl = "/Reimage/Main#/GBMemo/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.Reimage_GBMemo, NodeCode.Reimage_GBMemo_Input);
                scope.Complete();
            }
        }
Example #12
0
        public void CompleteNotFinishTask()
        {
            var tasks = TaskWork.Search(e => e.RefID == ProjectId &&
                                        e.Status == TaskWorkStatus.UnFinish &&
                                        (e.TypeCode == FlowCode.Reimage_TempClosureMemo || e.TypeCode == FlowCode.Reimage_ReopenMemo)).ToList();

            if (tasks.Count > 0)
            {
                foreach (var task in tasks)
                {
                    task.Status = TaskWorkStatus.Finished;
                    string strTypeCode = task.TypeCode.Split('_')[1];
                    task.Url = string.Format("/Reimage/Main#/{0}/Process/View?projectId={1}", strTypeCode, ProjectId);
                }
                TaskWork.Update(tasks.ToArray());
            }
        }
Example #13
0
        public void Submit()
        {
            var task = TaskWork.GetTaskWork(ProjectId, LastUpdateUserAccount, TaskWorkStatus.UnFinish,
                                            FlowCode.Rebuild, FlowCode.Rebuild_ConsInvtChecking);

            task.Status     = TaskWorkStatus.Finished;
            task.FinishTime = DateTime.Now;
            string taskUrl = "/Rebuild/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.Rebuild_ConsInvtChecking, NodeCode.Rebuild_ConsInvtChecking_Input);
                scope.Complete();
            }
        }
Example #14
0
        /// <summary>
        /// Edit准备
        /// </summary>
        /// <param name="projectId"></param>
        /// <returns></returns>
        public bool PreEdit(string projectId)
        {
            //如果流程已经到了ClosurePackage审批环节就不能Edit
            if (ProjectInfo.IsFlowStarted(projectId, FlowCode.Closure_ClosurePackage))
            {
                return(false);
            }
            else
            {
                #region Package撤回
                var needWidthDraw = TaskWork.Count(i => i.TypeCode == FlowCode.Closure_ClosurePackage && i.RefID == projectId && i.Status == TaskWorkStatus.UnFinish) > 0;
                if (needWidthDraw)
                {
                    //任务取消
                    var taskList = TaskWork.Search(i => i.TypeCode == FlowCode.Closure_ClosurePackage && i.RefID == projectId && i.Status != TaskWorkStatus.Cancel).ToArray();
                    foreach (var taskItem in taskList)
                    {
                        taskItem.Status = TaskWorkStatus.Cancel;
                    }
                    if (taskList.Length > 0)
                    {
                        TaskWork.Update(taskList);
                    }

                    //Package数据isHistory置成true
                    var package = ClosurePackage.Search(i => i.ProjectId == projectId && i.IsHistory == false).ToArray();
                    foreach (var pacItem in package)
                    {
                        pacItem.IsHistory             = true;
                        pacItem.LastUpdateTime        = DateTime.Now;
                        pacItem.LastUpdateUserAccount = ClientCookie.UserCode;
                    }
                    if (package.Length > 0)
                    {
                        ClosurePackage.Update(package);
                    }
                }
                #endregion

                return(true);
            }
        }
Example #15
0
        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();
            }
        }
Example #16
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();
            }
        }
        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();
            }
        }
Example #18
0
 public override string Edit()
 {
     using (TransactionScope tranScope = new TransactionScope())
     {
         Mapper.CreateMap <TempClosurePackage, TempClosurePackage>();
         var package = Mapper.Map <TempClosurePackage>(this);
         package.Id                = Guid.NewGuid();
         package.IsHistory         = false;
         package.CreateUserAccount = ClientCookie.UserCode;
         package.CreateTime        = DateTime.Now;
         Add(package);
         IsHistory = true;
         Update(this);
         ProjectInfo.Reset(ProjectId, FlowCode.TempClosure_ClosurePackage);
         ProjectInfo.Reset(ProjectId, FlowCode.TempClosure);
         var attachments = Attachment.GetList(this.TableName, Id.ToString(), "");
         var NewAtts     = new List <Attachment>();
         attachments.ForEach(att =>
         {
             var newAttach        = Duplicator.AutoCopy(att);
             newAttach.RefTableID = package.Id.ToString();
             newAttach.ID         = Guid.NewGuid();
             NewAtts.Add(newAttach);
         });
         Attachment.Add(NewAtts.ToArray());
         var assetActor = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == ProjectId && pu.RoleCode == ProjectUserRoleCode.AssetActor);
         var oldTasks   = TaskWork.Search(t => t.RefID == ProjectId && t.Status == TaskWorkStatus.UnFinish).AsNoTracking().ToList();
         oldTasks.ForEach(t =>
         {
             t.Status = TaskWorkStatus.Cancel;
         });
         TaskWork.Update(oldTasks.ToArray());
         var    latestTask = TaskWork.FirstOrDefault(t => t.RefID == ProjectId && t.TypeCode == FlowCode.TempClosure_ClosurePackage);
         string url        = "/TempClosure/Main#/ClosurePackage?projectId=" + ProjectId;
         TaskWork.SendTask(ProjectId, latestTask.Title, latestTask.StoreCode, url, assetActor, FlowCode.TempClosure, FlowCode.TempClosure_ClosurePackage, "Start");
         tranScope.Complete();
         return(url);
     }
 }
Example #19
0
 public override string Edit()
 {
     using (var tranScope = new TransactionScope())
     {
         var info     = RenewalInfo.Get(this.ProjectId);
         var consInfo = Duplicator.AutoCopy(this);
         consInfo.Id                = Guid.NewGuid();
         consInfo.IsHistory         = false;
         consInfo.CreateUserAccount = ClientCookie.UserCode;
         consInfo.Add();
         IsHistory = true;
         this.Update();
         ProjectInfo.Reset(ProjectId, this.WorkflowCode);
         var attachments = Attachment.GetList(this.TableName, Id.ToString(), string.Empty);
         attachments.ForEach(att =>
         {
             att.RefTableID = consInfo.Id.ToString();
             att.ID         = Guid.NewGuid();
         });
         Attachment.Add(attachments.ToArray());
         var reinBasic = ReinvestmentBasicInfo.GetByConsInfoId(this.Id);
         if (reinBasic != null)
         {
             var newReinBasic = Duplicator.AutoCopy(reinBasic);
             newReinBasic.Id         = 0;
             newReinBasic.ConsInfoID = consInfo.Id;
             newReinBasic.Add();
         }
         var wf = WriteOffAmount.GetByConsInfoId(this.Id);
         if (wf != null)
         {
             var newWf = Duplicator.AutoCopy(wf);
             newWf.Id         = Guid.NewGuid();
             newWf.ConsInfoID = consInfo.Id;
             newWf.Add();
         }
         var reinCost = ReinvestmentCost.GetByConsInfoId(this.Id);
         if (reinCost != null)
         {
             var newReinCost = Duplicator.AutoCopy(reinCost);
             newReinCost.Id         = Guid.NewGuid();
             newReinCost.ConsInfoID = consInfo.Id;
             newReinCost.Add();
         }
         var oldTasks = TaskWork.Search(t => t.RefID == ProjectId &&
                                        t.Status == TaskWorkStatus.UnFinish &&
                                        new string[] { FlowCode.Renewal_ConsInfo, FlowCode.Renewal_Tool }.Contains(t.TypeCode)).ToList();
         oldTasks.ForEach(t =>
         {
             t.Status = TaskWorkStatus.Cancel;
         });
         TaskWork.Update(oldTasks.ToArray());
         var toolUploadTask = TaskWork.FirstOrDefault(t => t.RefID == ProjectId &&
                                                      t.TypeCode == FlowCode.Renewal_Tool &&
                                                      t.ReceiverAccount == info.AssetActorAccount &&
                                                      t.ActivityName == "AssetActor" &&
                                                      t.Status == TaskWorkStatus.UnFinish);
         if (toolUploadTask != null)
         {
             toolUploadTask.Status = TaskWorkStatus.Cancel;
             toolUploadTask.Update();
         }
         CompleteRenewalToolTask();
         var task = info.GenerateSubmitTask(this.WorkflowCode);
         tranScope.Complete();
         return(task.Url);
     }
 }
Example #20
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);
        }
Example #21
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!");
            //}
        }
Example #22
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();
                }
            }
        }
Example #23
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();
            }
        }
Example #24
0
        public override string Edit()
        {
            //取消未处理完成的任务(主要是Package最后一个环节办理完后,不走K2流程生成的1条回到Actor的任务)
            var oldTask = TaskWork.Search(i => i.SourceCode == FlowCode.Closure && i.TypeCode == FlowCode.Closure_ClosurePackage && i.RefID == this.ProjectId && i.Status == TaskWorkStatus.UnFinish).ToArray();

            foreach (var taskItem in oldTask)
            {
                taskItem.Status = TaskWorkStatus.Cancel;
            }
            TaskWork.Update(oldTask);

            //var taskWork = TaskWork.FirstOrDefault(e => e.ReceiverAccount == ClientCookie.UserCode
            //            && e.SourceCode == FlowCode.Closure
            //            && e.TypeCode == FlowCode.Closure_ClosurePackage && e.RefID == this.ProjectId);


            //taskWork.Status = TaskWorkStatus.UnFinish;
            //taskWork.StatusNameZHCN = "任务";
            //taskWork.StatusNameENUS = "任务";

            //var closureEntity = ClosureInfo.GetByProjectId(this.ProjectId);
            //taskWork.ReceiverAccount = closureEntity.AssetActorAccount;
            //taskWork.ReceiverNameENUS = closureEntity.AssetActorNameENUS;
            //taskWork.ReceiverNameZHCN = closureEntity.AssetActorNameZHCN;
            //taskWork.Id = Guid.NewGuid();
            //taskWork.CreateTime = DateTime.Now;
            //taskWork.Url = TaskWork.BuildUrl(FlowCode.Closure_ClosurePackage, this.ProjectId, "");
            //taskWork.ActivityName = NodeCode.Start;
            //taskWork.ActionName = SetTaskActionName(ProjectId);
            //taskWork.ProcInstID = null;
            //taskWork.FinishTime = null;
            //TaskWork.Add(taskWork);
            var url = GeneratePackageTask(ProjectId);

            this.IsHistory = true;

            this.Save();

            var objectCopy = new ObjectCopy();
            var newEntity  = objectCopy.AutoCopy(this);

            newEntity.Id         = Guid.NewGuid();
            newEntity.ProcInstID = 0;
            newEntity.IsHistory  = false;
            newEntity.Add();

            var projectEntity = ProjectInfo.Get(this.ProjectId, FlowCode.Closure_ClosurePackage);

            projectEntity.Status = ProjectStatus.UnFinish;

            ProjectInfo.Update(projectEntity);
            ProjectInfo.Reset(ProjectId, FlowCode.Closure_ClosurePackage);
            ProjectInfo.Reset(ProjectId, FlowCode.Closure);
            var attList = Attachment.Search(e => e.RefTableID == this.Id.ToString() &&
                                            e.RefTableName == ClosurePackage.TableName).AsNoTracking().ToList();

            var newList = new List <Attachment>();

            foreach (var att in attList)
            {
                var newAtt = objectCopy.AutoCopy(att);
                newAtt.RefTableID = newEntity.Id.ToString();
                newAtt.ID         = Guid.NewGuid();
                newList.Add(newAtt);
            }
            Attachment.Add(newList.ToArray());
            return(url);
        }
Example #25
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;
            }
        }