public ActionResult GetPagingBlackList(GetPagingErrorLogBlackListRequest request, int page, int rows)
        {
            var result = string.Empty;

            if (request == null)
            {
                request = new GetPagingErrorLogBlackListRequest();
            }
            request.PageIndex = page;
            request.PageSize  = rows;

            var rs = _errorLogBlackListService.GetPagingBlackList(request);

            if (rs.ReturnCode == ReturnCodeType.Success)
            {
                result = "{\"total\": " + rs.Content.TotalCount + ",\"rows\":" + rs.Content.Entities.ToJson(dateTimeFormat: DateTimeTypeConst.DATETIME) + "}";
            }

            return(Content(result));
        }
        /// <summary>
        /// 获取黑名单列表(分页)
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public PagingResult <GetPagingErrorLogBlackListResponse> GetPagingBlackList(GetPagingErrorLogBlackListRequest request)
        {
            PagingResult <GetPagingErrorLogBlackListResponse> result = null;
            var totalCount = 0;
            var startIndex = (request.PageIndex - 1) * request.PageSize + 1;
            var endIndex   = request.PageIndex * request.PageSize;

            using (var conn = DapperHelper.CreateConnection())
            {
                var multi  = conn.QueryMultiple(@"--获取所有(分页)
                                SELECT  rs.*
                                FROM    ( SELECT    ROW_NUMBER() OVER ( ORDER BY errorLogBlackList.id DESC ) AS RowNum ,
                                                    errorLogBlackList.system_code AS SystemCode ,
                                                    errorLogBlackList.machine_name AS MachineName ,
                                                    errorLogBlackList.ip_address AS IpAddress ,
                                                    errorLogBlackList.client_ip AS ClientIp ,
                                                    errorLogBlackList.appdomain_name AS AppdomainName ,
                                                    errorLogBlackList.is_regex AS IsRegex ,
                                                    errorLogBlackList.created_time AS CreatedTime ,
                                                    errorLogBlackList.last_updated_time AS LastUpdatedTime ,
                                                    *
                                          FROM      dbo.t_logs_error_log_black_list (NOLOCK) AS errorLogBlackList
                                        ) AS rs
                                WHERE   rs.RowNum BETWEEN @Start AND @End;

                                --获取所有total
                                SELECT  COUNT(errorLogBlackList.id)
                                FROM    dbo.t_logs_error_log_black_list (NOLOCK) AS errorLogBlackList;", new { @Start = startIndex, @End = endIndex });
                var query1 = multi.Read <GetPagingErrorLogBlackListResponse>();
                var query2 = multi.Read <int>();
                totalCount = query2.First();

                result = new PagingResult <GetPagingErrorLogBlackListResponse>(totalCount, request.PageIndex, request.PageSize, query1);
            }

            return(result);
        }
Beispiel #3
0
        /// <summary>
        /// 获取黑名单列表(分页)
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ServiceResult <PagingResult <GetPagingErrorLogBlackListResponse> > GetPagingBlackList(GetPagingErrorLogBlackListRequest request)
        {
            var result = new ServiceResult <PagingResult <GetPagingErrorLogBlackListResponse> >
            {
                ReturnCode = ReturnCodeType.Error,
                Content    = new PagingResult <GetPagingErrorLogBlackListResponse>()
            };

            var rs = _errorLogBlackListDao.GetPagingBlackList(request);

            result.ReturnCode = ReturnCodeType.Success;
            result.Content    = rs;

            return(result);
        }