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); } } }
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); }
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); }