Exemplo n.º 1
0
        private void SaveComment()
        {
            var projectComment = new ProjectComment()
            {
                RefTableId         = Id,
                RefTableName       = _refTableName,
                CreateTime         = CreateTime,
                CreateUserAccount  = CreateUserAccount,
                CreateUserNameZHCN = CreateUser.NameZHCN,
                UserAccount        = CreateUserAccount,
                UserNameENUS       = CreateUser.NameENUS,
                Id             = Guid.NewGuid(),
                Action         = ProjectCommentAction.Submit,
                Status         = ProjectCommentStatus.Submit,
                ProcInstID     = ProcInstId,
                SourceCode     = FlowCode.Reimage,
                SourceNameENUS = FlowCode.Reimage,
                SourceNameZHCN = ""
            };

            if (!string.IsNullOrEmpty(Comment))
            {
                projectComment.Content = Comment.Trim();
            }
            var userInfo = ProjectUsers.Get(CreateUserAccount, ProjectId);

            if (userInfo != null)
            {
                projectComment.TitleCode     = userInfo.RoleCode;
                projectComment.TitleNameENUS = userInfo.RoleNameENUS;
                projectComment.TitleNameZHCN = userInfo.RoleNameZHCN;
            }
            projectComment.Add();
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
0
        public override void Recall(string comment)
        {
            using (TransactionScope tranScope = new TransactionScope())
            {
                ProjectInfo.Reset(this.ProjectId, this.WorkflowCode, ProjectStatus.Recalled);
                ProjectComment.AddComment(
                    ProjectCommentAction.Recall,
                    comment,
                    this.Id,
                    this.TableName,
                    FlowCode.TempClosure,
                    this.ProcInstId,
                    ProjectCommentStatus.Submit
                    );
                var actor            = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == this.ProjectId && pu.RoleCode == ProjectUserRoleCode.AssetActor);
                var legal            = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == this.ProjectId && pu.RoleCode == ProjectUserRoleCode.Legal);
                var oldUnfinishTasks = TaskWork.Search(t => t.RefID == this.ProjectId && t.TypeCode == FlowCode.TempClosure_LegalReview && t.Status == TaskWorkStatus.UnFinish).ToList();
                oldUnfinishTasks.ForEach(t =>
                {
                    t.Status = TaskWorkStatus.Cancel;
                });
                TaskWork.Update(oldUnfinishTasks.ToArray());
                tranScope.Complete();
            }
            string comments = ClientCookie.UserNameZHCN + "进行了流程撤回操作";

            K2FxContext.Current.GoToActivityAndRecord(
                this.ProcInstId.Value,
                this.WorkflowActOriginator,
                ClientCookie.UserCode,
                ProjectAction.Recall,
                comments
                );
            //ProjectInfo.Reset(this.ProjectId, WorkflowCode);
        }
Exemplo n.º 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);
     }
 }
Exemplo n.º 5
0
        public void Submit(string comment, Action onExecuting = null)
        {
            var legal = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == this.ProjectId && pu.RoleCode == ProjectUserRoleCode.Legal);
            var task  = TaskWork.GetTaskWork(this.ProjectId, ClientCookie.UserCode, TaskWorkStatus.UnFinish,
                                             FlowCode.TempClosure, this.WorkflowCode);

            task.Status     = TaskWorkStatus.Finished;
            task.FinishTime = DateTime.Now;
            List <ProcessDataField> dataFields = new List <ProcessDataField>
            {
                new ProcessDataField("dest_Creator", this.CreateUserAccount),
                new ProcessDataField("dest_Legal", legal.UserAccount),
                new ProcessDataField("ProcessCode", this.WorkflowProcessCode),
                new ProcessDataField("ProjectTaskInfo", JsonConvert.SerializeObject(task))
            };
            var procInstId = K2FxContext.Current.StartProcess(WorkflowProcessCode, ClientCookie.UserCode, dataFields);

            if (procInstId > 0)
            {
                using (TransactionScope tranScope = new TransactionScope())
                {
                    TaskWork.Update(task);
                    this.ProcInstId        = procInstId;
                    this.CreateTime        = DateTime.Now;
                    this.CreateUserAccount = ClientCookie.UserCode;
                    this.Update();
                    var project = ProjectInfo.Get(this.ProjectId, this.WorkflowCode);
                    project.CreateUserAccount = ClientCookie.UserCode;
                    project.Update();
                    var SavedComment = ProjectComment.GetSavedComment(this.Id, this.TableName, ClientCookie.UserCode);
                    if (SavedComment != null)
                    {
                        SavedComment.Status     = ProjectCommentStatus.Submit;
                        SavedComment.Content    = comment;
                        SavedComment.CreateTime = DateTime.Now;
                        SavedComment.Update();
                    }
                    else
                    {
                        ProjectComment.AddComment(
                            ProjectCommentAction.Submit,
                            comment,
                            this.Id,
                            this.TableName,
                            FlowCode.TempClosure,
                            procInstId,
                            ProjectCommentStatus.Submit
                            );
                    }
                    ProjectInfo.FinishNode(this.ProjectId, this.WorkflowCode, NodeCode.TempClosure_LegalReview_Input);
                    if (onExecuting != null)
                    {
                        onExecuting();
                    }
                    tranScope.Complete();
                }
            }
        }
Exemplo n.º 6
0
        private List <ProjectUsers> GetProjectUserList()
        {
            var usersList  = new List <ProjectUsers>();
            var assetActor = ProjectUsers.Get(ProjectUserRoleCode.AssetActor, ProjectUserRoleCode.AssetActor, ProjectUserRoleCode.AssetActor, AssetActorAccount, AssetActorNameENUS, AssetActorNameZHCN, ProjectId);

            assetActor.CreateUserAccount = CreateUserAccount;
            assetActor.CreateUserName    = CreateUserNameZHCN + "(" + CreateUserNameENUS + ")";
            usersList.Add(assetActor);

            var assetRep = ProjectUsers.Get(ProjectUserRoleCode.AssetRep, ProjectUserRoleCode.AssetRep, ProjectUserRoleCode.AssetRep, AssetRepAccount, AssetRepNameENUS, AssetRepNameZHCN, ProjectId);

            assetRep.CreateUserAccount = CreateUserAccount;
            assetRep.CreateUserName    = CreateUserNameZHCN + "(" + CreateUserNameENUS + ")";
            usersList.Add(assetRep);

            var finance = ProjectUsers.Get(ProjectUserRoleCode.Finance, ProjectUserRoleCode.Finance, ProjectUserRoleCode.Finance, FinanceAccount, FinanceNameENUS, FinanceNameZHCN, ProjectId);

            finance.CreateUserAccount = CreateUserAccount;
            finance.CreateUserName    = CreateUserNameZHCN + "(" + CreateUserNameENUS + ")";
            usersList.Add(finance);

            var legal = ProjectUsers.Get(ProjectUserRoleCode.Legal, ProjectUserRoleCode.Legal, ProjectUserRoleCode.Legal, LegalAccount, LegalNameENUS, LegalNameZHCN, ProjectId);

            legal.CreateUserAccount = CreateUserAccount;
            legal.CreateUserName    = CreateUserNameZHCN + "(" + CreateUserNameENUS + ")";
            usersList.Add(legal);

            var pm = ProjectUsers.Get(ProjectUserRoleCode.PM, ProjectUserRoleCode.PM, ProjectUserRoleCode.PM, PMAccount, PMNameZHCN, PMNameENUS, ProjectId);

            pm.CreateUserAccount = CreateUserAccount;
            pm.CreateUserName    = CreateUserNameZHCN + "(" + CreateUserNameENUS + ")";
            usersList.Add(pm);

            var assertMgr = ProjectUsers.Get(SystemCode.Instance.GetCodeName(ProjectUserRoleCode.AssetManager, SystemLanguage.ENUS), SystemCode.Instance.GetCodeName(ProjectUserRoleCode.AssetManager, SystemLanguage.ZHCN), ProjectUserRoleCode.AssetManager, AssetManagerAccount, AssetManagerNameENUS, AssetManagerNameZHCN, ProjectId);

            assertMgr.CreateUserAccount = CreateUserAccount;
            assertMgr.CreateUserName    = CreateUserNameZHCN + "(" + CreateUserNameENUS + ")";
            usersList.Add(assertMgr);

            var cm = ProjectUsers.Get(SystemCode.Instance.GetCodeName(ProjectUserRoleCode.CM, SystemLanguage.ENUS), SystemCode.Instance.GetCodeName(ProjectUserRoleCode.CM, SystemLanguage.ZHCN), ProjectUserRoleCode.CM, CMAccount, CMNameENUS, CMNameZHCN, ProjectId);

            cm.CreateUserAccount = CreateUserAccount;
            cm.CreateUserName    = CreateUserNameZHCN + "(" + CreateUserNameENUS + ")";
            usersList.Add(cm);

            if (NecessaryNoticeUserList != null && NecessaryNoticeUserList.Count > 0)
            {
                usersList.AddRange(NecessaryNoticeUserList.Select(
                                       user => ProjectUsers.Get(ProjectUserRoleCode.View, ProjectUserRoleCode.View, ProjectUserRoleCode.View, user.UserAccount, user.UserNameENUS, user.UserNameZHCN, ProjectId)));
            }
            if (NoticeUserList != null && NoticeUserList.Count > 0)
            {
                usersList.AddRange(NoticeUserList.Select(
                                       user => ProjectUsers.Get(ProjectUserRoleCode.View, ProjectUserRoleCode.View, ProjectUserRoleCode.View, user.UserAccount, user.UserNameENUS, user.UserNameZHCN, ProjectId)));
            }
            return(usersList);
        }
Exemplo n.º 7
0
        public void Submit(string comment, Action onExecuting = null)
        {
            var actor = ProjectUsers.GetProjectUser(this.ProjectId, ProjectUserRoleCode.AssetActor);
            var task  = TaskWork.GetTaskWork(ProjectId, ClientCookie.UserCode, TaskWorkStatus.UnFinish,
                                             FlowCode.Renewal, WorkflowCode);
            var dataFields = SetWorkflowDataFields(task);
            var procInstId = K2FxContext.Current.StartProcess(WorkflowProcessCode, ClientCookie.UserCode, dataFields);

            if (procInstId > 0)
            {
                using (TransactionScope tranScope = new TransactionScope())
                {
                    this.ProcInstId        = procInstId;
                    this.CreateTime        = DateTime.Now;
                    this.CreateUserAccount = ClientCookie.UserCode;
                    this.Update();
                    var approveDialogUser = new ApproveDialogUser();
                    approveDialogUser.Id         = Guid.NewGuid();
                    approveDialogUser.LegalCode  = AppUsers.Legal.Code;
                    approveDialogUser.ProjectId  = this.ProjectId;
                    approveDialogUser.FlowCode   = this.WorkflowCode;
                    approveDialogUser.RefTableID = this.Id.ToString();
                    approveDialogUser.Add();
                    var project = ProjectInfo.Get(this.ProjectId, this.WorkflowCode);
                    project.CreateUserAccount = ClientCookie.UserCode;
                    project.Update();
                    var SavedComment = ProjectComment.GetSavedComment(this.Id, this.TableName, ClientCookie.UserCode);
                    if (SavedComment != null)
                    {
                        SavedComment.Status     = ProjectCommentStatus.Submit;
                        SavedComment.Content    = comment;
                        SavedComment.CreateTime = DateTime.Now;
                        SavedComment.Update();
                    }
                    else
                    {
                        ProjectComment.AddComment(
                            ProjectCommentAction.Submit,
                            comment,
                            this.Id,
                            this.TableName,
                            FlowCode.Renewal,
                            procInstId,
                            ProjectCommentStatus.Submit
                            );
                    }
                    ProjectInfo.FinishNode(this.ProjectId, this.WorkflowCode, NodeCode.Renewal_LegalApproval_Input);
                    if (onExecuting != null)
                    {
                        onExecuting();
                    }
                    tranScope.Complete();
                }
            }
        }
Exemplo n.º 8
0
        public void Submit(string comment, Action onExecuting = null)
        {
            var actor = ProjectUsers.GetProjectUser(this.ProjectId, ProjectUserRoleCode.AssetActor);
            var task  = TaskWork.GetTaskWork(ProjectId, ClientCookie.UserCode, TaskWorkStatus.UnFinish,
                                             FlowCode.Renewal, WorkflowCode);
            var dataFields = SetWorkflowDataFields(task);
            var procInstId = K2FxContext.Current.StartProcess(WorkflowProcessCode, ClientCookie.UserCode, dataFields);

            if (procInstId > 0)
            {
                using (TransactionScope tranScope = new TransactionScope())
                {
                    task.Finish();
                    this.ProcInstId        = procInstId;
                    this.CreateTime        = DateTime.Now;
                    this.CreateUserAccount = ClientCookie.UserCode;
                    this.Update();
                    var project = ProjectInfo.Get(this.ProjectId, this.WorkflowCode);
                    project.CreateUserAccount = ClientCookie.UserCode;
                    project.Update();
                    var SavedComment = ProjectComment.GetSavedComment(this.Id, this.TableName, ClientCookie.UserCode);
                    if (SavedComment != null)
                    {
                        SavedComment.Status     = ProjectCommentStatus.Submit;
                        SavedComment.Content    = comment;
                        SavedComment.CreateTime = DateTime.Now;
                        SavedComment.Update();
                    }
                    else
                    {
                        ProjectComment.AddComment(
                            ProjectCommentAction.Submit,
                            comment,
                            this.Id,
                            this.TableName,
                            FlowCode.Renewal,
                            procInstId,
                            ProjectCommentStatus.Submit
                            );
                    }
                    if (onExecuting != null)
                    {
                        onExecuting();
                    }
                    ProjectInfo.FinishNode(ProjectId, WorkflowCode, NodeCode.Renewal_Letter_Upload);
                    ProjectProgress.SetProgress(ProjectId, "20%");
                    tranScope.Complete();
                }
            }
        }
Exemplo n.º 9
0
        //public void SetPackageHoldingSource()
        //{
        //    var packageHoldingDto = new PackageHoldingDto();
        //    packageHoldingDto.ProjectId = ProjectId;
        //    packageHoldingDto.FlowCode = FlowCode;

        //    if (FlowCode == Constants.FlowCode.Reimage)
        //    {
        //        var wfEntity = BaseWFEntity.GetWorkflowEntity(ProjectId, Constants.FlowCode.Reimage_Package);

        //        if (wfEntity != null)
        //        {
        //            var packageRoleUsers = BaseWFEntity.GetPackageHoldingRoleUsers();
        //            if (packageRoleUsers.Select(e => e.Code).Contains(ClientCookie.UserCode)
        //                && ProjectInfo.Any(e => e.ProjectId == ProjectId
        //                    && e.FlowCode == Constants.FlowCode.Reimage_ConsInfo
        //                    && e.Status == ProjectStatus.Finished)
        //                && ProjectInfo.Any(e => e.ProjectId == ProjectId
        //                    && e.FlowCode == Constants.FlowCode.Reimage_Summary
        //                    && e.Status == ProjectStatus.Finished)
        //                && ProjectInfo.Any(e => e.ProjectId == ProjectId
        //                    && e.FlowCode == Constants.FlowCode.Reimage_Package
        //                    && e.Status == ProjectStatus.UnFinish))
        //            {
        //                packageHoldingDto.HasRight = true;
        //                //packageHoldingDto.HasRight = false;

        //                packageHoldingDto.Status = wfEntity.GetPackageHoldingStatus();

        //            }
        //        }

        //    }

        //    PackageHoldingDto = packageHoldingDto;
        //}

        public void SetPendingRight()
        {
            var marketAssetMgr   = Employee.GetEmployeesByRole(RoleCode.Market_Asset_Mgr);
            var regionalAssetMgr = Employee.GetEmployeesByRole(RoleCode.Regional_Asset_Mgr);

            var packageRoleUsers = BaseWFEntity.GetPackageHoldingRoleUsers();

            if (ProjectUsers.Any(pu => pu.ProjectId == ProjectId &&
                                 pu.UserAccount == ClientCookie.UserCode &&
                                 pu.RoleCode == ProjectUserRoleCode.AssetActor) ||
                packageRoleUsers.Select(e => e.Code).Contains(ClientCookie.UserCode) ||
                marketAssetMgr.Select(e => e.Code).Contains(ClientCookie.UserCode) ||
                regionalAssetMgr.Select(e => e.Code).Contains(ClientCookie.UserCode))
            {
                HasPendingRight = true;
            }
        }
Exemplo n.º 10
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);
     }
 }
Exemplo n.º 11
0
        public static List <SimpleEmployee> GetEmployeeContact(string projectId)
        {
            var roleCodeFilter = new List <string>()
            {
                ProjectUserRoleCode.AssetActor,
                ProjectUserRoleCode.AssetManager,
                ProjectUserRoleCode.AssetRep
            };
            var projectUsers = ProjectUsers.Search(e => e.ProjectId == projectId &&
                                                   roleCodeFilter.Contains(e.RoleCode))
                               .Select(e => e.UserAccount)
                               .ToList();

            var storeEmployees = Employee.Search(e => projectUsers.Contains(e.Code)).Select(e => new SimpleEmployee()
            {
                NameENUS     = e.NameENUS,
                Mail         = e.Mail,
                Mobile       = e.Mobile,
                Phone        = e.Phone,
                PositionENUS = e.PositionENUS
            }).ToList();

            return(storeEmployees);
        }
Exemplo n.º 12
0
 public void AddProjectUsers()
 {
     ProjectUsers.Add(GetProjectUserList().ToArray());
 }
Exemplo n.º 13
0
        public static void Create(PostCreateWorkflow <RenewalInfo> postCreateRenewal)
        {
            using (TransactionScope tranScope = new TransactionScope())
            {
                var usCode    = postCreateRenewal.Entity.USCode;
                var store     = StoreBasicInfo.GetStorInfo(usCode);
                var projectId = ProjectInfo.CreateMainProject(FlowCode.Renewal, usCode, NodeCode.Start, ClientCookie.UserCode);
                postCreateRenewal.Entity.Id = Guid.NewGuid();
                postCreateRenewal.Entity.CreateUserAccount = ClientCookie.UserCode;
                postCreateRenewal.Entity.CreateTime        = DateTime.Now;
                postCreateRenewal.Entity.StoreNameENUS     = store.NameENUS;
                postCreateRenewal.Entity.StoreNameZHCN     = store.NameZHCN;

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

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

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

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

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

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

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

                postCreateRenewal.Entity.ProjectId = projectId;
                postCreateRenewal.Entity.Add();
                ProjectInfo.CreateSubProject(FlowCode.Renewal_Letter, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.AssetActor.UserAccount);
                RenewalLetter.Create(projectId, postCreateRenewal.Team.AssetActor.UserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_LLNegotiation, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.AssetActor.UserAccount);
                RenewalLLNegotiation.Create(projectId, postCreateRenewal.Team.AssetActor.UserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_ConsInfo, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.PM.UserAccount);
                RenewalConsInfo.Create(projectId, postCreateRenewal.Team.PM.UserAccount, postCreateRenewal.Entity.NeedProjectCostEst);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_Tool, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.Finance.UserAccount);
                var tool = RenewalTool.Create(projectId, postCreateRenewal.Team.Finance.UserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_ClearanceReport, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.AssetActor.UserAccount);
                RenewalClearanceReport.Create(projectId, postCreateRenewal.Team.AssetActor.UserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_ConfirmLetter, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.AssetActor.UserAccount);
                RenewalConfirmLetter.Create(projectId, postCreateRenewal.Team.AssetActor.UserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_Analysis, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.AssetActor.UserAccount);
                var analysis = RenewalAnalysis.Create(postCreateRenewal.Entity);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_LegalApproval, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.AssetActor.UserAccount);
                RenewalLegalApproval.Create(projectId, postCreateRenewal.Team.AssetActor.UserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_Package, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.AssetActor.UserAccount);
                RenewalPackage.Create(projectId, postCreateRenewal.Team.AssetActor.UserAccount, analysis.Id, tool.Id);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_ContractInfo, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.AssetActor.UserAccount);
                RenewalContractInfo.Create(projectId);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_SiteInfo, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.PM.UserAccount);
                RenewalSiteInfo.Create(projectId, postCreateRenewal.Team.PM.UserAccount);

                ProjectInfo.CreateSubProject(FlowCode.Renewal_GBMemo, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.PM.UserAccount);

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

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

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

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

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

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

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

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

                ProjectUsers.Add(projectUsers.ToArray());

                postCreateRenewal.Viewers.ForEach(v =>
                {
                    v.Id                = Guid.NewGuid();
                    v.ProjectId         = projectId;
                    v.CreateDate        = DateTime.Now;
                    v.CreateUserAccount = ClientCookie.UserCode;
                    v.RoleCode          = ProjectUserRoleCode.View;
                });
                ProjectUsers.Add(postCreateRenewal.Viewers.ToArray());
                //postCreateRenewal.NecessaryViewers.ForEach(v =>
                //{
                //    v.Id = Guid.NewGuid();
                //    v.ProjectId = projectId;
                //    v.CreateDate = DateTime.Now;
                //    v.CreateUserAccount = ClientCookie.UserCode;
                //    v.RoleCode = ProjectUserRoleCode.View;
                //});
                //ProjectUsers.Add(postCreateRenewal.NecessaryViewers.ToArray());
                Remind.SendRemind(projectId, FlowCode.Renewal, projectUsers);
                Remind.SendRemind(projectId, FlowCode.Renewal, postCreateRenewal.Viewers);
                postCreateRenewal.Entity.GenerateSubmitTask(FlowCode.Renewal_Letter);
                postCreateRenewal.Entity.GenerateSubmitTask(FlowCode.Renewal_LLNegotiation);
                postCreateRenewal.Entity.CreateAttachmentsMemo();
                ProjectNode.GenerateOnCreate(FlowCode.Renewal, projectId);
                ProjectProgress.SetProgress(projectId, "10%");
                tranScope.Complete();
            }
        }
Exemplo n.º 14
0
        public Dictionary <string, string> GetPrintTemplateFields()
        {
            var project            = ProjectInfo.Get(this.ProjectId, FlowCode.TempClosure_ClosurePackage);
            var storeBasic         = StoreBasicInfo.FirstOrDefault(s => s.StoreCode == project.USCode);
            var storeContract      = StoreContractInfo.Get(storeBasic.StoreCode);
            var assetMgr           = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == ProjectId && pu.RoleCode == ProjectUserRoleCode.AssetManager);
            var assetActor         = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == ProjectId && pu.RoleCode == ProjectUserRoleCode.AssetActor);
            var assetRep           = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == ProjectId && pu.RoleCode == ProjectUserRoleCode.AssetRep);
            var tempClosurePackage = TempClosurePackage.Get(ProjectId);
            var tempClosure        = TempClosureInfo.Get(ProjectId);
            Dictionary <string, string> templateFileds = new Dictionary <string, string>();

            templateFileds.Add("WorkflowName", SystemCode.Instance.GetCodeName(FlowCode.TempClosure, ClientCookie.Language));
            templateFileds.Add("ProjectID", ProjectId);
            templateFileds.Add("USCode", storeBasic.StoreCode);
            templateFileds.Add("Region", storeBasic.Region);
            templateFileds.Add("StoreNameEN", storeBasic.NameENUS);
            templateFileds.Add("Market", storeBasic.Market);
            templateFileds.Add("City", storeBasic.CityZHCN);
            templateFileds.Add("StoreNameCN", storeBasic.NameZHCN);
            templateFileds.Add("StoreAge", Math.Floor((DateTime.Now - storeBasic.OpenDate).TotalDays / 365D).ToString());
            templateFileds.Add("OpenDate", storeBasic.OpenDate.ToString("yyyy-MM-dd"));
            var storeInfo = StoreBasicInfo.GetStore(project.USCode);

            if (storeInfo.StoreContractInfo != null)
            {
                templateFileds.Add("CurrentLeaseENDYear", storeContract.EndYear);
            }
            else
            {
                templateFileds.Add("CurrentLeaseENDYear", "");
            }

            if (assetMgr != null)
            {
                templateFileds.Add("AssetsManager", assetMgr.UserNameENUS);
            }
            else
            {
                templateFileds.Add("AssetsManager", "");
            }

            templateFileds.Add("AssetsActor", assetActor.UserNameENUS);
            templateFileds.Add("AssetsRep", assetRep.UserNameENUS);
            templateFileds.Add("Address", storeBasic.AddressZHCN);
            templateFileds.Add("CloseDate", storeBasic.CloseDate.HasValue ? (storeBasic.CloseDate.Value.Year != 1900 ? storeBasic.CloseDate.Value.ToString("yyyy-MM-dd") : "") : "");
            templateFileds.Add("ClosureDate", tempClosure.ActualTempClosureDate.ToString("yyyy-MM-dd"));
            templateFileds.Add("LeaseExpireDate", tempClosure.LeaseExpireDate.HasValue ? tempClosure.LeaseExpireDate.Value.ToString("yyyy-MM-dd") : "");
            templateFileds.Add("ReOpenDate", tempClosure.ActualReopenDate.ToString("yyyy-MM-dd"));
            templateFileds.Add("RentFreeTerm", string.IsNullOrEmpty(tempClosurePackage.RentReliefClause) ? "否" : "是");
            templateFileds.Add("RentFreeStartDate", tempClosurePackage.RentReliefStartDate.HasValue ? tempClosurePackage.RentReliefStartDate.Value.ToString("yyyy-MM-dd") : "");
            templateFileds.Add("RentFreeEndDate", tempClosurePackage.RentReliefEndDate.HasValue ? tempClosurePackage.RentReliefEndDate.Value.ToString("yyyy-MM-dd") : "");
            templateFileds.Add("FreeRentTerm", tempClosurePackage.RentReliefClause);
            templateFileds.Add("LandlordName", tempClosure.LandlordName);
            if (tempClosurePackage.RentRelief.HasValue)
            {
                templateFileds.Add("ReliefRent", tempClosurePackage.RentRelief.Value ? "是" : "否");
            }
            else
            {
                templateFileds.Add("ReliefRent", "");
            }

            return(templateFileds);
        }
Exemplo n.º 15
0
        public void Resubmit(string comment, string SerialNumber, ApproveUsers newApprover, Action onExecuting = null)
        {
            var    assetActor = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == this.ProjectId && pu.RoleCode == ProjectUserRoleCode.AssetActor);
            string destMRMgrs = newApprover.MarketMgr.Code;

            if (newApprover.RegionalMgr != null)
            {
                destMRMgrs += ";" + newApprover.RegionalMgr.Code;
            }
            List <ProcessDataField> dataFields = new List <ProcessDataField>
            {
                new ProcessDataField("dest_Creator", this.CreateUserAccount),
                new ProcessDataField("dest_MRMgrs", destMRMgrs),
                new ProcessDataField("dest_GMApprovers", string.Concat(newApprover.MDD.Code, ";", newApprover.GM.Code, ";", newApprover.FC.Code)),
                new ProcessDataField("dest_VPGM", newApprover.VPGM.Code),
                new ProcessDataField("ProcessCode", this.WorkflowProcessCode)
            };

            K2FxContext.Current.ApprovalProcess(SerialNumber, ClientCookie.UserCode, "Resubmit", comment, dataFields);
            using (TransactionScope tranScope = new TransactionScope())
            {
                var project = ProjectInfo.Get(this.ProjectId, FlowCode.TempClosure_ClosurePackage);
                project.CreateUserAccount = ClientCookie.UserCode;
                project.Update();
                this.CreateUserAccount = ClientCookie.UserCode;
                Update(this);
                var approver = ApproveDialogUser.GetApproveDialogUser(this.Id.ToString());
                if (approver == null)
                {
                    approver = new ApproveDialogUser();
                }
                approver.ProjectId     = this.ProjectId;
                approver.RefTableID    = this.Id.ToString();
                approver.FlowCode      = this.WorkflowCode;
                approver.MarketMgrCode = newApprover.MarketMgr.Code;
                if (newApprover.RegionalMgr != null)
                {
                    approver.RegionalMgrCode = newApprover.RegionalMgr.Code;
                }
                else
                {
                    approver.RegionalMgrCode = null;
                }
                approver.MDDCode          = newApprover.MDD.Code;
                approver.GMCode           = newApprover.GM.Code;
                approver.FCCode           = newApprover.FC.Code;
                approver.VPGMCode         = newApprover.VPGM.Code;
                approver.MCCLAssetMgrCode = newApprover.MCCLAssetMgr.Code;
                approver.MCCLAssetDtrCode = newApprover.MCCLAssetDtr.Code;
                approver.NoticeUsers      = string.Join(";", newApprover.NoticeUsers.Select(u => u.Code).ToArray());
                approver.Save();
                ProjectInfo.FinishNode(this.ProjectId, this.WorkflowCode, NodeCode.TempClosure_ClosurePackage_Input);
                var SavedComment = ProjectComment.GetSavedComment(this.Id, this.TableName, ClientCookie.UserCode);
                if (SavedComment != null)
                {
                    SavedComment.Status     = ProjectCommentStatus.Submit;
                    SavedComment.Action     = ProjectCommentAction.ReSubmit;
                    SavedComment.Content    = comment;
                    SavedComment.CreateTime = DateTime.Now;
                    SavedComment.Update();
                }
                else
                {
                    ProjectComment.AddComment(
                        ProjectCommentAction.ReSubmit,
                        comment,
                        this.Id,
                        this.TableName,
                        FlowCode.TempClosure,
                        this.ProcInstId,
                        ProjectCommentStatus.Submit
                        );
                }

                var task = TaskWork.FirstOrDefault(t => t.RefID == this.ProjectId && t.TypeCode == this.WorkflowCode && t.ReceiverAccount == assetActor.UserAccount);
                task.Finish();
                if (onExecuting != null)
                {
                    onExecuting();
                }
                tranScope.Complete();
            }
        }
Exemplo n.º 16
0
        public static int SendTask(string refId, string title, string storeCode, string url, ProjectUsers receiver, string sourceCode, string typeCode, string activityName, int?procInstId = null)
        {
            var task     = new TaskWork();
            var source   = FlowInfo.Get(sourceCode);
            var taskType = FlowInfo.Get(typeCode);

            task.SourceCode       = source.Code;
            task.SourceNameENUS   = source.NameENUS;
            task.SourceNameZHCN   = source.NameZHCN;
            task.Status           = TaskWorkStatus.UnFinish;
            task.StatusNameZHCN   = "任务";
            task.StatusNameENUS   = "任务";
            task.Title            = title;
            task.RefID            = refId;
            task.StoreCode        = storeCode;
            task.ReceiverAccount  = receiver.UserAccount;
            task.ReceiverNameENUS = receiver.UserNameENUS;
            task.ReceiverNameZHCN = receiver.UserNameZHCN;
            task.TypeCode         = taskType.Code;
            task.TypeNameENUS     = taskType.NameENUS;
            task.TypeNameZHCN     = taskType.NameZHCN;
            task.ProcInstID       = procInstId;
            task.Id                = Guid.NewGuid();
            task.Url               = url;
            task.CreateTime        = DateTime.Now;
            task.CreateUserAccount = ClientCookie.UserCode;
            task.Sequence          = 0;
            task.ActivityName      = activityName;
            return(Add(task));
        }
Exemplo n.º 17
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();
            }
        }
Exemplo n.º 18
0
        public void Submit(string comment, ApproveUsers approvers, Action onExecuting = null)
        {
            var legal = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == this.ProjectId && pu.RoleCode == ProjectUserRoleCode.Legal);
            var task  = TaskWork.GetTaskWork(this.ProjectId, ClientCookie.UserCode, TaskWorkStatus.UnFinish,
                                             FlowCode.TempClosure, this.WorkflowCode);

            task.Status     = TaskWorkStatus.Finished;
            task.FinishTime = DateTime.Now;
            string destMRMgrs = approvers.MarketMgr.Code;

            if (approvers.RegionalMgr != null)
            {
                destMRMgrs += ";" + approvers.RegionalMgr.Code;
            }
            List <ProcessDataField> dataFields = new List <ProcessDataField>
            {
                new ProcessDataField("dest_Creator", this.CreateUserAccount),
                new ProcessDataField("dest_MRMgrs", destMRMgrs),
                new ProcessDataField("dest_GMApprovers", string.Concat(approvers.MDD.Code, ";", approvers.GM.Code, ";", approvers.FC.Code)),
                new ProcessDataField("dest_VPGM", approvers.VPGM.Code),
                new ProcessDataField("ProcessCode", this.WorkflowProcessCode),
                new ProcessDataField("ProjectTaskInfo", JsonConvert.SerializeObject(task))
            };
            var procInstId = K2FxContext.Current.StartProcess(WorkflowProcessCode, ClientCookie.UserCode, dataFields);

            if (procInstId > 0)
            {
                using (TransactionScope tranScope = new TransactionScope())
                {
                    TaskWork.Update(task);
                    var project = ProjectInfo.Get(this.ProjectId, FlowCode.TempClosure_ClosurePackage);
                    project.CreateUserAccount = ClientCookie.UserCode;
                    project.Update();
                    this.CreateUserAccount = ClientCookie.UserCode;
                    this.ProcInstId        = procInstId;
                    Update(this);
                    var approver = ApproveDialogUser.GetApproveDialogUser(this.Id.ToString());
                    if (approver == null)
                    {
                        approver = new ApproveDialogUser();
                    }
                    approver.ProjectId     = this.ProjectId;
                    approver.RefTableID    = this.Id.ToString();
                    approver.FlowCode      = FlowCode.TempClosure_ClosurePackage;
                    approver.MarketMgrCode = approvers.MarketMgr.Code;
                    if (approvers.RegionalMgr != null)
                    {
                        approver.RegionalMgrCode = approvers.RegionalMgr.Code;
                    }
                    approver.MDDCode  = approvers.MDD.Code;
                    approver.GMCode   = approvers.GM.Code;
                    approver.FCCode   = approvers.FC.Code;
                    approver.VPGMCode = approvers.VPGM.Code;
                    //approver.MCCLAssetMgrCode = approvers.MCCLAssetMgr.Code;
                    //approver.MCCLAssetDtrCode = approvers.MCCLAssetDtr.Code;
                    approver.NecessaryNoticeUsers = string.Join(";", approvers.NecessaryNoticeUsers.Select(u => u.Code).ToArray());
                    approver.NoticeUsers          = string.Join(";", approvers.NoticeUsers.Select(u => u.Code).ToArray());
                    approver.Save();
                    ProjectInfo.FinishNode(this.ProjectId, FlowCode.TempClosure_ClosurePackage, NodeCode.TempClosure_ClosurePackage_Input);
                    var SavedComment = ProjectComment.GetSavedComment(this.Id, this.TableName, ClientCookie.UserCode);
                    if (SavedComment != null)
                    {
                        SavedComment.Status     = ProjectCommentStatus.Submit;
                        SavedComment.Content    = comment;
                        SavedComment.CreateTime = DateTime.Now;
                        SavedComment.Update();
                    }
                    else
                    {
                        ProjectComment.AddComment(
                            ProjectCommentAction.Submit,
                            comment,
                            this.Id,
                            "TempClosurePackage",
                            FlowCode.TempClosure,
                            this.ProcInstId,
                            ProjectCommentStatus.Submit
                            );
                    }
                    if (onExecuting != null)
                    {
                        onExecuting();
                    }
                    tranScope.Complete();
                }
            }
        }