private void AddToCart(string pizzaName)
        {
            var addToCartUrl = SearchForPizza(pizzaName);
            var response     = httpClient.GetString(addToCartUrl);

            DebugContent.WriteToHtmlFile(response);
        }
        private PersistentSessionHttpClient LoginToPizzaProvider(string username, string password)
        {
            var client = new PersistentSessionHttpClient();

            var loginPostForm = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("email", username),
                new KeyValuePair <string, string>("passwd", password),
                new KeyValuePair <string, string>("back", "identity"),
                new KeyValuePair <string, string>("SubmitLogin", "")
            };

            var response = client.Post(loginPage, loginPostForm);
            var content  = response.Content.ReadAsStringAsync().Result;

            // Failed to login - page was not redirected to identity page
            if (!content.Contains("<title>Identity - CarusoPizza</title>"))
            {
                throw new PizzaProviderException($"Failed to login user '{username}'. Check that password is correct, try to log via web on {loginPage}");
            }

            DebugContent.WriteToHtmlFile(content);

            return(client);
        }
Exemple #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            SpriteBatch = new SpriteBatch(GraphicsDevice);
            DebugContent.Load(this.Content);

            //TODO: use this.Content to load your game content here
        }
        private string GetToken()
        {
            var cartPage = httpClient.GetString(orderUrl);

            DebugContent.WriteToHtmlFile(cartPage);

            var tokenVariable = Regex.Match(cartPage, "var static_token = '.*'").Value;

            sessionToken = tokenVariable.Substring(20, 32);
            if (sessionToken == null)
            {
                throw new PizzaProviderException("Failed to get static sessionToken");
            }
            return(sessionToken);
        }
Exemple #5
0
        private void buttonSetFilters_Click(object sender, RoutedEventArgs e)
        {
            var setFiltersWindow = new SetFiltersWindow(_filtersViewModel)
            {
                Topmost = true,
                Owner   = Window.GetWindow(this),
                WindowStartupLocation = WindowStartupLocation.CenterOwner
            };

            setFiltersWindow.ShowDialog();

            string[] allLines = _allText.ToString().Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            DebugContent.Clear();
            foreach (string line in allLines)
            {
                if (_filtersViewModel.FilterMatches(line))
                {
                    DebugContent.AppendText(line + Environment.NewLine);
                }
            }
        }
        private string SearchForPizza(string pizzaName)
        {
            pizzaName = pizzaName.ToLower();

            var url     = $"{ProviderUrlConst}cs/vyhledavani?search_query={pizzaName}";
            var content = httpClient.GetString(url);

            DebugContent.WriteToHtmlFile(content);

            var document = new HtmlDocument();

            document.LoadHtml(content);
            var pizzas   = GetPizzas(document.DocumentNode).ToList();
            var searched = pizzas.FirstOrDefault(p => p.Name == pizzaName);

            if (searched == null)
            {
                throw new PizzaProviderException($"Failed to find order button for pizza {pizzaName}. It is possible that the pizzeria is closed at the moment or that there are no pizzas with name {pizzaName}.");
            }

            return(searched.OrderUrl);
        }
Exemple #7
0
 internal DebugDirectory(DebugContent debugContent, long directoryOffset, IMAGE_DEBUG_DIRECTORY debugDirectory)
 {
     content = debugContent;
     location = new StreamLocation(directoryOffset,DebugDirectory.Size);
     directory = debugDirectory;
 }
Exemple #8
0
 private void buttonClear_Click(object sender, RoutedEventArgs e)
 {
     DebugContent.Clear();
     _allText.Clear();
 }
Exemple #9
0
 private void DoWrite(string str)
 {
     DebugContent.AppendText(str + Environment.NewLine);
     DebugContent.ScrollToEnd();
 }