Example #1
0
        private async void btnValidate_Click(object sender, RoutedEventArgs e)
        {
            if (ValidateInput() == false)
            {
                return;
            }

            browserPlaceHolder.Children.Clear();
            using (browser = new Awesomium.Windows.Controls.WebControl())
            {
                browser.Height = browserPlaceHolder.Height;
                browser.Width  = browserPlaceHolder.Width;

                var overlay = new System.Windows.Controls.Canvas()
                {
                    Height = browserPlaceHolder.Height, Width = browserPlaceHolder.Width
                };
                overlay.Opacity    = .5;
                overlay.Background = System.Windows.Media.Brushes.Gray;

                browserPlaceHolder.Children.Add(browser);
                browserPlaceHolder.Children.Add(overlay);

                if (cbUseSSHProxy.IsChecked == true)
                {
                    browser.WebSession = WebCore.CreateWebSession(new WebPreferences()
                    {
                        Plugins     = false,
                        ProxyConfig = string.Format("socks4://{0}:{1}", txtLocalHost.Text, txtLocalPort.Text)
                    });

                    await browser.WaitPageLoadComplete(() =>
                    {
                        browser.Source = "api.ipify.org".ToUri();
                    });

                    string ip = Regex.Match(browser.HTML, ValidIpAddressRegex).Value;

                    MessageBox.Show(string.Format("Proxy IP: {0}", ip));
                }

                btnValidate.IsEnabled        = false;
                btnRedeem.IsEnabled          = false;
                btnParseAmazonCode.IsEnabled = false;

                CTSRedeemAmazon = new CancellationTokenSource();
                decimal currentBalance = await browser.AuthenticateToAmazonAsync(txtAmazonUsername.Text, txtPassword.Password, CTSRedeemAmazon.Token);

                if (currentBalance > -1)
                {
                    lblBalance.Content = string.Format("Balance: {0}", currentBalance.ToString("C"));

                    int gcCount = 0;

                    decimal validationBalance = 0;

                    int validationSuccessCount = 0;
                    int validationFailureCount = 0;

                    int delayMS = string.IsNullOrWhiteSpace(txtDelayMS.Text) ? 0 : int.Parse(txtDelayMS.Text);

                    foreach (AmazonGiftCode gc in colParsedAmazonGiftCodes)
                    {
                        gcCount++;
                        try
                        {
                            decimal currentGCValidationValue = await browser.ValidateAmazonAsync(txtAmazonUsername.Text, txtPassword.Password, gc.Code, CTSRedeemAmazon.Token, delayMS);

                            if (currentGCValidationValue > 0)
                            {
                                if (gc.Value == null)
                                {
                                    gc.Value = currentGCValidationValue;

                                    gc.Validated = true;
                                    validationSuccessCount++;
                                    validationBalance += currentGCValidationValue;
                                }
                                else
                                {
                                    if (gc.Value == currentGCValidationValue)
                                    {
                                        gc.Validated = true;
                                        validationSuccessCount++;
                                        validationBalance += currentGCValidationValue;
                                    }
                                    else
                                    {
                                        gc.Validated = false;
                                        validationFailureCount++;
                                    }
                                }
                            }
                            else
                            {
                                gc.Validated = false;
                                validationFailureCount++;
                            }

                            datagridParsedAmazonCodes.ScrollIntoView(gc);
                        }
                        catch (OperationCanceledException ex)
                        {
                        }
                    }
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine(string.Format("Successful Validations: {0}/{1}", validationSuccessCount, colParsedAmazonGiftCodes.Count()));
                    sb.AppendLine(string.Format("Failed Validations: {0}/{1}", validationFailureCount, colParsedAmazonGiftCodes.Count()));
                    sb.AppendLine(string.Format("Validated Balance: ${0}", validationBalance));
                    txtResults.Text = sb.ToString();
                }
                else
                {
                    MessageBox.Show("Authentication failure.");
                }

                btnRedeem.IsEnabled          = true;
                btnValidate.IsEnabled        = true;
                btnParseAmazonCode.IsEnabled = true;
            }
            browserPlaceHolder.Children.Clear();
        }
Example #2
0
        private async void btnRedeem_Click(object sender, RoutedEventArgs e)
        {
            if (ValidateInput() == false)
            {
                return;
            }


            browserPlaceHolder.Children.Clear();
            using (browser = new Awesomium.Windows.Controls.WebControl())
            {
                browser.Height = browserPlaceHolder.Height;
                browser.Width  = browserPlaceHolder.Width;

                browserPlaceHolder.Children.Add(browser);

                if (cbUseSSHProxy.IsChecked == true)
                {
                    browser.WebSession = WebCore.CreateWebSession(new WebPreferences()
                    {
                        Plugins     = false,
                        ProxyConfig = string.Format("socks4://{0}:{1}", txtLocalHost.Text, txtLocalPort.Text)
                    });

                    await browser.WaitPageLoadComplete(() =>
                    {
                        browser.Source = "api.ipify.org".ToUri();
                    });

                    string ip = Regex.Match(browser.HTML, ValidIpAddressRegex).Value;

                    MessageBox.Show(string.Format("Proxy IP: {0}", ip));
                }

                btnParseAmazonCode.IsEnabled = false;
                btnRedeem.IsEnabled          = false;
                btnValidate.IsEnabled        = false;

                //await browser.WaitPageLoadComplete(() =>
                //{
                //    browser.Source = "amazon.com".ToUri();
                //});

                CTSRedeemAmazon = new CancellationTokenSource();
                decimal currentBalance = await browser.AuthenticateToAmazonAsync(txtAmazonUsername.Text, txtPassword.Password, CTSRedeemAmazon.Token);

                if (currentBalance > -1)
                {
                    lblBalance.Content = string.Format("Balance: {0}", currentBalance.ToString("C"));

                    int gcCount = 0;

                    decimal previousBalance = currentBalance;

                    decimal startingBalance = currentBalance;

                    int delayMS = string.IsNullOrWhiteSpace(txtDelayMS.Text) ? 0 : int.Parse(txtDelayMS.Text);

                    foreach (AmazonGiftCode gc in colParsedAmazonGiftCodes)
                    {
                        try
                        {
                            gcCount++;


                            currentBalance = await browser.RedeemAmazonAsync(gc.Code, CTSRedeemAmazon.Token, delayMS);

                            lblBalance.Content = string.Format("Balance: {0}", currentBalance.ToString("C"));

                            if (currentBalance > previousBalance)
                            {
                                gc.Redeemed     = true;
                                gc.Validated    = true;
                                gc.Value        = (currentBalance - previousBalance);
                                previousBalance = currentBalance;
                            }
                            else
                            {
                                gc.Redeemed = false;
                            }
                        }
                        catch (OperationCanceledException ex)
                        {
                        }
                        datagridParsedAmazonCodes.ScrollIntoView(gc);
                    }
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine(string.Format("Starting balance: ${0}", startingBalance));
                    sb.AppendLine(string.Format("Ending balance: ${0}", currentBalance));
                    sb.AppendLine(string.Format("Value redeemed: ${0}", currentBalance - startingBalance));
                    txtResults.Text = sb.ToString();
                }
                else
                {
                    MessageBox.Show("Authentication failure.");
                }

                btnRedeem.IsEnabled          = true;
                btnValidate.IsEnabled        = true;
                btnParseAmazonCode.IsEnabled = true;
            }
            browserPlaceHolder.Children.Clear();
        }