Aggiornamento dipendenze e passaggio a Newtonsoft.Json

- Aggiornamento alla versione 5.0.0-preview.25503.2 di Microsoft.ML.
- Aggiornamento alla versione 33.1.0 di CsvHelper.
- Aggiornamento alla versione 13.0.4 di Newtonsoft.Json.
- Aggiornamento alla versione 112.1.1-alpha.0.4 di RestSharp.
- Sostituzione di System.Text.Json con Newtonsoft.Json.
- Modifiche nei metodi per utilizzare JToken e JObject.
- Aggiornamento dei file .csproj e packages.config.
- Miglioramenti nella gestione delle eccezioni e nei log.
- Rimozione di riferimenti inutilizzati e miglioramenti generali.
This commit is contained in:
Alberto Balbo
2025-10-08 17:55:48 +02:00
parent f767fe6e35
commit 2236c19c07
17 changed files with 247 additions and 260 deletions

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.ML.FastTree.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.FastTree.props" Condition="Exists('..\packages\Microsoft.ML.FastTree.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.FastTree.props')" /> <Import Project="..\packages\Microsoft.ML.FastTree.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.FastTree.props" Condition="Exists('..\packages\Microsoft.ML.FastTree.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.FastTree.props')" />
<Import Project="..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.props" Condition="Exists('..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.props')" /> <Import Project="..\packages\Microsoft.ML.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.props" Condition="Exists('..\packages\Microsoft.ML.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.props')" />
<Import Project="..\packages\Microsoft.ML.CpuMath.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.CpuMath.props" Condition="Exists('..\packages\Microsoft.ML.CpuMath.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.CpuMath.props')" /> <Import Project="..\packages\Microsoft.ML.CpuMath.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.CpuMath.props" Condition="Exists('..\packages\Microsoft.ML.CpuMath.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.CpuMath.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -59,49 +59,50 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="CsvHelper, Version=33.0.0.0, Culture=neutral, PublicKeyToken=8c4959082be5c823, processorArchitecture=MSIL"> <Reference Include="CsvHelper, Version=33.0.0.0, Culture=neutral, PublicKeyToken=8c4959082be5c823, processorArchitecture=MSIL">
<HintPath>..\packages\CsvHelper.33.0.1\lib\net48\CsvHelper.dll</HintPath> <HintPath>..\packages\CsvHelper.33.1.0\lib\net48\CsvHelper.dll</HintPath>
<Private>True</Private>
</Reference> </Reference>
<Reference Include="Dapper, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Dapper, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Dapper.2.1.66\lib\net461\Dapper.dll</HintPath> <HintPath>..\packages\Dapper.2.1.66\lib\net461\Dapper.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.10.0.0-preview.4.25258.110\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath> <HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.10.0.0-rc.1.25451.107\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.Bcl.HashCode, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="Microsoft.Bcl.HashCode, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.HashCode.6.0.0\lib\net462\Microsoft.Bcl.HashCode.dll</HintPath> <HintPath>..\packages\Microsoft.Bcl.HashCode.6.0.0\lib\net462\Microsoft.Bcl.HashCode.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.Bcl.Numerics, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="Microsoft.Bcl.Numerics, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Numerics.10.0.0-preview.4.25258.110\lib\net462\Microsoft.Bcl.Numerics.dll</HintPath> <HintPath>..\packages\Microsoft.Bcl.Numerics.10.0.0-rc.1.25451.107\lib\net462\Microsoft.Bcl.Numerics.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.ML.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="Microsoft.ML.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\lib\netstandard2.0\Microsoft.ML.Core.dll</HintPath> <HintPath>..\packages\Microsoft.ML.5.0.0-preview.25503.2\lib\netstandard2.0\Microsoft.ML.Core.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.ML.CpuMath, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="Microsoft.ML.CpuMath, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ML.CpuMath.5.0.0-preview.1.25127.4\lib\netstandard2.0\Microsoft.ML.CpuMath.dll</HintPath> <HintPath>..\packages\Microsoft.ML.CpuMath.5.0.0-preview.25503.2\lib\netstandard2.0\Microsoft.ML.CpuMath.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.ML.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="Microsoft.ML.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\lib\netstandard2.0\Microsoft.ML.Data.dll</HintPath> <HintPath>..\packages\Microsoft.ML.5.0.0-preview.25503.2\lib\netstandard2.0\Microsoft.ML.Data.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.ML.DataView, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="Microsoft.ML.DataView, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ML.DataView.5.0.0-preview.1.25127.4\lib\netstandard2.0\Microsoft.ML.DataView.dll</HintPath> <HintPath>..\packages\Microsoft.ML.DataView.5.0.0-preview.25503.2\lib\netstandard2.0\Microsoft.ML.DataView.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.ML.FastTree, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="Microsoft.ML.FastTree, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ML.FastTree.5.0.0-preview.1.25127.4\lib\netstandard2.0\Microsoft.ML.FastTree.dll</HintPath> <HintPath>..\packages\Microsoft.ML.FastTree.5.0.0-preview.25503.2\lib\netstandard2.0\Microsoft.ML.FastTree.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.ML.KMeansClustering, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="Microsoft.ML.KMeansClustering, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\lib\netstandard2.0\Microsoft.ML.KMeansClustering.dll</HintPath> <HintPath>..\packages\Microsoft.ML.5.0.0-preview.25503.2\lib\netstandard2.0\Microsoft.ML.KMeansClustering.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.ML.PCA, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="Microsoft.ML.PCA, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\lib\netstandard2.0\Microsoft.ML.PCA.dll</HintPath> <HintPath>..\packages\Microsoft.ML.5.0.0-preview.25503.2\lib\netstandard2.0\Microsoft.ML.PCA.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.ML.StandardTrainers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="Microsoft.ML.StandardTrainers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\lib\netstandard2.0\Microsoft.ML.StandardTrainers.dll</HintPath> <HintPath>..\packages\Microsoft.ML.5.0.0-preview.25503.2\lib\netstandard2.0\Microsoft.ML.StandardTrainers.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.ML.Transforms, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="Microsoft.ML.Transforms, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\lib\netstandard2.0\Microsoft.ML.Transforms.dll</HintPath> <HintPath>..\packages\Microsoft.ML.5.0.0-preview.25503.2\lib\netstandard2.0\Microsoft.ML.Transforms.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.13.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference> </Reference>
<Reference Include="RestSharp, Version=112.1.1.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL"> <Reference Include="RestSharp, Version=112.1.1.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.112.1.1-alpha.0.4\lib\net48\RestSharp.dll</HintPath> <HintPath>..\packages\RestSharp.112.1.1-alpha.0.4\lib\net48\RestSharp.dll</HintPath>
@@ -111,21 +112,21 @@
<HintPath>..\packages\System.Buffers.4.6.1\lib\net462\System.Buffers.dll</HintPath> <HintPath>..\packages\System.Buffers.4.6.1\lib\net462\System.Buffers.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.CodeDom, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="System.CodeDom, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.CodeDom.10.0.0-preview.4.25258.110\lib\net462\System.CodeDom.dll</HintPath> <HintPath>..\packages\System.CodeDom.10.0.0-rc.1.25451.107\lib\net462\System.CodeDom.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Collections.Immutable, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Reference Include="System.Collections.Immutable, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Collections.Immutable.10.0.0-preview.4.25258.110\lib\net462\System.Collections.Immutable.dll</HintPath> <HintPath>..\packages\System.Collections.Immutable.10.0.0-rc.1.25451.107\lib\net462\System.Collections.Immutable.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.IO.Pipelines, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="System.IO.Pipelines, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Pipelines.10.0.0-preview.2.25163.2\lib\net462\System.IO.Pipelines.dll</HintPath> <HintPath>..\packages\System.IO.Pipelines.10.0.0-rc.1.25451.107\lib\net462\System.IO.Pipelines.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Memory, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="System.Memory, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.6.3\lib\net462\System.Memory.dll</HintPath> <HintPath>..\packages\System.Memory.4.6.3\lib\net462\System.Memory.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Numerics" /> <Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Tensors, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="System.Numerics.Tensors, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Tensors.10.0.0-preview.4.25258.110\lib\net462\System.Numerics.Tensors.dll</HintPath> <HintPath>..\packages\System.Numerics.Tensors.10.0.0-rc.1.25451.107\lib\net462\System.Numerics.Tensors.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Numerics.Vectors, Version=4.1.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Reference Include="System.Numerics.Vectors, Version=4.1.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.6.1\lib\net462\System.Numerics.Vectors.dll</HintPath> <HintPath>..\packages\System.Numerics.Vectors.4.6.1\lib\net462\System.Numerics.Vectors.dll</HintPath>
@@ -134,13 +135,13 @@
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.1.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll</HintPath> <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.1.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Text.Encodings.Web, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="System.Text.Encodings.Web, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encodings.Web.10.0.0-preview.2.25163.2\lib\net462\System.Text.Encodings.Web.dll</HintPath> <HintPath>..\packages\System.Text.Encodings.Web.10.0.0-rc.1.25451.107\lib\net462\System.Text.Encodings.Web.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Text.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="System.Text.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.10.0.0-preview.2.25163.2\lib\net462\System.Text.Json.dll</HintPath> <HintPath>..\packages\System.Text.Json.10.0.0-rc.1.25451.107\lib\net462\System.Text.Json.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Threading.Channels, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="System.Threading.Channels, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Channels.10.0.0-preview.4.25258.110\lib\net462\System.Threading.Channels.dll</HintPath> <HintPath>..\packages\System.Threading.Channels.10.0.0-rc.1.25451.107\lib\net462\System.Threading.Channels.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="System.Threading.Tasks.Extensions, Version=4.2.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.6.3\lib\net462\System.Threading.Tasks.Extensions.dll</HintPath> <HintPath>..\packages\System.Threading.Tasks.Extensions.4.6.3\lib\net462\System.Threading.Tasks.Extensions.dll</HintPath>
@@ -240,10 +241,10 @@
<ErrorText>Questo progetto fa riferimento a uno o più pacchetti NuGet che non sono presenti in questo computer. Usare lo strumento di ripristino dei pacchetti NuGet per scaricarli. Per altre informazioni, vedere http://go.microsoft.com/fwlink/?LinkID=322105. Il file mancante è {0}.</ErrorText> <ErrorText>Questo progetto fa riferimento a uno o più pacchetti NuGet che non sono presenti in questo computer. Usare lo strumento di ripristino dei pacchetti NuGet per scaricarli. Per altre informazioni, vedere http://go.microsoft.com/fwlink/?LinkID=322105. Il file mancante è {0}.</ErrorText>
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('..\packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets'))" /> <Error Condition="!Exists('..\packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.ML.CpuMath.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.CpuMath.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.ML.CpuMath.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.CpuMath.props'))" /> <Error Condition="!Exists('..\packages\Microsoft.ML.CpuMath.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.CpuMath.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.ML.CpuMath.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.CpuMath.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.props'))" /> <Error Condition="!Exists('..\packages\Microsoft.ML.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.ML.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.targets'))" /> <Error Condition="!Exists('..\packages\Microsoft.ML.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.ML.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.ML.FastTree.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.FastTree.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.ML.FastTree.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.FastTree.props'))" /> <Error Condition="!Exists('..\packages\Microsoft.ML.FastTree.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.FastTree.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.ML.FastTree.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.FastTree.props'))" />
</Target> </Target>
<Import Project="..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.targets" Condition="Exists('..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.targets')" /> <Import Project="..\packages\Microsoft.ML.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.targets" Condition="Exists('..\packages\Microsoft.ML.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.targets')" />
</Project> </Project>

View File

@@ -1,20 +1,16 @@
using System; using System;
using System.Collections.Generic;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Linq; using Newtonsoft.Json.Linq;
using System.Text;
using System.Text.Json.Nodes;
using System.Threading.Tasks;
namespace HorseRacingPredictor.Football.Database namespace HorseRacingPredictor.Football.Database
{ {
internal class BetType : HorseRacingPredictor.Football.Manager.Database internal class BetType : HorseRacingPredictor.Football.Manager.Database
{ {
public void Upsert(SqlConnection connection, JsonNode betType) public void Upsert(SqlConnection connection, JToken betType)
{ {
try try
{ {
var id = betType["id"]?.GetValue<int>(); var id = betType["id"]?.Value<int>();
if (id == null) return; // Salta il record se l'id è null if (id == null) return; // Salta il record se l'id è null
var query = @" var query = @"
@@ -29,7 +25,7 @@ namespace HorseRacingPredictor.Football.Database
using (var command = new SqlCommand(query, connection)) using (var command = new SqlCommand(query, connection))
{ {
command.Parameters.AddWithValue("@bet_type_id", id); command.Parameters.AddWithValue("@bet_type_id", id);
command.Parameters.AddWithValue("@name", betType["name"]?.GetValue<string>() ?? ""); command.Parameters.AddWithValue("@name", betType["name"]?.Value<string>() ?? "");
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }
} }

View File

@@ -1,20 +1,16 @@
using System; using System;
using System.Collections.Generic;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Linq; using Newtonsoft.Json.Linq;
using System.Text;
using System.Text.Json.Nodes;
using System.Threading.Tasks;
namespace HorseRacingPredictor.Football.Database namespace HorseRacingPredictor.Football.Database
{ {
internal class Bookmaker : HorseRacingPredictor.Football.Manager.Database internal class Bookmaker : HorseRacingPredictor.Football.Manager.Database
{ {
public void Upsert(SqlConnection connection, JsonNode bookmaker) public void Upsert(SqlConnection connection, JToken bookmaker)
{ {
try try
{ {
var id = bookmaker["id"]?.GetValue<int>(); var id = bookmaker["id"]?.Value<int>();
if (id == null) return; // Salta il record se l'id è null if (id == null) return; // Salta il record se l'id è null
var query = @" var query = @"
@@ -29,7 +25,7 @@ namespace HorseRacingPredictor.Football.Database
using (var command = new SqlCommand(query, connection)) using (var command = new SqlCommand(query, connection))
{ {
command.Parameters.AddWithValue("@bookmaker_id", id); command.Parameters.AddWithValue("@bookmaker_id", id);
command.Parameters.AddWithValue("@name", bookmaker["name"]?.GetValue<string>() ?? ""); command.Parameters.AddWithValue("@name", bookmaker["name"]?.Value<string>() ?? "");
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }
} }

View File

@@ -1,16 +1,12 @@
using System; using System;
using System.Collections.Generic;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Linq; using Newtonsoft.Json.Linq;
using System.Text;
using System.Text.Json.Nodes;
using System.Threading.Tasks;
namespace HorseRacingPredictor.Football.Database namespace HorseRacingPredictor.Football.Database
{ {
internal class Comparison : HorseRacingPredictor.Football.Manager.Database internal class Comparison : HorseRacingPredictor.Football.Manager.Database
{ {
public void Upsert(SqlConnection connection, int predictionId, JsonNode comparison) public void Upsert(SqlConnection connection, int predictionId, JToken comparison)
{ {
try try
{ {
@@ -56,20 +52,20 @@ namespace HorseRacingPredictor.Football.Database
command.Parameters.AddWithValue("@prediction_id", predictionId); command.Parameters.AddWithValue("@prediction_id", predictionId);
// Aggiungi tutti i parametri del confronto // Aggiungi tutti i parametri del confronto
command.Parameters.AddWithValue("@form_home", comparison["form"]?["home"]?.GetValue<string>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@form_home", comparison["form"]?["home"]?.Value<string>() ?? (object)DBNull.Value);
command.Parameters.AddWithValue("@form_away", comparison["form"]?["away"]?.GetValue<string>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@form_away", comparison["form"]?["away"]?.Value<string>() ?? (object)DBNull.Value);
command.Parameters.AddWithValue("@att_home", comparison["att"]?["home"]?.GetValue<string>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@att_home", comparison["att"]?["home"]?.Value<string>() ?? (object)DBNull.Value);
command.Parameters.AddWithValue("@att_away", comparison["att"]?["away"]?.GetValue<string>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@att_away", comparison["att"]?["away"]?.Value<string>() ?? (object)DBNull.Value);
command.Parameters.AddWithValue("@def_home", comparison["def"]?["home"]?.GetValue<string>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@def_home", comparison["def"]?["home"]?.Value<string>() ?? (object)DBNull.Value);
command.Parameters.AddWithValue("@def_away", comparison["def"]?["away"]?.GetValue<string>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@def_away", comparison["def"]?["away"]?.Value<string>() ?? (object)DBNull.Value);
command.Parameters.AddWithValue("@poisson_home", comparison["poisson_distribution"]?["home"]?.GetValue<string>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@poisson_home", comparison["poisson_distribution"]?["home"]?.Value<string>() ?? (object)DBNull.Value);
command.Parameters.AddWithValue("@poisson_away", comparison["poisson_distribution"]?["away"]?.GetValue<string>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@poisson_away", comparison["poisson_distribution"]?["away"]?.Value<string>() ?? (object)DBNull.Value);
command.Parameters.AddWithValue("@h2h_home", comparison["h2h"]?["home"]?.GetValue<string>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@h2h_home", comparison["h2h"]?["home"]?.Value<string>() ?? (object)DBNull.Value);
command.Parameters.AddWithValue("@h2h_away", comparison["h2h"]?["away"]?.GetValue<string>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@h2h_away", comparison["h2h"]?["away"]?.Value<string>() ?? (object)DBNull.Value);
command.Parameters.AddWithValue("@goals_home", comparison["goals"]?["home"]?.GetValue<string>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@goals_home", comparison["goals"]?["home"]?.Value<string>() ?? (object)DBNull.Value);
command.Parameters.AddWithValue("@goals_away", comparison["goals"]?["away"]?.GetValue<string>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@goals_away", comparison["goals"]?["away"]?.Value<string>() ?? (object)DBNull.Value);
command.Parameters.AddWithValue("@total_home", comparison["total"]?["home"]?.GetValue<string>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@total_home", comparison["total"]?["home"]?.Value<string>() ?? (object)DBNull.Value);
command.Parameters.AddWithValue("@total_away", comparison["total"]?["away"]?.GetValue<string>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@total_away", comparison["total"]?["away"]?.Value<string>() ?? (object)DBNull.Value);
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }

View File

@@ -1,17 +1,17 @@
using System; using System;
using System.Data; using System.Data;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Text.Json.Nodes; using Newtonsoft.Json.Linq;
namespace HorseRacingPredictor.Football.Database namespace HorseRacingPredictor.Football.Database
{ {
internal class Fixture : HorseRacingPredictor.Football.Manager.Database internal class Fixture : HorseRacingPredictor.Football.Manager.Database
{ {
public void Upsert(SqlConnection connection, SqlTransaction transaction, JsonNode fixture) public void Upsert(SqlConnection connection, SqlTransaction transaction, JToken fixture)
{ {
try try
{ {
var id = fixture["id"]?.GetValue<int>(); var id = fixture["id"]?.Value<int>();
if (id == null) return; // Salta il record se l'id è null if (id == null) return; // Salta il record se l'id è null
var query = @" var query = @"
@@ -63,20 +63,20 @@ namespace HorseRacingPredictor.Football.Database
// Parametri principali // Parametri principali
command.Parameters.AddWithValue("@fixture_id", id); command.Parameters.AddWithValue("@fixture_id", id);
command.Parameters.AddWithValue("@timezone", fixture["timezone"]?.GetValue<string>() ?? ""); command.Parameters.AddWithValue("@timezone", fixture["timezone"]?.Value<string>() ?? "");
command.Parameters.AddWithValue("@date", fixture["date"]?.GetValue<DateTime>() ?? DateTime.MinValue); command.Parameters.AddWithValue("@date", fixture["date"]?.Value<DateTime>() ?? DateTime.MinValue);
command.Parameters.AddWithValue("@timestamp", fixture["timestamp"]?.GetValue<long>() ?? 0L); command.Parameters.AddWithValue("@timestamp", fixture["timestamp"]?.Value<long>() ?? 0L);
command.Parameters.AddWithValue("@referee", fixture["referee"]?.GetValue<string>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@referee", fixture["referee"]?.Value<string>() ?? (object)DBNull.Value);
// Parametri venue // Parametri venue
int? venueId = venue?["id"]?.GetValue<int?>(); int? venueId = venue?["id"]?.Value<int?>();
command.Parameters.AddWithValue("@venue_id", venueId.HasValue ? (object)venueId.Value : DBNull.Value); command.Parameters.AddWithValue("@venue_id", venueId.HasValue ? (object)venueId.Value : DBNull.Value);
// Parametri status // Parametri status
command.Parameters.AddWithValue("@status_long", status?["long"]?.GetValue<string>() ?? ""); command.Parameters.AddWithValue("@status_long", status?["long"]?.Value<string>() ?? "");
command.Parameters.AddWithValue("@status_short", status?["short"]?.GetValue<string>() ?? ""); command.Parameters.AddWithValue("@status_short", status?["short"]?.Value<string>() ?? "");
int? elapsed = status?["elapsed"]?.GetValue<int?>(); int? elapsed = status?["elapsed"]?.Value<int?>();
int? extra = null; // Assumo che l'API restituisca questo valore, altrimenti va gestito come gli altri int? extra = null; // Assumo che l'API restituisca questo valore, altrimenti va gestito come gli altri
command.Parameters.AddWithValue("@status_elapsed", elapsed.HasValue ? (object)elapsed.Value : DBNull.Value); command.Parameters.AddWithValue("@status_elapsed", elapsed.HasValue ? (object)elapsed.Value : DBNull.Value);
@@ -101,11 +101,11 @@ namespace HorseRacingPredictor.Football.Database
/// <summary> /// <summary>
/// Metodo di supporto per inserire/aggiornare le informazioni sulla venue /// Metodo di supporto per inserire/aggiornare le informazioni sulla venue
/// </summary> /// </summary>
private void UpsertVenue(SqlConnection connection, SqlTransaction transaction, JsonNode venue) private void UpsertVenue(SqlConnection connection, SqlTransaction transaction, JToken venue)
{ {
try try
{ {
var id = venue["id"]?.GetValue<int>(); var id = venue["id"]?.Value<int>();
if (id == null) return; if (id == null) return;
var query = @" var query = @"
@@ -121,8 +121,8 @@ namespace HorseRacingPredictor.Football.Database
using (var command = new SqlCommand(query, connection, transaction)) using (var command = new SqlCommand(query, connection, transaction))
{ {
command.Parameters.AddWithValue("@venue_id", id); command.Parameters.AddWithValue("@venue_id", id);
command.Parameters.AddWithValue("@name", venue["name"]?.GetValue<string>() ?? ""); command.Parameters.AddWithValue("@name", venue["name"]?.Value<string>() ?? "");
command.Parameters.AddWithValue("@city", venue["city"]?.GetValue<string>() ?? ""); command.Parameters.AddWithValue("@city", venue["city"]?.Value<string>() ?? "");
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }
} }

View File

@@ -3,20 +3,20 @@ using System.Collections.Generic;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.Json.Nodes; using Newtonsoft.Json.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace HorseRacingPredictor.Football.Database namespace HorseRacingPredictor.Football.Database
{ {
internal class FixtureLeague : HorseRacingPredictor.Football.Manager.Database internal class FixtureLeague : HorseRacingPredictor.Football.Manager.Database
{ {
public void Upsert(SqlConnection connection, SqlTransaction transaction, int fixtureId, int leagueId, JsonNode leagueData) public void Upsert(SqlConnection connection, SqlTransaction transaction, int fixtureId, int leagueId, JToken leagueData)
{ {
try try
{ {
// Estrai i valori prima della query per utilizzarli nel log // Estrai i valori prima della query per utilizzarli nel log
string round = leagueData["round"]?.GetValue<string>() ?? ""; string round = leagueData["round"]?.Value<string>() ?? "";
bool? standings = leagueData["standings"]?.GetValue<bool?>(); bool? standings = leagueData["standings"]?.Value<bool?>();
string standingsValue = standings.HasValue ? standings.Value.ToString() : "NULL"; string standingsValue = standings.HasValue ? standings.Value.ToString() : "NULL";
// Log dell'operazione prima di tentare l'upsert // Log dell'operazione prima di tentare l'upsert

View File

@@ -1,12 +1,12 @@
using System; using System;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Text.Json.Nodes; using Newtonsoft.Json.Linq;
namespace HorseRacingPredictor.Football.Database namespace HorseRacingPredictor.Football.Database
{ {
internal class Goals : HorseRacingPredictor.Football.Manager.Database internal class Goals : HorseRacingPredictor.Football.Manager.Database
{ {
public void Upsert(SqlConnection connection, JsonNode goals, int fixtureId) public void Upsert(SqlConnection connection, JToken goals, int fixtureId)
{ {
try try
{ {
@@ -27,8 +27,8 @@ namespace HorseRacingPredictor.Football.Database
END"; END";
using (var command = new SqlCommand(query, connection)) using (var command = new SqlCommand(query, connection))
{ {
command.Parameters.AddWithValue("@home", goals["home"]?.GetValue<int?>() ?? 0); command.Parameters.AddWithValue("@home", goals["home"]?.Value<int?>() ?? 0);
command.Parameters.AddWithValue("@away", goals["away"]?.GetValue<int?>() ?? 0); command.Parameters.AddWithValue("@away", goals["away"]?.Value<int?>() ?? 0);
command.Parameters.AddWithValue("@fixture_id", fixtureId); command.Parameters.AddWithValue("@fixture_id", fixtureId);
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }

View File

@@ -1,16 +1,16 @@
using System; using System;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Text.Json.Nodes; using Newtonsoft.Json.Linq;
namespace HorseRacingPredictor.Football.Database namespace HorseRacingPredictor.Football.Database
{ {
internal class League : HorseRacingPredictor.Football.Manager.Database internal class League : HorseRacingPredictor.Football.Manager.Database
{ {
public void Upsert(SqlConnection connection, JsonNode league) public void Upsert(SqlConnection connection, JToken league)
{ {
try try
{ {
var id = league["id"]?.GetValue<int>(); var id = league["id"]?.Value<int>();
if (id == null) return; // Salta il record se l'id è null if (id == null) return; // Salta il record se l'id è null
var query = @" var query = @"
@@ -25,11 +25,11 @@ namespace HorseRacingPredictor.Football.Database
using (var command = new SqlCommand(query, connection)) using (var command = new SqlCommand(query, connection))
{ {
command.Parameters.AddWithValue("@league_id", id); command.Parameters.AddWithValue("@league_id", id);
command.Parameters.AddWithValue("@name", league["name"]?.GetValue<string>() ?? ""); command.Parameters.AddWithValue("@name", league["name"]?.Value<string>() ?? "");
command.Parameters.AddWithValue("@country", league["country"]?.GetValue<string>() ?? ""); command.Parameters.AddWithValue("@country", league["country"]?.Value<string>() ?? "");
command.Parameters.AddWithValue("@logo", league["logo"]?.GetValue<string>() ?? ""); command.Parameters.AddWithValue("@logo", league["logo"]?.Value<string>() ?? "");
command.Parameters.AddWithValue("@flag", league["flag"]?.GetValue<string>() ?? ""); command.Parameters.AddWithValue("@flag", league["flag"]?.Value<string>() ?? "");
command.Parameters.AddWithValue("@season", league["season"]?.GetValue<int>() ?? 0); command.Parameters.AddWithValue("@season", league["season"]?.Value<int>() ?? 0);
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }
} }
@@ -39,11 +39,11 @@ namespace HorseRacingPredictor.Football.Database
} }
} }
public void Upsert(SqlConnection connection, SqlTransaction transaction, JsonNode league) public void Upsert(SqlConnection connection, SqlTransaction transaction, JToken league)
{ {
try try
{ {
var id = league["id"]?.GetValue<int>(); var id = league["id"]?.Value<int>();
if (id == null) return; // Salta il record se l'id è null if (id == null) return; // Salta il record se l'id è null
var query = @" var query = @"
@@ -58,11 +58,11 @@ namespace HorseRacingPredictor.Football.Database
using (var command = new SqlCommand(query, connection, transaction)) using (var command = new SqlCommand(query, connection, transaction))
{ {
command.Parameters.AddWithValue("@league_id", id); command.Parameters.AddWithValue("@league_id", id);
command.Parameters.AddWithValue("@name", league["name"]?.GetValue<string>() ?? ""); command.Parameters.AddWithValue("@name", league["name"]?.Value<string>() ?? "");
command.Parameters.AddWithValue("@country", league["country"]?.GetValue<string>() ?? ""); command.Parameters.AddWithValue("@country", league["country"]?.Value<string>() ?? "");
command.Parameters.AddWithValue("@logo", league["logo"]?.GetValue<string>() ?? ""); command.Parameters.AddWithValue("@logo", league["logo"]?.Value<string>() ?? "");
command.Parameters.AddWithValue("@flag", league["flag"]?.GetValue<string>() ?? ""); command.Parameters.AddWithValue("@flag", league["flag"]?.Value<string>() ?? "");
command.Parameters.AddWithValue("@season", league["season"]?.GetValue<int>() ?? 0); command.Parameters.AddWithValue("@season", league["season"]?.Value<int>() ?? 0);
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }
} }

View File

@@ -1,12 +1,12 @@
using System; using System;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Text.Json.Nodes; using Newtonsoft.Json.Linq;
namespace HorseRacingPredictor.Football.Database namespace HorseRacingPredictor.Football.Database
{ {
internal class LeagueStats : HorseRacingPredictor.Football.Manager.Database internal class LeagueStats : HorseRacingPredictor.Football.Manager.Database
{ {
public int Insert(SqlConnection connection, int? teamId, int? predictionId, bool isHome, JsonNode stats) public int Insert(SqlConnection connection, int? teamId, int? predictionId, bool isHome, JToken stats)
{ {
try try
{ {
@@ -35,27 +35,27 @@ namespace HorseRacingPredictor.Football.Database
command.Parameters.AddWithValue("@team_id", teamId.HasValue ? (object)teamId.Value : DBNull.Value); command.Parameters.AddWithValue("@team_id", teamId.HasValue ? (object)teamId.Value : DBNull.Value);
command.Parameters.AddWithValue("@prediction_id", predictionId.HasValue ? (object)predictionId.Value : DBNull.Value); command.Parameters.AddWithValue("@prediction_id", predictionId.HasValue ? (object)predictionId.Value : DBNull.Value);
command.Parameters.AddWithValue("@is_home", isHome); command.Parameters.AddWithValue("@is_home", isHome);
command.Parameters.AddWithValue("@form", stats["form"]?.GetValue<string>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@form", stats["form"]?.Value<string>() ?? (object)DBNull.Value);
var fixtures = stats["fixtures"]; var fixtures = stats["fixtures"];
command.Parameters.AddWithValue("@fixtures_played_home", fixtures?["played"]?["home"]?.GetValue<int?>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@fixtures_played_home", fixtures?["played"]?["home"]?.Value<int?>() ?? (object)DBNull.Value);
command.Parameters.AddWithValue("@fixtures_played_away", fixtures?["played"]?["away"]?.GetValue<int?>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@fixtures_played_away", fixtures?["played"]?["away"]?.Value<int?>() ?? (object)DBNull.Value);
command.Parameters.AddWithValue("@fixtures_played_total", fixtures?["played"]?["total"]?.GetValue<int?>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@fixtures_played_total", fixtures?["played"]?["total"]?.Value<int?>() ?? (object)DBNull.Value);
var wins = stats["fixtures"]?["wins"]; var wins = stats["fixtures"]?["wins"];
command.Parameters.AddWithValue("@wins_home", wins?["home"]?.GetValue<int?>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@wins_home", wins?["home"]?.Value<int?>() ?? (object)DBNull.Value);
command.Parameters.AddWithValue("@wins_away", wins?["away"]?.GetValue<int?>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@wins_away", wins?["away"]?.Value<int?>() ?? (object)DBNull.Value);
command.Parameters.AddWithValue("@wins_total", wins?["total"]?.GetValue<int?>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@wins_total", wins?["total"]?.Value<int?>() ?? (object)DBNull.Value);
var draws = stats["fixtures"]?["draws"]; var draws = stats["fixtures"]?["draws"];
command.Parameters.AddWithValue("@draws_home", draws?["home"]?.GetValue<int?>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@draws_home", draws?["home"]?.Value<int?>() ?? (object)DBNull.Value);
command.Parameters.AddWithValue("@draws_away", draws?["away"]?.GetValue<int?>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@draws_away", draws?["away"]?.Value<int?>() ?? (object)DBNull.Value);
command.Parameters.AddWithValue("@draws_total", draws?["total"]?.GetValue<int?>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@draws_total", draws?["total"]?.Value<int?>() ?? (object)DBNull.Value);
var loses = stats["fixtures"]?["loses"]; var loses = stats["fixtures"]?["loses"];
command.Parameters.AddWithValue("@loses_home", loses?["home"]?.GetValue<int?>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@loses_home", loses?["home"]?.Value<int?>() ?? (object)DBNull.Value);
command.Parameters.AddWithValue("@loses_away", loses?["away"]?.GetValue<int?>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@loses_away", loses?["away"]?.Value<int?>() ?? (object)DBNull.Value);
command.Parameters.AddWithValue("@loses_total", loses?["total"]?.GetValue<int?>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@loses_total", loses?["total"]?.Value<int?>() ?? (object)DBNull.Value);
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }

View File

@@ -1,26 +1,27 @@
using System; using System;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Text.Json.Nodes; using System.Linq;
using Newtonsoft.Json.Linq;
namespace HorseRacingPredictor.Football.Database namespace HorseRacingPredictor.Football.Database
{ {
internal class Odds : HorseRacingPredictor.Football.Manager.Database internal class Odds : HorseRacingPredictor.Football.Manager.Database
{ {
public void Upsert(SqlConnection connection, JsonNode bookmakers, int fixtureId) public void Upsert(SqlConnection connection, JToken bookmakers, int fixtureId)
{ {
try try
{ {
// Aggiungiamo log per tracciare la struttura dei dati // Aggiungiamo log per tracciare la struttura dei dati
LogError($"Inizio elaborazione quote per fixture {fixtureId} con {bookmakers?.AsArray().Count ?? 0} bookmakers", null); LogError($"Inizio elaborazione quote per fixture {fixtureId} con {bookmakers?.Children().Count() ?? 0} bookmakers", null);
// Per ogni bookmaker // Per ogni bookmaker
foreach (var bookmaker in bookmakers.AsArray()) foreach (var bookmaker in bookmakers.Children())
{ {
int bookmakerId = bookmaker["id"].GetValue<int>(); int bookmakerId = bookmaker["id"].Value<int>();
var bets = bookmaker["bets"]; var bets = bookmaker["bets"];
// Cerchiamo le quote di tipo Match Winner (1X2) // Cerchiamo le quote di tipo Match Winner (1X2)
foreach (var bet in bets.AsArray()) foreach (var bet in bets.Children())
{ {
// Gestiamo in modo più sicuro il recupero di valori dal JSON // Gestiamo in modo più sicuro il recupero di valori dal JSON
string betName = GetStringValueSafe(bet, "name"); string betName = GetStringValueSafe(bet, "name");
@@ -35,7 +36,7 @@ namespace HorseRacingPredictor.Football.Database
if (betTypeId == 0) continue; if (betTypeId == 0) continue;
// Estrai e salva le quote // Estrai e salva le quote
foreach (var value in bet["values"].AsArray()) foreach (var value in bet["values"].Children())
{ {
// Gestiamo in modo più sicuro il recupero di valori dal JSON // Gestiamo in modo più sicuro il recupero di valori dal JSON
string valueType = GetStringValueSafe(value, "value"); string valueType = GetStringValueSafe(value, "value");
@@ -128,9 +129,9 @@ namespace HorseRacingPredictor.Football.Database
} }
/// <summary> /// <summary>
/// Ottiene un valore stringa da un JsonNode in modo sicuro /// Ottiene un valore stringa da un JToken in modo sicuro
/// </summary> /// </summary>
private string GetStringValueSafe(JsonNode node, string propertyName) private string GetStringValueSafe(JToken node, string propertyName)
{ {
try try
{ {
@@ -140,10 +141,10 @@ namespace HorseRacingPredictor.Football.Database
var value = node[propertyName]; var value = node[propertyName];
// Gestiamo diversi tipi di nodi // Gestiamo diversi tipi di nodi
if (value.GetValueKind() == System.Text.Json.JsonValueKind.String) if (value.Type == JTokenType.String)
return value.GetValue<string>(); return value.Value<string>();
else if (value.GetValueKind() == System.Text.Json.JsonValueKind.Number) else if (value.Type == JTokenType.Float || value.Type == JTokenType.Integer)
return value.GetValue<decimal>().ToString(); return value.Value<decimal>().ToString();
else else
return value.ToString(); return value.ToString();
} }
@@ -155,9 +156,9 @@ namespace HorseRacingPredictor.Football.Database
} }
/// <summary> /// <summary>
/// Ottiene un valore decimale da un JsonNode in modo sicuro /// Ottiene un valore decimale da un JToken in modo sicuro
/// </summary> /// </summary>
private decimal GetDecimalValueSafe(JsonNode node, string propertyName) private decimal GetDecimalValueSafe(JToken node, string propertyName)
{ {
try try
{ {
@@ -167,15 +168,15 @@ namespace HorseRacingPredictor.Football.Database
var value = node[propertyName]; var value = node[propertyName];
// Gestiamo diversi tipi di nodi // Gestiamo diversi tipi di nodi
if (value.GetValueKind() == System.Text.Json.JsonValueKind.Number) if (value.Type == JTokenType.Float || value.Type == JTokenType.Integer)
{ {
// Assicuriamoci che il valore sia esattamente quello originale // Assicuriamoci che il valore sia esattamente quello originale
return value.GetValue<decimal>(); return value.Value<decimal>();
} }
else if (value.GetValueKind() == System.Text.Json.JsonValueKind.String) else if (value.Type == JTokenType.String)
{ {
// Utilizziamo InvariantCulture per garantire una corretta interpretazione dei decimali // Utilizziamo InvariantCulture per garantire una corretta interpretazione dei decimali
if (decimal.TryParse(value.GetValue<string>(), if (decimal.TryParse(value.Value<string>(),
System.Globalization.NumberStyles.Any, System.Globalization.NumberStyles.Any,
System.Globalization.CultureInfo.InvariantCulture, System.Globalization.CultureInfo.InvariantCulture,
out decimal result)) out decimal result))
@@ -185,7 +186,7 @@ namespace HorseRacingPredictor.Football.Database
} }
// Aggiungiamo un log più dettagliato per aiutare il debug // Aggiungiamo un log più dettagliato per aiutare il debug
LogError($"Impossibile convertire '{value}' (tipo: {value.GetValueKind()}) in decimal per proprietà '{propertyName}'", null); LogError($"Impossibile convertire '{value}' (tipo: {value.Type}) in decimal per proprietà '{propertyName}'", null);
return 0; return 0;
} }
catch (Exception ex) catch (Exception ex)

View File

@@ -1,30 +1,30 @@
using System; using System;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Text.Json.Nodes; using Newtonsoft.Json.Linq;
namespace HorseRacingPredictor.Football.Database namespace HorseRacingPredictor.Football.Database
{ {
internal class Prediction : HorseRacingPredictor.Football.Manager.Database internal class Prediction : HorseRacingPredictor.Football.Manager.Database
{ {
public void Upsert(SqlConnection connection, JsonNode predictions, int fixtureId) public void Upsert(SqlConnection connection, JToken predictions, int fixtureId)
{ {
try try
{ {
// Estrazione dei dati dalla risposta JSON // Estrazione dei dati dalla risposta JSON
string advice = predictions["advice"]?.GetValue<string>(); string advice = predictions["advice"]?.Value<string>();
if (string.IsNullOrEmpty(advice)) return; // Nessuna previsione se non c'è consiglio if (string.IsNullOrEmpty(advice)) return; // Nessuna previsione se non c'è consiglio
// Estrazione degli altri valori, con gestione null // Estrazione degli altri valori, con gestione null
int? winnerId = predictions["winner"]?["id"]?.GetValue<int?>(); int? winnerId = predictions["winner"]?["id"]?.Value<int?>();
string winnerName = predictions["winner"]?["name"]?.GetValue<string>(); string winnerName = predictions["winner"]?["name"]?.Value<string>();
string winnerComment = predictions["winner"]?["comment"]?.GetValue<string>(); string winnerComment = predictions["winner"]?["comment"]?.Value<string>();
bool? winOrDraw = predictions["win_or_draw"]?.GetValue<bool?>(); bool? winOrDraw = predictions["win_or_draw"]?.Value<bool?>();
string underOver = predictions["under_over"]?.GetValue<string>(); string underOver = predictions["under_over"]?.Value<string>();
string goalsHome = predictions["goals"]?["home"]?.GetValue<string>(); string goalsHome = predictions["goals"]?["home"]?.Value<string>();
string goalsAway = predictions["goals"]?["away"]?.GetValue<string>(); string goalsAway = predictions["goals"]?["away"]?.Value<string>();
string percentHome = predictions["percent"]?["home"]?.GetValue<string>(); string percentHome = predictions["percent"]?["home"]?.Value<string>();
string percentDraw = predictions["percent"]?["draw"]?.GetValue<string>(); string percentDraw = predictions["percent"]?["draw"]?.Value<string>();
string percentAway = predictions["percent"]?["away"]?.GetValue<string>(); string percentAway = predictions["percent"]?["away"]?.Value<string>();
// Query per l'upsert con tutti i campi disponibili // Query per l'upsert con tutti i campi disponibili
var query = @" var query = @"

View File

@@ -1,12 +1,12 @@
using System; using System;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Text.Json.Nodes; using Newtonsoft.Json.Linq;
namespace HorseRacingPredictor.Football.Database namespace HorseRacingPredictor.Football.Database
{ {
internal class Score : HorseRacingPredictor.Football.Manager.Database internal class Score : HorseRacingPredictor.Football.Manager.Database
{ {
public void Upsert(SqlConnection connection, JsonNode score, int fixtureId) public void Upsert(SqlConnection connection, JToken score, int fixtureId)
{ {
try try
{ {
@@ -26,14 +26,14 @@ namespace HorseRacingPredictor.Football.Database
END"; END";
using (var command = new SqlCommand(query, connection)) using (var command = new SqlCommand(query, connection))
{ {
command.Parameters.AddWithValue("@home_halftime", score["halftime"]["home"]?.GetValue<int?>() ?? 0); command.Parameters.AddWithValue("@home_halftime", score["halftime"]?["home"]?.Value<int?>() ?? 0);
command.Parameters.AddWithValue("@away_halftime", score["halftime"]["away"]?.GetValue<int?>() ?? 0); command.Parameters.AddWithValue("@away_halftime", score["halftime"]?["away"]?.Value<int?>() ?? 0);
command.Parameters.AddWithValue("@home_fulltime", score["fulltime"]["home"]?.GetValue<int?>() ?? 0); command.Parameters.AddWithValue("@home_fulltime", score["fulltime"]?["home"]?.Value<int?>() ?? 0);
command.Parameters.AddWithValue("@away_fulltime", score["fulltime"]["away"]?.GetValue<int?>() ?? 0); command.Parameters.AddWithValue("@away_fulltime", score["fulltime"]?["away"]?.Value<int?>() ?? 0);
command.Parameters.AddWithValue("@home_extratime", score["extratime"]["home"]?.GetValue<int?>() ?? 0); command.Parameters.AddWithValue("@home_extratime", score["extratime"]?["home"]?.Value<int?>() ?? 0);
command.Parameters.AddWithValue("@away_extratime", score["extratime"]["away"]?.GetValue<int?>() ?? 0); command.Parameters.AddWithValue("@away_extratime", score["extratime"]?["away"]?.Value<int?>() ?? 0);
command.Parameters.AddWithValue("@home_penalty", score["penalty"]["home"]?.GetValue<int?>() ?? 0); command.Parameters.AddWithValue("@home_penalty", score["penalty"]?["home"]?.Value<int?>() ?? 0);
command.Parameters.AddWithValue("@away_penalty", score["penalty"]["away"]?.GetValue<int?>() ?? 0); command.Parameters.AddWithValue("@away_penalty", score["penalty"]?["away"]?.Value<int?>() ?? 0);
command.Parameters.AddWithValue("@fixture_id", fixtureId); command.Parameters.AddWithValue("@fixture_id", fixtureId);
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }

View File

@@ -1,17 +1,17 @@
using System; using System;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Text.Json.Nodes; using Newtonsoft.Json.Linq;
namespace HorseRacingPredictor.Football.Database namespace HorseRacingPredictor.Football.Database
{ {
internal class Team : HorseRacingPredictor.Football.Manager.Database internal class Team : HorseRacingPredictor.Football.Manager.Database
{ {
public void UpsertTeams(SqlConnection connection, SqlTransaction transaction, JsonNode teams, int fixtureId) public void UpsertTeams(SqlConnection connection, SqlTransaction transaction, JToken teams, int fixtureId)
{ {
try try
{ {
var homeTeamId = teams["home"]["id"]?.GetValue<int>(); var homeTeamId = teams["home"]["id"]?.Value<int>();
var awayTeamId = teams["away"]["id"]?.GetValue<int>(); var awayTeamId = teams["away"]["id"]?.Value<int>();
if (homeTeamId == null || awayTeamId == null) return; // Salta il record se uno degli id è null if (homeTeamId == null || awayTeamId == null) return; // Salta il record se uno degli id è null
var queryTeam = @" var queryTeam = @"
@@ -31,14 +31,14 @@ namespace HorseRacingPredictor.Football.Database
// Upsert home team // Upsert home team
command.Parameters.AddWithValue("@team_id", homeTeamId); command.Parameters.AddWithValue("@team_id", homeTeamId);
command.Parameters.AddWithValue("@name", homeTeam["name"]?.GetValue<string>() ?? ""); command.Parameters.AddWithValue("@name", homeTeam["name"]?.Value<string>() ?? "");
command.Parameters.AddWithValue("@logo", homeTeam["logo"]?.GetValue<string>() ?? ""); command.Parameters.AddWithValue("@logo", homeTeam["logo"]?.Value<string>() ?? "");
command.ExecuteNonQuery(); command.ExecuteNonQuery();
// Upsert away team // Upsert away team
command.Parameters["@team_id"].Value = awayTeamId; command.Parameters["@team_id"].Value = awayTeamId;
command.Parameters["@name"].Value = awayTeam["name"]?.GetValue<string>() ?? ""; command.Parameters["@name"].Value = awayTeam["name"]?.Value<string>() ?? "";
command.Parameters["@logo"].Value = awayTeam["logo"]?.GetValue<string>() ?? ""; command.Parameters["@logo"].Value = awayTeam["logo"]?.Value<string>() ?? "";
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }

View File

@@ -1,16 +1,12 @@
using System; using System;
using System.Collections.Generic;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Linq; using Newtonsoft.Json.Linq;
using System.Text;
using System.Text.Json.Nodes;
using System.Threading.Tasks;
namespace HorseRacingPredictor.Football.Database namespace HorseRacingPredictor.Football.Database
{ {
internal class TeamStats : HorseRacingPredictor.Football.Manager.Database internal class TeamStats : HorseRacingPredictor.Football.Manager.Database
{ {
public int Insert(SqlConnection connection, int? teamId, int? predictionId, bool isHome, JsonNode stats) public int Insert(SqlConnection connection, int? teamId, int? predictionId, bool isHome, JToken stats)
{ {
try try
{ {
@@ -35,18 +31,18 @@ namespace HorseRacingPredictor.Football.Database
command.Parameters.AddWithValue("@team_id", teamId.HasValue ? (object)teamId.Value : DBNull.Value); command.Parameters.AddWithValue("@team_id", teamId.HasValue ? (object)teamId.Value : DBNull.Value);
command.Parameters.AddWithValue("@prediction_id", predictionId.HasValue ? (object)predictionId.Value : DBNull.Value); command.Parameters.AddWithValue("@prediction_id", predictionId.HasValue ? (object)predictionId.Value : DBNull.Value);
command.Parameters.AddWithValue("@is_home", isHome); command.Parameters.AddWithValue("@is_home", isHome);
command.Parameters.AddWithValue("@played", stats["played"]?.GetValue<int?>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@played", stats["played"]?.Value<int?>() ?? (object)DBNull.Value);
command.Parameters.AddWithValue("@form", stats["form"]?.GetValue<string>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@form", stats["form"]?.Value<string>() ?? (object)DBNull.Value);
command.Parameters.AddWithValue("@att", stats["att"]?.GetValue<string>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@att", stats["att"]?.Value<string>() ?? (object)DBNull.Value);
command.Parameters.AddWithValue("@def", stats["def"]?.GetValue<string>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@def", stats["def"]?.Value<string>() ?? (object)DBNull.Value);
var goalsFor = stats["goals"]?["for"]; var goalsFor = stats["goals"]?["for"];
command.Parameters.AddWithValue("@goals_for_total", goalsFor?["total"]?.GetValue<int?>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@goals_for_total", goalsFor?["total"]?.Value<int?>() ?? (object)DBNull.Value);
command.Parameters.AddWithValue("@goals_for_average", goalsFor?["average"]?.GetValue<string>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@goals_for_average", goalsFor?["average"]?.Value<string>() ?? (object)DBNull.Value);
var goalsAgainst = stats["goals"]?["against"]; var goalsAgainst = stats["goals"]?["against"];
command.Parameters.AddWithValue("@goals_against_total", goalsAgainst?["total"]?.GetValue<int?>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@goals_against_total", goalsAgainst?["total"]?.Value<int?>() ?? (object)DBNull.Value);
command.Parameters.AddWithValue("@goals_against_average", goalsAgainst?["average"]?.GetValue<string>() ?? (object)DBNull.Value); command.Parameters.AddWithValue("@goals_against_average", goalsAgainst?["average"]?.Value<string>() ?? (object)DBNull.Value);
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }

View File

@@ -2,12 +2,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using RestSharp;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Data.SqlClient; using System.Data.SqlClient;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using RestSharp;
namespace HorseRacingPredictor.Football namespace HorseRacingPredictor.Football
{ {
@@ -156,20 +155,20 @@ namespace HorseRacingPredictor.Football
return; return;
} }
var json = JsonDocument.Parse(fixturesResponse.Content).RootElement; var json = JObject.Parse(fixturesResponse.Content);
// Verifica che la risposta contenga dati validi // Verifica che la risposta contenga dati validi
if (!json.TryGetProperty("response", out var responseElement)) if (json["response"] == null)
{ {
return; return;
} }
// Per ogni partita, recupera la previsione // Per ogni partita, recupera la previsione
foreach (var item in responseElement.EnumerateArray()) foreach (var item in json["response"])
{ {
try try
{ {
int fixtureId = item.GetProperty("fixture").GetProperty("id").GetInt32(); int fixtureId = item["fixture"]["id"].Value<int>();
// Utilizza il prediction manager per ottenere la previsione // Utilizza il prediction manager per ottenere la previsione
_predictionManager.GetPredictionByFixture(fixtureId); _predictionManager.GetPredictionByFixture(fixtureId);
@@ -255,11 +254,10 @@ namespace HorseRacingPredictor.Football
responses.Add(response); responses.Add(response);
// Controlla se ci sono altre pagine // Controlla se ci sono altre pagine
var json = JsonDocument.Parse(response.Content).RootElement; var json = JObject.Parse(response.Content);
if (json.TryGetProperty("paging", out var pagingElement) && if (json["paging"] != null && json["paging"]["total"] != null)
pagingElement.TryGetProperty("total", out var totalElement))
{ {
int totalPages = totalElement.GetInt32(); int totalPages = json["paging"]["total"].Value<int>();
hasMorePages = currentPage < totalPages; hasMorePages = currentPage < totalPages;
} }
else else
@@ -281,7 +279,7 @@ namespace HorseRacingPredictor.Football
{ {
try try
{ {
var jsonObject = JsonNode.Parse(jsonResponse); var jsonObject = JObject.Parse(jsonResponse);
_database.ExecuteTransactionalQuery("l'elaborazione dei dati calcistici", (connection, transaction) => _database.ExecuteTransactionalQuery("l'elaborazione dei dati calcistici", (connection, transaction) =>
{ {
@@ -291,7 +289,7 @@ namespace HorseRacingPredictor.Football
((Manager.Database)_database).DisableAllConstraints(connection, transaction); ((Manager.Database)_database).DisableAllConstraints(connection, transaction);
// FASE 1: Inserisci le leghe // FASE 1: Inserisci le leghe
foreach (var responseItem in jsonObject["response"].AsArray()) foreach (var responseItem in jsonObject["response"])
{ {
var league = responseItem["league"]; var league = responseItem["league"];
if (league != null && league["id"] != null) if (league != null && league["id"] != null)
@@ -301,11 +299,11 @@ namespace HorseRacingPredictor.Football
} }
// FASE 2: Inserisci i bookmakers e i tipi di scommessa // FASE 2: Inserisci i bookmakers e i tipi di scommessa
foreach (var responseItem in jsonObject["response"].AsArray()) foreach (var responseItem in jsonObject["response"])
{ {
if (responseItem["bookmakers"] != null) if (responseItem["bookmakers"] != null)
{ {
foreach (var bookmaker in responseItem["bookmakers"].AsArray()) foreach (var bookmaker in responseItem["bookmakers"])
{ {
if (bookmaker["id"] != null) if (bookmaker["id"] != null)
{ {
@@ -314,7 +312,7 @@ namespace HorseRacingPredictor.Football
// Tipi di scommessa // Tipi di scommessa
if (bookmaker["bets"] != null) if (bookmaker["bets"] != null)
{ {
foreach (var bet in bookmaker["bets"].AsArray()) foreach (var bet in bookmaker["bets"])
{ {
if (bet["id"] != null && bet["name"] != null) if (bet["id"] != null && bet["name"] != null)
{ {
@@ -328,7 +326,7 @@ namespace HorseRacingPredictor.Football
} }
// FASE 3: Inserisci le squadre (senza relazione con fixture) // FASE 3: Inserisci le squadre (senza relazione con fixture)
foreach (var responseItem in jsonObject["response"].AsArray()) foreach (var responseItem in jsonObject["response"])
{ {
var teams = responseItem["teams"]; var teams = responseItem["teams"];
if (teams != null && teams["home"] != null && teams["away"] != null && if (teams != null && teams["home"] != null && teams["away"] != null &&
@@ -340,7 +338,7 @@ namespace HorseRacingPredictor.Football
} }
// FASE 4: Inserisci i fixture e venue // FASE 4: Inserisci i fixture e venue
foreach (var responseItem in jsonObject["response"].AsArray()) foreach (var responseItem in jsonObject["response"])
{ {
var fixture = responseItem["fixture"]; var fixture = responseItem["fixture"];
if (fixture != null && fixture["id"] != null) if (fixture != null && fixture["id"] != null)
@@ -350,7 +348,7 @@ namespace HorseRacingPredictor.Football
} }
// FASE 5: Inserisci relazioni tra entità e dati dipendenti // FASE 5: Inserisci relazioni tra entità e dati dipendenti
foreach (var responseItem in jsonObject["response"].AsArray()) foreach (var responseItem in jsonObject["response"])
{ {
int? fixtureId = null; int? fixtureId = null;
try try
@@ -358,7 +356,7 @@ namespace HorseRacingPredictor.Football
var fixture = responseItem["fixture"]; var fixture = responseItem["fixture"];
if (fixture != null && fixture["id"] != null) if (fixture != null && fixture["id"] != null)
{ {
fixtureId = fixture["id"].GetValue<int>(); fixtureId = fixture["id"].Value<int>();
// Relazioni fixture-team // Relazioni fixture-team
var teams = responseItem["teams"]; var teams = responseItem["teams"];
@@ -372,7 +370,7 @@ namespace HorseRacingPredictor.Football
var league = responseItem["league"]; var league = responseItem["league"];
if (league != null && league["id"] != null) if (league != null && league["id"] != null)
{ {
int leagueId = league["id"].GetValue<int>(); int leagueId = league["id"].Value<int>();
_fixtureLeagueRepository.Upsert(connection, transaction, fixtureId.Value, leagueId, league); _fixtureLeagueRepository.Upsert(connection, transaction, fixtureId.Value, leagueId, league);
} }
@@ -399,7 +397,7 @@ namespace HorseRacingPredictor.Football
} }
// FASE 6: Inserisci dati che richiedono fixture e teams: quote e previsioni // FASE 6: Inserisci dati che richiedono fixture e teams: quote e previsioni
foreach (var responseItem in jsonObject["response"].AsArray()) foreach (var responseItem in jsonObject["response"])
{ {
int? fixtureId = null; int? fixtureId = null;
try try
@@ -407,7 +405,7 @@ namespace HorseRacingPredictor.Football
var fixture = responseItem["fixture"]; var fixture = responseItem["fixture"];
if (fixture != null && fixture["id"] != null) if (fixture != null && fixture["id"] != null)
{ {
fixtureId = fixture["id"].GetValue<int>(); fixtureId = fixture["id"].Value<int>();
// Quote // Quote
if (responseItem["bookmakers"] != null) if (responseItem["bookmakers"] != null)
@@ -442,15 +440,15 @@ namespace HorseRacingPredictor.Football
} }
// Head-to-head // Head-to-head
if (predictions["h2h"] != null && predictions["h2h"].AsArray().Any()) if (predictions["h2h"] != null && predictions["h2h"].Any())
{ {
_h2hRepository.DeleteForPrediction(connection, predictionId.Value); _h2hRepository.DeleteForPrediction(connection, predictionId.Value);
foreach (var h2hFixture in predictions["h2h"].AsArray()) foreach (var h2hFixture in predictions["h2h"])
{ {
if (h2hFixture["fixture"] != null && h2hFixture["fixture"]["id"] != null) if (h2hFixture["fixture"] != null && h2hFixture["fixture"]["id"] != null)
{ {
_h2hRepository.Insert(connection, predictionId.Value, h2hFixture["fixture"]["id"].GetValue<int>()); _h2hRepository.Insert(connection, predictionId.Value, h2hFixture["fixture"]["id"].Value<int>());
} }
} }
} }
@@ -462,7 +460,7 @@ namespace HorseRacingPredictor.Football
// Home team stats // Home team stats
if (teams["home"] != null && teams["home"]["id"] != null && predictions["teams"]["home"] != null) if (teams["home"] != null && teams["home"]["id"] != null && predictions["teams"]["home"] != null)
{ {
int homeTeamId = teams["home"]["id"].GetValue<int>(); int homeTeamId = teams["home"]["id"].Value<int>();
if (predictions["teams"]["home"]["team"] != null) if (predictions["teams"]["home"]["team"] != null)
{ {
@@ -480,7 +478,7 @@ namespace HorseRacingPredictor.Football
// Away team stats // Away team stats
if (teams["away"] != null && teams["away"]["id"] != null && predictions["teams"]["away"] != null) if (teams["away"] != null && teams["away"]["id"] != null && predictions["teams"]["away"] != null)
{ {
int awayTeamId = teams["away"]["id"].GetValue<int>(); int awayTeamId = teams["away"]["id"].Value<int>();
if (predictions["teams"]["away"]["team"] != null) if (predictions["teams"]["away"]["team"] != null)
{ {
@@ -583,36 +581,36 @@ namespace HorseRacingPredictor.Football
try try
{ {
var json = JsonDocument.Parse(response.Content).RootElement; var json = JObject.Parse(response.Content);
// Verifica che la risposta contenga dati validi // Verifica che la risposta contenga dati validi
if (!json.TryGetProperty("response", out var responseElement)) if (json["response"] == null)
{ {
return dataTable; return dataTable;
} }
// Aggiungi righe // Aggiungi righe
foreach (var item in responseElement.EnumerateArray()) foreach (var item in json["response"])
{ {
try try
{ {
var row = dataTable.NewRow(); var row = dataTable.NewRow();
// Estrai i dati dalla risposta JSON // Estrai i dati dalla risposta JSON
row["ID"] = item.GetProperty("fixture").GetProperty("id").GetInt32(); row["ID"] = item["fixture"]["id"].Value<int>();
row["Paese"] = item.GetProperty("league").GetProperty("country").GetString(); row["Paese"] = item["league"]["country"].Value<string>();
row["Campionato"] = item.GetProperty("league").GetProperty("name").GetString(); row["Campionato"] = item["league"]["name"].Value<string>();
row["Data / Ora"] = DateTime.Parse(item.GetProperty("fixture").GetProperty("date").GetString()); row["Data / Ora"] = DateTime.Parse(item["fixture"]["date"].Value<string>());
row["Stato"] = item.GetProperty("fixture").GetProperty("status").GetProperty("long").GetString(); row["Stato"] = item["fixture"]["status"]["long"].Value<string>();
row["Casa"] = item.GetProperty("teams").GetProperty("home").GetProperty("name").GetString(); row["Casa"] = item["teams"]["home"]["name"].Value<string>();
row["Trasferta"] = item.GetProperty("teams").GetProperty("away").GetProperty("name").GetString(); row["Trasferta"] = item["teams"]["away"]["name"].Value<string>();
// Per i goals, controlla se sono null // Per i goals, controlla se sono null
var goalsElement = item.GetProperty("goals"); var goalsElement = item["goals"];
row["Goals Casa"] = goalsElement.GetProperty("home").ValueKind == JsonValueKind.Null ? row["Goals Casa"] = goalsElement["home"].Type == JTokenType.Null ?
0 : goalsElement.GetProperty("home").GetInt32(); 0 : goalsElement["home"].Value<int>();
row["Goals Trasferta"] = goalsElement.GetProperty("away").ValueKind == JsonValueKind.Null ? row["Goals Trasferta"] = goalsElement["away"].Type == JTokenType.Null ?
0 : goalsElement.GetProperty("away").GetInt32(); 0 : goalsElement["away"].Value<int>();
// Le colonne delle quote e previsione rimangono temporaneamente vuote // Le colonne delle quote e previsione rimangono temporaneamente vuote
row["Quota Casa"] = DBNull.Value; row["Quota Casa"] = DBNull.Value;
@@ -662,18 +660,18 @@ namespace HorseRacingPredictor.Football
continue; continue;
} }
var json = JsonDocument.Parse(response.Content).RootElement; var json = JObject.Parse(response.Content);
if (!json.TryGetProperty("response", out var responseElement)) if (json["response"] == null)
{ {
continue; continue;
} }
foreach (var item in responseElement.EnumerateArray()) foreach (var item in json["response"])
{ {
try try
{ {
int fixtureId = item.GetProperty("fixture").GetProperty("id").GetInt32(); int fixtureId = item["fixture"]["id"].Value<int>();
// Trova la riga corrispondente nella tabella delle partite // Trova la riga corrispondente nella tabella delle partite
DataRow[] matchingRows = combinedTable.Select($"ID = {fixtureId}"); DataRow[] matchingRows = combinedTable.Select($"ID = {fixtureId}");
@@ -682,23 +680,23 @@ namespace HorseRacingPredictor.Football
DataRow row = matchingRows[0]; DataRow row = matchingRows[0];
// Cerca le quote del bookmaker (assumiamo Bet365 con ID 8) // Cerca le quote del bookmaker (assumiamo Bet365 con ID 8)
if (item.TryGetProperty("bookmakers", out var bookmakersElement)) if (item["bookmakers"] != null)
{ {
foreach (var bookmaker in bookmakersElement.EnumerateArray()) foreach (var bookmaker in item["bookmakers"])
{ {
if (bookmaker.GetProperty("id").GetInt32() == 8) // Bet365 if (bookmaker["id"].Value<int>() == 8) // Bet365
{ {
if (bookmaker.TryGetProperty("bets", out var betsElement)) if (bookmaker["bets"] != null)
{ {
foreach (var bet in betsElement.EnumerateArray()) foreach (var bet in bookmaker["bets"])
{ {
if (bet.GetProperty("name").GetString() == "Match Winner") if (bet["name"].Value<string>() == "Match Winner")
{ {
// Elabora le quote 1X2 // Elabora le quote 1X2
foreach (var value in bet.GetProperty("values").EnumerateArray()) foreach (var value in bet["values"])
{ {
string betType = value.GetProperty("value").GetString(); string betType = value["value"].Value<string>();
string odd = value.GetProperty("odd").GetString(); string odd = value["odd"].Value<string>();
switch (betType) switch (betType)
{ {
@@ -729,16 +727,15 @@ namespace HorseRacingPredictor.Football
var predictionResponse = _predictionManager.GetPredictionByFixture(fixtureId); var predictionResponse = _predictionManager.GetPredictionByFixture(fixtureId);
if (predictionResponse != null && predictionResponse.IsSuccessful) if (predictionResponse != null && predictionResponse.IsSuccessful)
{ {
var predictionJson = JsonDocument.Parse(predictionResponse.Content).RootElement; var predictionJson = JObject.Parse(predictionResponse.Content);
if (predictionJson.TryGetProperty("response", out var predResponse) && if (predictionJson["response"] != null && predictionJson["response"].Any())
predResponse.EnumerateArray().Any())
{ {
var prediction = predResponse.EnumerateArray().First(); var prediction = predictionJson["response"].First;
if (prediction.TryGetProperty("predictions", out var predsElement) && if (prediction["predictions"] != null &&
predsElement.TryGetProperty("winner", out var winnerElement) && prediction["predictions"]["winner"] != null &&
winnerElement.TryGetProperty("name", out var winnerNameElement)) prediction["predictions"]["winner"]["name"] != null)
{ {
row["Previsione"] = winnerNameElement.GetString(); row["Previsione"] = prediction["predictions"]["winner"]["name"].Value<string>();
} }
} }
} }

View File

@@ -2,7 +2,6 @@ using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using RestSharp; using RestSharp;
using HorseRacingPredictor.Football.Database; using HorseRacingPredictor.Football.Database;
using HorseRacingPredictor.Football.API;
using League = HorseRacingPredictor.Football.API.League; using League = HorseRacingPredictor.Football.API.League;
using Fixture = HorseRacingPredictor.Football.API.Fixture; using Fixture = HorseRacingPredictor.Football.API.Fixture;

View File

@@ -1,23 +1,28 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="CsvHelper" version="33.0.1" targetFramework="net481" /> <package id="CsvHelper" version="33.1.0" targetFramework="net481" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="10.0.0-preview.4.25258.110" targetFramework="net481" /> <package id="Microsoft.Bcl.AsyncInterfaces" version="10.0.0-rc.1.25451.107" targetFramework="net481" />
<package id="Microsoft.Bcl.HashCode" version="6.0.0" targetFramework="net481" /> <package id="Microsoft.Bcl.HashCode" version="6.0.0" targetFramework="net481" />
<package id="Microsoft.Bcl.Numerics" version="10.0.0-preview.4.25258.110" targetFramework="net481" /> <package id="Microsoft.Bcl.Numerics" version="10.0.0-rc.1.25451.107" targetFramework="net481" />
<package id="Microsoft.CSharp" version="4.7.0" targetFramework="net481" /> <package id="Microsoft.CSharp" version="4.7.0" targetFramework="net481" />
<package id="Microsoft.ML" version="5.0.0-preview.1.25127.4" targetFramework="net481" /> <package id="Microsoft.ML" version="5.0.0-preview.25503.2" targetFramework="net481" />
<package id="Microsoft.ML.CpuMath" version="5.0.0-preview.1.25127.4" targetFramework="net481" /> <package id="Microsoft.ML.CpuMath" version="5.0.0-preview.25503.2" targetFramework="net481" />
<package id="Microsoft.ML.DataView" version="5.0.0-preview.1.25127.4" targetFramework="net481" /> <package id="Microsoft.ML.DataView" version="5.0.0-preview.25503.2" targetFramework="net481" />
<package id="Microsoft.ML.FastTree" version="5.0.0-preview.1.25127.4" targetFramework="net481" /> <package id="Microsoft.ML.FastTree" version="5.0.0-preview.25503.2" targetFramework="net481" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net481" /> <package id="Newtonsoft.Json" version="13.0.4" targetFramework="net481" />
<package id="RestSharp" version="112.1.1-alpha.0.4" targetFramework="net481" />
<package id="System.Buffers" version="4.6.1" targetFramework="net481" /> <package id="System.Buffers" version="4.6.1" targetFramework="net481" />
<package id="System.CodeDom" version="10.0.0-preview.4.25258.110" targetFramework="net481" /> <package id="System.CodeDom" version="10.0.0-rc.1.25451.107" targetFramework="net481" />
<package id="System.Collections.Immutable" version="10.0.0-preview.4.25258.110" targetFramework="net481" /> <package id="System.Collections.Immutable" version="10.0.0-rc.1.25451.107" targetFramework="net481" />
<package id="System.IO.Pipelines" version="10.0.0-rc.1.25451.107" targetFramework="net481" />
<package id="System.Memory" version="4.6.3" targetFramework="net481" /> <package id="System.Memory" version="4.6.3" targetFramework="net481" />
<package id="System.Numerics.Tensors" version="10.0.0-preview.4.25258.110" targetFramework="net481" /> <package id="System.Numerics.Tensors" version="10.0.0-rc.1.25451.107" targetFramework="net481" />
<package id="System.Numerics.Vectors" version="4.6.1" targetFramework="net481" /> <package id="System.Numerics.Vectors" version="4.6.1" targetFramework="net481" />
<package id="System.Reflection.Emit.Lightweight" version="4.7.0" targetFramework="net481" /> <package id="System.Reflection.Emit.Lightweight" version="4.7.0" targetFramework="net481" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.1.2" targetFramework="net481" /> <package id="System.Runtime.CompilerServices.Unsafe" version="6.1.2" targetFramework="net481" />
<package id="System.Threading.Channels" version="10.0.0-preview.4.25258.110" targetFramework="net481" /> <package id="System.Text.Encodings.Web" version="10.0.0-rc.1.25451.107" targetFramework="net481" />
<package id="System.Text.Json" version="10.0.0-rc.1.25451.107" targetFramework="net481" />
<package id="System.Threading.Channels" version="10.0.0-rc.1.25451.107" targetFramework="net481" />
<package id="System.Threading.Tasks.Extensions" version="4.6.3" targetFramework="net481" /> <package id="System.Threading.Tasks.Extensions" version="4.6.3" targetFramework="net481" />
<package id="System.ValueTuple" version="4.6.1" targetFramework="net481" />
</packages> </packages>