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

            switch (status)
            {
            case TaskWorkStatus.K2ProcessApproved:
            {
                ProjectProgress.SetProgress(ProjectId, "90%");
                var taskcontract = TaskWork.Search(e => e.RefID == ProjectId && e.TypeCode == FlowCode.Renewal_ContractInfo).FirstOrDefault();
                if (taskcontract == null)
                {
                    info.GenerateSubmitTask(FlowCode.Renewal_ContractInfo);
                }
                var taskSiteinfo = TaskWork.Search(e => e.RefID == ProjectId && e.TypeCode == FlowCode.Renewal_SiteInfo).FirstOrDefault();
                if (taskSiteinfo == null)
                {
                    info.GenerateSubmitTask(FlowCode.Renewal_SiteInfo);
                }

                ProjectInfo.CompleteMainIfEnable(ProjectId);
                ProjectInfo.FinishNode(ProjectId, WorkflowCode, NodeCode.Renewal_Package_Approval);
            }
            break;

            case TaskWorkStatus.K2ProcessDeclined:
            {
                ProjectInfo.UpdateProjectStatus(ProjectId, FlowCode.Renewal, ProjectStatus.Rejected);
                ProjectInfo.Reject(ProjectId, FlowCode.Renewal_Package);
            }
            break;
            }
        }
示例#2
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);
        }
示例#3
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);
     }
 }
        public ReimageConsInvtChecking GetConsInvtChecking(string strProjectId, string entityId = "")
        {
            ProjectId = strProjectId;
            ReimageConsInvtChecking entity = null;

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

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

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

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

                        entity.IsShowEdit   = projectInfo.Status == ProjectStatus.Finished && !isExistTask;
                        entity.IsShowRecall = projectInfo.Status != ProjectStatus.Finished && !isExistTask;
                    }
                }
            }
            else
            {
                entity = new ReimageConsInvtChecking();
                entity.IsProjectFreezed = CheckIfFreezeProject(strProjectId);
            }
            entity.IsShowSave = ProjectInfo.IsFlowSavable(strProjectId, FlowCode.Reimage_ConsInvtChecking);
            PopulateAppUsers(entity);
            return(entity);
        }
示例#5
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());
            }
        }
示例#6
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);
            }
        }
示例#7
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);
     }
 }
示例#8
0
        public override string Edit()
        {
            string url;

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

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

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

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

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

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

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

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

            return(url);
        }
示例#9
0
        public override string Edit()
        {
            var taskWork = TaskWork.Search(e => e.ReceiverAccount == ClientCookie.UserCode &&
                                           e.SourceCode == FlowCode.Closure &&
                                           e.TypeCode == FlowCode.Closure_ConsInvtChecking && e.RefID == this.ProjectId
                                           ).AsNoTracking().FirstOrDefault();


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

            var closureEntity = ClosureInfo.GetByProjectId(this.ProjectId);

            taskWork.ReceiverAccount  = closureEntity.PMAccount;
            taskWork.ReceiverNameENUS = closureEntity.PMNameENUS;
            taskWork.ReceiverNameZHCN = closureEntity.PMNameZHCN;
            taskWork.Id           = Guid.NewGuid();
            taskWork.ProcInstID   = null;
            taskWork.CreateTime   = DateTime.Now;
            taskWork.Url          = "/Closure/Main#/ConsInvtChecking?projectId=" + this.ProjectId;
            taskWork.ActivityName = NodeCode.Start;
            taskWork.ActionName   = SetTaskActionName(ProjectId);
            taskWork.ProcInstID   = null;
            taskWork.FinishTime   = null;
            TaskWork.Add(taskWork);


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

            newEntity.Id         = Guid.NewGuid();
            newEntity.ProcInstID = 0;
            newEntity.Save();

            //var projectEntity = ProjectInfo.Get(this.ProjectId, FlowCode.Closure_ConsInvtChecking);
            //projectEntity.Status = ProjectStatus.UnFinish;

            //ProjectInfo.Update(projectEntity);
            //ProjectInfo.UpdateProjectNode(this.ProjectId, FlowCode.Closure_ConsInvtChecking,
            //    NodeCode.Closure_ConsInvtChecking_Approve);

            //ProjectInfo.Reset(ProjectId, FlowCode.Closure);
            ProjectInfo.Reset(ProjectId, FlowCode.Closure_ConsInvtChecking);
            ProjectInfo.UnFinishNode(this.ProjectId, FlowCode.Closure_ConsInvtChecking, NodeCode.Closure_ConsInvtChecking_Approve, ProjectStatus.UnFinish);

            var attList = Attachment.Search(e => e.RefTableID == this.Id.ToString() &&
                                            e.RefTableName == ClosureConsInvtChecking.TableName).AsNoTracking();

            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(taskWork.Url);
        }
示例#10
0
        public override string Edit()
        {
            if (!PreEdit(this.ProjectId))
            {
                return("");
            }
            var taskWork = TaskWork.Search(e => e.ReceiverAccount == ClientCookie.UserCode &&
                                           e.SourceCode == FlowCode.Closure &&
                                           e.TypeCode == FlowCode.Closure_LegalReview && e.RefID == this.ProjectId
                                           ).FirstOrDefault();

            TaskWork.Cancel(t => t.RefID == ProjectId && t.Status == TaskWorkStatus.UnFinish && t.TypeCode == this.WorkflowCode);//取消老的流程实例的所有未完成任务
            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.AssetActorNameENUS;
            taskWork.Id           = Guid.NewGuid();
            taskWork.ProcInstID   = null;
            taskWork.CreateTime   = DateTime.Now;
            taskWork.Url          = "/closure/Main#/LegalReview?projectId=" + this.ProjectId;
            taskWork.ActivityName = NodeCode.Start;
            taskWork.ActionName   = SetTaskActionName(ProjectId);
            TaskWork.Add(taskWork);


            this.IsHistory = true;
            //TaskWork.SetTaskHistory(this.Id, this.ProcInstID);

            this.Save();
            var _db = GetDb();

            _db.Entry(this).State = EntityState.Modified;

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

            newEntity.Id           = Guid.NewGuid();
            newEntity.ProcInstID   = 0;
            newEntity.LegalCommers = "";
            newEntity.Save();
            ProjectInfo.Reset(this.ProjectId, FlowCode.Closure_LegalReview);
            var attList = Attachment.Search(e => e.RefTableID == this.Id.ToString() &&
                                            e.RefTableName == ClosureLegalReview.TableName).AsNoTracking().ToList();

            var newList = new List <Attachment>();

            foreach (var att in attList)
            {
                var newAtt = objCopy.AutoCopy(att);
                newAtt.RefTableID = newEntity.Id.ToString();
                newAtt.ID         = Guid.NewGuid();
                newList.Add(newAtt);
            }
            Attachment.AddList(newList);

            _db.SaveChanges();
            return(taskWork.Url);
        }
示例#11
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;
            }
        }
示例#12
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);
        }
示例#13
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);
     }
 }