コード例 #1
0
        public void InitDatabaseTest()
        {
            var result = false;

            if (LogicBroker.InitDatabase())
            {
                Console.WriteLine("Database initialization completed successfully");
                result = true;
            }
            else
            {
                Console.WriteLine("Database initialization failed.");
            }

            Assert.IsTrue(result);
        }
コード例 #2
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            //  portions of code are thanks to a Gist by Ronnie Overby at https://gist.github.com/ronnieoverby/7568387
            HSTLogger = new Logger();
            if (HSTLogger.IsEnabled)
            {
                AppDomain.CurrentDomain.UnhandledException += (sig, exc) =>
                                                              LogUnhandledException((Exception)exc.ExceptionObject, "AppDomain.CurrentDomain.UnhandledException");

                DispatcherUnhandledException += (sig, exc) =>
                                                LogUnhandledException(exc.Exception, "Application.Current.DispatcherUnhandledException");

                TaskScheduler.UnobservedTaskException += (sig, exc) =>
                                                         LogUnhandledException(exc.Exception, "TaskScheduler.UnobservedTaskException");

                HSTLogger.Data("Application Startup", "Initialize Database called");
                try
                {
                    if (DatabaseInitLoaded = LogicBroker.InitDatabase())
                    {
                        HSTLogger.Data("Application Startup", "Initialize Database completed. Launching UI.");
                        DoDbBackup           = true;
                        _peopleCollection    = Factory.CollectionFactory.GetPeopleCollectionObject();
                        _homesCollection     = Factory.CollectionFactory.GetHomesCollectionObject();
                        _homeSalesCollection = Factory.CollectionFactory.GetHomeSalesCollectionObject();
                        _recosCollection     = Factory.CollectionFactory.GetRECosCollectionObject();
                        new MainWindow().Show();
                    }
                    else
                    {
                        HSTLogger.Data("Application Startup", "Application Startup failed to load file data.");
                    }
                    HSTLogger.Flush();
                }
                catch (Exception ex)
                {
                    HSTLogger.Data("WindowLoading Exception thrown", ex.Message);
                    LogInnerExceptionMessages(ex, "WindowLoading InnerException");
                    HSTLogger.Flush();
                    _          = MessageBox.Show($"While launching, the application was unable to load the backup files. Application will now close.", "Unable to load file data.", MessageBoxButton.OK);
                    DoDbBackup = false;
                    App.Current.Shutdown();
                }
            }
        }