/// <summary> /// Returns a page of errors from the folder in descending order of logged time as defined by the sortable filenames. /// </summary> public override int GetErrors(int pageIndex, int pageSize, IList errorEntryList) { if (pageIndex < 0) { pageIndex = 0; } if (pageSize < 0) { pageSize = 25; } string[] fileList = Directory.GetFiles(LogPath, "*.xml"); if (fileList.Length < 1) { return(0); } Array.Sort(fileList); Array.Reverse(fileList); int currentItem = pageIndex * pageSize; int lastItem = (currentItem + pageSize < fileList.Length) ? currentItem + pageSize : fileList.Length; for (int i = currentItem; i < lastItem; i++) { FileInfo f = new FileInfo(fileList[i]); FileStream s = f.OpenRead(); XmlTextReader r = new XmlTextReader(s); try { while (r.IsStartElement("error")) { SimpleErrorHandler.Error error = new SimpleErrorHandler.Error(); error.FromXml(r); error.IsProtected = f.IsReadOnly; // have we "protected" this file from deletion? errorEntryList.Add(new ErrorLogEntry(this, error.Id, error)); } } finally { r.Close(); } } return(fileList.Length); }
/// <summary> /// Returns the specified error from the filesystem, or throws an exception if it does not exist. /// </summary> public override ErrorLogEntry GetError(string id) { string[] fileList = Directory.GetFiles(LogPath, string.Format("*{0}.xml", id)); if (fileList.Length < 1) { throw new Exception(string.Format("Can't locate error file for errorId {0}", id)); } FileInfo f = new FileInfo(fileList[0]); FileStream s = f.OpenRead(); XmlTextReader r = new XmlTextReader(s); SimpleErrorHandler.Error error = new SimpleErrorHandler.Error(); error.FromXml(r); r.Close(); return(new ErrorLogEntry(this, id, error)); }
/// <summary> /// Returns a page of errors from the folder in descending order of logged time as defined by the sortable filenames. /// </summary> public override int GetErrors(int pageIndex, int pageSize, IList errorEntryList) { if (pageIndex < 0) pageIndex = 0; if (pageSize < 0) pageSize = 25; string[] fileList = Directory.GetFiles(LogPath, "*.xml"); if (fileList.Length < 1) return 0; Array.Sort(fileList); Array.Reverse(fileList); int currentItem = pageIndex * pageSize; int lastItem = (currentItem + pageSize < fileList.Length) ? currentItem + pageSize : fileList.Length; for (int i = currentItem; i < lastItem; i++) { FileInfo f = new FileInfo(fileList[i]); FileStream s = f.OpenRead(); XmlTextReader r = new XmlTextReader(s); try { while (r.IsStartElement("error")) { SimpleErrorHandler.Error error = new SimpleErrorHandler.Error(); error.FromXml(r); error.IsProtected = f.IsReadOnly; // have we "protected" this file from deletion? errorEntryList.Add(new ErrorLogEntry(this, error.Id, error)); } } finally { r.Close(); } } return fileList.Length; }
/// <summary> /// Returns the specified error from the filesystem, or throws an exception if it does not exist. /// </summary> public override ErrorLogEntry GetError(string id) { string[] fileList = Directory.GetFiles(LogPath, string.Format("*{0}.xml", id)); if (fileList.Length < 1) throw new Exception(string.Format("Can't locate error file for errorId {0}", id)); FileInfo f = new FileInfo(fileList[0]); FileStream s = f.OpenRead(); XmlTextReader r = new XmlTextReader(s); SimpleErrorHandler.Error error = new SimpleErrorHandler.Error(); error.FromXml(r); r.Close(); return new ErrorLogEntry(this, id, error); }