IEnumerable <ProjectDto> GetProjects4CurrentUser() { var list = new List <ProjectDto>(); try { var userId = AuthUtility.GetUserId(User);//User.Identity.GetUserId(); var projs = _projectMemberService.GetProjectsByUser(userId); Log.InfoFormat("用户({0})获取项目总数:{1}", AuthUtility.GetUserName(User), projs.Count); foreach (var m in projs) { var proj = _projService.GetProjectById(m.ProjectId); if (proj == null) { // Log.WarnFormat("项目({0})已被删除", m.ProjectId); continue; } var vault = _mfvaultService.GetVaultById(proj.VaultId); if (vault == null) { // Log.WarnFormat("文档库({0})已被删除", proj.VaultId); continue; } var projDto = proj.ToDto(vault, false); list.Add(projDto); } } catch (Exception ex) { Log.Error(string.Format("获取用户项目异常:{0}", ex.Message), ex); } return(list); }
//[AllowAnonymous] public ActionResult Invitelogin(int inviterId, int projectId) { string tempIp = Request.UserHostAddress; var loginStatusModel = new LoginStatusModel { Ip = tempIp, LoginDateUtc = DateTime.UtcNow }; Api.AccountController.UpdateLoginInfo(loginStatusModel, AuthUtility.GetUserId(User), _userManager, _userService); var res = GetUserProfile(_userManager); var user = res; Session["UserId"] = user.Id; Session["Email"] = user.Email; var host = Utility.GetHost(Request.Url); var roles = AuthUtility.GetUserRoles(User.Identity); var userId = AuthUtility.GetUserId(User); var userEntity = _userManager.FindById(userId); //获取邀请人名字和项目内容 var appModel = Api.CloudController.GetClouds(userEntity, _uservaultService, _cloudService, _vaultTemplateService, _vaultService, _mfvaultService, host, roles); //_usercloudService, Session["userApp"] = appModel; var inviterRes = GetUserProfile(_userManager, inviterId); var inviterProfile = inviterRes; var projectRes = Api.ProjectController.GetProject(projectId, _projService, _mfvaultService, _vaultTemplateService); var project = projectRes; var returnStr = "{'state':'success','inviter':'" + inviterProfile.UserName + "','projectName':'" + project.Name + "','projectDes':'" + project.Description + "'}"; return(Content(returnStr)); }
private IEnumerable <VaultKey> GetCurrentVaultsEx() { var userId = AuthUtility.GetUserId(User); var userName = AuthUtility.GetUserName(User); var password = DBWorldCache.Get(userId.ToString()); var isAdUser = !String.IsNullOrEmpty(AuthUtility.GetUserDomain(User.Identity)); var server = _vaultServer.GetServer(); var vaultGuids = _workHourService.GetCurrentVaults(userName, password, isAdUser, server); return(vaultGuids); }
private IEnumerable <VaultKey> GetCurrentVaults(long?statusId = null) { var userId = AuthUtility.GetUserId(User); var uvs = _userVaultService.GetVaults(userId); return((from v in uvs let proj = _projService.GetProjectByVault(v.Id) where statusId == null || proj.StatusId == statusId.Value select new VaultKey { Guid = v.Guid, Name = proj.Name }).ToList()); }
/// <summary> /// 获取当前用户的项目库 /// </summary> /// <returns></returns> IEnumerable <ProjectDto> GetProjects4CurrentUser() { var list = new List <ProjectDto>(); var userId = AuthUtility.GetUserId(User); //User.Identity.GetUserId(); var projs = _projectMemberService.GetProjectsByUser(userId); foreach (var m in projs) { try { var proj = _projectService.GetProjectById(m.ProjectId); var vault = _mfvaultService.GetVaultById(proj.VaultId); var projDto = proj.ToDto(vault, false); list.Add(projDto); } catch (Exception ex) { Log.Error(string.Format("获取用户项目异常:{0}", ex.Message), ex); } } return(list); }