/// <summary> /// </summary> /// <returns> /// </returns> public async Task <IActionResult> IndexAsync() { await _hub.Clients.User(_iUserInfo.UserId).SendAsync("welcome", "欢迎您访问系统"); //用户数量 ViewBag.SysUserCount = await userManager.Users.CountAsync(); // 系统使用次数 ViewBag.shiyong = await _iSysUserLogService.GetAll().CountAsync(); //执行速度 ViewBag.SysUserLogDayDuration = _iDapperRepository.QueryAsync("select * from (SELECT top 10 'Keys'=CAST(createddatetime AS DATE ),'Value'=CEILING(AVG(Duration)) FROM sysuserlogs GROUP BY CAST(createddatetime AS DATE ) order by keys desc) as temp order by keys").Result.ToDictionary(a => a.Keys.ToShortDateString(), b => b.Value); //使用次数 曲线图 ViewBag.SysUserLogDayCount = _iDapperRepository.QueryAsync("select * from (SELECT top 10 'Keys'=CAST(createddatetime AS DATE ),'Value'=COUNT(*) FROM sysuserlogs GROUP BY CAST(createddatetime AS DATE ) order by keys desc) as temp order by keys;").Result.ToDictionary(a => a.Keys.ToShortDateString(), b => b.Value); //当前访问的数据库大小 ViewBag.DbSize = _iDapperRepository.QueryAsync($"sp_spaceused").Result.FirstOrDefault()?.database_size.ToString(); //当前用户未读消息数量 ViewBag.MessageUnread = await _iSysMessageCenterService.GetAll(a => (a.AddresseeId == null || a.AddresseeId.Contains(_iUserInfo.UserId)) && a.SysMessageReceiveds.All(b => b.CreatedBy != _iUserInfo.UserId)).CountAsync(); ViewBag.CacheCountInMemory = await _IEasyCachingProviderFactory.GetCachingProvider(EasyCachingConstValue.DefaultInMemoryName).GetCountAsync(); ViewBag.CacheCountRedis = await _IEasyCachingProviderFactory.GetCachingProvider(EasyCachingConstValue.DefaultRedisName).GetCountAsync(); return(View()); }
/// <summary> /// </summary> /// <param name="DepartmentId"> /// </param> /// <returns> /// </returns> public async Task <IActionResult> IndexAsync(string DepartmentId) { var user = await _iSysUserService.GetUserAsync(HttpContext.User); var deps = _ISysDepartmentSysUserService.GetAll(a => a.SysUserId == _iUserInfo.UserId); //切换部门 if (!string.IsNullOrEmpty(DepartmentId)) { deps = deps.Where(a => a.SysDepartment.SystemId == DepartmentId); } if (deps.Any()) { var claims = await _iSysUserService.GetClaimsAsync(user); await _iSysUserService.RemoveClaimsAsync(user, claims.Where(a => a.Type == "DepartmentId")); //保存到用户信息 await _iSysUserService.AddClaimAsync(user, new Claim("DepartmentId", deps.First().SysDepartment.SystemId)); await _signInManager.SignInAsync(user, true); } var userroles = await _iSysUserService.GetRolesAsync(user); ViewBag.MessageCount = _iSysMessageCenterService.GetAll(a => (a.AddresseeId == null || a.AddresseeId.Contains(_iUserInfo.UserId)) && a.SysMessageReceiveds.All(b => b.CreatedBy != _iUserInfo.UserId)).Count(); ViewBag.Menu = JsonConvert.SerializeObject(_sysControllerService.GetAll(a => a.Display && a.Enable && a.SysControllerSysActions.Any( b => b.SysRoleSysControllerSysActions.Any(c => userroles.Any(d => d == c.IdentityRole.Name) )) && a.SysArea.AreaName.Equals("Platform")).Select(a => new { id = a.SystemId, pId = a.SystemId.Substring(0, a.SystemId.Length - 3), name = a.Name, url = a.ControllerName == null ? "javascript:;" : "#" + Url.Action(a.ActionName, a.ControllerName), target = "_self" })); ViewBag.OffsiderbarHelp = _iSysHelpService.GetAll(); var nickName = HttpContext.User.FindFirstValue("Nickname"); if (string.IsNullOrEmpty(nickName)) { nickName = HttpContext.User.Identity.Name; } ViewBag.nickName = nickName; // 读取部门 ViewBag.Department = new SelectList(_ISysDepartmentSysUserService.GetAll(a => a.SysUserId == _iUserInfo.UserId).Select(a => a.SysDepartment).OrderBy(a => a.SystemId), "SystemId", "Name", _iUserInfo.DepartmentId); _logger.LogInformation("Access Platform Successful!"); return(View()); }
// GET: Platform/MyMessage /// <summary> /// 我收到的消息列表 /// </summary> /// <returns> /// </returns> public async Task <IActionResult> Index(string keyword, int pageIndex = 1) { var model = _iSysMessageService.GetAll(a => a.AddresseeId == null || a.AddresseeId.Contains(_iUserInfo.UserId) && a.SysMessageReceiveds.All(b => b.Remark != "Deleted")).OrderBy(a => a.SysMessageReceiveds.Any(r => r.CreatedBy == _iUserInfo.UserId)).ThenByDescending(a => a.CreatedDateTime).Select(a => new { read = a.SysMessageReceiveds.Any(b => b.CreatedBy == _iUserInfo.UserId), a.Title, a.Content, a.UserCreatedBy, a.CreatedDateTime, a.Id }).Search(keyword); return(View(model.PageResult(pageIndex, 20))); }