private void ParseVaulted(HtmlNode cell, RowData data) { var text = cell.InnerText.Trim(); if (text.Equals("yes", StringComparison.InvariantCultureIgnoreCase)) { data.IsVaulted = true; } else if (text.Equals("no", StringComparison.InvariantCultureIgnoreCase)) { data.IsVaulted = false; } }
private void ParsePartCell(HtmlNode cell, RowData data) { data.PartName = HttpUtility.HtmlDecode(cell.InnerText); }
/// <inheritdoc /> public RowData ParseRowOfSimpleRewardsTable(HtmlNode row) { if (row == null) { throw new ArgumentNullException(nameof(row)); } if (row.Name != "tr") { throw new ArgumentException("Argument must be a table row HtmlNode", nameof(row)); } var col = 0; var rowData = new RowData(); foreach (var cell in row.ChildNodes) { if (cell.Name != "td") { continue; } switch (col) { case 0: ParseItemCell(cell, rowData); break; case 1: ParsePartCell(cell, rowData); break; case 2: ParseRelicTierCell(cell, rowData); break; case 3: ParseRelicNameCell(cell, rowData); break; case 4: ParseRelicRarityCell(cell, rowData); break; case 5: ParseVaulted(cell, rowData); break; } col++; } if (rowData.ItemName == null || rowData.ItemName == "Forma") { return(null); } if (!rowData.DropChance.HasValue) { return(null); } if (!rowData.IsVaulted.HasValue) { return(null); } if (!rowData.RelicTier.HasValue) { return(null); } return(rowData); }
/// <inheritdoc /> public async Task <PrimeItem> AddOrUpdateRowData(RowData rowData) { // Create or retreive item var primeItem = await AddOrUpdatePeristentItem( new PrimeItem() { Name = rowData.ItemName, WikiUrl = rowData.ItemUrl, }, (dest, source, _) => { if (dest.Name != source.Name) { dest.Name = source.Name; } if (dest.WikiUrl != source.WikiUrl) { dest.WikiUrl = source.WikiUrl; } } ); // Create or retreive part var primePart = await AddOrUpdatePeristentItem( new PrimePart() { Name = rowData.PartName, }, (dest, source, _) => { if (dest.Name != source.Name) { dest.Name = source.Name; } }); // Create or retreive relic var relic = await AddOrUpdatePeristentItem( new Relic() { Tier = rowData.RelicTier.Value, Name = rowData.RelicName, WikiUrl = rowData.RelicUrl, IsVaulted = rowData.IsVaulted.Value, }, (dest, source, _) => { if (dest.Tier != source.Tier) { dest.Tier = source.Tier; } if (dest.Name != source.Name) { dest.Name = source.Name; } if (dest.WikiUrl != source.WikiUrl) { dest.WikiUrl = source.WikiUrl; } if (dest.IsVaulted != source.IsVaulted) { dest.IsVaulted = source.IsVaulted; } }); // Link prime item with prime part var partIngredient = await AddOrUpdatePeristentItem( new PrimePartIngredient() { PrimeItemId = primeItem.Id, PrimeItem = primeItem, PrimePartId = primePart.Id, PrimePart = primePart, Count = 1 // Placeholder value }, (dest, source, entry) => { if (dest.PrimeItemId != source.PrimeItemId) { dest.PrimeItemId = source.PrimeItemId; dest.PrimeItem = source.PrimeItem; } if (dest.PrimePartId != source.PrimePartId) { dest.PrimePartId = source.PrimePartId; dest.PrimePart = source.PrimePart; } // Only update the count if it is 0 -> count cannot be known in this call if (dest.Count == 0) { dest.Count = source.Count; } else { entry.Property(i => i.Count).IsModified = false; } }); // Link prime part with relic var relicDrop = await AddOrUpdateItem( new RelicDrop() { RelicId = relic.Id, Relic = relic, PrimePartIngredientId = partIngredient.Id, PrimePartIngredient = partIngredient, DropChance = rowData.DropChance.Value, }, r => new object[] { r.RelicId, r.PrimePartIngredientId }, (dest, source, _) => { if (dest.RelicId != source.RelicId) { dest.RelicId = source.RelicId; dest.Relic = source.Relic; } if (dest.PrimePartIngredientId != source.PrimePartIngredientId) { dest.PrimePartIngredientId = source.PrimePartIngredientId; dest.PrimePartIngredient = source.PrimePartIngredient; } if (dest.DropChance != source.DropChance) { dest.DropChance = source.DropChance; } } ); return(primeItem); }