Ejemplo n.º 1
0
        private void RefreshStatus()
        {
            string logFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\LWATracing";

            if (!Directory.Exists(logFolder))
            {
                _files.Clear();
                ActiveLog = null;
                return;
            }

            string[] files = null;
            try
            {
                files = Directory.GetFiles(logFolder, "LWAJSPersistent*.log", SearchOption.TopDirectoryOnly);
            }
            catch (Exception) { }

            if ((files == null) || (files.Length == 0))
            {
                _files.Clear();
                ActiveLog = null;
                return;
            }

            Dictionary <string, LogFile> clone = _files;

            _files = new Dictionary <string, LogFile>();

            foreach (string filename in files)
            {
                try
                {
                    LogFile log = null;
                    if (clone.ContainsKey(filename))
                    {
                        log = clone[filename];
                        clone.Remove(filename);
                    }
                    else
                    {
                        log = new LogFile(filename, this);
                    }

                    _files[filename] = log;
                    log.Refresh();

                    if (ActiveLog == null)
                    {
                        ActiveLog = log;
                    }
                    else
                    {
                        if (File.GetLastWriteTime(filename) > File.GetLastWriteTime(ActiveLog.FileName))
                        {
                            ActiveLog = log;
                        }
                    }
                }
                catch (Exception) { }
            }

            foreach (KeyValuePair <string, LogFile> pair in clone)
            {
                pair.Value.Close();
            }

            clone.Clear();
        }
Ejemplo n.º 2
0
 public ClientPersistentLoggerActiveLogChangedEventArgs(LogFile newLog, LogFile oldLog)
 {
     this.NewLog = newLog;
     this.OldLog = oldLog;
 }