Пример #1
0
        private async void ButtonStartService_Click(object sender, RoutedEventArgs e)
        {
            Invoke(() => Console.Clear());

            if (!(Service is null) && Service.IsRunning)
            {
                ConsoleLog($"{Service.Name} is already running...");

                return;
            }

            if (string.IsNullOrEmpty(MainWindow.Settings.CaptchaApiKey))
            {
                ConsoleLog("Please set your 2captcha api key under settings");

                return;
            }

            var balanceResult = await CaptchaHelper.GetCaptchaBalance();

            if (balanceResult == "ERROR_ZERO_BALANCE")
            {
                ConsoleLog("Not enough balance to perform 2captcha operations");

                return;
            }

            var servActionId = (int)(Invoke(() => ComboBoxServiceAction.SelectedItem as PairValueModel)?.Key ?? -1);

            if (servActionId < 0)
            {
                return;
            }

            var accountService = (Service = new AccountService()) as AccountService;

            accountService.OnStatusUpdate += AccountService_OnStatusUpdate;

            switch (servActionId)
            {
            case 0:
                QueueImportedAccounts();
                break;

            case 1:
                GenerateQueuePrefixEmails();
                break;

            case 2:
                GenerateAndQueueAccounts();
                break;

            case 3:
                QueueUnlockAccounts();
                accountService.AccountServiceType = AccountServiceType.Unlocking;
                break;
            }

            var result = await Service.Start();

            if (!result)
            {
                ConsoleLog(Service.LastError);
                return;
            }

            ConsoleLog($"{Service.Name} started!");
            Invoke(() => ServiceTabs.SelectedIndex = 3);
        }