Load() static private method

static private Load ( string filePath ) : GlobalDatabase
filePath string
return GlobalDatabase
Example #1
0
        private static async Task InitGlobalDatabaseAndServices()
        {
            string globalDatabaseFile = Path.Combine(SharedInfo.ConfigDirectory, SharedInfo.GlobalDatabaseFileName);

            if (!File.Exists(globalDatabaseFile))
            {
                ASF.ArchiLogger.LogGenericInfo(Strings.Welcome);
                ASF.ArchiLogger.LogGenericWarning(Strings.WarningPrivacyPolicy);
                await Task.Delay(10 * 1000).ConfigureAwait(false);
            }

            GlobalDatabase = GlobalDatabase.Load(globalDatabaseFile);
            if (GlobalDatabase == null)
            {
                ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorDatabaseInvalid, globalDatabaseFile));
                await Task.Delay(5 * 1000).ConfigureAwait(false);
                await Exit(1).ConfigureAwait(false);

                return;
            }

            ArchiWebHandler.Init();
            IPC.Initialize(GlobalConfig.IPCHost, GlobalConfig.IPCPort);
            OS.Init(GlobalConfig.Headless);
            WebBrowser.Init();

            WebBrowser = new WebBrowser(ASF.ArchiLogger, true);
        }
Example #2
0
        private static void InitServices()
        {
            string globalConfigFile = Path.Combine(SharedInfo.ConfigDirectory, SharedInfo.GlobalConfigFileName);

            GlobalConfig = GlobalConfig.Load(globalConfigFile);
            if (GlobalConfig == null)
            {
                ArchiLogger.LogGenericError("Global config could not be loaded, please make sure that " + globalConfigFile + " exists and is valid!");
                Exit(1);
            }

            string globalDatabaseFile = Path.Combine(SharedInfo.ConfigDirectory, SharedInfo.GlobalDatabaseFileName);

            GlobalDatabase = GlobalDatabase.Load(globalDatabaseFile);
            if (GlobalDatabase == null)
            {
                ArchiLogger.LogGenericError("Global database could not be loaded, if issue persists, please remove " + globalDatabaseFile + " in order to recreate database!");
                Exit(1);
            }

            ArchiWebHandler.Init();
            WebBrowser.Init();

            WebBrowser = new WebBrowser(ArchiLogger);
        }
Example #3
0
        private static async Task InitGlobalDatabaseAndServices()
        {
            string globalDatabaseFile = Path.Combine(SharedInfo.ConfigDirectory, SharedInfo.GlobalDatabaseFileName);

            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 = await GlobalDatabase.Load(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;
            }

            if (Debugging.IsUserDebugging)
            {
                ASF.ArchiLogger.LogGenericDebug(SharedInfo.GlobalDatabaseFileName + ": " + JsonConvert.SerializeObject(GlobalDatabase, Formatting.Indented));
            }

            // If debugging is on, we prepare debug directory prior to running
            if (GlobalConfig.Debug)
            {
                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();
            WebBrowser = new WebBrowser(ASF.ArchiLogger, GlobalConfig.WebProxy, true);

            if (GlobalConfig.IPC && (GlobalConfig.IPCPrefixes.Count > 0))
            {
                IPC.Start(GlobalConfig.IPCPrefixes);
            }
        }
Example #4
0
        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();
        }
Example #5
0
        private static async Task InitServices()
        {
            string globalConfigFile = Path.Combine(SharedInfo.ConfigDirectory, SharedInfo.GlobalConfigFileName);

            GlobalConfig = GlobalConfig.Load(globalConfigFile);
            if (GlobalConfig == null)
            {
                ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorGlobalConfigNotLoaded, globalConfigFile));
                await Task.Delay(5 * 1000).ConfigureAwait(false);

                Exit(1);
                return;
            }

            if (!string.IsNullOrEmpty(GlobalConfig.CurrentCulture))
            {
                try {
                    // GetCultureInfo() would be better but we can't use it for specifying neutral cultures such as "en"
                    CultureInfo culture = CultureInfo.CreateSpecificCulture(GlobalConfig.CurrentCulture);
                    CultureInfo.DefaultThreadCurrentCulture = CultureInfo.DefaultThreadCurrentUICulture = culture;
                } catch (CultureNotFoundException) {
                    ASF.ArchiLogger.LogGenericError(Strings.ErrorInvalidCurrentCulture);
                }
            }

            int defaultResourceSetCount = 0;
            int currentResourceSetCount = 0;

            ResourceSet defaultResourceSet = Strings.ResourceManager.GetResourceSet(CultureInfo.CreateSpecificCulture("en-US"), true, true);

            if (defaultResourceSet != null)
            {
                defaultResourceSetCount = defaultResourceSet.Cast <object>().Count();
            }

            ResourceSet currentResourceSet = Strings.ResourceManager.GetResourceSet(CultureInfo.CurrentCulture, true, false);

            if (currentResourceSet != null)
            {
                currentResourceSetCount = currentResourceSet.Cast <object>().Count();
            }

            if (currentResourceSetCount < defaultResourceSetCount)
            {
                float translationCompleteness = currentResourceSetCount / (float)defaultResourceSetCount;
                ASF.ArchiLogger.LogGenericInfo(string.Format(Strings.TranslationIncomplete, CultureInfo.CurrentCulture.Name, translationCompleteness.ToString("P1")));
            }

            string globalDatabaseFile = Path.Combine(SharedInfo.ConfigDirectory, SharedInfo.GlobalDatabaseFileName);

            if (!File.Exists(globalDatabaseFile))
            {
                ASF.ArchiLogger.LogGenericInfo(Strings.Welcome);
                ASF.ArchiLogger.LogGenericWarning(Strings.WarningPrivacyPolicy);
                await Task.Delay(15 * 1000).ConfigureAwait(false);
            }

            GlobalDatabase = GlobalDatabase.Load(globalDatabaseFile);
            if (GlobalDatabase == null)
            {
                ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorDatabaseInvalid, globalDatabaseFile));
                await Task.Delay(5 * 1000).ConfigureAwait(false);

                Exit(1);
                return;
            }

            ArchiWebHandler.Init();
            WebBrowser.Init();
            WCF.Init();

            WebBrowser = new WebBrowser(ASF.ArchiLogger);
        }