Esempio n. 1
0
        public void GetSettings(out LimsVisualizerSettings limsVisualizerSettings)
        {
            try
            {
                limsVisualizerSettings = new LimsVisualizerSettings();
                var settingsFile = _GetSettingsFilePath();

                LogWriter.WriteDebugMessage(string.Format("Reading settings. File: '{0}'", settingsFile));
                if (!File.Exists(settingsFile))
                {
                    limsVisualizerSettings.FilePath = Environment.GetEnvironmentVariable("SYSTEMDRIVE") + @"\Anton Paar\Davis 5\Data Monitoring\";
                    limsVisualizerSettings.DueTime = new TimeSpan(0, 0, 0, 0, 500);
                    LogWriter.WriteDebugMessage("Settings file not found, using default settings.");
                    return;
                }

                var fileStream = new FileStream(settingsFile, FileMode.Open, FileAccess.Read, FileShare.None);
                var settingsReader = new StreamReader(fileStream);

                limsVisualizerSettings.FilePath = settingsReader.ReadLine();
                limsVisualizerSettings.DueTime = new TimeSpan(0, 0, 0, 0, Convert.ToInt16(settingsReader.ReadLine()));
                settingsReader.Close();
                LogWriter.WriteDebugMessage(string.Format("Settings file found. FilePath: '{0}' DueTime: '{1}'",
                    limsVisualizerSettings.FilePath,
                    limsVisualizerSettings.DueTime));
            }
            catch (Exception exception)
            {
                LogWriter.WriteFailureMessage("Reading settings file failed!");
                LogWriter.WriteException(exception);
                throw;
            }
        }
        public void GetSettings(out LimsVisualizerSettings limsVisualizerSettings)
        {
            try
            {
                limsVisualizerSettings = new LimsVisualizerSettings();
                var settingsFile = _GetSettingsFilePath();

                LogWriter.WriteDebugMessage(string.Format("Reading settings. File: '{0}'", settingsFile));
                if (!File.Exists(settingsFile))
                {
                    limsVisualizerSettings.FilePath = Environment.GetEnvironmentVariable("SYSTEMDRIVE") + @"\Anton Paar\Davis 5\Data Monitoring\";
                    limsVisualizerSettings.DueTime  = new TimeSpan(0, 0, 0, 0, 500);
                    LogWriter.WriteDebugMessage("Settings file not found, using default settings.");
                    return;
                }

                var fileStream     = new FileStream(settingsFile, FileMode.Open, FileAccess.Read, FileShare.None);
                var settingsReader = new StreamReader(fileStream);

                limsVisualizerSettings.FilePath = settingsReader.ReadLine();
                limsVisualizerSettings.DueTime  = new TimeSpan(0, 0, 0, 0, Convert.ToInt16(settingsReader.ReadLine()));
                settingsReader.Close();
                LogWriter.WriteDebugMessage(string.Format("Settings file found. FilePath: '{0}' DueTime: '{1}'",
                                                          limsVisualizerSettings.FilePath,
                                                          limsVisualizerSettings.DueTime));
            }
            catch (Exception exception)
            {
                LogWriter.WriteFailureMessage("Reading settings file failed!");
                LogWriter.WriteException(exception);
                throw;
            }
        }
        public void WriteSettings(LimsVisualizerSettings limsVisualizerSettings)
        {
            try
            {
                var settingsFile = _GetSettingsFilePath();

                LogWriter.WriteDebugMessage(string.Format("Writing settings file. FilePath: '{0}' DueTime: '{1}'",
                                                          limsVisualizerSettings.FilePath,
                                                          limsVisualizerSettings.DueTime));
                var fileStream     = new FileStream(settingsFile, FileMode.Create, FileAccess.Write, FileShare.None);
                var settingsWriter = new StreamWriter(fileStream);

                settingsWriter.WriteLine(limsVisualizerSettings.FilePath);
                settingsWriter.WriteLine(limsVisualizerSettings.DueTime.TotalMilliseconds);
                settingsWriter.Close();
                LogWriter.WriteDebugMessage("Settings file was successfully written.");
            }
            catch (Exception exception)
            {
                LogWriter.WriteFailureMessage("Writing settings file failed!");
                LogWriter.WriteException(exception);
                throw;
            }
        }
Esempio n. 4
0
        public void WriteSettings(LimsVisualizerSettings limsVisualizerSettings)
        {
            try
            {
                var settingsFile = _GetSettingsFilePath();

                LogWriter.WriteDebugMessage(string.Format("Writing settings file. FilePath: '{0}' DueTime: '{1}'",
                    limsVisualizerSettings.FilePath,
                    limsVisualizerSettings.DueTime));
                var fileStream = new FileStream(settingsFile, FileMode.Create, FileAccess.Write, FileShare.None);
                var settingsWriter = new StreamWriter(fileStream);

                settingsWriter.WriteLine(limsVisualizerSettings.FilePath);
                settingsWriter.WriteLine(limsVisualizerSettings.DueTime.TotalMilliseconds);
                settingsWriter.Close();
                LogWriter.WriteDebugMessage("Settings file was successfully written.");
            }
            catch (Exception exception)
            {
                LogWriter.WriteFailureMessage("Writing settings file failed!");
                LogWriter.WriteException(exception);
                throw;
            }
        }