Example #1
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 #2
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 #3
0
        public static void Create(PostCreateWorkflow <TempClosureInfo> tempClosure)
        {
            using (TransactionScope tranScope = new TransactionScope())
            {
                var store = StoreBasicInfo.GetStorInfo(tempClosure.Entity.USCode);
                tempClosure.Entity.Id = Guid.NewGuid();
                tempClosure.Entity.CreateUserAccount = ClientCookie.UserCode;
                tempClosure.Entity.CreateTime        = DateTime.Now;

                tempClosure.Entity.StoreNameENUS = store.NameENUS;
                tempClosure.Entity.StoreNameZHCN = store.NameZHCN;

                tempClosure.Entity.AssetRepAccount  = tempClosure.Team.AssetRep.UserAccount;
                tempClosure.Entity.AssetRepNameENUS = tempClosure.Team.AssetRep.UserNameENUS;
                tempClosure.Entity.AssetRepNameZHCN = tempClosure.Team.AssetRep.UserNameZHCN;

                tempClosure.Entity.AssetActorAccount  = tempClosure.Team.AssetActor.UserAccount;
                tempClosure.Entity.AssetActorNameENUS = tempClosure.Team.AssetActor.UserNameENUS;
                tempClosure.Entity.AssetActorNameZHCN = tempClosure.Team.AssetActor.UserNameZHCN;

                tempClosure.Entity.FinanceAccount  = tempClosure.Team.Finance.UserAccount;
                tempClosure.Entity.FinanceNameENUS = tempClosure.Team.Finance.UserNameENUS;
                tempClosure.Entity.FinanceNameZHCN = tempClosure.Team.Finance.UserNameZHCN;

                tempClosure.Entity.PMAccount  = tempClosure.Team.PM.UserAccount;
                tempClosure.Entity.PMNameENUS = tempClosure.Team.PM.UserNameENUS;
                tempClosure.Entity.PMNameZHCN = tempClosure.Team.PM.UserNameZHCN;

                tempClosure.Entity.LegalAccount  = tempClosure.Team.Legal.UserAccount;
                tempClosure.Entity.LegalNameENUS = tempClosure.Team.Legal.UserNameENUS;
                tempClosure.Entity.LegalNameZHCN = tempClosure.Team.Legal.UserNameZHCN;

                tempClosure.Entity.AssetManagerAccount  = tempClosure.Team.AssetMgr.UserAccount;
                tempClosure.Entity.AssetManagerNameENUS = tempClosure.Team.AssetMgr.UserNameENUS;
                tempClosure.Entity.AssetManagerNameZHCN = tempClosure.Team.AssetMgr.UserNameZHCN;

                tempClosure.Entity.CMAccount  = tempClosure.Team.CM.UserAccount;
                tempClosure.Entity.CMNameENUS = tempClosure.Team.CM.UserNameENUS;
                tempClosure.Entity.CMNameZHCN = tempClosure.Team.CM.UserNameZHCN;

                var projectId = ProjectInfo.CreateMainProject(FlowCode.TempClosure, tempClosure.Entity.USCode, NodeCode.Start, tempClosure.Entity.CreateUserAccount);
                tempClosure.Entity.ProjectId = projectId;
                Add(tempClosure.Entity);

                List <ProjectUsers> projectUsers = new List <ProjectUsers>();

                tempClosure.Team.AssetRep.Id                = Guid.NewGuid();
                tempClosure.Team.AssetRep.ProjectId         = projectId;
                tempClosure.Team.AssetRep.CreateDate        = DateTime.Now;
                tempClosure.Team.AssetRep.CreateUserAccount = ClientCookie.UserCode;
                tempClosure.Team.AssetRep.RoleCode          = ProjectUserRoleCode.AssetRep;
                tempClosure.Team.AssetRep.RoleNameENUS      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.AssetRep, SystemLanguage.ENUS);
                tempClosure.Team.AssetRep.RoleNameZHCN      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.AssetRep, SystemLanguage.ZHCN);
                projectUsers.Add(tempClosure.Team.AssetRep);

                tempClosure.Team.AssetActor.Id                = Guid.NewGuid();
                tempClosure.Team.AssetActor.ProjectId         = projectId;
                tempClosure.Team.AssetActor.CreateDate        = DateTime.Now;
                tempClosure.Team.AssetActor.CreateUserAccount = ClientCookie.UserCode;
                tempClosure.Team.AssetActor.RoleCode          = ProjectUserRoleCode.AssetActor;
                tempClosure.Team.AssetActor.RoleNameENUS      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.AssetActor, SystemLanguage.ENUS);
                tempClosure.Team.AssetActor.RoleNameZHCN      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.AssetActor, SystemLanguage.ZHCN);
                projectUsers.Add(tempClosure.Team.AssetActor);

                tempClosure.Team.Finance.Id                = Guid.NewGuid();
                tempClosure.Team.Finance.ProjectId         = projectId;
                tempClosure.Team.Finance.CreateDate        = DateTime.Now;
                tempClosure.Team.Finance.CreateUserAccount = ClientCookie.UserCode;
                tempClosure.Team.Finance.RoleCode          = ProjectUserRoleCode.Finance;
                tempClosure.Team.Finance.RoleNameENUS      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.Finance, SystemLanguage.ENUS);
                tempClosure.Team.Finance.RoleNameZHCN      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.Finance, SystemLanguage.ZHCN);
                projectUsers.Add(tempClosure.Team.Finance);

                tempClosure.Team.PM.Id                = Guid.NewGuid();
                tempClosure.Team.PM.ProjectId         = projectId;
                tempClosure.Team.PM.CreateDate        = DateTime.Now;
                tempClosure.Team.PM.CreateUserAccount = ClientCookie.UserCode;
                tempClosure.Team.PM.RoleCode          = ProjectUserRoleCode.PM;
                tempClosure.Team.PM.RoleNameENUS      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.PM, SystemLanguage.ENUS);
                tempClosure.Team.PM.RoleNameZHCN      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.PM, SystemLanguage.ZHCN);
                projectUsers.Add(tempClosure.Team.PM);

                tempClosure.Team.Legal.Id                = Guid.NewGuid();
                tempClosure.Team.Legal.ProjectId         = projectId;
                tempClosure.Team.Legal.CreateDate        = DateTime.Now;
                tempClosure.Team.Legal.CreateUserAccount = ClientCookie.UserCode;
                tempClosure.Team.Legal.RoleCode          = ProjectUserRoleCode.Legal;
                tempClosure.Team.Legal.RoleNameENUS      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.Legal, SystemLanguage.ENUS);
                tempClosure.Team.Legal.RoleNameZHCN      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.Legal, SystemLanguage.ZHCN);
                projectUsers.Add(tempClosure.Team.Legal);

                tempClosure.Team.AssetMgr.Id                = Guid.NewGuid();
                tempClosure.Team.AssetMgr.ProjectId         = projectId;
                tempClosure.Team.AssetMgr.CreateDate        = DateTime.Now;
                tempClosure.Team.AssetMgr.CreateUserAccount = ClientCookie.UserCode;
                tempClosure.Team.AssetMgr.RoleCode          = ProjectUserRoleCode.AssetManager;
                tempClosure.Team.AssetMgr.RoleNameENUS      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.AssetManager, SystemLanguage.ENUS);
                tempClosure.Team.AssetMgr.RoleNameZHCN      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.AssetManager, SystemLanguage.ZHCN);
                projectUsers.Add(tempClosure.Team.AssetMgr);

                tempClosure.Team.CM.Id                = Guid.NewGuid();
                tempClosure.Team.CM.ProjectId         = projectId;
                tempClosure.Team.CM.CreateDate        = DateTime.Now;
                tempClosure.Team.CM.CreateUserAccount = ClientCookie.UserCode;
                tempClosure.Team.CM.RoleCode          = ProjectUserRoleCode.CM;
                tempClosure.Team.CM.RoleNameENUS      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.CM, SystemLanguage.ENUS);
                tempClosure.Team.CM.RoleNameZHCN      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.CM, SystemLanguage.ZHCN);
                projectUsers.Add(tempClosure.Team.CM);
                ProjectUsers.Add(projectUsers.ToArray());

                tempClosure.Viewers.ForEach(v =>
                {
                    v.Id                = Guid.NewGuid();
                    v.ProjectId         = projectId;
                    v.CreateDate        = DateTime.Now;
                    v.CreateUserAccount = ClientCookie.UserCode;
                    v.RoleCode          = ProjectUserRoleCode.View;
                });
                ProjectUsers.Add(tempClosure.Viewers.ToArray());
                //tempClosure.NecessaryViewers.ForEach(v =>
                //{
                //    v.Id = Guid.NewGuid();
                //    v.ProjectId = projectId;
                //    v.CreateDate = DateTime.Now;
                //    v.CreateUserAccount = ClientCookie.UserCode;
                //    v.RoleCode = ProjectUserRoleCode.View;
                //});
                //ProjectUsers.Add(tempClosure.NecessaryViewers.ToArray());

                Remind.SendRemind(projectId, FlowCode.TempClosure, projectUsers);
                ProjectInfo.CreateSubProject(FlowCode.TempClosure_LegalReview, projectId, tempClosure.Entity.USCode, NodeCode.Start, ClientCookie.UserCode);
                TempClosureLegalReview.Create(projectId);
                ProjectInfo.CreateSubProject(FlowCode.TempClosure_ClosurePackage, projectId, tempClosure.Entity.USCode, NodeCode.Start, ClientCookie.UserCode);
                TempClosurePackage.Create(projectId);
                ProjectInfo.CreateSubProject(FlowCode.TempClosure_ClosureMemo, projectId, tempClosure.Entity.USCode, NodeCode.Start, ClientCookie.UserCode);
                ProjectInfo.CreateSubProject(FlowCode.TempClosure_ReopenMemo, projectId, tempClosure.Entity.USCode, NodeCode.Start, ClientCookie.UserCode);

                string taskUrl = TaskWork.BuildUrl(FlowCode.TempClosure_LegalReview, projectId, "");
                string title   = TaskWork.BuildTitle(projectId, store.NameZHCN, store.NameENUS);
                TaskWork.SendTask(projectId, title, store.StoreCode, taskUrl, tempClosure.Team.AssetActor, FlowCode.TempClosure, FlowCode.TempClosure_LegalReview, "Start");
                ProjectNode.GenerateOnCreate(FlowCode.TempClosure, projectId);
                tranScope.Complete();
            }
        }