Example #1
0
        public string GenerateAttachment()
        {
            var    records      = RenewalLLNegotiationRecord.GetRecords(Id);
            var    templateName = HttpContext.Current.Server.MapPath("~/Template/Renewal_LLNegotiationRecord_Template.xlsx");
            string fileName     = string.Concat(HttpContext.Current.Server.MapPath("~/UploadFiles/"), Guid.NewGuid(), ".xlsx");

            File.Copy(templateName, fileName);
            FileInfo file = new FileInfo(fileName);
            ExcelDataInputDirector excelDirector = new ExcelDataInputDirector(file, ExcelDataInputType.RenewalLLNegotiationRecord);
            List <ExcelInputDTO>   datas         = records.Select(r => new ExcelInputDTO
            {
                McdParticipants = r.McdParticipants,
                Content         = r.Content,
                LLParticipants  = r.LLParticipants,
                Topic           = r.Topic,
                Location        = r.Location,
                MeetingDate     = r.Date.Value.ToString("yyyy-MM-dd"),
                CreateDate      = r.CreateTime.ToString("yyyy-MM-dd")
            }).ToList();

            excelDirector.ListInput(datas);
            Guid       reqId = new Guid("f314bf06-f557-4893-ae78-af3b0b561885");
            Attachment att   = Attachment.Get(Id.ToString(), reqId);

            if (att == null)
            {
                att = new Attachment();
                att.InternalName    = Path.GetFileName(fileName);
                att.RefTableName    = this.TableName;
                att.RefTableID      = Id.ToString();
                att.RelativePath    = "//";
                att.Name            = "Negotiation Record List";
                att.Extension       = ".xlsx";
                att.Length          = (int)file.Length;
                att.CreateTime      = DateTime.Now;
                att.CreatorNameZHCN = ClientCookie.UserNameZHCN;
                att.CreatorNameENUS = ClientCookie.UserNameENUS;
                att.CreatorID       = ClientCookie.UserCode;
                att.ID            = Guid.NewGuid();
                att.RequirementId = reqId;
                att.TypeCode      = "";
                Attachment.Add(att);
            }
            else
            {
                att.InternalName    = Path.GetFileName(fileName);
                att.RefTableName    = this.TableName;
                att.RefTableID      = Id.ToString();
                att.RelativePath    = "//";
                att.Name            = "Negotiation Record List";
                att.Extension       = ".xlsx";
                att.Length          = (int)file.Length;
                att.CreateTime      = DateTime.Now;
                att.CreatorNameZHCN = ClientCookie.UserNameZHCN;
                att.CreatorNameENUS = ClientCookie.UserNameENUS;
                att.CreatorID       = ClientCookie.UserCode;
                Attachment.Update(att);
            }
            return(fileName);
        }
Example #2
0
        public override string Edit()
        {
            using (TransactionScope tranScope = new TransactionScope())
            {
                var info = RenewalInfo.Get(ProjectId);

                this.IsHistory = true;
                this.Update();
                var entity = Duplicator.AutoCopy(this);
                entity.Id        = Guid.NewGuid();
                entity.IsHistory = false;
                entity.Add();
                var attachments = Attachment.GetList(this.TableName, Id.ToString(), string.Empty);
                attachments.ForEach(att =>
                {
                    att.RefTableID = entity.Id.ToString();
                    att.ID         = Guid.NewGuid();
                });
                Attachment.Add(attachments.ToArray());
                TaskWork.Cancel(e => e.TypeCode == this.WorkflowCode && e.RefID == ProjectId && e.Status == TaskWorkStatus.UnFinish);
                ProjectInfo.Reset(ProjectId, this.WorkflowCode);
                var task = info.GenerateSubmitTask(this.WorkflowCode);
                tranScope.Complete();

                return(task.Url);
            }
        }
Example #3
0
        public override string Edit()
        {
            var info = RenewalInfo.Get(this.ProjectId);

            using (var tranScope = new TransactionScope())
            {
                var legalApproval = Duplicator.AutoCopy(this);
                legalApproval.Id                = Guid.NewGuid();
                legalApproval.IsHistory         = false;
                legalApproval.LegalComments     = "";
                legalApproval.CreateUserAccount = ClientCookie.UserCode;
                legalApproval.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 = legalApproval.Id.ToString();
                    att.ID         = Guid.NewGuid();
                });
                Attachment.Add(attachments.ToArray());
                var assetActor = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == ProjectId && pu.RoleCode == ProjectUserRoleCode.AssetActor);
                TaskWork.Cancel(t => t.RefID == ProjectId && t.Status == TaskWorkStatus.UnFinish);
                var task = info.GenerateSubmitTask(this.WorkflowCode);
                tranScope.Complete();
                return(task.Url);
            }
        }
Example #4
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 #5
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 #6
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 #7
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);
        }
Example #8
0
 public void GenerateCover()
 {
     if (!Attachment.Any(att => att.RefTableID == this.Id.ToString() && att.RequirementId == new Guid("9D1E247C-AAE0-44F6-869E-F50B3E633C1C")))
     {
         var info             = RenewalInfo.Get(this.ProjectId);
         var store            = StoreBasicInfo.GetStorInfo(info.USCode);
         var contract         = StoreContractInfo.Get(info.USCode);
         var context          = HttpContext.Current;
         var templateFileName = context.Server.MapPath("~/Template/RenewalCover_Template_v20130922.xlsx");
         var fileName         = context.Server.MapPath(string.Format("~/UploadFiles/{0}.xlsx", Guid.NewGuid()));
         File.Copy(templateFileName, fileName);
         var fileInfo = new FileInfo(fileName);
         ExcelDataInputDirector excelDirector = new ExcelDataInputDirector(fileInfo, ExcelDataInputType.RenewalCover);
         ExcelInputDTO          excelInput    = new ExcelInputDTO();
         excelInput.Region              = store.RegionENUS;
         excelInput.Province            = store.ProvinceZHCN;
         excelInput.City                = store.CityENUS;
         excelInput.Market              = store.MarketENUS;
         excelInput.StoreName           = store.NameZHCN;
         excelInput.USCode              = store.StoreCode;
         excelInput.OpenDate            = store.OpenDate;
         excelInput.LeaseExpirationDate = contract.EndDate.Value;
         excelInput.Priority            = info.Priority;
         excelDirector.Input(excelInput);
         var att = new Attachment();
         att.ID              = Guid.NewGuid();
         att.RefTableID      = this.Id.ToString();
         att.RefTableName    = this.TableName;
         att.RelativePath    = "/";
         att.TypeCode        = "Cover";
         att.RequirementId   = Guid.Parse("9D1E247C-AAE0-44F6-869E-F50B3E633C1C");
         att.Name            = "Cover";
         att.Extension       = fileInfo.Extension;
         att.InternalName    = fileInfo.Name;
         att.ContentType     = "application/vnd.ms-excel";
         att.Length          = (int)fileInfo.Length;
         att.CreatorID       = ClientCookie.UserCode;
         att.CreatorNameENUS = ClientCookie.UserNameENUS;
         att.CreatorNameZHCN = ClientCookie.UserNameZHCN;
         att.CreateTime      = DateTime.Now;
         att.Add();
     }
 }
Example #9
0
        public override string Edit()
        {
            using (var tranScope = new TransactionScope())
            {
                var info   = RenewalInfo.Get(this.ProjectId);
                var entity = Duplicator.AutoCopy(this);
                entity.Id                = Guid.NewGuid();
                entity.IsHistory         = false;
                entity.CreateTime        = DateTime.Now;
                entity.CreateUserAccount = ClientCookie.UserCode;
                entity.Add();
                this.IsHistory = true;
                this.Update();
                ProjectInfo.Reset(ProjectId, this.WorkflowCode);
                var attachments = Attachment.GetList(this.TableName, Id.ToString(), string.Empty);
                attachments.ForEach(att =>
                {
                    att.RefTableID = entity.Id.ToString();
                    att.ID         = Guid.NewGuid();
                });
                Attachment.Add(attachments.ToArray());

                //var TypeCodes = new[] { FlowCode.Renewal_ContractInfo, FlowCode.Renewal_SiteInfo };
                //foreach (var typeCode in TypeCodes)
                //{
                //    var proj = ProjectInfo.Search(e => e.ProjectId == ProjectId && e.FlowCode == typeCode).FirstOrDefault();
                //    if (proj != null && proj.Status != ProjectStatus.Finished)
                //    {
                //        var oldTask = TaskWork.Search(t => t.RefID == ProjectId && t.Status == TaskWorkStatus.UnFinish && t.TypeCode == typeCode).FirstOrDefault();
                //        if (oldTask != null)
                //        {
                //            oldTask.Status = TaskWorkStatus.Cancel;
                //            TaskWork.Update(oldTask);
                //        }
                //    }
                //}
                var task = info.GenerateSubmitTask(this.WorkflowCode);
                tranScope.Complete();
                return(task.Url);
            }
        }
        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 #11
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 #12
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 #13
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 #14
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 #15
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 #16
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);
     }
 }