Пример #1
0
        /// <summary>
        /// Delete all the quotes in a quote page from the database.
        /// </summary>
        /// <param name="quotePage"></param>
        public static async Task RemoveFromDatabase(QuotePage quotePage)
        {
            List <DatabaseHelpers.Quotes.Quote> delete = new List <DatabaseHelpers.Quotes.Quote>();

            await Task.Factory.StartNew(() =>
            {
                IEnumerable <DatabaseHelpers.Quotes.Quote> list = QuoteDatabase.AllQuotes();

                foreach (WikiquoteScreensaverLib.Common.Quote wikiQuote in quotePage)
                {
                    foreach (DatabaseHelpers.Quotes.Quote dbQuote in list)
                    {
                        if (dbQuote.Content == wikiQuote.Text)
                        {
                            delete.Add(dbQuote);
                            break;
                        }
                    }
                }
            });

            await Task.Factory.StartNew(() =>
            {
                foreach (DatabaseHelpers.Quotes.Quote dbQuote in delete)
                {
                    QuoteDatabase.DeleteQuote(dbQuote);
                }
            });
        }
Пример #2
0
 public void Reset()
 {
     CurrentQuotePage  = null;
     _searchResults    = null;
     _oldSearchResults = null;
     _oldSearchText    = String.Empty;
     _oldSearchTarget  = SearchTargets.QuoteTexts;
 }
Пример #3
0
 public QuoteViewModel(QuotePage page)
 {
     _quoteLabel       = page.FindByName <Label>("QuoteLabel");
     _quoteAuthorLabel = page.FindByName <Label>("QuoteAuthorLabel");
     FetchQuoteCommand = new Command(FetchQuote);
     StoreQuoteCommand = new Command(StoreQuote);
     _restClient       = DependencyService.Get <IRestClient>();
     _persistor        = DependencyService.Get <IPersistor>();
 }
Пример #4
0
        public void RemoveResultsFor(QuotePage page)
        {
            if (_currentQuotePage == page)
            {
                _searchResults = null;
            }

            if (_oldSearchResults != null)
            {
                _oldSearchResults.Remove(page);
            }
        }
Пример #5
0
        private void delete_Click(object sender, RoutedEventArgs e)
        {
            changesMade = true;

            QuotePage page = (QuotePage)((ContentPresenter)(((FrameworkElement)sender).TemplatedParent)).Content;

            playlist.Remove(page);

            if (!addedPages.Remove(page))
            {
                removedPages.Add(page);
            }
        }
Пример #6
0
        public void BeforeClass()
        {
            //Get login screen data
            loginFeatureParsedData = DataAccess.GetFeatureData("LoginScreen");
            //Get data for customer screen
            newCustomerFeatureParsedData = DataAccess.GetFeatureData("NewCustomerScreen");
            //Get data for update customer screen
            updateCustomerFeatureParsedData = DataAccess.GetFeatureData("UpdateCustomerScreen");
            //Get product line feature data
            productLineFeatureParsedData = DataAccess.GetFeatureData("ProductLineScreen");
            //Get data for Internal Infor Section
            internalInfoParsedData = DataAccess.GetFeatureData("InternalInfoScreen");

            //parse data of NewCustomerScreen feature in NewCustomerData class
            newCustomerData   = EnterNewCustomerPage.GetCustomerData(newCustomerFeatureParsedData);
            internalInforData = QuotePage.GetInternalInfoData(internalInfoParsedData);
        }
Пример #7
0
        internal void UpdateQuotesAsync(QuotePage page)
        {
            AsyncEnumerator asyncEnumerator = new AsyncEnumerator();

            lock (_asyncEnumerators)
            {
                _asyncEnumerators.Add(asyncEnumerator);
            }

            asyncEnumerator.BeginExecute(ProcessCollectQuotes(asyncEnumerator, page.Topic, page.Culture, page.Uri,
                                                              (quotes, topicTranslations) =>
            {
                page.Items             = quotes;
                page.TopicTranslations = topicTranslations;

                OnQuotesCollectingCompleted(new QuotesCollectingCompletedEventArgs(page, true));
            }),
                                         asyncEnumerator.EndExecute);
        }
Пример #8
0
        internal void CollectQuotesAsync(string topic, CultureInfo culture, Uri uri)
        {
            AsyncEnumerator asyncEnumerator = new AsyncEnumerator();

            lock (_asyncEnumerators)
            {
                _asyncEnumerators.Add(asyncEnumerator);
            }

            asyncEnumerator.BeginExecute(ProcessCollectQuotes(asyncEnumerator, topic, culture, uri,
                                                              (quotes, topicTranslations) =>
            {
                QuotePage page = new QuotePage(topic, uri, culture, quotes, topicTranslations);

                OnQuotesCollectingCompleted(new QuotesCollectingCompletedEventArgs(page, false));
                _playlist.Add(page);
            }),
                                         asyncEnumerator.EndExecute);
        }
Пример #9
0
        public void BeforeClassInitialization()
        {
            if (ConfigurationManager.AppSettings["Browser"] == "Chrome")
            {
                driver = new ChromeDriver();
            }
            else if (ConfigurationManager.AppSettings["Browser"] == "Firefox")
            {
                driver = new FirefoxDriver();
            }

            _ScreenshotUtil       = new ScreenshotUtil(driver);
            _LoginPage            = new LoginPage(driver);
            _BasePageClass        = new BasePageClass(driver);
            _HomePage             = new HomePage(driver);
            _EnterNewCustomerPage = new EnterNewCustomerPage(driver);
            _QuotePage            = new QuotePage(driver);

            _BasePageClass.OpenURL();

            _logger.Info($" :Successfully executed the BeforeClassInitialization() method for {this.GetType().Name}");
        }
Пример #10
0
        /// <summary>
        /// Adds a list of new quote pages to the database, randomizing
        /// the order of the quotes.
        /// </summary>
        /// <param name="quotePage"></param>
        public static async Task AddToDatabase(IList <QuotePage> quotePage)
        {
            await Task.Factory.StartNew(() =>
            {
                int pagesCount = quotePage.Count;
                Random random  = new Random((int)DateTime.Now.TimeOfDay.Ticks);

                // We have to loop through every date from now until the future to make
                // sure we fill up any holes in the database.
                DateTime?date = DateTime.Now.Date;

                while (pagesCount > 0)
                {
                    QuotePage page = quotePage[random.Next(0, pagesCount)];

                    if (page.Count == 0)
                    {
                        quotePage.Remove(page);
                        pagesCount--;
                        continue;
                    }

                    date = QuoteDatabase.NextFreeDate(date.Value);

                    if (!date.HasValue)
                    {
                        break;
                    }

                    AddToDatabase(page.Items[0], date.Value, page.Topic);

                    date = date.Value.AddDays(1);
                    page.Items.RemoveAt(0);
                }
            });
        }
Пример #11
0
        /// <summary>
        /// Adds a new quote page to the database.
        /// </summary>
        /// <param name="quotePage"></param>
        public static async Task AddToDatabase(QuotePage quotePage)
        {
            //DateTime? lastDate = QuoteDatabase.GetLastDate();
            //DateTime date = lastDate.HasValue ? lastDate.Value.AddDays(1) : DateTime.Now.Date;

            //foreach (WikiquoteScreensaverLib.Common.Quote each in quotePage)
            //{
            //	QuoteDatabase.AddQuote(
            //		new DatabaseHelpers.Quotes.Quote(date, null, each.Text, each.AdditionalInformation)
            //	);

            //	date = date.AddDays(1);
            //}

            await Task.Factory.StartNew(() =>
            {
                //
                // We have to loop through every date from now until the future to make
                // sure we fill up any holes in the database.
                //
                DateTime?date = DateTime.Now.Date;

                foreach (WikiquoteScreensaverLib.Common.Quote each in quotePage)
                {
                    date = QuoteDatabase.NextFreeDate(date.Value);

                    if (!date.HasValue)
                    {
                        break;
                    }

                    AddToDatabase(each, date.Value, quotePage.Topic);
                    date = date.Value.AddDays(1);
                }
            });
        }
Пример #12
0
 public void AddLookup(QuotePage page)
 {
     AddLookups(new QuotePage[] { page });
 }
 internal QuotesCollectingCompletedEventArgs(QuotePage page, bool update)
     : base(page.Topic, page.Culture, page.Uri)
 {
     _page   = page;
     _update = update;
 }