Ejemplo n.º 1
0
        public override void CommitLogEvent(LogEvent logEvent)
        {
            if (nextLog == -1)
                GetNextLogNumber();

            string fileName = GetFileName();

            if (!File.Exists(fileName))
            {
                log = new XmlLog();
            }
            else if( log == null )
            {
                log = new XmlLog();
                DefaultConfiguration.TryFromXml<XmlLog>(log, fileName);
            }

            if (log.LogEvents.Length >= entriesPerFile)
            {
                DefaultConfiguration.ToXml(log, fileName);
                nextLog++;
                CommitLogEvent(logEvent);
                return;
            }

            log.AddEvent(logEvent);
            FileInfo info = new FileInfo(fileName);
            if (!info.Directory.Exists)
            {
                info.Directory.Create();
            }
            DefaultConfiguration.ToXml(log, fileName);
        }
Ejemplo n.º 2
0
        private void GetNextLogNumber()
        {
            //string fileName = this.LogLocation + "\\" + this.LogName + "_";
            int check = 0;

            while (nextLog == -1)
            {
                string currentCheckFile = GetCheckFile(check);
                if (!File.Exists(currentCheckFile))
                {
                    nextLog = check;
                }
                else
                {
                    XmlLog checkLog = new XmlLog();
                    DefaultConfiguration.TryFromXml <XmlLog>(checkLog, currentCheckFile);
                    //checkLog.TryFromXml<XmlLog>(currentCheckFile);
                    if (checkLog.LogEvents.Length < entriesPerFile)
                    {
                        nextLog = check;
                    }
                }

                check++;
            }
        }
Ejemplo n.º 3
0
        public override void CommitLogEvent(LogEvent logEvent)
        {
            if (nextLog == -1)
            {
                GetNextLogNumber();
            }

            string fileName = GetFileName();

            if (!File.Exists(fileName))
            {
                log = new XmlLog();
            }
            else if (log == null)
            {
                log = new XmlLog();
                DefaultConfiguration.TryFromXml <XmlLog>(log, fileName);
            }

            if (log.LogEvents.Length >= entriesPerFile)
            {
                DefaultConfiguration.ToXml(log, fileName);
                nextLog++;
                CommitLogEvent(logEvent);
                return;
            }

            log.AddEvent(logEvent);
            FileInfo info = new FileInfo(fileName);

            if (!info.Directory.Exists)
            {
                info.Directory.Create();
            }
            DefaultConfiguration.ToXml(log, fileName);
        }
Ejemplo n.º 4
0
        private void GetNextLogNumber()
        {
            //string fileName = this.LogLocation + "\\" + this.LogName + "_";
            int check = 0;
            while (nextLog == -1)
            {
                string currentCheckFile = GetCheckFile(check);
                if (!File.Exists(currentCheckFile))
                    nextLog = check;
                else
                {
                    XmlLog checkLog = new XmlLog();
                    DefaultConfiguration.TryFromXml<XmlLog>(checkLog, currentCheckFile);
                    //checkLog.TryFromXml<XmlLog>(currentCheckFile);
                    if (checkLog.LogEvents.Length < entriesPerFile)
                        nextLog = check;
                }

                check++;
            }
        }
Ejemplo n.º 5
0
 public static bool TryFromXml(string filePath, out XmlLog log)
 {
     log = new XmlLog();
     return DefaultConfiguration.TryFromXml<XmlLog>(log, filePath);
 }
Ejemplo n.º 6
0
 public static bool TryFromXml(string filePath, out XmlLog log)
 {
     log = new XmlLog();
     return(DefaultConfiguration.TryFromXml <XmlLog>(log, filePath));
 }