Esempio n. 1
0
 private void CancelBackgroundWorker(object sender, RunWorkerCompletedEventArgs e)
 {
     if (e.Error != null)
     {
         ScopeVNSMessagingSystem.GetInstance().AddMessage("Error detected on scope " + SerialCode + "! PLEASE RESTART SCOPEVNS!");
         ErrorLoggingService.GetInstance().LogExceptionError(e.Error);
     }
 }
        public static ScopeVNSMessagingSystem GetInstance()
        {
            if (_instance == null)
            {
                _instance = new ScopeVNSMessagingSystem();
            }

            return(_instance);
        }
Esempio n. 3
0
 /// <summary>
 /// Logs a string to the error log file.
 /// </summary>
 public void LogStringError(string msg)
 {
     lock (_error_log_lock)
     {
         try
         {
             StreamWriter writer = new StreamWriter(_error_log_file, true);
             writer.WriteLine(msg);
             writer.Close();
         }
         catch
         {
             ScopeVNSMessagingSystem.GetInstance().AddMessage("Unable to log error to file");
         }
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Logs an exception to the error log file
        /// </summary>
        public void LogExceptionError(Exception e)
        {
            lock (_error_log_lock)
            {
                try
                {
                    StreamWriter writer              = new StreamWriter(_error_log_file, true);
                    string       timestamp           = DateTime.Now.ToString("yyyy-MM-dd:HH:mm:ss");
                    string       stacktrace          = e.StackTrace;
                    string       outermost_exception = e.Message;

                    string innermost_exception = string.Empty;
                    var    base_except         = e.GetBaseException();
                    if (base_except != null)
                    {
                        innermost_exception = base_except.Message;
                    }

                    string function = e.TargetSite.Name;

                    writer.WriteLine("NEW ERROR DETECTED");
                    writer.WriteLine(timestamp);
                    writer.WriteLine("Stack trace: " + stacktrace);
                    writer.WriteLine("Outermost exception message: " + outermost_exception);
                    writer.WriteLine("Innermost exception message: " + innermost_exception);
                    writer.WriteLine("Function name: " + function);
                    writer.WriteLine("END OF NEW ERROR");
                    writer.WriteLine();

                    writer.Close();
                }
                catch
                {
                    ScopeVNSMessagingSystem.GetInstance().AddMessage("Unable to log error to file");
                }
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public MainWindowViewModel()
 {
     //Subscribe to receive notifications from the ScopeVNS messaging system
     ScopeVNSMessagingSystem.GetInstance().PropertyChanged += ReactToNotificationsFromMessagingSystem;
 }