Compare commits

...

10 Commits

16 changed files with 338 additions and 194 deletions

View File

@@ -0,0 +1,17 @@
namespace lottery_co_uk_scraper.core.Models
{
internal class GameInformation
{
public int Id { get; set; }
public string GameName { get; set; }
public DayOfWeek DrawDay { get; set; }
public TimeOnly DrawClosing { get; set; }
public TimeOnly DrawOpening { get; set; }
public TimeOnly DrawTime { get; set; }
}
}

View File

@@ -8,7 +8,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="8.0.2" />
</ItemGroup>
</Project>

View File

@@ -8,9 +8,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.1">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

View File

@@ -5,9 +5,11 @@ VisualStudioVersion = 17.9.34321.82
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "lottery-co-uk-scraper", "lottery-co-uk-scraper\lottery-co-uk-scraper.csproj", "{D6F6C01A-F51A-4ED7-AC9F-67C7BF9AAB79}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lottery-co-uk-scraper.data", "lottery-co-uk-scraper.data\lottery-co-uk-scraper.data.csproj", "{57463DA3-7350-4A10-853C-6C766F96A039}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "lottery-co-uk-scraper.data", "lottery-co-uk-scraper.data\lottery-co-uk-scraper.data.csproj", "{57463DA3-7350-4A10-853C-6C766F96A039}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lottery-co-uk-scraper.core", "lottery-co-uk-scraper.core\lottery-co-uk-scraper.core.csproj", "{8CA5863C-1FBF-443A-A6A1-B49795C86520}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "lottery-co-uk-scraper.core", "lottery-co-uk-scraper.core\lottery-co-uk-scraper.core.csproj", "{8CA5863C-1FBF-443A-A6A1-B49795C86520}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lottery-co-uk-scraper.tests", "lottery-co-uk-scraper.tests\lottery-co-uk-scraper.tests.csproj", "{ADB3EC10-84F1-4928-9431-35A91816AA77}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -27,6 +29,10 @@ Global
{8CA5863C-1FBF-443A-A6A1-B49795C86520}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8CA5863C-1FBF-443A-A6A1-B49795C86520}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8CA5863C-1FBF-443A-A6A1-B49795C86520}.Release|Any CPU.Build.0 = Release|Any CPU
{ADB3EC10-84F1-4928-9431-35A91816AA77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ADB3EC10-84F1-4928-9431-35A91816AA77}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ADB3EC10-84F1-4928-9431-35A91816AA77}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ADB3EC10-84F1-4928-9431-35A91816AA77}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>lottery_co_uk_scraper.tests</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
</ItemGroup>
<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>
</Project>

View File

@@ -2,7 +2,7 @@
using lottery_co_uk_scraper.core.Models;
using lottery_co_uk_scraper.Utilities;
using Microsoft.Extensions.Logging;
using static lottery_co_uk_scraper.NationalLottery.Lotto;
using static lottery_co_uk_scraper.EuroMillions.DrawWinnerInformation; /// So this table should not exist here.
namespace lottery_co_uk_scraper.EuroMillions
{
@@ -35,7 +35,7 @@ namespace lottery_co_uk_scraper.EuroMillions
if (int.TryParse(ballSetUsedString, out int ballSetUsed))
{
AssignBallSetToModelProperty(LotteryTableRow.BallSetUsed, ballSetUsed, eurosResult);
AssignBallSetToModelProperty(EurosTableRow.BallSetUsed, ballSetUsed, eurosResult);
return ballSetUsed;
}
@@ -56,7 +56,7 @@ namespace lottery_co_uk_scraper.EuroMillions
{
try
{
if (containerNode == LotteryTableRow.BallSetUsed)
if (containerNode == EurosTableRow.BallSetUsed)
{
PropertyManager.SetProperty(nameof(eurosResult.BallSetUsed), eurosResult, ballSetUsed);
}
@@ -73,7 +73,7 @@ namespace lottery_co_uk_scraper.EuroMillions
{
try
{
var ballsDrawn = GetNodeById(doc.DocumentNode, LotteryTableRow.BallsDrawn);
var ballsDrawn = GetNodeById(doc.DocumentNode, EurosTableRow.BallsDrawn);
List<int>? euroBalls = ballsDrawn != null
? ExtractBalls(ballsDrawn, "euromillions-ball")
@@ -81,7 +81,7 @@ namespace lottery_co_uk_scraper.EuroMillions
if (euroBalls != null)
{
AssignDrawBallsToModelProperty(LotteryTableRow.BallsDrawn, euroBalls, eurosResult);
AssignDrawBallsToModelProperty(EurosTableRow.BallsDrawn, euroBalls, eurosResult);
}
else
{
@@ -127,7 +127,7 @@ namespace lottery_co_uk_scraper.EuroMillions
{
try
{
if (containerNode == LotteryTableRow.BallsDrawn)
if (containerNode == EurosTableRow.BallsDrawn)
{
if (ballInformation is List<int> balls && balls.Count >= 5)
{
@@ -161,7 +161,7 @@ namespace lottery_co_uk_scraper.EuroMillions
{
try
{
var ballsDrawn = GetNodeById(doc.DocumentNode, LotteryTableRow.BallsDrawn);
var ballsDrawn = GetNodeById(doc.DocumentNode, EurosTableRow.BallsDrawn);
List<int>? luckyStars = ballsDrawn != null
? ExtractLuckyStar(ballsDrawn, "euromillions-lucky-star")
@@ -169,7 +169,7 @@ namespace lottery_co_uk_scraper.EuroMillions
if (luckyStars != null)
{
AssignLuckyStarToModelProperty(LotteryTableRow.BallsDrawn, luckyStars, eurosResult);
AssignLuckyStarToModelProperty(EurosTableRow.BallsDrawn, luckyStars, eurosResult);
}
else
{
@@ -218,7 +218,7 @@ namespace lottery_co_uk_scraper.EuroMillions
{
try
{
if (containerNode == LotteryTableRow.BallsDrawn)
if (containerNode == EurosTableRow.BallsDrawn)
{
if (ballInformation is List<int> balls && balls.Count >= 2)
{

View File

@@ -28,10 +28,11 @@ namespace lottery_co_uk_scraper.EuroMillions
}
catch (Exception ex)
{
// ToDo: _logger.LogError
throw new Exception(ex.Message);
}
return null;
throw new Exception("Failed to Process Millionaire Maker Code.");
}
public static void AssignMillionaireMakerToModelProperty(string propertyName, List<string> raffleNumbers, EurosResult eurosResult)

View File

@@ -23,7 +23,8 @@ namespace lottery_co_uk_scraper.EuroMillions
}
else
{
return null;
// ToDo: _logger.LogError
throw new Exception("machineName is null");
}
}
catch (Exception ex)

View File

@@ -5,8 +5,11 @@ using System.Text.RegularExpressions;
namespace lottery_co_uk_scraper.EuroMillions
{
internal class DrawNumber
internal partial class DrawNumber
{
[GeneratedRegex(@"euromillions draw (\d+)")]
private static partial Regex MyRegex();
public static int ProcessDrawNumberFromMeta(HtmlDocument doc, EurosResult eurosResult)
{
var metaKeywords = doc.DocumentNode.Descendants("meta")
@@ -15,7 +18,7 @@ namespace lottery_co_uk_scraper.EuroMillions
if (metaKeywords != null)
{
var keywordsText = metaKeywords.GetAttributeValue("content", "");
var drawNumberMatch = Regex.Match(keywordsText, @"euromillions draw (\d+)");
var drawNumberMatch = MyRegex().Match(keywordsText);
if (drawNumberMatch.Success)
{

View File

@@ -28,11 +28,9 @@ namespace lottery_co_uk_scraper.EuroMillions
}
catch (Exception ex)
{
// ToDo: _logger.LogError
throw new Exception(ex.Message);
}
//ToDo: This isn't ideal how will i know if it fails.
return false;
}
public static void AssignDrawStatusToModelProperty(bool status, EurosResult eurosResult)
@@ -43,7 +41,8 @@ namespace lottery_co_uk_scraper.EuroMillions
}
catch (Exception ex)
{
// ToDo: _logger.LogError
throw new Exception(ex.Message);
}
}
}

View File

@@ -14,6 +14,8 @@ namespace lottery_co_uk_scraper.EuroMillions
internal class EurosTableRow()
{
internal const string BallSetUsed = "ballSetUsed";
internal const string BallsDrawn = "ballsDrawn";
internal const string Match1Plus2Stars = "Match 1 and 2 Stars";
internal const string Match2 = "Match 2";
internal const string Match2Plus1Star = "Match 2 and 1 Star";
@@ -124,11 +126,9 @@ namespace lottery_co_uk_scraper.EuroMillions
}
catch (Exception ex)
{
// ToDo Logger
Console.WriteLine();
// ToDo: _logger.LogError
throw new Exception(ex.Message);
}
return null;
}
private static HtmlNode GetNodeByDataTitle(HtmlNode sectionRow, string dataTitle)
@@ -141,10 +141,11 @@ namespace lottery_co_uk_scraper.EuroMillions
}
catch (Exception ex)
{
// ToDo: _logger.LogError
throw new Exception(ex.Message);
}
return null;
throw new Exception("Failed to get node by data title.");
}
public static void ProcessUKWinners(string sectionTitle, HtmlNode winnersNode, EurosResult eurosResult)
@@ -164,8 +165,8 @@ namespace lottery_co_uk_scraper.EuroMillions
}
catch (Exception ex)
{
// ToDo: Logger
Console.WriteLine("Nothing to match");
// ToDo: _logger.LogError
throw new Exception(ex.Message);
}
}
@@ -177,8 +178,8 @@ namespace lottery_co_uk_scraper.EuroMillions
}
catch (Exception ex)
{
// ToDo: Logger
Console.WriteLine("Nothing to match");
// ToDo: _logger.LogError
throw new Exception(ex.Message);
}
}
@@ -209,8 +210,8 @@ namespace lottery_co_uk_scraper.EuroMillions
}
catch (Exception ex)
{
// ToDo: Logger
Console.WriteLine("Nothing to match");
// ToDo: _logger.LogError
throw new Exception(ex.Message);
}
}
@@ -253,8 +254,8 @@ namespace lottery_co_uk_scraper.EuroMillions
}
catch (Exception ex)
{
// ToDo: Logger
Console.WriteLine("Nothing to match");
// ToDo: _logger.LogError
throw new Exception(ex.Message);
}
}
@@ -266,8 +267,8 @@ namespace lottery_co_uk_scraper.EuroMillions
}
catch (Exception ex)
{
// ToDo: Logger
Console.WriteLine("Nothing to match");
// ToDo: _logger.LogError
throw new Exception(ex.Message);
}
}
@@ -288,8 +289,8 @@ namespace lottery_co_uk_scraper.EuroMillions
}
catch (Exception ex)
{
// ToDo: Logger
Console.WriteLine("Nothing to match");
// ToDo: _logger.LogError
throw new Exception(ex.Message);
}
}
@@ -301,8 +302,8 @@ namespace lottery_co_uk_scraper.EuroMillions
}
catch (Exception ex)
{
// ToDo: Logger
Console.WriteLine("Nothing to match");
// ToDo: _logger.LogError
throw new Exception(ex.Message);
}
}
@@ -337,7 +338,7 @@ namespace lottery_co_uk_scraper.EuroMillions
catch (Exception ex)
{
// ToDo: Logger
Console.WriteLine(ex);
throw new Exception(ex.Message);
}
break;
@@ -370,7 +371,7 @@ namespace lottery_co_uk_scraper.EuroMillions
catch (Exception ex)
{
// ToDo: Logger
Console.WriteLine(ex);
throw new Exception(ex.Message);
}
break;
@@ -401,7 +402,7 @@ namespace lottery_co_uk_scraper.EuroMillions
catch (Exception ex)
{
// ToDo: Logger
Console.WriteLine("Nothing to match");
throw new Exception(ex.Message);
}
break;
@@ -432,7 +433,7 @@ namespace lottery_co_uk_scraper.EuroMillions
catch (Exception ex)
{
// ToDo: Logger
Console.WriteLine("Nothing to match");
throw new Exception(ex.Message);
}
break;
@@ -465,7 +466,7 @@ namespace lottery_co_uk_scraper.EuroMillions
catch (Exception ex)
{
// ToDo: Logger
Console.WriteLine("Nothing to match");
throw new Exception(ex.Message);
}
break;
@@ -496,7 +497,7 @@ namespace lottery_co_uk_scraper.EuroMillions
catch (Exception ex)
{
// ToDo: Logger
Console.WriteLine("Nothing to match");
throw new Exception(ex.Message);
}
break;
@@ -525,9 +526,9 @@ namespace lottery_co_uk_scraper.EuroMillions
}
}
catch (Exception ex)
{
{
// ToDo: Logger
Console.WriteLine("Nothing to match");
throw new Exception(ex.Message);
}
break;
@@ -560,7 +561,7 @@ namespace lottery_co_uk_scraper.EuroMillions
catch (Exception ex)
{
// ToDo: Logger
Console.WriteLine("Nothing to match");
throw new Exception(ex.Message);
}
break;
@@ -591,7 +592,7 @@ namespace lottery_co_uk_scraper.EuroMillions
catch (Exception ex)
{
// ToDo: Logger
Console.WriteLine("Nothing to match");
throw new Exception(ex.Message);
}
break;
@@ -622,7 +623,7 @@ namespace lottery_co_uk_scraper.EuroMillions
catch (Exception ex)
{
// ToDo: Logger
Console.WriteLine("Nothing to match");
throw new Exception(ex.Message);
}
break;
@@ -719,10 +720,10 @@ namespace lottery_co_uk_scraper.EuroMillions
PropertyManager.SetProperty(nameof(eurosResult.TotalWinners), eurosResult, value);
}
}
catch
catch (Exception ex)
{
// ToDo: Logger
Console.WriteLine("Nothing to match");
throw new Exception(ex.Message);
}
break;

View File

@@ -2,7 +2,7 @@
using lottery_co_uk_scraper.core.Models;
using lottery_co_uk_scraper.Utilities;
using Microsoft.Extensions.Logging;
using static lottery_co_uk_scraper.NationalLottery.Lotto;
using static lottery_co_uk_scraper.NationalLottery.DrawWinnerInformation;
namespace lottery_co_uk_scraper.NationalLottery
{
@@ -176,9 +176,9 @@ namespace lottery_co_uk_scraper.NationalLottery
}
else
{
_logger.LogError("Bonus Ball appear to be null.");
_logger.LogError("Bonus Ball appears to be null.");
throw new Exception("Bonus Ballappear to be null.");
throw new Exception("Bonus Ball appears to be null.");
}
}
catch (Exception ex)
@@ -194,15 +194,16 @@ namespace lottery_co_uk_scraper.NationalLottery
try
{
var bonusBallNode = ballsDrawn.Descendants("span")
.FirstOrDefault(x => x.HasClass(ballClass));
.FirstOrDefault(x => x.HasClass(ballClass));
if (bonusBallNode != null && int.TryParse(bonusBallNode.InnerText, out int bonusBall))
{
return bonusBall;
}
_logger.LogError("Failed to parse {className} value: {x.InnerText}", ballClass, x.InnerText);
throw new Exception($"Failed to parse {ballClass} value: {x.InnerText}");
_logger.LogError("Failed to parse {className}", ballClass);
throw new Exception($"Failed to parse {ballClass}");
}
catch
{

View File

@@ -1,6 +1,5 @@
using HtmlAgilityPack;
using lottery_co_uk_scraper.core.Models;
using static lottery_co_uk_scraper.NationalLottery.Lotto;
using System.Globalization;
using lottery_co_uk_scraper.Utilities;
using System.Text.RegularExpressions;
@@ -9,6 +8,25 @@ namespace lottery_co_uk_scraper.NationalLottery
{
internal partial class DrawWinnerInformation
{
[GeneratedRegex(@"(\d+)")]
private static partial Regex MyRegex();
internal static class LotteryTableRow
{
internal const string Match2 = "Match 2";
internal const string Match3 = "Match 3";
internal const string Match4 = "Match 4";
internal const string Match5 = "Match 5";
internal const string Match5Bonus = "Match 5 plus Bonus";
internal const string Match6 = "Match 6";
internal const string Total = "Totals";
internal const string Winners = "Winners";
internal const string PrizePerWinner = "Prize Per Winner";
internal const string PrizeFundAmount = "Prize Fund Amount";
internal const string BallSetUsed = "ballSetUsed";
internal const string BallsDrawn = "ballsDrawn";
}
public static void ProcessTableSection(HtmlNode table, string sectionTitle, LottoResult lottoResult)
{
try
@@ -48,9 +66,11 @@ namespace lottery_co_uk_scraper.NationalLottery
}
catch (Exception ex)
{
// ToDo: _logger.LogError
throw new Exception(ex.Message);
}
}
private static HtmlNode GetSectionRowByTitle(HtmlNode table, string sectionTitle)
{
try
@@ -64,15 +84,17 @@ namespace lottery_co_uk_scraper.NationalLottery
}
else
{
return null;
// ToDo: _logger.LogError
throw new Exception("sectionRow is null.");
}
}
catch (Exception ex)
{
// ToDo: _logger.LogError
throw new Exception(ex.Message);
}
return null;
throw new Exception("Failed to get section by row title.");
}
private static HtmlNode GetNodeByDataTitle(HtmlNode sectionRow, string dataTitle)
@@ -84,26 +106,37 @@ namespace lottery_co_uk_scraper.NationalLottery
public static void ProcessWinnersTable(HtmlDocument doc, LottoResult lottoResult)
{
var table = doc.DocumentNode.Descendants("table")
.FirstOrDefault(x => x.Attributes["class"] != null && x.Attributes["class"].Value.Contains("lotto mobFormat"));
if (table != null)
try
{
HtmlNode match2Section = GetSectionRowByTitle(table, LotteryTableRow.Match2);
if (match2Section != null)
var table = doc.DocumentNode.Descendants("table")
.FirstOrDefault(x => x.Attributes["class"] != null && x.Attributes["class"].Value.Contains("lotto mobFormat"));
if (table != null)
{
ProcessTableSection(table, LotteryTableRow.Match2, lottoResult);
HtmlNode match2Section = GetSectionRowByTitle(table, LotteryTableRow.Match2);
if (match2Section != null)
{
ProcessTableSection(table, LotteryTableRow.Match2, lottoResult);
}
else
{
// ToDo: I don't need this write line, log the information about it being a draw with no match twos.
//_logger.LogInformation("");
Console.WriteLine("Section row with title 'Match 2' not found. Continuing without processing Match 2.");
}
ProcessTableSection(table, LotteryTableRow.Match3, lottoResult);
ProcessTableSection(table, LotteryTableRow.Match4, lottoResult);
ProcessTableSection(table, LotteryTableRow.Match5, lottoResult);
ProcessTableSection(table, LotteryTableRow.Match5Bonus, lottoResult);
ProcessTableSection(table, LotteryTableRow.Match6, lottoResult);
ProcessTableSection(table, LotteryTableRow.Total, lottoResult);
}
else
{
Console.WriteLine("Section row with title 'Match 2' not found. Continuing without processing Match 2.");
}
ProcessTableSection(table, LotteryTableRow.Match3, lottoResult);
ProcessTableSection(table, LotteryTableRow.Match4, lottoResult);
ProcessTableSection(table, LotteryTableRow.Match5, lottoResult);
ProcessTableSection(table, LotteryTableRow.Match5Bonus, lottoResult);
ProcessTableSection(table, LotteryTableRow.Match6, lottoResult);
ProcessTableSection(table, LotteryTableRow.Total, lottoResult);
}
catch (Exception ex)
{
//_logger.LogError("");
throw new Exception(ex.Message);
}
}
@@ -111,126 +144,196 @@ namespace lottery_co_uk_scraper.NationalLottery
{
switch (sectionTitle)
{
#region Match 2
case LotteryTableRow.Match2:
if (columnTitle == LotteryTableRow.Winners)
try
{
PropertyManager.SetProperty(nameof(lottoResult.TotalMatched2), lottoResult, value);
if (columnTitle == LotteryTableRow.Winners)
{
PropertyManager.SetProperty(nameof(lottoResult.TotalMatched2), lottoResult, value);
}
if (columnTitle == LotteryTableRow.PrizePerWinner)
{
PropertyManager.SetProperty(nameof(lottoResult.Matched2Prize), lottoResult, value);
}
if (columnTitle == LotteryTableRow.PrizeFundAmount)
{
PropertyManager.SetProperty(nameof(lottoResult.Matched2PrizeFund), lottoResult, value);
}
}
catch(Exception ex)
{
// ToDo: _logger.LogError
throw new Exception(ex.Message);
}
if (columnTitle == LotteryTableRow.PrizePerWinner)
{
PropertyManager.SetProperty(nameof(lottoResult.Matched2Prize), lottoResult, value);
}
if (columnTitle == LotteryTableRow.PrizeFundAmount)
{
PropertyManager.SetProperty(nameof(lottoResult.Matched2PrizeFund), lottoResult, value);
}
break;
break;
#endregion
#region Match 3
case LotteryTableRow.Match3:
if (columnTitle == LotteryTableRow.Winners)
try
{
PropertyManager.SetProperty(nameof(lottoResult.TotalMatched3), lottoResult, value);
if (columnTitle == LotteryTableRow.Winners)
{
PropertyManager.SetProperty(nameof(lottoResult.TotalMatched3), lottoResult, value);
}
if (columnTitle == LotteryTableRow.PrizePerWinner)
{
PropertyManager.SetProperty(nameof(lottoResult.Matched3Prize), lottoResult, value);
}
if (columnTitle == LotteryTableRow.PrizeFundAmount)
{
PropertyManager.SetProperty(nameof(lottoResult.Matched3PrizeFund), lottoResult, value);
}
}
catch (Exception ex)
{
// ToDo: _logger.LogError
throw new Exception(ex.Message);
}
if (columnTitle == LotteryTableRow.PrizePerWinner)
{
PropertyManager.SetProperty(nameof(lottoResult.Matched3Prize), lottoResult, value);
}
if (columnTitle == LotteryTableRow.PrizeFundAmount)
{
PropertyManager.SetProperty(nameof(lottoResult.Matched3PrizeFund), lottoResult, value);
}
break;
break;
#endregion
#region Match 4
case LotteryTableRow.Match4:
if (columnTitle == LotteryTableRow.Winners)
try
{
PropertyManager.SetProperty(nameof(lottoResult.TotalMatched4), lottoResult, value);
if (columnTitle == LotteryTableRow.Winners)
{
PropertyManager.SetProperty(nameof(lottoResult.TotalMatched4), lottoResult, value);
}
if (columnTitle == LotteryTableRow.PrizePerWinner)
{
PropertyManager.SetProperty(nameof(lottoResult.Matched4Prize), lottoResult, value);
}
if (columnTitle == LotteryTableRow.PrizeFundAmount)
{
PropertyManager.SetProperty(nameof(lottoResult.Matched4PrizeFund), lottoResult, value);
}
}
catch (Exception ex)
{
// ToDo: _logger.LogError
throw new Exception(ex.Message);
}
if (columnTitle == LotteryTableRow.PrizePerWinner)
{
PropertyManager.SetProperty(nameof(lottoResult.Matched4Prize), lottoResult, value);
}
if (columnTitle == LotteryTableRow.PrizeFundAmount)
{
PropertyManager.SetProperty(nameof(lottoResult.Matched4PrizeFund), lottoResult, value);
}
break;
break;
#endregion
#region Match 5
case LotteryTableRow.Match5:
if (columnTitle == LotteryTableRow.Winners)
try
{
PropertyManager.SetProperty(nameof(lottoResult.TotalMatched5), lottoResult, value);
if (columnTitle == LotteryTableRow.Winners)
{
PropertyManager.SetProperty(nameof(lottoResult.TotalMatched5), lottoResult, value);
}
if (columnTitle == LotteryTableRow.PrizePerWinner)
{
PropertyManager.SetProperty(nameof(lottoResult.Matched5Prize), lottoResult, value);
}
if (columnTitle == LotteryTableRow.PrizeFundAmount)
{
PropertyManager.SetProperty(nameof(lottoResult.Matched5PrizeFund), lottoResult, value);
}
}
catch (Exception ex)
{
// ToDo: _logger.LogError
throw new Exception(ex.Message);
}
if (columnTitle == LotteryTableRow.PrizePerWinner)
{
PropertyManager.SetProperty(nameof(lottoResult.Matched5Prize), lottoResult, value);
}
if (columnTitle == LotteryTableRow.PrizeFundAmount)
{
PropertyManager.SetProperty(nameof(lottoResult.Matched5PrizeFund), lottoResult, value);
}
break;
break;
#endregion
#region Match 5 + Bonus
case LotteryTableRow.Match5Bonus:
if (columnTitle == LotteryTableRow.Winners)
try
{
PropertyManager.SetProperty(nameof(lottoResult.TotalMatched5PlusBonus), lottoResult, value);
if (columnTitle == LotteryTableRow.Winners)
{
PropertyManager.SetProperty(nameof(lottoResult.TotalMatched5PlusBonus), lottoResult, value);
}
if (columnTitle == LotteryTableRow.PrizePerWinner)
{
PropertyManager.SetProperty(nameof(lottoResult.Matched5PlusBonusPrize), lottoResult, value);
}
if (columnTitle == LotteryTableRow.PrizeFundAmount)
{
PropertyManager.SetProperty(nameof(lottoResult.Matched5PlusBonusPrizeFund), lottoResult, value);
}
}
catch (Exception ex)
{
// ToDo: _logger.LogError
throw new Exception(ex.Message);
}
if (columnTitle == LotteryTableRow.PrizePerWinner)
{
PropertyManager.SetProperty(nameof(lottoResult.Matched5PlusBonusPrize), lottoResult, value);
}
if (columnTitle == LotteryTableRow.PrizeFundAmount)
{
PropertyManager.SetProperty(nameof(lottoResult.Matched5PlusBonusPrizeFund), lottoResult, value);
}
break;
break;
#endregion
#region Match 6
case LotteryTableRow.Match6:
if (columnTitle == LotteryTableRow.Winners)
try
{
PropertyManager.SetProperty(nameof(lottoResult.TotalMatched6), lottoResult, value);
if (columnTitle == LotteryTableRow.Winners)
{
PropertyManager.SetProperty(nameof(lottoResult.TotalMatched6), lottoResult, value);
}
if (columnTitle == LotteryTableRow.PrizePerWinner)
{
PropertyManager.SetProperty(nameof(lottoResult.Matched6Prize), lottoResult, value);
}
if (columnTitle == LotteryTableRow.PrizeFundAmount)
{
PropertyManager.SetProperty(nameof(lottoResult.Matched6PrizeFund), lottoResult, value);
}
}
catch (Exception ex)
{
// ToDo: _logger.LogError
throw new Exception(ex.Message);
}
if (columnTitle == LotteryTableRow.PrizePerWinner)
{
PropertyManager.SetProperty(nameof(lottoResult.Matched6Prize), lottoResult, value);
}
if (columnTitle == LotteryTableRow.PrizeFundAmount)
{
PropertyManager.SetProperty(nameof(lottoResult.Matched6PrizeFund), lottoResult, value);
}
break;
break;
#endregion
#region Totals
case LotteryTableRow.Total:
if (columnTitle == LotteryTableRow.Winners)
try
{
PropertyManager.SetProperty(nameof(lottoResult.TotalWinners), lottoResult, value);
if (columnTitle == LotteryTableRow.Winners)
{
PropertyManager.SetProperty(nameof(lottoResult.TotalWinners), lottoResult, value);
}
if (columnTitle == LotteryTableRow.PrizeFundAmount)
{
PropertyManager.SetProperty(nameof(lottoResult.TotalPrizeFund), lottoResult, value);
}
}
catch (Exception ex)
{
// ToDo: _logger.LogError
throw new Exception(ex.Message);
}
if (columnTitle == LotteryTableRow.PrizeFundAmount)
{
PropertyManager.SetProperty(nameof(lottoResult.TotalPrizeFund), lottoResult, value);
}
break;
break;
#endregion
}
}
@@ -544,8 +647,5 @@ namespace lottery_co_uk_scraper.NationalLottery
{
AssignValueToModelProperty(sectionTitle, columnTitle, LotteryTableRow.Total, winnersNode, lottoResult);
}
[GeneratedRegex(@"(\d+)")]
private static partial Regex MyRegex();
}
}

View File

@@ -37,21 +37,5 @@ namespace lottery_co_uk_scraper.NationalLottery
Console.WriteLine($"An error occurred: {ex.Message}");
}
}
public static class LotteryTableRow
{
public const string Match2 = "Match 2";
public const string Match3 = "Match 3";
public const string Match4 = "Match 4";
public const string Match5 = "Match 5";
public const string Match5Bonus = "Match 5 plus Bonus";
public const string Match6 = "Match 6";
public const string Total = "Totals";
public const string Winners = "Winners";
public const string PrizePerWinner = "Prize Per Winner";
public const string PrizeFundAmount = "Prize Fund Amount";
public const string BallSetUsed = "ballSetUsed";
public const string BallsDrawn= "ballsDrawn";
}
}
}

View File

@@ -21,7 +21,7 @@ namespace lottery_co_uk_scraper
foreach (string extractedUrl in extractedUrls)
{
await Lotto.GetLottoNumbers(extractedUrl, client);
//await Lotto.GetLottoNumbers(extractedUrl, client);
}
}
}

View File

@@ -9,8 +9,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.11.58" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.1">
<PackageReference Include="HtmlAgilityPack" Version="1.11.59" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
@@ -21,4 +21,11 @@
<ProjectReference Include="..\lottery-co-uk-scraper.data\lottery-co-uk-scraper.data.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="EuroMillions\" />
<Folder Include="NationalLottery\" />
<Folder Include="SetForLife\" />
<Folder Include="Thunderball\" />
</ItemGroup>
</Project>