private LogDirectory.LogFileId GenerateLogFileId(SortedList <LogDirectory.LogFileId, FileInfo> logFiles, DateTime date, bool startNewLog, out bool newLogStarted) { int i = logFiles.Count - 1; bool flag = false; LogDirectory.LogFileId logFileId = null; newLogStarted = true; while (i >= 0) { logFileId = logFiles.Keys[i]; if (logFileId.SameLogSeries(date, this)) { flag = true; break; } i--; } if (!flag) { return(new LogDirectory.LogFileId(date, this.note, 1)); } if (this.maxLogFileSize > 0L && logFiles.Values[i].Length >= this.maxLogFileSize) { startNewLog = true; } newLogStarted = startNewLog; if (!startNewLog) { return(logFileId); } return(logFileId.Next); }
private string GetLogFileNameFromId(LogDirectory.LogFileId id) { int weekNumber = LogDirectory.GetWeekNumber(id.Date); return(Path.Combine(this.FullName, string.Format(CultureInfo.InvariantCulture, this.production, new object[] { this.prefix, id.Date, id.Instance, this.note, ".LOG", weekNumber }))); }
private SortedList <LogDirectory.LogFileId, FileInfo> GetLogFileList() { SortedList <LogDirectory.LogFileId, FileInfo> sortedList = new SortedList <LogDirectory.LogFileId, FileInfo>(); FileInfo[] files = this.directory.GetFiles(this.dirTemplate); for (int i = 0; i < files.Length; i++) { LogDirectory.LogFileId logFileIdFromName = this.GetLogFileIdFromName(files[i].Name); if (logFileIdFromName != null) { sortedList[logFileIdFromName] = files[i]; } } return(sortedList); }
int IComparable.CompareTo(object o) { LogDirectory.LogFileId logFileId = o as LogDirectory.LogFileId; if (logFileId == null) { throw new ArgumentException("object is not a LogFileId"); } if (this.date < logFileId.date) { return(-1); } if (logFileId.date < this.date) { return(1); } if (this.instance != logFileId.instance) { return(this.instance - logFileId.instance); } return(this.note.CompareTo(logFileId.note)); }