Пример #1
0
        public async Task <IEnumerable <AppInstanceHistoryModel> > GetDeletedAppInstanceHistory(AppInstanceHistoryModel model)
        {
            // TODO. THIS ACTION MAY BE SLOW WHEN REQUEST LOG TABLE WOULD BE LARGE
            var logs = await _dbContext.RequestLogs
                       .Where(x =>
                              x.AppInstanceId != null &&
                              x.Failed == false &&
                              PathChecker(x.Body, "DeleteAppInstance")).ToListAsync();

            if (!logs.Any())
            {
                return(new List <AppInstanceHistoryModel>());
            }

            return(logs.Select(x => new AppInstanceHistoryModel
            {
                AppInstance = JsonConvert.DeserializeObject <AppInstanceInfoModel>(x.Body),
                UserId = x.UserId,
                StartTime = x.StartTime,
                ProcessDuration = x.ProcessDuration,
                LogId = x.Id,
                Action = GetActionFromUrl(x.Path)
            }).ToList());
        }
Пример #2
0
        public async Task <IEnumerable <AppInstanceHistoryModel> > GetAppInstanceHistory(AppInstanceHistoryModel model)
        {
            var logs = await _dbContext.RequestLogs.Where(x => x.AppInstanceId == model.AppInstance.Id && x.Failed == false).OrderByDescending(x => x.Id).ToListAsync();

            var result = logs.Select(x => new AppInstanceHistoryModel
            {
                AppInstance     = JsonConvert.DeserializeObject <AppInstanceInfoModel>(x.Body),
                UserId          = x.UserId,
                StartTime       = x.StartTime,
                ProcessDuration = x.ProcessDuration,
                LogId           = x.Id,
                Action          = GetActionFromUrl(x.Path)
            }).ToList();

            return(result);
        }