Пример #1
0
        public async Task <GetApiCallLogsForAdminResponse> GetApiCallLogsForAdminAsync([FromUri] GetApiCallLogsRequest request)
        {
            int      diffTimeZoneOffset = DateTimeOffset.Now.Offset.Hours - request.TimeZoneOffset;
            DateTime from = request.From.AddHours(diffTimeZoneOffset);
            DateTime to   = request.To.AddDays(1).AddHours(diffTimeZoneOffset);

            var apiCallLogs =
                await
                _apiCallLogQueries.GetApiCallLogsAsync(request.Ip, request.Path, request.RequestHeaders,
                                                       request.RequestContent, request.ResponseHeaders, request.ResponseContent, from, to);

            var apiCallLogModels = apiCallLogs.Select(apiCallLog => new ApiCallLogForAdminModel
            {
                Ip = apiCallLog.Ip,
                ExecutionTimeMs = apiCallLog.ExecutionTimeMs,
                Id              = apiCallLog.Id,
                ThreadId        = apiCallLog.ThreadId,
                Method          = apiCallLog.Method,
                Path            = apiCallLog.Path,
                Prefix          = apiCallLog.Prefix,
                RecordedOn      = apiCallLog.RecordedOn,
                ServerName      = apiCallLog.ServerName,
                ResponseContent = apiCallLog.ResponseContent,
                ResponseHeaders = apiCallLog.ResponseHeaders,
                ResponseCode    = apiCallLog.ResponseCode,
                ResponsePhrase  = apiCallLog.ResponsePhrase,
                RequestHeaders  = apiCallLog.RequestHeaders,
                RequestContent  = apiCallLog.RequestContent
            });

            return(new GetApiCallLogsForAdminResponse
            {
                Valid = true,
                TotalCount = apiCallLogs.Count(),
                ApiCallLogs = apiCallLogModels.ToPagedList(request).ToArray()
            });
        }