Пример #1
0
 private void btnSupermarkt_Click(object sender, EventArgs e)
 {
     if (lbSupermarkten.SelectedItem != null)
     {
         Supermarkt supermarkt = lbSupermarkten.SelectedItem as Supermarkt;
     }
 }
Пример #2
0
        protected async override void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            Frame rootFrame = Window.Current.Content as Frame;

            if (rootFrame == null)
            {
                rootFrame           = new Frame();
                rootFrame.CacheSize = 1;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                }

                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
#if WINDOWS_PHONE_APP
                // Removes the turnstile navigation for startup.
                if (rootFrame.ContentTransitions != null)
                {
                    this.transitions = new TransitionCollection();
                    foreach (var c in rootFrame.ContentTransitions)
                    {
                        this.transitions.Add(c);
                    }
                }

                rootFrame.ContentTransitions = null;
                rootFrame.Navigated         += this.RootFrame_FirstNavigated;
#endif
                if ((await Supermarkt.GetSelectedSupermarketsFromStorage()) == null)
                {
                    if (!rootFrame.Navigate(typeof(ConfigureSupermarkets), e.Arguments))
                    {
                        throw new Exception("Failed to create initial page");
                    }
                }
                else
                {
                    if (!rootFrame.Navigate(typeof(MainPage), e.Arguments))
                    {
                        throw new Exception("Failed to create initial page");
                    }
                }
            }

            Window.Current.Activate();
        }
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            Exception AppException = null;

            LoadingControl.DisplayLoadingError(false);
            LoadingControl.SetLoadingStatus(true);

            try
            {
                supermarkt               = Supermarkt.Deserialize(e.NavigationParameter as string);
                this.DataContext         = supermarkt;
                supermarkt.ProductPagina = await GetSAData.GetDiscountsFromSupermarket(supermarkt, false);

                this.ProductsLV.DataContext = supermarkt.ProductPagina.Producten;
                DiscountVallidTextbox.Text  = supermarkt.ProductPagina.DiscountValid;

                try
                {
                    if (SelectedItem != null)
                    {
                        foreach (Product p in supermarkt.ProductPagina.Producten)
                        {
                            if (p.ID == SelectedItem.ID)
                            {
                                supermarkt.ProductPagina.SelectedItem = p;
                                SelectedItem            = null;
                                ProductsLV.SelectedItem = p;
                                break;
                            }
                        }

                        ProductsLV.ScrollIntoView(supermarkt.ProductPagina.SelectedItem);
                    }
                }
                catch
                {
                }
            }
            catch (Exception ex)
            {
                AppException = ex;
                LoadingControl.DisplayLoadingError(true);
            }
            finally
            {
                Task t = Task.Run(() => ClientIDHandler.instance.PostAppStats(ClientIDHandler.AppName.Supermarkt_Aanbiedingen));
                LoadingControl.SetLoadingStatus(false);
            }

            if (AppException != null)
            {
                Task t = Task.Run(() => ExceptionHandler.instance.PostException(new AppException(AppException), (int)ClientIDHandler.AppName.Supermarkt_Aanbiedingen));
            }
        }
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            BackgroundTaskDeferral deferral = taskInstance.GetDeferral();

            if (DateTime.Now.Hour > 7)
            {
                foreach (Supermarkt s in await Supermarkt.GetSelectedSupermarketsFromStorage())
                {
                    await s.GetProductpagina(true);
                }

                deferral.Complete();
            }
        }
Пример #5
0
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            Exception AppException = null;

            try
            {
                CountCombovox.ItemsSource  = ItemCount;
                CountCombovox.SelectedItem = (CountCombovox.ItemsSource as string[])[0];

                supermarkt       = Supermarkt.Deserialize(e.NavigationParameter as string);
                this.DataContext = supermarkt;

                //GetBoodschappenlijstje
                IList <BoodschappenLijstje> lijstjes = await BoodschappenLijstje.GetBoodschappenLijstjes();

                foreach (BoodschappenLijstje b in lijstjes)
                {
                    if (b.supermarkt.Name == supermarkt.Name)
                    {
                        foreach (BoodschappenlijstjeItem BItem in b.Producten)
                        {
                            if (BItem.SupermarktItem.Name == supermarkt.ProductPagina.SelectedItem.Name)
                            {
                                DeleteButton.Visibility         = Windows.UI.Xaml.Visibility.Visible;
                                AddButtonText.Text              = "Wijzig";
                                BoodschappenlijstTextblock.Text = "Verander aantal in boodschappenlijst:";
                                CountCombovox.SelectedIndex     = BItem.Count - 1;
                            }
                        }

                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                AppException = ex;
            }

            if (AppException != null)
            {
                Task t = Task.Run(() => ExceptionHandler.instance.PostException(new AppException(AppException), (int)ClientIDHandler.AppName.Supermarkt_Aanbiedingen));
            }
        }
Пример #6
0
        public static ProductPagina GetDiscountsFromSupermarket(Supermarkt supermarkt)
        {
            ProductPagina productPagina = CacheHandler.GetData("GetDiscountsFromSupermarket", supermarkt.URL, new string[] { }) as ProductPagina;

            if (productPagina != null)
            {
                return(productPagina);
            }

            bool DateUndetermined = supermarkt.URL.Contains("lidl");

            string PageSource = HttpHandler.GetDataFromWebPage("http://www.supermarktaanbiedingen.com" + supermarkt.URL);

            productPagina = DiscountsFromSupermarketParser.GetProductPaginaFromSourceAndURL(PageSource, supermarkt);

            CrawledFromInternetRequests++;
            CacheHandler.AddToCache("GetDiscountsFromSupermarket", supermarkt.URL, new string[] { }, productPagina);

            return(productPagina);
        }
        public static ProductPagina GetProductPaginaFromSourceAndURL(string Source, Supermarkt supermarkt)
        {
            ProductPagina CurrentPage = null;

            try
            {
                //Clear header
                Source = Source.Substring(HtmlParserUtil.GetPositionOfStringInHTMLSource("<h1 class=\"discount-title\">", Source));

                string ValidUntil = HtmlParserUtil.GetContentAndSubstringInput("<small> - ", "</small>", Source, out Source);

                while (ValidUntil.Contains('<') && ValidUntil.Contains('>'))
                {
                    try
                    {
                        int Index1 = ValidUntil.IndexOf('<');
                        int Index2 = ValidUntil.IndexOf('>', Index1);

                        ValidUntil = ValidUntil.Replace(ValidUntil.Substring(Index1, Index2 + 1 - Index1), "");
                    }
                    catch
                    {
                        break;
                    }
                }

                CurrentPage = new ProductPagina(ValidUntil, new List <Product>(), supermarkt);

                GetProductsFromSource(Source, CurrentPage);

                Debug.WriteLine(supermarkt.Name + ": " + (CurrentPage.Producten.Last() as Product).Name);
            }
            catch (Exception e)
            {
                throw e;
            }

            return(CurrentPage);
        }
        private async void NextButton_Click(object sender, RoutedEventArgs e)
        {
            NextButton.IsEnabled = false;
            List <Supermarkt> SelectedSupermarkets = new List <Supermarkt>();

            foreach (Supermarkt s in Supermarkets)
            {
                if (s.SupermarketEnabled)
                {
                    SelectedSupermarkets.Add(s);
                }
            }

            await Supermarkt.SaveSupermarketsToStorage(SelectedSupermarkets);

            if (!Frame.Navigate(typeof(MainPage)))
            {
                ;
            }
            {
            }
        }