Beispiel #1
0
        private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
        {
            try
            {
                ILog logger = new Logger(new Framework.SL.Repositories.LogEntryWebserviceRepository());
                ErrorLogEntry error = new ErrorLogEntry()
                {
                    Message = e.ExceptionObject.ToString(),
                    Source = "UNHANDLED IN: " + sender.GetType().ToString(),
                    TimeStamp = DateTime.Now
                };

                logger.WriteEntry(error);
                e.Handled = true;
            }
            catch (Exception logException)
            {
                // If the app is running outside of the debugger then report the exception using
                // the browser's exception mechanism. On IE this will display it a yellow alert 
                // icon in the status bar and Firefox will display a script error.
                if (!System.Diagnostics.Debugger.IsAttached)
                {
                    // NOTE: This will allow the application to continue running after an exception has been thrown
                    // but not handled. 
                    // For production applications this error handling should be replaced with something that will 
                    // report the error to the website and stop the application.
                    e.Handled = true;
                    //MessageBox.Show(e.ExceptionObject.Message);
                    //Deployment.Current.Dispatcher.BeginInvoke(delegate { ReportErrorToDOM(e); });
                }
            }
        }
        public void Should_save_all_logEntry_types()
        {
            
            LogEntry errorLog = new ErrorLogEntry("TestFramework", "Error message");
            LogEntry warningLog = new WarningLogEntry("TestFramework", "Warning message");
            LogEntry infoLog = new InfoLogEntry("TestFramework", "Information message");

            logRepo.Save(infoLog);
            logRepo.Save(warningLog);
            logRepo.Save(errorLog);

            logRepo.Get(new AllSpecification<LogEntry>())
                .Count().ShouldBe(3);

        }
Beispiel #3
0
        public void Should_save_all_logs()
        {
            var logger = new Logger(mockPersister.Object);
            logger.VerbosityLevel = int.MaxValue;

            LogEntry infoLog = new InfoLogEntry("TestFramework", "Information message");
            LogEntry warningLog = new WarningLogEntry("TestFramework", "Warning message");
            LogEntry errorLog = new ErrorLogEntry("TestFramework", "Error message");

            logger.WriteEntry(infoLog);
            logger.WriteEntry(warningLog);
            logger.WriteEntry(errorLog);

            savedLogs.Contains(infoLog).ShouldBeTrue();
            savedLogs.Contains(warningLog).ShouldBeTrue();
            savedLogs.Contains(errorLog).ShouldBeTrue();
        }
Beispiel #4
0
 public static IEnumerable<TaskDefinition> LoadFromFolder(string folder)
 {
     var definitions = new List<TaskDefinition>();
     foreach (var dll in GetDlls(folder))
     {
         try
         {
             definitions.AddRange(LoadFromDll(dll));
         } catch (Exception e)
         {
             var logEntry = new ErrorLogEntry() {
                 Source = "TaskDefinitionLoader",
                 TimeStamp = DateTime.Now,
                 Message = "Failed to load TaskDefinition from Dll. Exception: " + e.Message
             };
             ServiceLocator.Instance.GetInstance<ILog>().WriteEntry(logEntry);
         }
     }
     return definitions;
 }