private async System.Threading.Tasks.Task InviteUser()
        {
            if (!HasErrors)
            {
                if (ProjectUsers.Any(nav => nav.EMail == NewUserEmail) || AllCompanyUsers.Any(nav => nav.EMail == NewUserEmail))
                {
                    ChangeNotification.Raise(new Notification
                    {
                        Title   = Properties.Resources.User_Invitation_Exists_Title,
                        Content = string.Format(Properties.Resources.User_Invitation_Exists_Content, NewUserEmail)
                    });
                }
                else
                {
                    try
                    {
                        User newUser = await adminService.InviteNewUserAsync(NewUserEmail, SelectedProject, globalModel.CurrentUser);

                        ProjectUsers.Add(mapper.Map <ProjectUser>(newUser));
                    }
                    catch (TimeoutException timeoutEx)
                    {
                        _eventAggregator.GetEvent <TimeoutErrorEvent>().Publish(timeoutEx);
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Helper method to add a user to project users list
        /// </summary>
        /// <param name="user">The User who will be assigned to the project.</param>
        public void AssignUser(User user)
        {
            if (ProjectUsers.Any(aUser => aUser.UserId == user.Id))
            {
                return;
            }
            var associatedUser = Mapper.Map <ProjectUser>(user);

            ProjectUsers.Add(associatedUser);
        }
        private async System.Threading.Tasks.Task AddUserToProject()
        {
            try
            {
                await adminService.AddUserToProjectAsync(AllCompanySelectedUser, SelectedProject, false);

                ProjectUsers.Add(mapper.Map <ProjectUser>(AllCompanySelectedUser));
                AllCompanyUsers.Remove(AllCompanySelectedUser);
            }
            catch (TimeoutException timeoutEx)
            {
                _eventAggregator.GetEvent <TimeoutErrorEvent>().Publish(timeoutEx);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Helper method to initialize DateCreated, CreatedBy, LastEditedBy, and DateLastEdited properties
        /// </summary>
        /// <param name="user">The User who created the project.</param>
        public void SetCreatedDetails(User user)
        {
            var date = DateTime.UtcNow;

            CreatedBy      = user;
            DateCreated    = date;
            LastEditedBy   = user;
            DateLastEdited = date;
            if (ProjectUsers.Any(aUser => aUser.UserId == user.Id))
            {
                return;
            }
            var associatedUser = Mapper.Map <ProjectUser>(user);

            ProjectUsers.Add(associatedUser);
        }
Beispiel #5
0
        /// <summary>
        /// 提交Closure
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public IHttpActionResult PostClosure(ClosureInfo entity)
        {
            using (TransactionScope tranScope = new TransactionScope())
            {
                //    bll.BeginTransAction();
                //    try
                //    {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                if (entity.ClosureReasonCode != "Others")
                {
                    entity.ClosureReasonRemark = string.Empty;
                }

                if (entity.Id == new Guid())
                {
                    entity.Id = Guid.NewGuid();

                    entity.CreateDate = DateTime.Now;

                    entity.ProjectId = ProjectInfo.CreateMainProject(FlowCode.Closure, entity.USCode, NodeCode.Start, entity.CreateUserAccount);



                    ClosureInfo.Add(entity);
                }
                else
                {
                    ClosureInfo.Update(entity);
                }
                //    bll.Commit();
                //}
                //catch (Exception ex)
                //{
                //    bll.Rollback();
                //    return BadRequest(ex.Message);
                //}
                var usersList  = new List <ProjectUsers>();
                var assetActor = GetClosureUsers(ProjectUserRoleCode.AssetActor, ProjectUserRoleCode.AssetActor, ProjectUserRoleCode.AssetActor, entity.AssetActorAccount, entity.AssetActorNameENUS, entity.AssetActorNameZHCN, entity.ProjectId);
                usersList.Add(assetActor);
                var assetRep = GetClosureUsers(ProjectUserRoleCode.AssetRep, ProjectUserRoleCode.AssetRep, ProjectUserRoleCode.AssetRep, entity.AssetRepAccount, entity.AssetRepNameENUS, entity.AssetRepNameZHCN, entity.ProjectId);
                usersList.Add(assetRep);
                var finance = GetClosureUsers(ProjectUserRoleCode.Finance, ProjectUserRoleCode.Finance, ProjectUserRoleCode.Finance, entity.FinanceAccount, entity.FinanceNameENUS, entity.FinanceNameZHCN, entity.ProjectId);
                usersList.Add(finance);
                var Legal = GetClosureUsers(ProjectUserRoleCode.Legal, ProjectUserRoleCode.Legal, ProjectUserRoleCode.Legal, entity.LegalAccount, entity.LegalNameENUS, entity.LegalNameZHCN, entity.ProjectId);
                usersList.Add(Legal);
                var PM = GetClosureUsers(ProjectUserRoleCode.PM, ProjectUserRoleCode.PM, ProjectUserRoleCode.PM, entity.PMAccount, entity.PMNameZHCN, entity.PMNameENUS, entity.ProjectId);
                usersList.Add(PM);
                var assertMgr = GetClosureUsers(ProjectUserRoleCode.AssetManager, ProjectUserRoleCode.AssetManager, ProjectUserRoleCode.AssetManager, entity.AssetManagerAccount, entity.AssetManagerNameENUS,
                                                entity.AssetManagerNameZHCN, entity.ProjectId);
                usersList.Add(assertMgr);

                var cm = GetClosureUsers(ProjectUserRoleCode.CM, ProjectUserRoleCode.CM, ProjectUserRoleCode.CM, entity.CMAccount, entity.CMNameENUS,
                                         entity.CMNameZHCN, entity.ProjectId);
                usersList.Add(cm);
                if (entity.NecessaryNoticeUserList != null && entity.NecessaryNoticeUserList.Count > 0)
                {
                    usersList.AddRange(entity.NecessaryNoticeUserList.Select(
                                           user => GetClosureUsers(ProjectUserRoleCode.View, ProjectUserRoleCode.View, ProjectUserRoleCode.View, user.Code, user.NameENUS, user.NameZHCN,
                                                                   entity.ProjectId)));
                }
                if (entity.NoticeUserList != null && entity.NoticeUserList.Count > 0)
                {
                    usersList.AddRange(entity.NoticeUserList.Select(
                                           user => GetClosureUsers(ProjectUserRoleCode.View, ProjectUserRoleCode.View, ProjectUserRoleCode.View, user.Code, user.NameENUS, user.NameZHCN,
                                                                   entity.ProjectId)));
                }

                ProjectUsers.Add(usersList.ToArray());
                SendRemind(entity);
                SendWorkTaskAndEmail(entity);

                //初始化项目信息

                ProjectInfo.CreateSubProject(FlowCode.Closure_WOCheckList, entity.ProjectId, entity.USCode, NodeCode.Start, PM.UserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Closure_LegalReview, entity.ProjectId, entity.USCode, NodeCode.Start, assetActor.UserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Closure_ClosureTool, entity.ProjectId, entity.USCode, NodeCode.Start, finance.UserAccount);

                var store = StoreBasicInfo.GetStorInfo(entity.USCode);

                var closureTool = new ClosureTool();
                closureTool.Id                   = Guid.NewGuid();
                closureTool.ProjectId            = entity.ProjectId;
                closureTool.IsHistory            = false;
                closureTool.IsOptionOffered      = entity.IsRelocation();
                closureTool.PipelineName         = store.PipelineNameENUS;
                closureTool.RelocationPipelineID = store.PipelineID;
                closureTool.Add();

                var woCheckList = new ClosureWOCheckList
                {
                    Id                = Guid.NewGuid(),
                    ProjectId         = entity.ProjectId,
                    CreateTime        = DateTime.Now,
                    CreateUserAccount = ClientCookie.UserCode,
                    CreateUserName    = ClientCookie.UserNameENUS,
                    IsHistory         = false
                };
                woCheckList.Add();

                var legalReview = new ClosureLegalReview
                {
                    Id                = Guid.NewGuid(),
                    ProjectId         = entity.ProjectId,
                    CreateTime        = DateTime.Now,
                    CreateUserAccount = ClientCookie.UserCode,
                    CreateUserName    = ClientCookie.UserNameENUS,
                    IsHistory         = false
                };
                legalReview.Add();

                var executiveSummary = new ClosureExecutiveSummary
                {
                    Id             = Guid.NewGuid(),
                    ProjectId      = entity.ProjectId,
                    CreateTime     = DateTime.Now,
                    CreatorAccount = ClientCookie.UserCode,
                    CreatorName    = ClientCookie.UserNameENUS,
                    IsHistory      = false
                };
                executiveSummary.Add();

                //var package = new ClosurePackage
                //{
                //    Id = Guid.NewGuid(),
                //    ProjectId = entity.ProjectId,
                //    CreateTime = DateTime.Now,
                //    CreateUserAccount = ClientCookie.UserCode,
                //    IsHistory = false
                //};
                //package.Add();

                var projectContractInfo = ProjectContractInfo.GetContractWithHistory(entity.ProjectId).Current;
                projectContractInfo.Add();

                ProjectInfo.CreateSubProject(FlowCode.Closure_ExecutiveSummary, entity.ProjectId, entity.USCode, NodeCode.Start, assetActor.UserAccount);

                ProjectInfo.CreateSubProject(FlowCode.Closure_ClosurePackage, entity.ProjectId, entity.USCode, NodeCode.Start, assetActor.UserAccount);

                ProjectInfo.CreateSubProject(FlowCode.Closure_ConsInvtChecking, entity.ProjectId, entity.USCode, NodeCode.Start, entity.PMAccount);


                ProjectInfo.CreateSubProject(FlowCode.Closure_ContractInfo, entity.ProjectId, entity.USCode,
                                             NodeCode.Start, entity.CreateUserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Closure_Memo, entity.ProjectId, entity.USCode,
                                             NodeCode.Start, entity.CreateUserAccount);
                ProjectNode.GenerateOnCreate(FlowCode.Closure, entity.ProjectId);
                try
                {
                    //bllActionLog.Add(new ActionLog
                    //{
                    //    Id = Guid.NewGuid(),
                    //    ProjectId = entity.ProjectId,
                    //    Action = ActionType.Submit,
                    //    CreateTime = DateTime.Now,
                    //    Operator = entity.CreateUserAccount,
                    //    OperatorENUS = entity.CreateUserNameENUS,
                    //    OperatorZHCN = entity.CreateUserNameZHCN,
                    //    Remark = "",
                    //    OperatorTitle = "创建流程"
                    //});
                    tranScope.Complete();
                    //bll.GetDb().SaveChanges();
                }
                catch (DbEntityValidationException dbEx)
                {
                    tranScope.Dispose();
                }


                return(Ok(entity));
            }
        }