예제 #1
0
        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);
        }
예제 #2
0
        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
            })));
        }
예제 #3
0
        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);
        }
예제 #4
0
 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));
 }