コード例 #1
0
        public async Task <AllTokenRequestLogReadListResponse> GetTokenRequestLogs(AllTokenRequestLogReadListRequest request)
        {
            var response = new AllTokenRequestLogReadListResponse();

            var currentUser = _cacheManager.GetCachedCurrentUser(request.CurrentUserId);

            if (!currentUser.IsSuperAdmin)
            {
                response.SetInvalid();
                return(response);
            }

            Expression <Func <TokenRequestLog, object> > orderByColumn = x => x.Id;
            Expression <Func <TokenRequestLog, bool> >   filter        = null;

            if (request.SearchTerm.IsNotEmpty())
            {
                filter = x => x.Name.Contains(request.SearchTerm);
            }

            List <TokenRequestLog> entities;

            if (request.PagingInfo.Skip < 1)
            {
                entities = await _tokenRequestLogRepository.SelectAfter(filter, request.PagingInfo.LastUid, request.PagingInfo.Take, orderByColumn, request.PagingInfo.IsAscending);
            }
            else
            {
                entities = await _tokenRequestLogRepository.SelectMany(filter, request.PagingInfo.Skip, request.PagingInfo.Take, orderByColumn, request.PagingInfo.IsAscending);
            }

            if (entities != null)
            {
                for (var i = 0; i < entities.Count; i++)
                {
                    var entity = entities[i];
                    var dto    = _tokenRequestLogFactory.CreateDtoFromEntity(entity);
                    response.Items.Add(dto);
                }
            }

            response.PagingInfo.Skip           = request.PagingInfo.Skip;
            response.PagingInfo.Take           = request.PagingInfo.Take;
            response.PagingInfo.LastUid        = request.PagingInfo.LastUid;
            response.PagingInfo.IsAscending    = request.PagingInfo.IsAscending;
            response.PagingInfo.TotalItemCount = await _tokenRequestLogRepository.Count(filter);

            response.Status = ResponseStatus.Success;
            return(response);
        }
コード例 #2
0
        public async Task <IActionResult> TokenRequestLogListData(int skip, int take)
        {
            var request = new AllTokenRequestLogReadListRequest(CurrentUser.Id);

            SetPaging(skip, take, request);

            var response = await _adminService.GetTokenRequestLogs(request);

            if (response.Status.IsNotSuccess)
            {
                return(NotFound());
            }

            var result = new DataResult();

            result.AddHeaders("organization_name", "user_name", "ip", "country", "city", "http_method", "response_code", "created_at");

            for (var i = 0; i < response.Items.Count; i++)
            {
                var item          = response.Items[i];
                var stringBuilder = new StringBuilder();
                stringBuilder.Append($"{item.Uid}{DataResult.SEPARATOR}");
                stringBuilder.Append($"{result.PrepareLink($"/Organization/Detail/{item.OrganizationUid}", item.OrganizationName)}{DataResult.SEPARATOR}");
                stringBuilder.Append($"{result.PrepareLink($"/Integration/Detail/{item.IntegrationUid}", item.IntegrationName)}{DataResult.SEPARATOR}");
                stringBuilder.Append($"{item.Ip}{DataResult.SEPARATOR}");
                stringBuilder.Append($"{item.Country}{DataResult.SEPARATOR}");
                stringBuilder.Append($"{item.City}{DataResult.SEPARATOR}");
                stringBuilder.Append($"{item.HttpMethod}{DataResult.SEPARATOR}");
                stringBuilder.Append($"{item.ResponseCode}{DataResult.SEPARATOR}");
                stringBuilder.Append($"{GetDateTimeAsString(item.CreatedAt)}{DataResult.SEPARATOR}");

                result.Data.Add(stringBuilder.ToString());
            }

            result.PagingInfo      = response.PagingInfo;
            result.PagingInfo.Type = PagingInfo.PAGE_NUMBERS;

            return(Json(result));
        }
コード例 #3
0
        public async Task <AllTokenRequestLogReadListResponse> GetAllTokenRequestLogs(AllTokenRequestLogReadListRequest request)
        {
            var response = new AllTokenRequestLogReadListResponse();

            var entities = await _tokenRequestLogRepository.SelectMany(null, request.PagingInfo.Skip, request.PagingInfo.Take, x => x.Id, request.PagingInfo.IsAscending);

            if (entities != null)
            {
                for (var i = 0; i < entities.Count; i++)
                {
                    var entity = entities[i];
                    var dto    = _tokenRequestLogFactory.CreateDtoFromEntity(entity);
                    response.Items.Add(dto);
                }
            }

            response.Status = ResponseStatus.Success;
            return(response);
        }
コード例 #4
0
        public static AllTokenRequestLogReadListRequest GetAllTokenRequestLogReadListRequest()
        {
            var request = new AllTokenRequestLogReadListRequest(CurrentUserId);

            return(request);
        }