Example #1
0
        private void UpdateAttachmentStatusByReinvenstmentType()
        {
            var isHide       = false;
            var typecodeList = new List <string>()
            {
                "ReinCost", "WriteOff"
            };
            var attachmentRequirementIds = AttachmentRequirement.Search(e => e.RefTableName == "MajorLeaseConsInfo" &&
                                                                        typecodeList.Contains(e.TypeCode)).Select(e => e.Id).ToList();
            var attachments = Attachment.Search(e => e.RequirementId.HasValue &&
                                                e.RefTableID == Id.ToString() &&
                                                attachmentRequirementIds.Contains(e.RequirementId.Value)).ToList();

            if (attachments.Any())
            {
                if (ReinvenstmentType.HasValue &&
                    ReinvenstmentType.Value == 2)
                {
                    isHide = true;
                }

                foreach (var attachment in attachments)
                {
                    attachment.IsHide = isHide;
                }

                Attachment.Update(attachments.ToArray());
            }
        }
Example #2
0
        public override string Edit()
        {
            var taskUrl = string.Format("/MajorLease/Main#/LegalReview?projectId={0}", ProjectId);

            using (var scope = new TransactionScope())
            {
                var majorLeaseInfo = MajorLeaseInfo.Search(e => e.ProjectId.Equals(ProjectId)).FirstOrDefault();
                if (majorLeaseInfo == null)
                {
                    throw new Exception("Could not find the Major Lease Info, please check it!");
                }
                TaskWork.Cancel(t => t.RefID == ProjectId && t.Status == TaskWorkStatus.UnFinish && t.TypeCode == this.WorkflowCode);//取消老的流程实例的所有未完成任务
                var task = majorLeaseInfo.GenerateTaskWork(WorkflowCode,
                                                           "LegalReview",
                                                           "LegalReview",
                                                           taskUrl);
                task.ActivityName = NodeCode.Start;
                task.ActionName   = SetTaskActionName(ProjectId);
                TaskWork.Add(task);

                var package = MajorLeaseChangePackage.GetMajorPackageInfo(ProjectId);
                if (package != null)
                {
                    package.ProjectId = ProjectId;
                    package.CompleteActorPackageTask(majorLeaseInfo.AssetActorAccount);
                }
                IsHistory = true;
                Update(this);
                var attachments = Attachment.Search(e => e.RefTableID == Id.ToString() &&
                                                    e.RefTableName == WFMajorLeaseLegalReview.TableName).ToList();

                ProjectInfo.Reset(ProjectId, WorkflowCode);


                Mapper.CreateMap <MajorLeaseLegalReview, MajorLeaseLegalReview>();
                var newMajorLeaseLR = Mapper.Map <MajorLeaseLegalReview>(this);
                newMajorLeaseLR.Id         = Guid.Empty;
                newMajorLeaseLR.ProcInstID = null;
                newMajorLeaseLR.IsHistory  = false;
                newMajorLeaseLR.Comments   = null;
                newMajorLeaseLR.Save();

                var newAttachmentList = new List <Attachment>();
                Mapper.CreateMap <Attachment, Attachment>();
                foreach (var attachment in attachments)
                {
                    var newAttachment = Mapper.Map <Attachment>(attachment);
                    newAttachment.RefTableID = newMajorLeaseLR.Id.ToString();
                    newAttachment.ID         = Guid.NewGuid();
                    newAttachmentList.Add(newAttachment);
                }
                Attachment.Add(newAttachmentList.ToArray());
                scope.Complete();
            }

            return(taskUrl);
        }
Example #3
0
        public override string Edit()
        {
            var taskWork = TaskWork.FirstOrDefault(e => e.ReceiverAccount == ClientCookie.UserCode && e.SourceCode == FlowCode.Closure && e.TypeCode == FlowCode.Closure_ExecutiveSummary && 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_ExecutiveSummary, this.ProjectId, "");
            taskWork.ActivityName = NodeCode.Start;
            taskWork.ProcInstID   = null;
            taskWork.FinishTime   = null;
            taskWork.ActionName   = SetTaskActionName(ProjectId);
            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.IsHistory  = false;
            newEntity.Add();

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

            projectEntity.Status = ProjectStatus.UnFinish;

            ProjectInfo.Update(projectEntity);
            ProjectInfo.Reset(ProjectId, FlowCode.Closure_ExecutiveSummary);
            ProjectInfo.Reset(ProjectId, FlowCode.Closure);
            var attList = Attachment.Search(e => e.RefTableID == this.Id.ToString() && e.RefTableName == ClosureExecutiveSummary.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(taskWork.Url);
        }
Example #4
0
        public override string Edit()
        {
            var taskUrl = string.Format("/MajorLease/Main#/ConsInfo?projectId={0}", ProjectId);

            using (var scope = new TransactionScope())
            {
                var majorLeaseInfo = MajorLeaseInfo.FirstOrDefault(e => e.ProjectId.Equals(ProjectId));
                if (majorLeaseInfo == null)
                {
                    throw new Exception("Could not find the Major Lease Info, please check it!");
                }
                var task = majorLeaseInfo.GenerateTaskWork(FlowCode.MajorLease_ConsInfo,
                                                           "ConsInfo",
                                                           "ConsInfo",
                                                           taskUrl);
                task.ActivityName = NodeCode.Start;
                task.ActionName   = SetTaskActionName(ProjectId);
                TaskWork.Add(task);

                var package = MajorLeaseChangePackage.GetMajorPackageInfo(ProjectId);
                if (package != null)
                {
                    package.ProjectId = ProjectId;
                    package.CompleteActorPackageTask(majorLeaseInfo.AssetActorAccount);
                }

                IsHistory = true;
                Update(this);
                var attachments = Attachment.Search(e => e.RefTableID == Id.ToString() &&
                                                    e.RefTableName == WFMajorLeaseConsInfo.TableName).AsNoTracking().ToList();

                ProjectInfo.Reset(ProjectId, FlowCode.MajorLease_ConsInfo);

                Mapper.CreateMap <MajorLeaseConsInfo, MajorLeaseConsInfo>();
                var form = Mapper.Map <MajorLeaseConsInfo>(this);
                form.Id         = Guid.Empty;
                form.ProcInstID = null;
                form.IsHistory  = false;
                form.Comments   = null;
                form.Save("Edit");

                var newAttachmentList = new List <Attachment>();
                Mapper.CreateMap <Attachment, Attachment>();
                foreach (var attachment in attachments)
                {
                    var newAttachment = Mapper.Map <Attachment>(attachment);
                    newAttachment.RefTableID = form.Id.ToString();
                    newAttachment.ID         = Guid.NewGuid();
                    newAttachmentList.Add(newAttachment);
                }
                Attachment.Add(newAttachmentList.ToArray());
                scope.Complete();
            }

            return(taskUrl);
        }
        public override string Edit()
        {
            var taskUrl = string.Format("/MajorLease/Main#/ConsInvtChecking?projectId={0}", ProjectId);

            using (var scope = new TransactionScope())
            {
                GenerateConsInvtCheckingTask();
                IsHistory = true;
                Update(this);

                var attachments = Attachment.Search(e => e.RefTableID == Id.ToString() &&
                                                    e.RefTableName == WFMajorLeaseConsInvtChecking.TableName).AsNoTracking().ToList();

                ProjectInfo.Reset(ProjectId, WorkflowCode);

                Mapper.CreateMap <MajorLeaseConsInvtChecking, MajorLeaseConsInvtChecking>();
                var form = Mapper.Map <MajorLeaseConsInvtChecking>(this);
                form.Id         = Guid.Empty;
                form.ProcInstID = null;
                form.IsHistory  = false;
                form.Comments   = null;
                form.Save("Edit");

                CopyReinvestmentCost(Id, form.Id);
                CopyWriteOffAmount(Id, form.Id);

                var newAttachmentList = new List <Attachment>();
                Mapper.CreateMap <Attachment, Attachment>();
                foreach (var attachment in attachments)
                {
                    var newAttachment = Mapper.Map <Attachment>(attachment);
                    newAttachment.RefTableID = form.Id.ToString();
                    newAttachment.ID         = Guid.NewGuid();
                    newAttachmentList.Add(newAttachment);
                }
                Attachment.Add(newAttachmentList.ToArray());
                scope.Complete();
            }

            return(taskUrl);
        }
Example #6
0
        public static dynamic GetContractByUsCode(string usCode)
        {
            var contract = StoreContractInfo.Get(usCode);

            List <StoreContractInfoAttached> attachContract = null;

            if (contract != null)
            {
                attachContract = StoreContractInfoAttached.Search(c => c.LeaseRecapID == contract.LeaseRecapID.ToString()).ToList();
            }

            List <Attachment> attachProject = null;

            if (contract != null)
            {
                var projectContractInfo = ProjectContractInfo.Search(i => i.ContractInfoId == contract.Id).Select(p => p.Id.ToString()).ToList();
                attachProject = Attachment.Search(i => projectContractInfo.Contains(i.RefTableID)).ToList();
            }
            //if (contract.McDLegalEntity != null && contract.McDLegalEntity.StartsWith("suoya"))
            //    contract.McDLegalEntity = Dictionary.Search(d => d.Value == contract.McDLegalEntity).FirstOrDefault().NameZHCN;
            //if (contract.McDOwnership != null && contract.McDOwnership.StartsWith("suoya"))
            //    contract.McDOwnership = Dictionary.Search(d => d.Value == contract.McDOwnership).FirstOrDefault().NameZHCN;
            //if (contract.LeasePurchase != null && contract.LeasePurchase.StartsWith("suoya"))
            //    contract.LeasePurchase = Dictionary.Search(d => d.Value == contract.LeasePurchase).FirstOrDefault().NameZHCN;
            //if (contract.RentPaymentArrangement != null && contract.RentPaymentArrangement.StartsWith("suoya"))
            //    contract.RentPaymentArrangement = Dictionary.Search(d => d.Value == contract.RentPaymentArrangement).FirstOrDefault().NameZHCN;

            var histories = StoreContractInfo.GetAll(usCode).ToList();

            return(new
            {
                Current = contract,
                Histories = histories,
                Attachments = new
                {
                    contract = attachContract,
                    project = attachProject
                }
            });
        }
Example #7
0
        public override string Edit()
        {
            if (!PreEdit(this.ProjectId))
            {
                return("");
            }
            var closureEntity = ClosureInfo.GetByProjectId(this.ProjectId);
            var store         = StoreBasicInfo.GetStorInfo(closureEntity.USCode);
            var taskWork      = new TaskWork();
            var source        = FlowInfo.Get(FlowCode.Closure);
            var taskType      = FlowInfo.Get(FlowCode.Closure_WOCheckList);

            taskWork.SourceCode     = source.Code;
            taskWork.SourceNameZHCN = source.NameZHCN;
            taskWork.SourceNameENUS = source.NameENUS;
            taskWork.Status         = TaskWorkStatus.UnFinish;
            taskWork.StatusNameZHCN = "任务";
            taskWork.StatusNameENUS = "任务";
            taskWork.Title          = TaskWork.BuildTitle(this.ProjectId, store.NameZHCN, store.NameENUS);
            taskWork.RefID          = this.ProjectId;
            taskWork.StoreCode      = closureEntity.USCode;

            taskWork.TypeCode         = taskType.Code;
            taskWork.TypeNameENUS     = taskType.NameENUS;
            taskWork.TypeNameZHCN     = taskType.NameZHCN;
            taskWork.ReceiverAccount  = closureEntity.PMAccount;
            taskWork.ReceiverNameENUS = closureEntity.PMNameENUS;
            taskWork.ReceiverNameZHCN = closureEntity.PMNameZHCN;
            taskWork.Id           = Guid.NewGuid();
            taskWork.CreateTime   = DateTime.Now;
            taskWork.Url          = TaskWork.BuildUrl(FlowCode.Closure_WOCheckList, this.ProjectId, "");
            taskWork.ActivityName = NodeCode.Start;
            TaskWork.Add(taskWork);

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

            this.Save();
            var objectCopy = new ObjectCopy();
            var newWo      = objectCopy.AutoCopy(this);

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

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

            ProjectInfo.UnFinishNode(this.ProjectId, FlowCode.Closure_WOCheckList, NodeCode.Closure_WOCheckList_Approve, ProjectStatus.UnFinish);
            var attList = Attachment.Search(e => e.RefTableID == this.Id.ToString() &&
                                            e.RefTableName == ClosureWOCheckList.TableName);
            var objCopy = new ObjectCopy();
            var newList = new List <Attachment>();

            foreach (var att in attList)
            {
                var newAtt = objCopy.AutoCopy(att);
                newAtt.RefTableID = newWo.Id.ToString();
                newAtt.ID         = Guid.NewGuid();
                newList.Add(newAtt);
            }
            Attachment.AddList(newList);
            return(taskWork.Url);
        }
Example #8
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);
        }
Example #9
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);
        }
Example #10
0
        public override string Edit()
        {
            var taskUrl = string.Format("/Reimage/Main#/ConsInfo?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(FlowCode.Reimage_ConsInfo,
                                                        "Reimage_ConsInfo",
                                                        "Reimage_ConsInfo",
                                                        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 == WFReimageConsInfo.TableName).AsNoTracking().ToList();



                ProjectInfo.Reset(ProjectId, FlowCode.Reimage_ConsInfo);
                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.Comments   = null;
                form.CreateTime = DateTime.Now;
                form.SaveEdit("edit");

                List <Attachment> 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);
        }
Example #11
0
        public override string Edit()
        {
            if (!PreEdit(this.ProjectId))
            {
                return("");
            }
            var closureEntity = ClosureInfo.GetByProjectId(this.ProjectId);
            var store         = StoreBasicInfo.GetStorInfo(closureEntity.USCode);
            var taskWork      = new TaskWork();
            var source        = FlowInfo.Get(FlowCode.Closure);
            var taskType      = FlowInfo.Get(FlowCode.Closure_ClosureTool);

            taskWork.SourceCode     = source.Code;
            taskWork.SourceNameZHCN = source.NameZHCN;
            taskWork.SourceNameENUS = source.NameENUS;
            taskWork.Status         = TaskWorkStatus.UnFinish;
            taskWork.StatusNameZHCN = "任务";
            taskWork.StatusNameENUS = "任务";
            taskWork.Title          = TaskWork.BuildTitle(this.ProjectId, store.NameZHCN, store.NameENUS);
            taskWork.RefID          = this.ProjectId;
            taskWork.StoreCode      = closureEntity.USCode;

            taskWork.TypeCode         = taskType.Code;
            taskWork.TypeNameENUS     = taskType.NameENUS;
            taskWork.TypeNameZHCN     = taskType.NameZHCN;
            taskWork.ReceiverAccount  = closureEntity.FinanceAccount;
            taskWork.ReceiverNameENUS = closureEntity.FinanceNameENUS;
            taskWork.ReceiverNameZHCN = closureEntity.FinanceNameZHCN;
            taskWork.Id           = Guid.NewGuid();
            taskWork.CreateTime   = DateTime.Now;
            taskWork.ActivityName = NodeCode.Start;
            taskWork.ActionName   = SetTaskActionName(ProjectId);
            taskWork.Url          = TaskWork.BuildUrl(FlowCode.Closure_ClosureTool, this.ProjectId, "");
            TaskWork.Add(taskWork);

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

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

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

            //复制ImpactOtherStore信息
            var impactOtherStores = ClosureToolImpactOtherStore.Search(i => i.ClosureId == this.Id).AsNoTracking().ToArray();

            if (impactOtherStores.Length > 0)
            {
                foreach (var impactItem in impactOtherStores)
                {
                    impactItem.Id        = Guid.NewGuid();
                    impactItem.ClosureId = newEntity.Id;
                }
                ClosureToolImpactOtherStore.Add(impactOtherStores);
            }

            ProjectInfo.Reset(this.ProjectId, FlowCode.Closure_ClosureTool);

            var attList = Attachment.Search(e => e.RefTableID == this.Id.ToString() &&
                                            e.RefTableName == ClosureTool.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);
            return(taskWork.Url);
        }
Example #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);
        }