Exemplo n.º 1
0
        public async Task <StatsDTO> CreateStats()
        {
            var now = _currentTimeProvider.Now;

            using (var uow = UnitOfWorkProvider.Create())
            {
                var result = new StatsDTO
                {
                    RunCountLastHour =
                        await uow.Context.Runs.CountAsync(r => r.CreatedAt > now.AddHours(-1)),

                    RunCountLastDay =
                        await uow.Context.Runs.CountAsync(r => r.CreatedAt > now.AddDays(-1)),

                    UploadedFilesCountThisWeek =
                        await uow.Context.Files.CountAsync(f => f.CreatedAt > now.AddDays(-7)),

                    UploadedFilesSizeThisWeek =
                        await uow.Context.Files.Where(f => f.CreatedAt > now.AddDays(-7)).SumAsync(f => f.FileSize),

                    ActiveUserCountLastDay =
                        await uow.Context.Users.CountAsync(u => u.Runs.Any(r => r.CreatedAt > now.AddDays(-1))),

                    RegisterUserCountThisWeek =
                        await uow.Context.Users.CountAsync(u => u.CreatedAt > now.AddDays(-7)),

                    BrokerStatus = _brokerStatus.GetStatus(),

                    BrokerClients = await _brokerStatus.GetConnectedAlgServersCount()
                };

                return(result);
            }
        }
Exemplo n.º 2
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var algServerCount = await _brokerStatus.GetConnectedAlgServersCount();

            var status = new WebServiceStatusViewModel()
            {
                IsAnyAlgServerOnline = !algServerCount.HasValue || algServerCount.Value > 0,
                IsLocalMode          = _modeOptions.Value.IsLocal
            };

            return(View(status));
        }