private static async Task InitGlobalDatabaseAndServices() { string globalDatabaseFile = ASF.GetFilePath(ASF.EFileType.Database); if (string.IsNullOrEmpty(globalDatabaseFile)) { ASF.ArchiLogger.LogNullError(nameof(globalDatabaseFile)); return; } if (!File.Exists(globalDatabaseFile)) { ASF.ArchiLogger.LogGenericInfo(Strings.Welcome); await Task.Delay(10 * 1000).ConfigureAwait(false); ASF.ArchiLogger.LogGenericWarning(Strings.WarningPrivacyPolicy); await Task.Delay(5 * 1000).ConfigureAwait(false); } GlobalDatabase globalDatabase = await GlobalDatabase.CreateOrLoad(globalDatabaseFile).ConfigureAwait(false); if (globalDatabase == null) { ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorDatabaseInvalid, globalDatabaseFile)); await Task.Delay(5 * 1000).ConfigureAwait(false); await Exit(1).ConfigureAwait(false); return; } ASF.InitGlobalDatabase(globalDatabase); // If debugging is on, we prepare debug directory prior to running if (Debugging.IsUserDebugging) { ASF.ArchiLogger.LogGenericDebug(globalDatabaseFile + ": " + JsonConvert.SerializeObject(ASF.GlobalDatabase, Formatting.Indented)); Logging.EnableTraceLogging(); if (Directory.Exists(SharedInfo.DebugDirectory)) { try { Directory.Delete(SharedInfo.DebugDirectory, true); await Task.Delay(1000).ConfigureAwait(false); // Dirty workaround giving Windows some time to sync } catch (IOException e) { ASF.ArchiLogger.LogGenericException(e); } } Directory.CreateDirectory(SharedInfo.DebugDirectory); DebugLog.AddListener(new Debugging.DebugListener()); DebugLog.Enabled = true; } WebBrowser.Init(); }
private static void InitServices() { GlobalConfig = GlobalConfig.Load(); if (GlobalConfig == null) { Logging.LogGenericError("Global config could not be loaded, please make sure that ASF.json exists and is valid!"); Thread.Sleep(5000); Exit(1); } GlobalDatabase = GlobalDatabase.Load(); if (GlobalDatabase == null) { Logging.LogGenericError("Global database could not be loaded!"); Thread.Sleep(5000); Exit(1); } ArchiWebHandler.Init(); WebBrowser.Init(); WCF.Init(); }
private static void InitServices() { Logging.Init(); WebBrowser.Init(); }