Init() private method

private Init ( ulong steamID, EUniverse universe, string webAPIUserNonce, string parentalPin ) : Task
steamID ulong
universe EUniverse
webAPIUserNonce string
parentalPin string
return Task
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
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();
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        private async void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            if (callback == null)
            {
                return;
            }

            EResult result = callback.Result;

            switch (result)
            {
            case EResult.AccountLogonDenied:
                AuthCode = Program.GetUserInput(SteamLogin, Program.EUserInputType.SteamGuard);
                break;

            case EResult.AccountLoginDeniedNeedTwoFactor:
                TwoFactorAuth = Program.GetUserInput(SteamLogin, Program.EUserInputType.TwoFactorAuthentication);
                break;

            case EResult.OK:
                Logging.LogGenericInfo(BotName, "Successfully logged on!");

                if (!SteamNickname.Equals("null"))
                {
                    SteamFriends.SetPersonaName(SteamNickname);
                }

                if (SteamParentalPIN.Equals("null"))
                {
                    SteamParentalPIN = Program.GetUserInput(BotName, Program.EUserInputType.SteamParentalPIN);
                }

                await ArchiWebHandler.Init(SteamClient, callback.WebAPIUserNonce, callback.VanityURL, SteamParentalPIN).ConfigureAwait(false);

                ulong clanID = SteamMasterClanID;
                if (clanID != 0)
                {
                    SteamFriends.JoinChat(clanID);
                }

                if (Statistics)
                {
                    SteamFriends.JoinChat(Program.ArchiSCFarmGroup);
                    await ArchiWebHandler.JoinClan(Program.ArchiSCFarmGroup).ConfigureAwait(false);
                }

                await CardsFarmer.StartFarming().ConfigureAwait(false);

                break;

            case EResult.Timeout:
            case EResult.TryAnotherCM:
                Logging.LogGenericWarning(BotName, "Unable to login to Steam: " + callback.Result + " / " + callback.ExtendedResult + ", retrying...");
                await Stop().ConfigureAwait(false);

                await Utilities.SleepAsync(CallbackSleep).ConfigureAwait(false);

                Start();
                break;

            default:
                Logging.LogGenericWarning(BotName, "Unable to login to Steam: " + callback.Result + " / " + callback.ExtendedResult);
                await Shutdown().ConfigureAwait(false);

                break;
            }
        }