Exemple #1
0
        private async void Application_Startup(object sender, StartupEventArgs e)
        {
            //set up sqlite
            SQLitePCL.Batteries.Init();

            //Load settings
            var settings = SettingsUtils.LoadSettings();

            //initialize logging
            InitializeLogging(settings);

            //Log unhandled exceptions
            AppDomain.CurrentDomain.UnhandledException += AppDomain_CurrentDomain_UnhandledException;

            //db
            var contextFactory = new DbContextFactory(() => new QpasDbContext());

            InitializeDb(contextFactory);

            //check for empty account fields and load preferences
            using (var dbContext = contextFactory.Get())
            {
                if (dbContext.EquitySummaries.Any(x => x.AccountID == null))
                {
                    App.Splash.LoadComplete();
                    var accountMigrationWindow = new AccountMigrationWindow();
                    accountMigrationWindow.ShowDialog();
                }
            }

            var data = await DataLoader.LoadData(contextFactory);

            var qdmsSource = new ExternalDataSources.QDMS(settings, data.DatasourcePreferences.ToList());
            var ds         = new DataSourcer(contextFactory, qdmsSource, data, settings.AllowExternalDataSource);

            var window = new MainWindow(data, settings, contextFactory, ds);
        }
Exemple #2
0
 private void MetroWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     SaveDataGridLayouts();
     SettingsUtils.SaveSettings(ViewModel.Settings);
     Dispose();
 }