public SQLiteLoggerAdapter(LoggerSettings LoggerSettings_,SQLiteAsyncConnection SQLiteLogConnection_) { LoggerSettings = LoggerSettings_; SQLiteLogConnection = SQLiteLogConnection_; var t = SQLiteLogConnection.CreateTableAsync<LogMessage>().Result; if (LoggerSettings.DeleteMessagesOnStart) { SQLiteLogConnection.DeleteAllAsync<LogMessage>(); } }
public static void Main() { Task.Run(() => { SplashScreen splashScreen = new SplashScreen("SplashScreen.png"); splashScreen.Show(true); }); // Logger initialization string pathtolog = null; try { pathtolog = Path.Combine(FileService.GetPathToApplicationDataFolder(), "log.db"); SQLiteConnectionString connstr = new SQLiteConnectionString(pathtolog,false); SQLiteConnectionWithLock SQLiteLogConnection = new SQLiteConnectionWithLock(new SQLitePlatformWin32(), connstr); LoggerSettings LoggerSettings = new LoggerSettings(); LoggerSettings.DeleteMessagesOnStart = true; Logger.LoggerSettings = LoggerSettings; //SQLiteLoggerAdapter.Initialization(LoggerSettings,SQLiteLogConnection); App.StaticLogger = new Logger(new SQLiteLoggerAdapter(LoggerSettings,new SQLiteAsyncConnection(()=>SQLiteLogConnection))); } catch(Exception ex) { MessageBox.Show("Cannot create a log"+Environment.NewLine+"path: "+pathtolog+Environment.NewLine+ex.Message); return; } App.StaticLogger.Write<Program>(LogMsgType.Trace,"This is developer copy = "+FileService.IsDevelopmentCopy); App.StaticLogger.Write<Program>(LogMsgType.Trace,"App folder : "+FileService.GetPathToApplicationFolder()); App.StaticLogger.Write<Program>(LogMsgType.Trace,"App data folder : "+FileService.GetPathToApplicationDataFolder()); //if (!FileService.IsDevelopmentCopy) //{ string path = FileService.GetPathToApplicationDataFolder(); AppDomain.CurrentDomain.SetData("DataDirectory",path); //} if (!Debugger.IsAttached) { //App.SplashScreen = new SplashScreen("Images/TxFlag_256.png"); //App.SplashScreen.Show(false, true); } // Make sure the settings are properly saved in the end //AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit; App.StaticLogger.Write<Program>(LogMsgType.Trace,"Loading a localization file"); Tx.UseFileSystemWatcher = false; Tx.LoadFromXmlFile(Path.Combine(FileService.GetPathToApplicationFolder(), "Dictionary.txd")); App.StaticLogger.Write<Program>(LogMsgType.Trace,"Set culture"); string appCulture = ""; if (!string.IsNullOrWhiteSpace(appCulture)) { Tx.SetCulture(appCulture); } //EFDbContext.DataBase.Migrate(); App.AppWnd_ViewModel = new AppWnd_ViewModel(); App.NavigationService = new NavigationService(App.AppWnd_ViewModel); try { App app = new App(); app.InitializeComponent(); app.Run(); } catch(Exception ex) { if (ex.GetType() != typeof(ObjectNotInitializedYetException)) { App.StaticLogger.WriteExeption<Program>(ex, "General exception"); MessageBox.Show( "General exception " + Environment.NewLine + ex.Message + Environment.NewLine + "Exception type :" + ex.GetType() + Environment.NewLine + "Stack trace :" + Environment.NewLine + ex.StackTrace ); //SQLiteLoggerAdapter.Close(); throw; } } }