Beispiel #1
0
        private void Process(IRuneScapeForm reqForm)
        {
            StatusUpdate
                (ServiceStatusCode.Started, reqForm);

            var         result   = false;
            RsWebHelper rsHelper = null;

            if (AccountServiceType == AccountServiceType.Creation)
            {
                var accountForm = (reqForm as RSAccountForm);
                rsHelper = new RsWebHelper(accountForm.ProxyName);

                result = CreateAccount(accountForm, rsHelper).Result;
            }
            else
            {
                rsHelper = new RsWebHelper();
                result   = UnlockAccount(reqForm as RSRecoveryForm, rsHelper).Result;
            }

            if (result)
            {
                StatusUpdate(ServiceStatusCode.Success, reqForm);
            }

            // Request complete
            lock (reqFormsQueueLock)
            {
                runningRequests.Remove(reqForm.RequestId);
            }

            rsHelper?.Dispose();
        }
Beispiel #2
0
        public void QueueReqForm(IRuneScapeForm account)
        {
            account.RequestId = Guid.NewGuid().ToString();

            lock (reqFormsQueueLock)
            {
                reqFormsQueue.Enqueue(account);
            }
        }
Beispiel #3
0
        private void AccountService_OnStatusUpdate(ServiceStatusCode statusCode, IRuneScapeForm form = null, string message = null)
        {
            if (statusCode == ServiceStatusCode.Updated)
            {
                Invoke(() =>
                {
                    var task = taskListItems.FirstOrDefault(x => x.GUID == form.RequestId);
                    if (task != null)
                    {
                        task.Description = message;
                    }
                });
            }
            else if (statusCode == ServiceStatusCode.Started)
            {
                AddTask(new TaskModel()
                {
                    GUID        = form.RequestId,
                    Name        = form.Email,
                    Description = "Awaiting...",
                    IsRunning   = true
                });
            }
            else if (statusCode == ServiceStatusCode.Success)
            {
                var task = Invoke(() => taskListItems.FirstOrDefault(x => x.GUID == form.RequestId));
                if (task != null)
                {
                    task.Description = "Complete";

                    var service = (Service as AccountService);
                    if (service.AccountServiceType == AccountServiceType.Creation)
                    {
                        HandleCreate(form as RSAccountForm);
                    }
                    else
                    {
                        HandleUnlock(form as RSRecoveryForm);
                    }
                }
            }
            else if (statusCode == ServiceStatusCode.Complete)
            {
                ConsoleLog("Stopped");
            }
        }
Beispiel #4
0
        private async Task <string> GetCaptchaSolveKey(IRuneScapeForm form, RsWebHelper rsHelper)
        {
            var captchaResult = string.Empty;

            StatusUpdate(ServiceStatusCode.Updated, form, "Requesting captcha solve");

            var googleKey = await rsHelper.GrabGoogleKey(form.RequestUrl);

            if (googleKey == string.Empty ||
                googleKey == "NO_GOOGLE_KEY")
            {
                StatusUpdate(ServiceStatusCode.Updated, form, "Error obtaining Google Key from requested page");
                return(string.Empty);
            }

            var captchaId = await
                            CaptchaHelper.RequestSolveCaptcha(googleKey, form.RequestUrl);

            if (captchaId == string.Empty)
            {
                StatusUpdate(ServiceStatusCode.Updated, form, "An error occured requesting captcha solve");
                return(string.Empty);
            }

            for (int i = 0; i < 60; i++)
            {
                StatusUpdate
                    (ServiceStatusCode.Updated, form, "Waiting for captcha to be solved");

                var response = await CaptchaHelper.GetSolveResult(captchaId);

                if (response != string.Empty &&
                    !response.Contains("CAPCHA_NOT_READY") && !response.Contains("ERROR"))
                {
                    captchaResult = response;
                    break;
                }

                Thread.Sleep(5 * 1000);
            }

            return(captchaResult);
        }
Beispiel #5
0
        public async Task <string> PostRequest(IRuneScapeForm requestForm)
        {
            var webForms = requestForm.Build();

            return(await httpHelper.PostRequest(requestForm.RequestUrl, new FormUrlEncodedContent(webForms)));
        }
Beispiel #6
0
 protected virtual void StatusUpdate(ServiceStatusCode statusCode, IRuneScapeForm account = null, string message = null)
 {
     OnStatusUpdate?.Invoke(statusCode, account, message);
 }