Esempio n. 1
0
        public void GenerateSiteInfoTask()
        {
            var taskWork = new TaskWork();

            taskWork.SourceCode     = FlowCode.Reimage;
            taskWork.SourceNameENUS = FlowCode.Reimage;
            taskWork.SourceNameZHCN = FlowCode.Reimage;
            taskWork.Status         = TaskWorkStatus.UnFinish;
            taskWork.StatusNameZHCN = "任务";
            taskWork.StatusNameENUS = "任务";
            taskWork.RefID          = ProjectId;
            taskWork.Id             = Guid.NewGuid();
            taskWork.CreateTime     = DateTime.Now;

            var reimageInfo = ReimageInfo.FirstOrDefault(e => e.ProjectId == ProjectId);

            if (reimageInfo == null)
            {
                throw new Exception("Cannot find the relative reimage info!");
            }

            taskWork.Title            = TaskWork.BuildTitle(ProjectId, reimageInfo.StoreNameZHCN, reimageInfo.StoreNameENUS);
            taskWork.TypeCode         = FlowCode.Reimage_SiteInfo;
            taskWork.TypeNameENUS     = FlowCode.Reimage_SiteInfo;
            taskWork.TypeNameZHCN     = FlowCode.Reimage_SiteInfo;
            taskWork.ReceiverAccount  = reimageInfo.PMAccount;
            taskWork.ReceiverNameENUS = reimageInfo.PMNameENUS;
            taskWork.ReceiverNameZHCN = reimageInfo.PMNameZHCN;
            taskWork.Url          = string.Format(@"/Reimage/Main#/SiteInfo/Process/Approval?projectId={0}&action={1}", ProjectId, "Confirm");
            taskWork.StoreCode    = reimageInfo.USCode;
            taskWork.ActivityName = NodeCode.Start;
            taskWork.ActionName   = SetTaskActionName(ProjectId);
            TaskWork.Add(taskWork);
        }
Esempio n. 2
0
        public void GenerateExecutiveSummaryTask(string projectId)
        {
            var taskWork = new TaskWork();

            taskWork.Id                = Guid.NewGuid();
            taskWork.CreateTime        = DateTime.Now;
            taskWork.CreateUserAccount = ClientCookie.UserCode;

            var closureInfo = ClosureInfo.GetByProjectId(projectId);

            taskWork.StoreCode        = closureInfo.USCode;
            taskWork.SourceCode       = FlowCode.Closure;
            taskWork.SourceNameZHCN   = "关店流程";
            taskWork.SourceNameENUS   = taskWork.SourceCode;
            taskWork.Status           = TaskWorkStatus.UnFinish;
            taskWork.StatusNameZHCN   = "任务";
            taskWork.StatusNameENUS   = "任务";
            taskWork.RefID            = projectId;
            taskWork.TypeCode         = FlowCode.Closure_ExecutiveSummary;
            taskWork.TypeNameENUS     = "ExecutiveSummary";
            taskWork.TypeNameZHCN     = "ExecutiveSummary";
            taskWork.ReceiverAccount  = closureInfo.AssetActorAccount;
            taskWork.ReceiverNameENUS = closureInfo.AssetActorNameENUS;
            taskWork.ReceiverNameZHCN = closureInfo.AssetActorNameZHCN;
            taskWork.Title            = TaskWork.BuildTitle(projectId, closureInfo.StoreNameZHCN, closureInfo.StoreNameENUS);
            taskWork.Url          = string.Format(@"/Closure/Main#/ExecutiveSummary?projectId={0}", projectId);
            taskWork.ActivityName = "Start";
            TaskWork.Add(taskWork);
        }
Esempio n. 3
0
        public static void GeneratePackageTask(string projectId)
        {
            var taskWork = new TaskWork();

            taskWork.SourceCode        = FlowCode.TempClosure;
            taskWork.SourceNameENUS    = taskWork.SourceCode;
            taskWork.SourceNameZHCN    = taskWork.SourceCode;
            taskWork.Status            = TaskWorkStatus.UnFinish;
            taskWork.StatusNameZHCN    = "任务";
            taskWork.StatusNameENUS    = "任务";
            taskWork.RefID             = projectId;
            taskWork.Id                = Guid.NewGuid();
            taskWork.CreateTime        = DateTime.Now;
            taskWork.CreateUserAccount = ClientCookie.UserCode;

            var tempClosure = TempClosureInfo.FirstOrDefault(i => i.ProjectId == projectId);

            if (tempClosure == null)
            {
                return;
            }

            taskWork.Title            = TaskWork.BuildTitle(projectId, tempClosure.StoreNameENUS, tempClosure.StoreNameZHCN);
            taskWork.TypeCode         = FlowCode.TempClosure_ClosurePackage;
            taskWork.TypeNameENUS     = "Closure Package";
            taskWork.TypeNameZHCN     = "Closure Package";
            taskWork.ReceiverAccount  = tempClosure.AssetActorAccount;
            taskWork.ReceiverNameENUS = tempClosure.AssetActorNameENUS;
            taskWork.ReceiverNameZHCN = tempClosure.AssetActorNameZHCN;
            taskWork.Url          = string.Format(@"/TempClosure/Main#/ClosurePackage?projectId={0}", projectId);
            taskWork.StoreCode    = tempClosure.USCode;
            taskWork.ActivityName = "Start";

            TaskWork.Add(taskWork);
        }
Esempio n. 4
0
        public void GenerateConsInvtCheckingTask(bool isScheduled = false)
        {
            var rmgInfo = ReimageInfo.Search(e => e.ProjectId.Equals(ProjectId)).AsNoTracking().FirstOrDefault();

            if (rmgInfo == null)
            {
                throw new Exception("Could not find the Reimage Info, please check it!");
            }
            var taskUrl = string.Format(@"/Reimage/Main#/ConsInvtChecking?projectId={0}", ProjectId);
            var task    = rmgInfo.GenerateTaskWork(WorkflowCode, WorkflowCode, WorkflowCode, taskUrl);

            task.ActivityName = NodeCode.Start;
            task.ActionName   = SetTaskActionName(ProjectId);

            if (!isScheduled)
            {
                TaskWork.Add(task);
            }
            else
            {
                var gbMemo = ReimageGBMemo.GetGBMemo(ProjectId);
                if (gbMemo != null && gbMemo.ConstCompletionDate.HasValue)
                {
                    ScheduleLog.GenerateTaskSchedule(gbMemo.ConstCompletionDate.Value.AddDays(60), task, ClientCookie.UserCode, ProjectId, FlowCode.Reimage_ConsInvtChecking, rmgInfo.USCode);
                }
            }
        }
Esempio n. 5
0
        public override string Edit()
        {
            var taskUrl = string.Format("/Renewal/Main#/GBMemo?projectId={0}", ProjectId);

            using (var scope = new TransactionScope())
            {
                var rbdInfo = RenewalInfo.Search(e => e.ProjectId.Equals(ProjectId)).FirstOrDefault();
                if (rbdInfo == null)
                {
                    throw new Exception("Could not find the Renewal Info, please check it!");
                }
                var task = rbdInfo.GenerateTaskWork(WorkflowCode, "Renewal GBMemo", "Renewal GBMemo", taskUrl);
                task.ActivityName = NodeCode.Start;
                task.ActionName   = SetTaskActionName(ProjectId);
                TaskWork.Add(task);
                CompleteNotifyTask(ProjectId);
                AttachmentsMemoProcessInfo.UpdateNotifyDate(ProjectId, FlowCode.GBMemo, false);
                IsHistory = true;
                Update(this);

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

                CopyAppUsers(Id.ToString(), entity.Id.ToString());

                scope.Complete();
            }
            return(taskUrl);
        }
Esempio n. 6
0
        public void Submit()
        {
            var  task     = TaskWork.GetTaskWork(ProjectId, LastUpdateUserAccount, TaskWorkStatus.UnFinish, FlowCode.Renewal, FlowCode.Renewal_GBMemo);
            bool isNoTask = false;

            if (task == null)
            {
                string taskUrl = "/Renewal/Main#/GBMemo/Process/View?projectId=" + ProjectId;
                task     = Info.GenerateTaskWork(FlowCode.Renewal_GBMemo, "GBMemo", "GBMemo", taskUrl);
                isNoTask = true;
            }
            ProcInstID = StartProcess(task);
            using (var scope = new TransactionScope())
            {
                task.Status     = TaskWorkStatus.Finished;
                task.FinishTime = DateTime.Now;
                if (isNoTask)
                {
                    TaskWork.Add(task);
                }
                else
                {
                    TaskWork.Update(task);
                }
                Save("Submit");
                ProjectInfo.FinishNode(ProjectId, FlowCode.Renewal_GBMemo, NodeCode.Renewal_GBMemo_Input);
                scope.Complete();
            }
        }
Esempio n. 7
0
        public string GeneratePackageTask(string projectId)
        {
            if (!TaskWork.Any(i => i.RefID == projectId && i.TypeCode == FlowCode.Closure_ClosurePackage && i.Status == TaskWorkStatus.UnFinish))
            {
                var taskWork = new TaskWork();
                taskWork.SourceCode        = FlowCode.Closure;
                taskWork.SourceNameENUS    = taskWork.SourceCode;
                taskWork.SourceNameZHCN    = "关店流程";
                taskWork.Status            = TaskWorkStatus.UnFinish;
                taskWork.StatusNameZHCN    = "任务";
                taskWork.StatusNameENUS    = "任务";
                taskWork.RefID             = projectId;
                taskWork.Id                = Guid.NewGuid();
                taskWork.CreateTime        = DateTime.Now;
                taskWork.CreateUserAccount = ClientCookie.UserCode;

                var closureInfo = ClosureInfo.GetByProjectId(projectId);

                taskWork.Title            = TaskWork.BuildTitle(projectId, closureInfo.StoreNameZHCN, closureInfo.StoreNameENUS);
                taskWork.TypeCode         = WorkflowCode;
                taskWork.TypeNameENUS     = "ClosurePackage";
                taskWork.TypeNameZHCN     = "ClosurePackage";
                taskWork.ReceiverAccount  = closureInfo.AssetActorAccount;
                taskWork.ReceiverNameENUS = closureInfo.AssetActorNameENUS;
                taskWork.ReceiverNameZHCN = closureInfo.AssetActorNameZHCN;
                taskWork.ActivityName     = "Start";
                taskWork.Url       = string.Format(@"/Closure/Main#/ClosurePackage?projectId={0}", projectId);
                taskWork.StoreCode = closureInfo.USCode;

                TaskWork.Add(taskWork);
                return(taskWork.Url);
            }
            return("");
        }
Esempio n. 8
0
        public TaskWork GenerateTask(string flowCode, string url, string receiver, string reveiverENUS, string receiverZHCN, string activityName)
        {
            TaskWork taskWork = new TaskWork();
            var      source   = FlowInfo.Get(FlowCode.Renewal);
            var      taskType = FlowInfo.Get(flowCode);

            taskWork.SourceCode     = source.Code;
            taskWork.SourceNameZHCN = source.NameZHCN;
            taskWork.SourceNameENUS = source.NameENUS;
            taskWork.Status         = TaskWorkStatus.UnFinish;
            taskWork.StatusNameZHCN = "任务";
            taskWork.StatusNameENUS = "任务";
            var title = TaskWork.BuildTitle(ProjectId, StoreNameZHCN, StoreNameENUS);

            taskWork.Title     = title;
            taskWork.RefID     = ProjectId;
            taskWork.StoreCode = USCode;

            taskWork.TypeCode         = taskType.Code;
            taskWork.TypeNameENUS     = taskType.NameENUS;
            taskWork.TypeNameZHCN     = taskType.NameZHCN;
            taskWork.ReceiverAccount  = receiver;
            taskWork.ReceiverNameENUS = reveiverENUS;
            taskWork.ReceiverNameZHCN = receiverZHCN;
            taskWork.Id                = Guid.NewGuid();
            taskWork.Url               = url;
            taskWork.CreateTime        = DateTime.Now;
            taskWork.CreateUserAccount = receiver;
            taskWork.Sequence          = 0;
            taskWork.ActivityName      = activityName;
            taskWork.Add();
            return(taskWork);
        }
        public void GenerateConsInvtCheckingTask(bool isScheduled = false)
        {
            if (CheckIfNeedGenerateConsInvtCheckingTask())
            {
                var taskUrl        = string.Format("/MajorLease/Main#/ConsInvtChecking?projectId={0}", ProjectId);
                var majorLeaseInfo = MajorLeaseInfo.Search(e => e.ProjectId.Equals(ProjectId)).AsNoTracking().FirstOrDefault();
                if (majorLeaseInfo == null)
                {
                    throw new Exception("Could not find the Major Lease Info, please check it!");
                }
                var task = majorLeaseInfo.GenerateTaskWork(WorkflowCode, WorkflowCode, WorkflowCode, taskUrl);
                task.ActivityName = NodeCode.Start;
                task.ActionName   = SetTaskActionName(ProjectId);
                task.CreateTime   = DateTime.Now;

                if (!isScheduled)
                {
                    TaskWork.Add(task);
                }
                else
                {
                    var consInfoRepos = new MajorLeaseConsInfo();
                    var consInfo      = consInfoRepos.GetConsInfo(ProjectId);
                    //到达Cons Info中的工程完工时间后60天 发出任务
                    if (consInfo.ReinBasicInfo != null &&
                        consInfo.ReinBasicInfo.ConsCompletionDate.HasValue)
                    {
                        ScheduleLog.GenerateTaskSchedule(consInfo.ReinBasicInfo.ConsCompletionDate.Value.AddDays(60), task, ClientCookie.UserCode, ProjectId, WorkflowCode, majorLeaseInfo.USCode);
                    }
                }
            }
        }
Esempio n. 10
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);
        }
Esempio n. 11
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);
        }
Esempio n. 12
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);
        }
Esempio n. 13
0
        public void SendWorkTask()
        {
            List <TaskWork> listTaskWork = new List <TaskWork>();
            string          strURI       = "/Rebuild/Main#/LegalReview?projectId=" + ProjectId;

            listTaskWork.Add(GenerateTaskWork(FlowCode.Rebuild_LegalReview, "LegalReview", "Legal Review", strURI));

            strURI = "/Rebuild/Main#/FinanceAnalysis?projectId=" + ProjectId;
            listTaskWork.Add(GenerateTaskWork(FlowCode.Rebuild_FinanceAnalysis, "FinanceAnalysis", "Finance Analysis", strURI));

            strURI = "/Rebuild/Main#/ConsInfo?projectId=" + ProjectId;
            listTaskWork.Add(GenerateTaskWork(FlowCode.Rebuild_ConsInfo, "ConsInfo", "Cons Info", strURI));
            TaskWork.Add(listTaskWork.ToArray());
        }
Esempio n. 14
0
        public override string Edit()
        {
            var taskUrl = string.Format("/Rebuild/Main#/LegalReview?projectId={0}", ProjectId);

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

                var package = RebuildPackage.GetRebuildPackageInfo(ProjectId);
                if (package != null)
                {
                    package.ProjectId = ProjectId;
                    package.CompleteActorPackageTask(rbdInfo.AssetActorAccount);
                }

                IsHistory = true;
                Update(this);

                ProjectInfo.Reset(ProjectId, WorkflowCode);

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

                CopyAttachment(Id.ToString(), newLeaseLR.Id.ToString());
                CopyAppUsers(Id.ToString(), newLeaseLR.Id.ToString());
                scope.Complete();
            }

            return(taskUrl);
        }
Esempio n. 15
0
        public override string Edit()
        {
            var taskUrl = string.Format("/Rebuild/Main#/ConsInfo?projectId={0}", ProjectId);

            using (var scope = new TransactionScope())
            {
                var rbdInfo = RebuildInfo.FirstOrDefault(e => e.ProjectId.Equals(ProjectId));
                if (rbdInfo == null)
                {
                    throw new Exception("Could not find the Rebuild Info, please check it!");
                }
                var task = rbdInfo.GenerateTaskWork(FlowCode.Rebuild_ConsInfo, WorkflowCode, WorkflowCode, taskUrl);
                task.ActivityName = NodeCode.Start;
                task.ActionName   = SetTaskActionName(ProjectId);
                TaskWork.Add(task);

                var package = RebuildPackage.GetRebuildPackageInfo(ProjectId);
                if (package != null)
                {
                    package.ProjectId = ProjectId;
                    package.CompleteActorPackageTask(rbdInfo.AssetActorAccount);
                }

                IsHistory = true;
                Update(this);

                ProjectInfo.Reset(ProjectId, FlowCode.Rebuild_ConsInfo);

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

                CopyAttachment(Id.ToString(), form.Id.ToString());
                CopyAppUsers(Id.ToString(), form.Id.ToString());
                CopyReinvestmentBasicInfo(ReinBasicInfo, Id);
                CopyReinvestmentCost(ReinCost, Id);
                CopyWriteOffAmount(WriteOff, Id);
                scope.Complete();
            }

            return(taskUrl);
        }
Esempio n. 16
0
        public override string Edit()
        {
            var taskUrl = string.Format("/Reimage/Main#/GBMemo?projectId={0}", ProjectId);

            using (var scope = new TransactionScope())
            {
                var rmgInfo = ReimageInfo.Search(e => e.ProjectId.Equals(ProjectId)).FirstOrDefault();
                if (rmgInfo == null)
                {
                    throw new Exception("Could not find the Reimage Info, please check it!");
                }
                var task = rmgInfo.GenerateTaskWork(WorkflowCode, "Reimage_GBMemo", "Reimage_GBMemo", taskUrl);
                task.ActivityName = NodeCode.Start;
                task.ActionName   = SetTaskActionName(ProjectId);
                TaskWork.Add(task);
                ProjectInfo.Reset(ProjectId, WorkflowCode);

                if (IsInOperation)
                {
                    ProjectInfo.Reset(ProjectId, FlowCode.Reimage_ReopenMemo);
                    ProjectInfo.Reset(ProjectId, FlowCode.Reimage_TempClosureMemo);
                }
                else
                {
                    CompleteNotFinishTask();
                }
                CompleteNotifyTask(ProjectId);
                IsHistory = true;
                Update(this);

                Mapper.CreateMap <ReimageGBMemo, ReimageGBMemo>();
                var entity = Mapper.Map <ReimageGBMemo>(this);
                entity.Id         = Guid.Empty;
                entity.ProcInstID = null;
                entity.IsHistory  = false;
                entity.Comments   = null;
                entity.CreateTime = DateTime.Now;
                entity.Save();

                CopyAppUsers(Id.ToString(), entity.Id.ToString());
                scope.Complete();
            }

            return(taskUrl);
        }
Esempio n. 17
0
 public override void Finish(TaskWorkStatus status, TaskWork task)
 {
     using (var scope = new TransactionScope())
     {
         switch (status)
         {
         case TaskWorkStatus.K2ProcessApproved:
             RenewalInfo renInfo   = RenewalInfo.Search(e => e.ProjectId.Equals(ProjectId)).FirstOrDefault();
             var         pmTaskUrl = string.Format(@"/Renewal/Main#/GBMemo/Process/Notify?projectId={0}", ProjectId);
             var         pmTask    = renInfo.GenerateTaskWork(WorkflowCode, "Renewal GBMemo", "Renewal GBMemo", pmTaskUrl);
             pmTask.ActivityName = "Notify";
             pmTask.ActionName   = "Notify";
             TaskWork.Add(pmTask);
             break;
         }
         scope.Complete();
     }
 }
Esempio n. 18
0
        public void SendWorkTask()
        {
            var listTaskWork = new List <TaskWork>
            {
                GenerateTaskWork(
                    FlowCode.Reimage_ConsInfo,
                    FlowCode.Reimage_ConsInfo,
                    FlowCode.Reimage_ConsInfo,
                    string.Format(@"/Reimage/Main#/ConsInfo?projectId={0}", ProjectId)),
                //GenerateTaskWork(
                //    FlowCode.Reimage_Summary,
                //    FlowCode.Reimage_Summary,
                //    FlowCode.Reimage_Summary,
                //    string.Format(@"/Reimage/Main#/Summary?projectId={0}", ProjectId)),
            };

            TaskWork.Add(listTaskWork.ToArray());
        }
Esempio n. 19
0
        public void SendWorkTask()
        {
            var listTaskWork = new List <TaskWork>();
            var strURI       = "/MajorLease/Main#/LegalReview?projectId=" + ProjectId;

            listTaskWork.Add(GenerateTaskWork(FlowCode.MajorLease_LegalReview, "LegalReview", "LegalReview", strURI));

            strURI = "/MajorLease/Main#/FinanceAnalysis?projectId=" + ProjectId;
            listTaskWork.Add(GenerateTaskWork(FlowCode.MajorLease_FinanceAnalysis, "FinanceAnalysis", "Finance Analysis", strURI));

            if (ChangeRedLineType.HasValue &&
                ChangeRedLineType.Value)
            {
                strURI = "/MajorLease/Main#/ConsInfo?projectId=" + ProjectId;
                listTaskWork.Add(GenerateTaskWork(FlowCode.MajorLease_ConsInfo, "ConsInfo", "Cons Info", strURI));
            }

            TaskWork.Add(listTaskWork.ToArray());
        }
Esempio n. 20
0
        public void GenerateConsInvertTask(string projectId)
        {
            if (CheckIfUnfreezePackageWorkflow(projectId))
            {
                if (!TaskWork.Any(e => e.RefID == projectId &&
                                  e.TypeCode == WorkflowCode &&
                                  e.Status == TaskWorkStatus.UnFinish))
                {
                    var taskWork = new TaskWork();
                    taskWork.SourceCode     = FlowCode.Reimage;
                    taskWork.SourceNameENUS = FlowCode.Reimage;
                    taskWork.SourceNameZHCN = FlowCode.Reimage;
                    taskWork.Status         = TaskWorkStatus.UnFinish;
                    taskWork.StatusNameZHCN = "任务";
                    taskWork.StatusNameENUS = "任务";
                    taskWork.RefID          = projectId;
                    taskWork.Id             = Guid.NewGuid();
                    taskWork.CreateTime     = DateTime.Now;
                    var reimageInfo = ReimageInfo.FirstOrDefault(e => e.ProjectId == projectId);

                    if (reimageInfo == null)
                    {
                        throw new Exception("Cannot find the relative reimage info!");
                    }

                    taskWork.Title            = TaskWork.BuildTitle(projectId, reimageInfo.StoreNameZHCN, reimageInfo.StoreNameENUS);
                    taskWork.TypeCode         = WorkflowCode;
                    taskWork.TypeNameENUS     = WorkflowCode;
                    taskWork.TypeNameZHCN     = WorkflowCode;
                    taskWork.ReceiverAccount  = reimageInfo.PMAccount;
                    taskWork.ReceiverNameENUS = reimageInfo.PMNameENUS;
                    taskWork.ReceiverNameZHCN = reimageInfo.PMNameZHCN;
                    taskWork.Url          = string.Format(@"/Reimage/Main#/ConsInvtChecking?projectId={0}", projectId);
                    taskWork.StoreCode    = reimageInfo.USCode;
                    taskWork.ActivityName = NodeCode.Start;
                    taskWork.ActionName   = SetTaskActionName(projectId);
                    TaskWork.Add(taskWork);
                }
            }
        }
Esempio n. 21
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;
            }
        }
Esempio n. 22
0
        public override void Finish(TaskWorkStatus status, TaskWork task)
        {
            using (var scope = new TransactionScope())
            {
                switch (status)
                {
                case TaskWorkStatus.K2ProcessApproved:
                    var imgInfo = ReimageInfo.Search(e => e.ProjectId.Equals(ProjectId)).FirstOrDefault();
                    ProjectInfo.FinishNode(ProjectId, FlowCode.Reimage_GBMemo, NodeCode.Finish, ProjectStatus.Finished);
                    if (IsInOperation)
                    {
                        ProjectInfo.FinishNode(ProjectId, FlowCode.Reimage_ReopenMemo, NodeCode.Finish, ProjectStatus.Finished);
                        ProjectInfo.FinishNode(ProjectId, FlowCode.Reimage_TempClosureMemo, NodeCode.Finish, ProjectStatus.Finished);
                    }
                    else
                    {
                        var taskUrlReopen = string.Format(@"/Reimage/Main#/ReopenMemo?projectId={0}", ProjectId);
                        var taskReopen    = imgInfo.GenerateTaskWork(FlowCode.Reimage_ReopenMemo, "Reopen Memo", "Reopen Memo", taskUrlReopen);
                        taskReopen.ActivityName = NodeCode.Start;
                        taskReopen.ActionName   = SetTaskActionName(ProjectId);
                        //TaskWork.Add(taskReopen);
                        if (rmgInfo.ReopenDate.HasValue)
                        {
                            ScheduleLog.GenerateTaskSchedule(rmgInfo.ReopenDate.Value.AddDays(-7), taskReopen, ClientCookie.UserCode, ProjectId, FlowCode.Reimage_ReopenMemo, rmgInfo.USCode);
                        }
                        ProjectInfo.Reset(ProjectId, FlowCode.Reimage_ReopenMemo);

                        var taskUrlClosure = string.Format(@"/Reimage/Main#/TempClosureMemo?projectId={0}", ProjectId);
                        var taskClosure    = imgInfo.GenerateTaskWork(FlowCode.Reimage_TempClosureMemo, "TempClosure Memo", "TempClosure Memo", taskUrlClosure);
                        taskClosure.ActivityName = NodeCode.Start;
                        taskClosure.ActionName   = SetTaskActionName(ProjectId);
                        TaskWork.Add(taskClosure);
                        ProjectInfo.Reset(ProjectId, FlowCode.Reimage_TempClosureMemo);
                    }

                    var consCheckingTask = TaskWork.FirstOrDefault(e => e.RefID == ProjectId && e.TypeCode == FlowCode.Reimage_ConsInvtChecking && e.Status == TaskWorkStatus.UnFinish);
                    var checkingProj     = ProjectInfo.FirstOrDefault(e => e.ProjectId == ProjectId && e.FlowCode == FlowCode.Reimage_ConsInvtChecking);
                    if (consCheckingTask == null && checkingProj != null &&
                        checkingProj.Status != ProjectStatus.Finished)
                    {
                        var consInvtChecking = new ReimageConsInvtChecking();
                        consInvtChecking.ProjectId = task.RefID;
                        consInvtChecking.GenerateConsInvtCheckingTask(true);
                    }

                    ProjectInfo.CompleteMainIfEnable(ProjectId);
                    var pmTaskUrl = string.Format(@"/Reimage/Main#/GBMemo/Process/Notify?projectId={0}", ProjectId);
                    var pmTask    = imgInfo.GenerateTaskWork(WorkflowCode, "Reimage GBMemo", "Reimage GBMemo", pmTaskUrl);
                    pmTask.ActivityName = "Notify";
                    pmTask.ActionName   = "Notify";
                    TaskWork.Add(pmTask);

                    GenerateSiteInfoTask();
                    break;

                case TaskWorkStatus.K2ProcessDeclined:
                    ProjectInfo.UpdateProjectStatus(ProjectId, FlowCode.Reimage, ProjectStatus.Rejected);
                    ProjectInfo.UpdateProjectStatus(ProjectId, FlowCode.Reimage_GBMemo, ProjectStatus.Rejected);
                    break;
                }
                scope.Complete();
            }
        }
Esempio n. 23
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);
        }
Esempio n. 24
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);
        }
Esempio n. 25
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);
        }
Esempio n. 26
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);
        }
Esempio n. 27
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);
        }