示例#1
0
        public IList <IAnyLog> GetPlistAnyLogs(List <FilterData> filters, PagingInput paging)
        {
            paging.Valid();
            var                filterStringBuilder = _acDomain.RetrieveRequiredService <ISqlFilterStringBuilder>();
            RdbDescriptor      db = GetExceptionLogDb();
            List <DbParameter> prams;
            var                filterString = filterStringBuilder.FilterString(db, filters, "t", out prams);

            if (!string.IsNullOrEmpty(filterString))
            {
                filterString = " where " + filterString;
            }
            var sql =
                @"select top({0}) * 
from (SELECT ROW_NUMBER() OVER(ORDER BY {1} {2}) AS RowNumber,* FROM {3} as t"
                + filterString + ") a WHERE a.RowNumber > {4}";
            var countSql = "select count(*) from AnyLog as t" + filterString;
            var anyLogs  = new List <IAnyLog>();
            var reader   = db.ExecuteReader(
                string.Format(sql, paging.PageSize, paging.SortField, paging.SortOrder, "AnyLog", paging.PageSize * paging.PageIndex), prams.ToArray());

            while (reader.Read())
            {
                anyLogs.Add(AnyLog.Create(reader));
            }
            paging.Total = (int)db.ExecuteScalar(countSql, prams.Select(p => ((ICloneable)p).Clone()).Cast <DbParameter>().ToArray());
            reader.Close();

            return(anyLogs);
        }
示例#2
0
        public IAnyLog Get(Guid id)
        {
            RdbDescriptor db     = GetAnyLogDb();
            const string  sql    = "select * from AnyLog where Id=@Id";
            var           reader = db.ExecuteReader(sql, CreateParameter(db, "Id", id, DbType.Guid));
            AnyLog        anyLog = null;

            if (reader.Read())
            {
                anyLog = AnyLog.Create(reader);
            }
            reader.Close();
            return(anyLog);
        }