Esempio n. 1
0
        public async Task <List <SysMenu> > GetTopLevelMenusByRoleIds(List <int> roleIds)
        {
            var menus = await _context.Set <SysRelation>()
                        .Where(it => roleIds.Contains(it.Roleid))
                        .Join(
                _context.Set <SysMenu>().Where(
                    menu => menu.Status == MenuStatus.Active && menu.Ismenu &&
                    menu.Levels == (int)MenuLevel.Top),
                relation => relation.Menuid,
                menu => menu.Id,
                (relation, menu) => menu)
                        .ToListAsync();

            return(menus);
        }
Esempio n. 2
0
        public void WarmupDatabase()
        {
            var xx    = _dbContext.Set <SysUser>().ToList();
            var sw    = Stopwatch.StartNew();
            var count = 0;

            count += _dbContext.Set <CmsArticle>().ToList().Count();
            count += _dbContext.Set <CmsBanner>().ToList().Count();
            count += _dbContext.Set <CmsChannel>().ToList().Count();
            count += _dbContext.Set <CmsContacts>().ToList().Count();
            count += _dbContext.Set <Message>().ToList().Count();
            count += _dbContext.Set <MessageSender>().ToList().Count();
            count += _dbContext.Set <MessageTemplate>().ToList().Count();
            count += _dbContext.Set <SysCfg>().ToList().Count();
            count += _dbContext.Set <SysDept>().ToList().Count();
            count += _dbContext.Set <SysDict>().ToList().Count();
            count += _dbContext.Set <SysFileInfo>().ToList().Count();
            count += _dbContext.Set <SysLoginLog>().ToList().Count();
            count += _dbContext.Set <SysMenu>().ToList().Count();
            count += _dbContext.Set <SysNotice>().ToList().Count();
            count += _dbContext.Set <SysOperationLog>().ToList().Count();
            count += _dbContext.Set <SysRelation>().ToList().Count();
            count += _dbContext.Set <SysRole>().ToList().Count();
            count += _dbContext.Set <SysTask>().ToList().Count();
            count += _dbContext.Set <SysTaskLog>().ToList().Count();
            count += _dbContext.Set <SysUser>().ToList().Count();
            sw.Stop();
            _dbContext.Set <SysTaskLog>().Add(new SysTaskLog
            {
                ExecAt       = DateTime.Now,
                ExecSuccess  = true,
                Name         = "刷新",
                IdTask       = 1,
                JobException = $"成功!执行时间:{sw.ElapsedMilliseconds}, count={count}"
            });
        }