5 assurer la sécurité la qualité et intégrer des logs #9
10 changed files with 265 additions and 91 deletions
|
|
@ -1,16 +1,38 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<configSections>
|
|
||||||
</configSections>
|
|
||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||||
</startup>
|
</startup>
|
||||||
|
<appSettings>
|
||||||
|
<add key="ApiAuthentication" value="admin:adminpwd" />
|
||||||
|
<add key="ApiUri" value="http://localhost/rest_mediatekdocuments/" />
|
||||||
|
</appSettings>
|
||||||
<runtime>
|
<runtime>
|
||||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
<dependentAssembly>
|
<dependentAssembly>
|
||||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
||||||
</dependentAssembly>
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="Google.Protobuf" publicKeyToken="a7d26565bac4d604" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-3.34.1.0" newVersion="3.34.1.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="K4os.Compression.LZ4.Streams" publicKeyToken="2186fa9121ef231d" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-1.3.8.0" newVersion="1.3.8.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="Serilog" publicKeyToken="24c2f752a8e58a10" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
</assemblyBinding>
|
</assemblyBinding>
|
||||||
</runtime>
|
</runtime>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
@ -12,6 +12,8 @@
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
<Deterministic>true</Deterministic>
|
<Deterministic>true</Deterministic>
|
||||||
|
<NuGetPackageImportStamp>
|
||||||
|
</NuGetPackageImportStamp>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
|
@ -33,20 +35,94 @@
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="BouncyCastle.Crypto, Version=1.8.5.0, Culture=neutral, PublicKeyToken=0e99375e54769942" />
|
<Reference Include="BouncyCastle.Crypto, Version=1.8.5.0, Culture=neutral, PublicKeyToken=0e99375e54769942">
|
||||||
<Reference Include="Google.Protobuf, Version=3.19.4.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604" />
|
<HintPath>..\packages\BouncyCastle.1.8.5\lib\BouncyCastle.Crypto.dll</HintPath>
|
||||||
<Reference Include="K4os.Compression.LZ4.Streams, Version=1.2.6.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d" />
|
</Reference>
|
||||||
<Reference Include="MySql.Data, Version=8.0.29.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL" />
|
<Reference Include="BouncyCastle.Cryptography, Version=2.0.0.0, Culture=neutral, PublicKeyToken=072edcf4a5328938, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\BouncyCastle.Cryptography.2.6.2\lib\net461\BouncyCastle.Cryptography.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Google.Protobuf, Version=3.34.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Google.Protobuf.3.34.1\lib\net45\Google.Protobuf.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="K4os.Compression.LZ4, Version=1.3.8.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\K4os.Compression.LZ4.1.3.8\lib\net462\K4os.Compression.LZ4.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="K4os.Compression.LZ4.Streams, Version=1.3.8.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\K4os.Compression.LZ4.Streams.1.3.8\lib\net462\K4os.Compression.LZ4.Streams.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="K4os.Hash.xxHash, Version=1.0.8.0, Culture=neutral, PublicKeyToken=32cd54395057cec3, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\K4os.Hash.xxHash.1.0.8\lib\net462\K4os.Hash.xxHash.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="MySql.Data, Version=8.0.29.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\MySql.Data.8.0.29\lib\net452\MySql.Data.dll</HintPath>
|
||||||
|
</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.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Serilog, Version=4.3.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Serilog.4.3.1\lib\net471\Serilog.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Serilog.Sinks.File, Version=7.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Serilog.Sinks.File.7.0.0\lib\net471\Serilog.Sinks.File.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.ComponentModel" />
|
||||||
|
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||||
<Reference Include="System.Configuration" />
|
<Reference Include="System.Configuration" />
|
||||||
|
<Reference Include="System.Configuration.ConfigurationManager, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Configuration.ConfigurationManager.8.0.0\lib\net462\System.Configuration.ConfigurationManager.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.Configuration.Install" />
|
<Reference Include="System.Configuration.Install" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Diagnostics.DiagnosticSource, Version=8.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.8.0.1\lib\net462\System.Diagnostics.DiagnosticSource.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.IO.Pipelines, Version=5.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.IO.Pipelines.5.0.2\lib\net461\System.IO.Pipelines.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.Management" />
|
<Reference Include="System.Management" />
|
||||||
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
|
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
<Reference Include="System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
|
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net" />
|
||||||
|
<Reference Include="System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Net.Http.2.0.20126.16343\lib\net40\System.Net.Http.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net.Http.Extensions, Version=2.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Net.Http.Formatting.Extension.5.2.3.0\lib\System.Net.Http.Extensions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Net.Http.Formatting.Extension.5.2.3.0\lib\System.Net.Http.Formatting.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net.Http.Primitives, Version=4.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Net.Http.Formatting.Extension.5.2.3.0\lib\System.Net.Http.Primitives.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net.Http.WebRequest, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Net.Http.2.0.20126.16343\lib\net40\System.Net.Http.WebRequest.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Numerics" />
|
||||||
|
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Threading.Channels, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Threading.Channels.8.0.0\lib\net462\System.Threading.Channels.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.Transactions" />
|
<Reference Include="System.Transactions" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
|
@ -54,11 +130,17 @@
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Deployment" />
|
<Reference Include="System.Deployment" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
<Reference Include="System.Net.Http" />
|
|
||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="Ubiety.Dns.Core, Version=2.2.1.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
|
<Reference Include="Ubiety.Dns.Core, Version=2.2.1.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||||
<Reference Include="ZstdNet, Version=1.4.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
|
<HintPath>..\packages\MySql.Data.8.0.29\lib\net452\Ubiety.Dns.Core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="ZstdNet, Version=1.4.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\MySql.Data.8.0.29\lib\net452\ZstdNet.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="ZstdSharp, Version=0.8.6.0, Culture=neutral, PublicKeyToken=8d151af33a4ad5cf, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\ZstdSharp.Port.0.8.6\lib\net462\ZstdSharp.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="controller\FrmAuthController.cs" />
|
<Compile Include="controller\FrmAuthController.cs" />
|
||||||
|
|
@ -124,4 +206,13 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup />
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<Import Project="..\packages\ZstdNet.1.4.5\build\ZstdNet.targets" Condition="Exists('..\packages\ZstdNet.1.4.5\build\ZstdNet.targets')" />
|
||||||
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ErrorText>Ce projet fait référence à des packages NuGet qui sont manquants sur cet ordinateur. Utilisez l'option de restauration des packages NuGet pour les télécharger. Pour plus d'informations, consultez http://go.microsoft.com/fwlink/?LinkID=322105. Le fichier manquant est : {0}.</ErrorText>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Error Condition="!Exists('..\packages\ZstdNet.1.4.5\build\ZstdNet.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\ZstdNet.1.4.5\build\ZstdNet.targets'))" />
|
||||||
|
<Error Condition="!Exists('..\packages\Serilog.4.3.1\build\Serilog.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Serilog.4.3.1\build\Serilog.targets'))" />
|
||||||
|
</Target>
|
||||||
|
<Import Project="..\packages\Serilog.4.3.1\build\Serilog.targets" Condition="Exists('..\packages\Serilog.4.3.1\build\Serilog.targets')" />
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -15,7 +15,6 @@ namespace MediaTekDocuments
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
|
||||||
//Application.Run(new FrmAuth());
|
|
||||||
FrmAuth auth = new FrmAuth();
|
FrmAuth auth = new FrmAuth();
|
||||||
|
|
||||||
if (auth.ShowDialog() == DialogResult.OK)
|
if (auth.ShowDialog() == DialogResult.OK)
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ using Newtonsoft.Json.Converters;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
namespace MediaTekDocuments.dal
|
namespace MediaTekDocuments.dal
|
||||||
{
|
{
|
||||||
|
|
@ -15,10 +16,6 @@ namespace MediaTekDocuments.dal
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Access
|
public class Access
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// adresse de l'API
|
|
||||||
/// </summary>
|
|
||||||
private static readonly string uriApi = "http://localhost/rest_mediatekdocuments/";
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// instance unique de la classe
|
/// instance unique de la classe
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -48,29 +45,34 @@ namespace MediaTekDocuments.dal
|
||||||
/// Méthode privée pour créer un singleton
|
/// Méthode privée pour créer un singleton
|
||||||
/// initialise l'accès à l'API
|
/// initialise l'accès à l'API
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
// Le constructeur redevient sans paramètre pour le Singleton
|
||||||
private Access()
|
private Access()
|
||||||
{
|
{
|
||||||
String authenticationString;
|
string authenticationString;
|
||||||
|
string uriApi;
|
||||||
|
|
||||||
|
Log.Logger = new LoggerConfiguration().MinimumLevel.Debug().WriteTo.File("logs/log.txt", rollingInterval: RollingInterval.Day).CreateLogger();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
authenticationString = "admin:adminpwd";
|
uriApi = ConfigurationManager.AppSettings["ApiUri"];
|
||||||
|
authenticationString = ConfigurationManager.AppSettings["ApiAuthentication"];
|
||||||
api = ApiRest.GetInstance(uriApi, authenticationString);
|
api = ApiRest.GetInstance(uriApi, authenticationString);
|
||||||
|
|
||||||
|
Log.Information("Log de : {NomMethode} : {Message}", nameof(Access), "Api instanciée");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Console.WriteLine(e.Message);
|
Log.Fatal(e, "Erreur fatale lors de l'initialisation de l'accès API");
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Création et retour de l'instance unique de la classe
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>instance unique de la classe</returns>
|
|
||||||
public static Access GetInstance()
|
public static Access GetInstance()
|
||||||
{
|
{
|
||||||
if (instance == null)
|
if (instance == null)
|
||||||
{
|
{
|
||||||
|
// On appelle le constructeur sans argument
|
||||||
instance = new Access();
|
instance = new Access();
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
|
|
@ -165,6 +167,7 @@ namespace MediaTekDocuments.dal
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine(ex.Message);
|
Console.WriteLine(ex.Message);
|
||||||
|
Log.Error(ex, "Erreur dans {NomMethode} : {Message}", nameof(CreerExemplaire), ex.Message);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -188,21 +191,21 @@ namespace MediaTekDocuments.dal
|
||||||
String code = (String)retour["code"];
|
String code = (String)retour["code"];
|
||||||
if (code.Equals("200"))
|
if (code.Equals("200"))
|
||||||
{
|
{
|
||||||
// dans le cas du GET (select), récupération de la liste d'objets
|
|
||||||
if (methode.Equals(GET))
|
if (methode.Equals(GET))
|
||||||
{
|
{
|
||||||
String resultString = JsonConvert.SerializeObject(retour["result"]);
|
String resultString = JsonConvert.SerializeObject(retour["result"]);
|
||||||
// construction de la liste d'objets à partir du retour de l'api
|
|
||||||
liste = JsonConvert.DeserializeObject<List<T>>(resultString, new CustomBooleanJsonConverter());
|
liste = JsonConvert.DeserializeObject<List<T>>(resultString, new CustomBooleanJsonConverter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine("code erreur = " + code + " message = " + (String)retour["message"]);
|
Console.WriteLine("code erreur = " + code + " message = " + (String)retour["message"]);
|
||||||
|
Log.Warning("API Retourne une erreur - Code: {Code}, Message: {Message}", code, (string)retour["message"]);
|
||||||
}
|
}
|
||||||
}catch(Exception e)
|
}catch(Exception e)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Erreur lors de l'accès à l'API : "+e.Message);
|
Console.WriteLine("Erreur lors de l'accès à l'API : "+e.Message);
|
||||||
|
Log.Error(e, "Erreur lors de l'accès à l'API via TraitementRecup");
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
return liste;
|
return liste;
|
||||||
|
|
@ -274,7 +277,7 @@ namespace MediaTekDocuments.dal
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Erreur lors de la suppression : " + ex.Message);
|
Log.Error(ex, "Erreur dans {NomMethode} : {Message}", nameof(DeleteCommande), ex.Message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -295,7 +298,7 @@ namespace MediaTekDocuments.dal
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine(ex.Message);
|
Log.Error(ex, "Erreur lors de la création de commande");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -303,12 +306,18 @@ namespace MediaTekDocuments.dal
|
||||||
public string GetNextCommandeId()
|
public string GetNextCommandeId()
|
||||||
{
|
{
|
||||||
List<dynamic> result = TraitementRecup<dynamic>(GET, "maxcommande", null);
|
List<dynamic> result = TraitementRecup<dynamic>(GET, "maxcommande", null);
|
||||||
|
if (result != null && result.Count > 0)
|
||||||
if (result != null && result.Count > 0 && result[0].maxId != null)
|
{
|
||||||
|
var firstResult = result[0];
|
||||||
|
if (firstResult != null && firstResult.maxId != null)
|
||||||
|
{
|
||||||
|
string lastId = firstResult.maxId.ToString();
|
||||||
|
if (lastId.Length > 1)
|
||||||
{
|
{
|
||||||
string lastId = result[0].maxId.ToString();
|
|
||||||
int nextIdVal = int.Parse(lastId.Substring(1)) + 1;
|
int nextIdVal = int.Parse(lastId.Substring(1)) + 1;
|
||||||
return "" + nextIdVal.ToString("D4");
|
return nextIdVal.ToString("D4");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return "0001";
|
return "0001";
|
||||||
}
|
}
|
||||||
|
|
@ -323,7 +332,7 @@ namespace MediaTekDocuments.dal
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Erreur mise à jour suivi : " + ex.Message);
|
Log.Error(ex, "Erreur dans {NomMethode} : {Message}", nameof(UpdateSuiviCommande), ex.Message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -345,7 +354,7 @@ namespace MediaTekDocuments.dal
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Erreur lors de l'accès à l'API : " + ex.Message);
|
Log.Error(ex, "Erreur dans {NomMethode} : {Message}", nameof(GetAbonnements), ex.Message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -358,7 +367,10 @@ namespace MediaTekDocuments.dal
|
||||||
JObject retour = api.RecupDistant(DELETE, "abonnement/" + jsonId, null);
|
JObject retour = api.RecupDistant(DELETE, "abonnement/" + jsonId, null);
|
||||||
return retour["code"].ToString().Equals("200");
|
return retour["code"].ToString().Equals("200");
|
||||||
}
|
}
|
||||||
catch { return false; }
|
catch(Exception ex) {
|
||||||
|
Log.Error(ex, "Erreur dans {NomMethode} : {Message}", nameof(SupprimerAbonnement), ex.Message);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Utilisateur GetConnection(string login, string pwd)
|
public Utilisateur GetConnection(string login, string pwd)
|
||||||
|
|
@ -376,6 +388,7 @@ namespace MediaTekDocuments.dal
|
||||||
{
|
{
|
||||||
return lesUtilisateurs[0];
|
return lesUtilisateurs[0];
|
||||||
}
|
}
|
||||||
|
Log.Warning("Tentative de connexion échouée pour le login : {Login}", login);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,27 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
|
<package id="BouncyCastle" version="1.8.5" targetFramework="net472" />
|
||||||
|
<package id="BouncyCastle.Cryptography" version="2.6.2" targetFramework="net472" />
|
||||||
|
<package id="Google.Protobuf" version="3.34.1" targetFramework="net472" />
|
||||||
|
<package id="K4os.Compression.LZ4" version="1.3.8" targetFramework="net472" />
|
||||||
|
<package id="K4os.Compression.LZ4.Streams" version="1.3.8" targetFramework="net472" />
|
||||||
|
<package id="K4os.Hash.xxHash" version="1.0.8" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.Bcl.AsyncInterfaces" version="5.0.0" targetFramework="net472" />
|
||||||
|
<package id="MySql.Data" version="8.0.29" targetFramework="net472" />
|
||||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
|
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
|
||||||
|
<package id="Serilog" version="4.3.1" targetFramework="net472" />
|
||||||
|
<package id="Serilog.Sinks.File" version="7.0.0" targetFramework="net472" />
|
||||||
|
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
|
||||||
|
<package id="System.Configuration.ConfigurationManager" version="8.0.0" targetFramework="net472" />
|
||||||
|
<package id="System.Diagnostics.DiagnosticSource" version="8.0.1" targetFramework="net472" />
|
||||||
|
<package id="System.IO.Pipelines" version="5.0.2" targetFramework="net472" />
|
||||||
|
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
|
||||||
|
<package id="System.Net.Http" version="2.0.20126.16343" targetFramework="net472" />
|
||||||
|
<package id="System.Net.Http.Formatting.Extension" version="5.2.3.0" targetFramework="net472" />
|
||||||
|
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
|
||||||
|
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net472" />
|
||||||
|
<package id="System.Threading.Channels" version="8.0.0" targetFramework="net472" />
|
||||||
|
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
|
||||||
|
<package id="ZstdNet" version="1.4.5" targetFramework="net472" />
|
||||||
|
<package id="ZstdSharp.Port" version="0.8.6" targetFramework="net472" />
|
||||||
</packages>
|
</packages>
|
||||||
|
|
@ -23,7 +23,8 @@ namespace MediaTekDocuments.view
|
||||||
|
|
||||||
private void FrmAuth_Load(object sender, EventArgs e)
|
private void FrmAuth_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
//
|
// Méthode laissée vide intentionnellement.
|
||||||
|
// Aucun traitement spécifique n'est requis au chargement du formulaire d'authentification.
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnLogin_Click(object sender, EventArgs e)
|
private void btnLogin_Click(object sender, EventArgs e)
|
||||||
|
|
@ -31,9 +32,9 @@ namespace MediaTekDocuments.view
|
||||||
string identifiant = txtIdentifiant.Text;
|
string identifiant = txtIdentifiant.Text;
|
||||||
string password = txtPassword.Text;
|
string password = txtPassword.Text;
|
||||||
|
|
||||||
Utilisateur user = controller.GetConnection(identifiant, password);
|
Utilisateur utilisateur = controller.GetConnection(identifiant, password);
|
||||||
|
|
||||||
if(user == null)
|
if(utilisateur == null)
|
||||||
{
|
{
|
||||||
txtIdentifiant.Text = "";
|
txtIdentifiant.Text = "";
|
||||||
txtPassword.Text = "";
|
txtPassword.Text = "";
|
||||||
|
|
@ -41,7 +42,7 @@ namespace MediaTekDocuments.view
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(user.LibelleService == "Culture")
|
if(utilisateur.LibelleService == "Culture")
|
||||||
{
|
{
|
||||||
MessageBox.Show("Vous n'êtes pas autorisé à accéder à cette application !", "Accès refusé", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
MessageBox.Show("Vous n'êtes pas autorisé à accéder à cette application !", "Accès refusé", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
this.DialogResult = DialogResult.Abort;
|
this.DialogResult = DialogResult.Abort;
|
||||||
|
|
@ -49,7 +50,7 @@ namespace MediaTekDocuments.view
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.user = user;
|
this.user = utilisateur;
|
||||||
this.DialogResult = DialogResult.OK;
|
this.DialogResult = DialogResult.OK;
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using MediaTekDocuments.model;
|
using MediaTekDocuments.model;
|
||||||
using MediaTekDocuments.controller;
|
using MediaTekDocuments.controller;
|
||||||
|
|
@ -33,7 +34,7 @@ namespace MediaTekDocuments.view
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.controller = new FrmMediatekController();
|
this.controller = new FrmMediatekController();
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.Text += " - " + user.Prenom + " " + user.Nom;
|
this.Text += " - " + this.user.Prenom + " " + user.Nom;
|
||||||
|
|
||||||
RemplirComboSuivi(controller.GetAllSuivis(), bdgSuivis, cboSuivi);
|
RemplirComboSuivi(controller.GetAllSuivis(), bdgSuivis, cboSuivi);
|
||||||
RemplirComboSuivi(controller.GetAllSuivis(), bdgSuivis, cboSuiviDvd);
|
RemplirComboSuivi(controller.GetAllSuivis(), bdgSuivis, cboSuiviDvd);
|
||||||
|
|
@ -115,7 +116,7 @@ namespace MediaTekDocuments.view
|
||||||
if (tabOngletsApplication.TabPages.Contains(tabCommandeLivres))
|
if (tabOngletsApplication.TabPages.Contains(tabCommandeLivres))
|
||||||
{
|
{
|
||||||
dgvListeLivre2.DataSource = null;
|
dgvListeLivre2.DataSource = null;
|
||||||
dgvListeLivre2.DataSource = bdgLivresListe;
|
dgvListeLivre2.DataSource = livres;
|
||||||
|
|
||||||
if (dgvListeLivre2.Columns.Count > 0 && dgvListeLivre2.Columns.Contains("isbn"))
|
if (dgvListeLivre2.Columns.Count > 0 && dgvListeLivre2.Columns.Contains("isbn"))
|
||||||
{
|
{
|
||||||
|
|
@ -454,7 +455,7 @@ namespace MediaTekDocuments.view
|
||||||
if (tabOngletsApplication.TabPages.Contains(tabCommandeDvd))
|
if (tabOngletsApplication.TabPages.Contains(tabCommandeDvd))
|
||||||
{
|
{
|
||||||
dgvDvd.DataSource = null;
|
dgvDvd.DataSource = null;
|
||||||
dgvDvd.DataSource = bdgDvdListe;
|
dgvDvd.DataSource = dvds;
|
||||||
|
|
||||||
if (dgvDvd.Columns.Count > 0 && dgvDvd.Columns.Contains("idRayon"))
|
if (dgvDvd.Columns.Count > 0 && dgvDvd.Columns.Contains("idRayon"))
|
||||||
{
|
{
|
||||||
|
|
@ -1398,11 +1399,14 @@ namespace MediaTekDocuments.view
|
||||||
dgvCommandes.DataSource = null;
|
dgvCommandes.DataSource = null;
|
||||||
dgvCommandes.Columns.Clear();
|
dgvCommandes.Columns.Clear();
|
||||||
dgvCommandes.DataSource = lesCommandes;
|
dgvCommandes.DataSource = lesCommandes;
|
||||||
string[] toHide = { "id", "idLivreDvd", "idSuivi" };
|
|
||||||
foreach (string col in toHide)
|
|
||||||
if (dgvCommandes.Columns.Contains(col)) dgvCommandes.Columns[col].Visible = false;
|
|
||||||
dgvCommandes.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
|
|
||||||
|
|
||||||
|
string[] toHide = { "id", "idLivreDvd", "idSuivi" };
|
||||||
|
dgvCommandes.Columns.Cast<DataGridViewColumn>()
|
||||||
|
.Where(col => toHide.Contains(col.Name))
|
||||||
|
.ToList()
|
||||||
|
.ForEach(col => col.Visible = false);
|
||||||
|
|
||||||
|
dgvCommandes.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
|
||||||
dgvCommandes.ClearSelection();
|
dgvCommandes.ClearSelection();
|
||||||
dgvCommandes.CurrentCell = null;
|
dgvCommandes.CurrentCell = null;
|
||||||
ViderZonesSaisieCommande();
|
ViderZonesSaisieCommande();
|
||||||
|
|
@ -1441,10 +1445,10 @@ namespace MediaTekDocuments.view
|
||||||
|
|
||||||
if (dgvCommandes.CurrentRow.Cells["Montant"].Value != null)
|
if (dgvCommandes.CurrentRow.Cells["Montant"].Value != null)
|
||||||
{
|
{
|
||||||
CommandeDocument commandeDocument = (CommandeDocument)dgvCommandes.CurrentRow.DataBoundItem;
|
|
||||||
updownMontant.Value = Convert.ToDecimal(dgvCommandes.CurrentRow.Cells["Montant"].Value);
|
updownMontant.Value = Convert.ToDecimal(dgvCommandes.CurrentRow.Cells["Montant"].Value);
|
||||||
updownNbExemplaire.Value = Convert.ToDecimal(dgvCommandes.CurrentRow.Cells["NbExemplaire"].Value);
|
updownNbExemplaire.Value = Convert.ToDecimal(dgvCommandes.CurrentRow.Cells["NbExemplaire"].Value);
|
||||||
string etape = commandeDocument.LibelleSuivi;
|
|
||||||
|
string etape = commande.LibelleSuivi;
|
||||||
cboSuivi.SelectedIndex = cboSuivi.FindStringExact(etape);
|
cboSuivi.SelectedIndex = cboSuivi.FindStringExact(etape);
|
||||||
|
|
||||||
grpNewCommande.Text = "Modifier commande";
|
grpNewCommande.Text = "Modifier commande";
|
||||||
|
|
@ -1452,8 +1456,6 @@ namespace MediaTekDocuments.view
|
||||||
dateTimeCommande.Enabled = false;
|
dateTimeCommande.Enabled = false;
|
||||||
updownMontant.Enabled = false;
|
updownMontant.Enabled = false;
|
||||||
updownNbExemplaire.Enabled = false;
|
updownNbExemplaire.Enabled = false;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -1466,8 +1468,6 @@ namespace MediaTekDocuments.view
|
||||||
{
|
{
|
||||||
if (dgvListeLivre2.CurrentCell != null && dgvCommandes.CurrentCell != null)
|
if (dgvListeLivre2.CurrentCell != null && dgvCommandes.CurrentCell != null)
|
||||||
{
|
{
|
||||||
string id = dgvListeLivre2.CurrentRow.Cells["Id"].Value.ToString();
|
|
||||||
string commandeId = dgvCommandes.CurrentRow.Cells["id"].Value.ToString();
|
|
||||||
CommandeDocument commande = (CommandeDocument)dgvCommandes.CurrentRow.DataBoundItem;
|
CommandeDocument commande = (CommandeDocument)dgvCommandes.CurrentRow.DataBoundItem;
|
||||||
btnDeleteCommande.Enabled = false;
|
btnDeleteCommande.Enabled = false;
|
||||||
|
|
||||||
|
|
@ -1647,9 +1647,12 @@ namespace MediaTekDocuments.view
|
||||||
{
|
{
|
||||||
dgvCommandesDvd.DataSource = null;
|
dgvCommandesDvd.DataSource = null;
|
||||||
dgvCommandesDvd.DataSource = lesCommandes;
|
dgvCommandesDvd.DataSource = lesCommandes;
|
||||||
|
|
||||||
string[] toHide = { "id", "idLivreDvd", "idSuivi" };
|
string[] toHide = { "id", "idLivreDvd", "idSuivi" };
|
||||||
foreach (string col in toHide)
|
dgvCommandesDvd.Columns.Cast<DataGridViewColumn>()
|
||||||
if (dgvCommandesDvd.Columns.Contains(col)) dgvCommandesDvd.Columns[col].Visible = false;
|
.Where(col => toHide.Contains(col.Name))
|
||||||
|
.ToList()
|
||||||
|
.ForEach(col => col.Visible = false);
|
||||||
|
|
||||||
dgvCommandesDvd.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
|
dgvCommandesDvd.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
|
||||||
}
|
}
|
||||||
|
|
@ -1768,10 +1771,8 @@ namespace MediaTekDocuments.view
|
||||||
|
|
||||||
private void btnDeleteCommandeDvd_Click(object sender, EventArgs e)
|
private void btnDeleteCommandeDvd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dgvCommandesDvd.CurrentCell != null && dgvCommandesDvd.CurrentCell != null)
|
if (dgvCommandesDvd.CurrentCell != null)
|
||||||
{
|
{
|
||||||
string id = dgvCommandesDvd.CurrentRow.Cells["Id"].Value.ToString();
|
|
||||||
string commandeId = dgvCommandesDvd.CurrentRow.Cells["id"].Value.ToString();
|
|
||||||
CommandeDocument commande = (CommandeDocument)dgvCommandesDvd.CurrentRow.DataBoundItem;
|
CommandeDocument commande = (CommandeDocument)dgvCommandesDvd.CurrentRow.DataBoundItem;
|
||||||
btnDeleteCommandeDvd.Enabled = false;
|
btnDeleteCommandeDvd.Enabled = false;
|
||||||
|
|
||||||
|
|
@ -1816,40 +1817,31 @@ namespace MediaTekDocuments.view
|
||||||
private void AlerteAbonnementsExpirants()
|
private void AlerteAbonnementsExpirants()
|
||||||
{
|
{
|
||||||
List<Revue> toutesLesRevues = controller.GetAllRevues();
|
List<Revue> toutesLesRevues = controller.GetAllRevues();
|
||||||
string message = "Abonnements se terminant sous 30 jours :\n";
|
StringBuilder stp = new StringBuilder("Abonnements se terminant sous 30 jours :\n");
|
||||||
bool alerte = false;
|
bool alerte = false;
|
||||||
|
|
||||||
foreach (Revue revue in toutesLesRevues)
|
foreach (Revue revue in toutesLesRevues)
|
||||||
{
|
{
|
||||||
List<Abonnement> abos = controller.GetAbonnements(revue.Id);
|
List<Abonnement> abos = controller.GetAbonnements(revue.Id);
|
||||||
// On prend le dernier abonnement (le plus récent)
|
|
||||||
Abonnement dernierAbo = abos.OrderByDescending(a => a.DateFinAbonnement).FirstOrDefault();
|
Abonnement dernierAbo = abos.OrderByDescending(a => a.DateFinAbonnement).FirstOrDefault();
|
||||||
|
|
||||||
if (dernierAbo != null && (dernierAbo.DateFinAbonnement - DateTime.Now).TotalDays <= 30
|
if (dernierAbo != null && (dernierAbo.DateFinAbonnement - DateTime.Now).TotalDays <= 30
|
||||||
&& (dernierAbo.DateFinAbonnement - DateTime.Now).TotalDays > 0)
|
&& (dernierAbo.DateFinAbonnement - DateTime.Now).TotalDays > 0)
|
||||||
{
|
{
|
||||||
message += $"- {revue.Titre} : finit le {dernierAbo.DateFinAbonnement:dd/MM/yyyy}\n";
|
stp.Append($"- {revue.Titre} : finit le {dernierAbo.DateFinAbonnement:dd/MM/yyyy}\n");
|
||||||
alerte = true;
|
alerte = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (alerte)
|
if (alerte)
|
||||||
{
|
{
|
||||||
MessageBox.Show(message, "Alerte Abonnements", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
MessageBox.Show(stp.ToString(), "Alerte Abonnements", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool PeutSupprimerAbonnement(Abonnement abonnement)
|
private bool PeutSupprimerAbonnement(Abonnement abonnement)
|
||||||
{
|
{
|
||||||
List<Exemplaire> exemplaires = controller.GetExemplairesRevue(abonnement.IdRevue);
|
List<Exemplaire> exemplaires = controller.GetExemplairesRevue(abonnement.IdRevue);
|
||||||
foreach (Exemplaire ex in exemplaires)
|
return !exemplaires.Exists(ex => ParutionDansAbonnement(abonnement.DateCommande,abonnement.DateFinAbonnement, ex.DateAchat));
|
||||||
{
|
|
||||||
if (ParutionDansAbonnement(abonnement.DateCommande, abonnement.DateFinAbonnement, ex.DateAchat))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ParutionDansAbonnement(DateTime dateCommande, DateTime dateFinAbonnement, DateTime dateParution)
|
public bool ParutionDansAbonnement(DateTime dateCommande, DateTime dateFinAbonnement, DateTime dateParution)
|
||||||
|
|
@ -1920,7 +1912,7 @@ namespace MediaTekDocuments.view
|
||||||
private void btnAbonnementAjouter_Click(object sender, EventArgs e)
|
private void btnAbonnementAjouter_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
string idRevue = txbRevuesCommandesNumRecherche.Text;
|
string idRevue = txbRevuesCommandesNumRecherche.Text;
|
||||||
if (idRevue.Equals(""))
|
if (string.IsNullOrEmpty(idRevue))
|
||||||
{
|
{
|
||||||
MessageBox.Show("Veuillez d'abord sélectionner une revue.", "Information");
|
MessageBox.Show("Veuillez d'abord sélectionner une revue.", "Information");
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Include="app.config" />
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -14,22 +14,23 @@ namespace Mediatek.Tests
|
||||||
Utilisateur user = new Utilisateur("1", "admin", "philippe", "erwann", 1, "administration");
|
Utilisateur user = new Utilisateur("1", "admin", "philippe", "erwann", 1, "administration");
|
||||||
FrmMediatek frm = new FrmMediatek(user);
|
FrmMediatek frm = new FrmMediatek(user);
|
||||||
|
|
||||||
DateTime debut = new DateTime(2024, 01, 01);
|
// Ajout de DateTimeKind.Local à chaque création d'objet DateTime
|
||||||
DateTime fin = new DateTime(2024, 12, 31);
|
DateTime debut = new DateTime(2024, 01, 01, 0, 0, 0, DateTimeKind.Local);
|
||||||
|
DateTime fin = new DateTime(2024, 12, 31, 0, 0, 0, DateTimeKind.Local);
|
||||||
|
|
||||||
DateTime parutionDebut = new DateTime(2024, 01, 01);
|
DateTime parutionDebut = new DateTime(2024, 01, 01, 0, 0, 0, DateTimeKind.Local);
|
||||||
Assert.IsTrue(frm.ParutionDansAbonnement(debut, fin, parutionDebut), "La date de début devrait être incluse.");
|
Assert.IsTrue(frm.ParutionDansAbonnement(debut, fin, parutionDebut), "La date de début devrait être incluse.");
|
||||||
|
|
||||||
DateTime parutionFin = new DateTime(2024, 12, 31);
|
DateTime parutionFin = new DateTime(2024, 12, 31, 0, 0, 0, DateTimeKind.Local);
|
||||||
Assert.IsTrue(frm.ParutionDansAbonnement(debut, fin, parutionFin), "La date de fin devrait être incluse.");
|
Assert.IsTrue(frm.ParutionDansAbonnement(debut, fin, parutionFin), "La date de fin devrait être incluse.");
|
||||||
|
|
||||||
DateTime parutionMilieu = new DateTime(2024, 06, 15);
|
DateTime parutionMilieu = new DateTime(2024, 06, 15, 0, 0, 0, DateTimeKind.Local);
|
||||||
Assert.IsTrue(frm.ParutionDansAbonnement(debut, fin, parutionMilieu), "Une date en milieu d'abonnement doit être vraie.");
|
Assert.IsTrue(frm.ParutionDansAbonnement(debut, fin, parutionMilieu), "Une date en milieu d'abonnement doit être vraie.");
|
||||||
|
|
||||||
DateTime parutionAvant = new DateTime(2023, 12, 31);
|
DateTime parutionAvant = new DateTime(2023, 12, 31, 0, 0, 0, DateTimeKind.Local);
|
||||||
Assert.IsFalse(frm.ParutionDansAbonnement(debut, fin, parutionAvant), "Une date avant le début doit être fausse.");
|
Assert.IsFalse(frm.ParutionDansAbonnement(debut, fin, parutionAvant), "Une date avant le début doit être fausse.");
|
||||||
|
|
||||||
DateTime parutionApres = new DateTime(2025, 01, 01);
|
DateTime parutionApres = new DateTime(2025, 01, 01, 0, 0, 0, DateTimeKind.Local);
|
||||||
Assert.IsFalse(frm.ParutionDansAbonnement(debut, fin, parutionApres), "Une date après la fin doit être fausse.");
|
Assert.IsFalse(frm.ParutionDansAbonnement(debut, fin, parutionApres), "Une date après la fin doit être fausse.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
31
Mediatek.Tests/app.config
Normal file
31
Mediatek.Tests/app.config
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<runtime>
|
||||||
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="Google.Protobuf" publicKeyToken="a7d26565bac4d604" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-3.34.1.0" newVersion="3.34.1.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="K4os.Compression.LZ4.Streams" publicKeyToken="2186fa9121ef231d" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-1.3.8.0" newVersion="1.3.8.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="Serilog" publicKeyToken="24c2f752a8e58a10" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
</assemblyBinding>
|
||||||
|
</runtime>
|
||||||
|
</configuration>
|
||||||
Loading…
Reference in a new issue