public async Task <IActionResult> View(ViewAddressModel model)
        {
            var appid = _tokenManager.ValidateAccessToken(model.AccessToken);
            var logs  = (await _dbContext
                         .ErrorLogs
                         .Where(t => t.AppId == appid)
                         .ToListAsync())
                        .GroupBy(t => t.Message)
                        .Select(t => new LogCollection
            {
                Message = t.Key,
                First   = t.OrderByDescending(p => p.LogTime).FirstOrDefault(),
                Count   = t.Count()
            })
                        .ToList();
            var viewModel = new ViewLogViewModel
            {
                AppId   = appid,
                Logs    = logs,
                Code    = ErrorType.Success,
                Message = "Successfully get your logs!"
            };

            return(this.Protocol(viewModel));
        }
Exemple #2
0
        public async Task <IActionResult> View(ViewAddressModel model)
        {
            var appid    = _tokenManager.ValidateAccessToken(model.AccessToken);
            var appLocal = await _dbContext.StatusApps.SingleOrDefaultAsync(t => t.AppId == appid);

            if (appLocal == null)
            {
                appLocal = new StatusApp
                {
                    AppId = appid
                };
                _dbContext.StatusApps.Add(appLocal);
                await _dbContext.SaveChangesAsync();
            }

            var logs = await _dbContext
                       .ErrorLogs
                       .Where(t => t.AppId == appid)
                       .ToListAsync();

            var viewModel = new ViewLogViewModel
            {
                AppId   = appLocal.AppId,
                Logs    = logs,
                Code    = ErrorType.Success,
                Message = "Successfully get your logs!"
            };

            return(Json(viewModel));
        }
Exemple #3
0
        public async Task <IActionResult> View(ViewAddressModel model)
        {
            var appid = await _tokenManager.ValidateAccessToken(model.AccessToken);

            var appLocal = await _dbContext.StatusApps.SingleOrDefaultAsync(t => t.AppId == appid);

            if (appLocal == null)
            {
                appLocal = new StatusApp
                {
                    AppId = appid
                };
                _dbContext.StatusApps.Add(appLocal);
                await _dbContext.SaveChangesAsync();
            }

            var logs = (await _dbContext
                        .ErrorLogs
                        .Where(t => t.AppId == appid)
                        .ToListAsync())
                       .GroupBy(t => t.Message)
                       .Select(t => new LogCollection
            {
                Message = t.Key,
                First   = t.OrderByDescending(p => p.LogTime).FirstOrDefault(),
                Count   = t.Count()
            })
                       .ToList();
            var viewModel = new ViewLogViewModel
            {
                AppId   = appLocal.AppId,
                Logs    = logs,
                Code    = ErrorType.Success,
                Message = "Successfully get your logs!"
            };

            return(Json(viewModel));
        }