5 assurer la sécurité la qualité et intégrer des logs #9
5 changed files with 72 additions and 14 deletions
|
|
@ -29,6 +29,10 @@
|
|||
<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>
|
||||
</runtime>
|
||||
</configuration>
|
||||
|
|
@ -62,6 +62,12 @@
|
|||
<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>
|
||||
</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.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>
|
||||
|
|
@ -74,6 +80,9 @@
|
|||
</Reference>
|
||||
<Reference Include="System.Configuration.Install" />
|
||||
<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>
|
||||
|
|
@ -81,7 +90,26 @@
|
|||
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
|
||||
<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>
|
||||
|
|
@ -89,6 +117,9 @@
|
|||
<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>
|
||||
|
|
@ -99,7 +130,6 @@
|
|||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Ubiety.Dns.Core, Version=2.2.1.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||
|
|
@ -182,5 +212,7 @@
|
|||
<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>
|
||||
|
|
@ -7,6 +7,7 @@ using Newtonsoft.Json.Converters;
|
|||
using Newtonsoft.Json.Linq;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using Serilog;
|
||||
|
||||
namespace MediaTekDocuments.dal
|
||||
{
|
||||
|
|
@ -48,19 +49,21 @@ namespace MediaTekDocuments.dal
|
|||
private Access()
|
||||
{
|
||||
string authenticationString;
|
||||
string uriApi; // Devient une variable locale au constructeur
|
||||
string uriApi;
|
||||
|
||||
Log.Logger = new LoggerConfiguration().MinimumLevel.Debug().WriteTo.File("logs/log.txt", rollingInterval: RollingInterval.Day).CreateLogger();
|
||||
|
||||
try
|
||||
{
|
||||
// Lecture directe depuis le fichier de configuration
|
||||
uriApi = ConfigurationManager.AppSettings["ApiUri"];
|
||||
authenticationString = ConfigurationManager.AppSettings["ApiAuthentication"];
|
||||
|
||||
// On passe la variable locale à l'API Rest
|
||||
api = ApiRest.GetInstance(uriApi, authenticationString);
|
||||
|
||||
Log.Information("Log de : {NomMethode} : {Message}", nameof(Access), "Api instancié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);
|
||||
}
|
||||
}
|
||||
|
|
@ -164,6 +167,7 @@ namespace MediaTekDocuments.dal
|
|||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
Log.Error(ex, "Erreur dans {NomMethode} : {Message}", nameof(CreerExemplaire), ex.Message);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -187,21 +191,21 @@ namespace MediaTekDocuments.dal
|
|||
String code = (String)retour["code"];
|
||||
if (code.Equals("200"))
|
||||
{
|
||||
// dans le cas du GET (select), récupération de la liste d'objets
|
||||
if (methode.Equals(GET))
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
return liste;
|
||||
|
|
@ -273,7 +277,7 @@ namespace MediaTekDocuments.dal
|
|||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -294,7 +298,7 @@ namespace MediaTekDocuments.dal
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
Log.Error(ex, "Erreur lors de la création de commande");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -328,7 +332,7 @@ namespace MediaTekDocuments.dal
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Erreur mise à jour suivi : " + ex.Message);
|
||||
Log.Error(ex, "Erreur dans {NomMethode} : {Message}", nameof(UpdateSuiviCommande), ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -350,7 +354,7 @@ namespace MediaTekDocuments.dal
|
|||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -363,7 +367,10 @@ namespace MediaTekDocuments.dal
|
|||
JObject retour = api.RecupDistant(DELETE, "abonnement/" + jsonId, null);
|
||||
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)
|
||||
|
|
@ -381,6 +388,7 @@ namespace MediaTekDocuments.dal
|
|||
{
|
||||
return lesUtilisateurs[0];
|
||||
}
|
||||
Log.Warning("Tentative de connexion échouée pour le login : {Login}", login);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,12 +9,18 @@
|
|||
<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="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" />
|
||||
|
|
|
|||
|
|
@ -18,6 +18,14 @@
|
|||
<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