Esempio n. 1
0
        private void Parse()
        {
            foreach (var jobData in _inputsWithHtml.GetConsumingEnumerable())
            {
                try
                {
                    if (_isStopping)
                    {
                        return;
                    }
                    foreach (CardWithExtraInfo cardWithExtraInfo in Parser.ParseCardInfo(jobData.Html))
                    {
                        string pictureUrl = WebAccess.ToAbsoluteUrl(jobData.Url, cardWithExtraInfo.PictureUrl);
                        int    idGatherer = Parser.ExtractIdGatherer(pictureUrl);
                        string baseUrl    = WebAccess.ToAbsoluteUrl(jobData.Url, string.Format("Languages.aspx?multiverseid={0}", idGatherer));

                        CardWithExtraInfo info = cardWithExtraInfo;

                        _downloadManager.ManageMultiPage(baseUrl, html =>
                        {
                            foreach (CardLanguageInfo language in Parser.ParseCardLanguage(html))
                            {
                                info.Add(language);
                            }
                        });

                        _downloadManager.InsertCardInDb(cardWithExtraInfo);
                        _downloadManager.InsertCardEditionInDb(jobData.EditionId, cardWithExtraInfo, pictureUrl);

                        foreach (int otherIdGatherer in cardWithExtraInfo.OtherIdGatherer)
                        {
                            _downloadManager.InsertCardEditionVariationInDb(idGatherer, otherIdGatherer, WebAccess.ToAbsoluteUrl(jobData.Url, string.Format(Parser.AlternativePictureUrl, otherIdGatherer), true));
                        }
                    }
                    _editions[jobData.EditionId].Progress();
                    _globalProgressReporter.Progress();
                }
                catch (Exception ex)
                {
                    SendError(ex);
                }
            }
        }
Esempio n. 2
0
 internal void InsertCardInDb(CardWithExtraInfo cardWithExtraInfo)
 {
     MagicDatabase.InsertNewCard(cardWithExtraInfo.Name, cardWithExtraInfo.Text, cardWithExtraInfo.Power, cardWithExtraInfo.Toughness,
                                 cardWithExtraInfo.CastingCost, cardWithExtraInfo.Loyalty, cardWithExtraInfo.Type,
                                 cardWithExtraInfo.PartName, cardWithExtraInfo.OtherPathName, cardWithExtraInfo.Languages);
 }
Esempio n. 3
0
        internal void InsertCardEditionInDb(int idEdition, CardWithExtraInfo cardWithExtraInfo, string pictureUrl)
        {
            int idGatherer = Parser.ExtractIdGatherer(cardWithExtraInfo.PictureUrl);

            MagicDatabase.InsertNewCardEdition(idGatherer, idEdition, cardWithExtraInfo.Name, cardWithExtraInfo.PartName, cardWithExtraInfo.Rarity, pictureUrl);
        }