Configuration for the NetLog service
        /// <summary>
        /// Obtain configuration from a file.  If the file name is not supplied the the default
        /// path of Constants.Data_DIR\netlog.json is used
        /// </summary>
        public static NetLogConfiguration FromFile(string filename=null)
        {
            if (filename == null)
            {
                filename = Constants.DATA_DIR + @"\netlog.json";
            }

            NetLogConfiguration configuration = new NetLogConfiguration();
            try
            {
                string configurationData = File.ReadAllText(filename);
                configuration = JsonConvert.DeserializeObject<NetLogConfiguration>(configurationData);
                configuration.dataPath = filename;
            }
            catch
            {
                configuration = new NetLogConfiguration();
                configuration.dataPath = filename;
                // See if there was old information present
                string oldFilename = Constants.DATA_DIR + @"\productpath";
                try
                {
                    string path = File.ReadAllText(oldFilename);
                    if (path != null)
                    {
                        configuration.path = path;
                        configuration.ToFile();
                        File.Delete(oldFilename);
                    }
                }
                catch { }
            }

            return configuration;
        }
 private void updateNetLogConfiguration()
 {
     NetLogConfiguration netLogConfiguration = new NetLogConfiguration();
     if (!string.IsNullOrWhiteSpace(netLogPathTextBox.Text))
     {
         netLogConfiguration.path = netLogPathTextBox.Text.Trim();
     }
     netLogConfiguration.ToFile();
     EDDI.Instance.Reload("Netlog monitor");
 }
        public ConfigurationWindow()
        {
            InitializeComponent();

            // Configure the NetLog tab
            configuration = NetLogConfiguration.FromFile();
            netLogPathTextBox.Text = configuration.path;

            Logging.Debug("Configuration is " + JsonConvert.SerializeObject(configuration));
        }
Exemplo n.º 4
0
        public ConfigurationWindow()
        {
            InitializeComponent();

            // Configure the NetLog tab
            configuration          = NetLogConfiguration.FromFile();
            netLogPathTextBox.Text = configuration.path;

            Logging.Debug("Configuration is " + JsonConvert.SerializeObject(configuration));
        }
 public void Start()
 {
     if (NetLogConfiguration.FromFile().path == null)
     {
         Logging.Info("Cannot start netlog monitor - path missing");
     }
     else
     {
         start();
     }
 }
Exemplo n.º 6
0
        private void updateNetLogConfiguration()
        {
            NetLogConfiguration netLogConfiguration = new NetLogConfiguration();

            if (!string.IsNullOrWhiteSpace(netLogPathTextBox.Text))
            {
                netLogConfiguration.path = netLogPathTextBox.Text.Trim();
            }
            netLogConfiguration.ToFile();
            EDDI.Instance.Reload("Netlog monitor");
        }
        /// <summary>
        /// Obtain configuration from a file.  If the file name is not supplied the the default
        /// path of Constants.Data_DIR\netlog.json is used
        /// </summary>
        public static NetLogConfiguration FromFile(string filename = null)
        {
            if (filename == null)
            {
                filename = Constants.DATA_DIR + @"\netlog.json";
            }

            NetLogConfiguration configuration = new NetLogConfiguration();

            try
            {
                string configurationData = File.ReadAllText(filename);
                configuration          = JsonConvert.DeserializeObject <NetLogConfiguration>(configurationData);
                configuration.dataPath = filename;
            }
            catch
            {
                configuration          = new NetLogConfiguration();
                configuration.dataPath = filename;
                // See if there was old information present
                string oldFilename = Constants.DATA_DIR + @"\productpath";
                try
                {
                    string path = File.ReadAllText(oldFilename);
                    if (path != null)
                    {
                        configuration.path = path;
                        configuration.ToFile();
                        File.Delete(oldFilename);
                    }
                }
                catch (Exception ex)
                {
                    Logging.Debug("Failed to read netlog configuration", ex);
                }
            }
            if (configuration == null)
            {
                configuration          = new NetLogConfiguration();
                configuration.dataPath = filename;
            }

            return(configuration);
        }
 public void Reload()
 {
     Directory = NetLogConfiguration.FromFile().path;
 }
 public NetLogMonitor() : base(NetLogConfiguration.FromFile().path, @"^netLog\.[0-9\.]+\.log$", result => HandleNetLogLine(result, EDDI.Instance.eventHandler))
 {
 }
 public bool Configured()
 {
     return(NetLogConfiguration.FromFile().path != null);
 }