public static PageData <Log4NetModel> GetListPage(QueryParamModel model) { PageData <Log4NetModel> result = new PageData <Log4NetModel>(); result.Rows = new List <Log4NetModel>(); try { int total = 0; int limit = 0; var filePaths = LogUtil.GetLogFileListByDateRange(model.BeginDate, model.EndDate, Log4NetHelper.Instance.GetLogDir); foreach (string path in filePaths) { string fileName = Path.GetFileName(path); if (fileName.EndsWith("log")) { total++; if (total > model.Offset) { if (model.Limit > limit) { Log4NetModel item = new Log4NetModel(); item.FileSize = LogUtil.CountSize(LogUtil.GetFileSize(path)); item.FileName = fileName; limit++; result.Rows.Add(item); } } } } result.Total = total; } catch (Exception e) { log.Error(e); } return(result); }
public static PageData <LogErrModel> GetErrLogListPage(QueryParamModel model) { PageData <LogErrModel> result = new PageData <LogErrModel>(); result.Rows = new List <LogErrModel>(); try { int total = 0; int limit = 0; var filePaths = GetLogFileListByDateRange(model.BeginDate, model.EndDate, LogConfig.GetErrDir()); foreach (string filePath in filePaths) { var listRows = GetLogRowLine(filePath, model.KeyWord); foreach (string row in listRows) { var item = GetLogErrModelByRow(row); if (item != null) { total++; if (total > model.Offset) { if (model.Limit > limit) { limit++; result.Rows.Add(item); } } } } } result.Total = total; } catch (Exception e) { log.Error(e); } return(result); }