From 78b8a810a0eb43efd55adb285c47aa218600c495 Mon Sep 17 00:00:00 2001 From: Antoine PEREDERII Date: Wed, 10 May 2023 10:22:26 +0200 Subject: [PATCH 1/5] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'.drone.yml'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index b8b996a..55472d9 100644 --- a/.drone.yml +++ b/.drone.yml @@ -33,7 +33,7 @@ steps: # accessible en ligne de commande par ${PLUGIN_SONAR_HOST} SONAR_HOST: https://codefirst.iut.uca.fr/sonar/ # accessible en ligne de commande par ${PLUGIN_SONAR_TOKEN} - SONNAR_TOKEN: + SONAR_TOKEN: from_secret: SECRET_SONAR_LOGIN commands: - cd src/Banquale/ From 14942e5c40597f4327c1c2e1460711662778f7be Mon Sep 17 00:00:00 2001 From: Antoine PEREDERII Date: Wed, 10 May 2023 10:32:32 +0200 Subject: [PATCH 2/5] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'.drone.yml'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index 55472d9..fb9b0ae 100644 --- a/.drone.yml +++ b/.drone.yml @@ -38,11 +38,11 @@ steps: commands: - cd src/Banquale/ - dotnet restore Banquale.sln - - dotnet sonarscanner begin /k:Banquale /d:sonar.host.url=$SONAR_HOST /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions="Tests/**" /d:sonar.login=$SONAR_TOKEN + - dotnet sonarscanner begin /k:"Banquale" /d:sonar.host.url="https://codefirst.iut.uca.fr/sonar" /d:sonar.login="sqp_f0b2dedfa2a5b789e29bd716fc31e4a337246115" - dotnet build Banquale.sln -c Release --no-restore - dotnet test Banquale.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" - - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" - - dotnet publish Banquale/Banquale.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/release -f:net7.0-android /p:AndroidSdkDirectory=/usr/lib/android-sdk +# - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" +# - dotnet publish Banquale/Banquale.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/release -f:net7.0-android /p:AndroidSdkDirectory=/usr/lib/android-sdk - dotnet sonarscanner end /d:sonar.login=$SONAR_TOKEN depends_on: [tests] From 33a5739dcdb856f3d3dbea3539f0d9928a2d2c1b Mon Sep 17 00:00:00 2001 From: Antoine PEREDERII Date: Wed, 10 May 2023 10:35:49 +0200 Subject: [PATCH 3/5] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'.drone.yml'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.drone.yml b/.drone.yml index fb9b0ae..f97d11b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -31,19 +31,19 @@ steps: secrets: [ SECRET_SONAR_LOGIN ] settings: # accessible en ligne de commande par ${PLUGIN_SONAR_HOST} - SONAR_HOST: https://codefirst.iut.uca.fr/sonar/ + sonar_host: https://codefirst.iut.uca.fr/sonar/ # accessible en ligne de commande par ${PLUGIN_SONAR_TOKEN} - SONAR_TOKEN: + sonar_token: from_secret: SECRET_SONAR_LOGIN commands: - cd src/Banquale/ - dotnet restore Banquale.sln - - dotnet sonarscanner begin /k:"Banquale" /d:sonar.host.url="https://codefirst.iut.uca.fr/sonar" /d:sonar.login="sqp_f0b2dedfa2a5b789e29bd716fc31e4a337246115" + - dotnet sonarscanner begin /k:"Banquale" /d:sonar.host.url=$${PLUGIN_SONAR_HOST} /d:sonar.login=$${PLUGIN_SONAR_TOKEN} - dotnet build Banquale.sln -c Release --no-restore - dotnet test Banquale.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" # - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" # - dotnet publish Banquale/Banquale.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/release -f:net7.0-android /p:AndroidSdkDirectory=/usr/lib/android-sdk - - dotnet sonarscanner end /d:sonar.login=$SONAR_TOKEN + - dotnet sonarscanner end /d:sonar.login=$${PLUGIN_SONAR_TOKEN} depends_on: [tests] - name: generate-and-deploy-docs From 448cf538c694a91612e128d4d9ee3e17ec84d073 Mon Sep 17 00:00:00 2001 From: Antoine PEREDERII Date: Wed, 10 May 2023 13:05:37 +0200 Subject: [PATCH 4/5] Update ReadMe.md with badges --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index d0e13da..bc86d13 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,10 @@ # Banquale [![Build Status](https://codefirst.iut.uca.fr/api/badges/antoine.perederii/Banquale/status.svg)](https://codefirst.iut.uca.fr/antoine.perederii/Banquale) +[![Quality Gate Status](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=Banquale&metric=alert_status&token=1a49717e4d2f15e2eecaaa971ebd8c83fb9bd5c5)](https://codefirst.iut.uca.fr/sonar/dashboard?id=Banquale) +[![Bugs](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=Banquale&metric=bugs&token=1a49717e4d2f15e2eecaaa971ebd8c83fb9bd5c5)](https://codefirst.iut.uca.fr/sonar/dashboard?id=Banquale) +[![Coverage](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=Banquale&metric=coverage&token=1a49717e4d2f15e2eecaaa971ebd8c83fb9bd5c5)](https://codefirst.iut.uca.fr/sonar/dashboard?id=Banquale) +[![Vulnerabilities](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=Banquale&metric=vulnerabilities&token=1a49717e4d2f15e2eecaaa971ebd8c83fb9bd5c5)](https://codefirst.iut.uca.fr/sonar/dashboard?id=Banquale) # Table of Content [overview--big-picture](#overview--big-picture) | [Features](#features) | [Getting Started](#getting-started) | [Prerequisites](#prerequisites) From 771dfebd455ecbc2d933450b081c14049561ab24 Mon Sep 17 00:00:00 2001 From: "titouan.louvet" Date: Wed, 10 May 2023 17:19:44 +0200 Subject: [PATCH 5/5] Update DataContractPers --- src/Banquale/Banquale/App.xaml.cs | 4 +- src/Banquale/Banquale/Banquale.csproj | 1 + .../DataContractPers.cs | 58 ++++++++++++++----- src/Banquale/Banquale/Model/Manager.cs | 7 ++- 4 files changed, 53 insertions(+), 17 deletions(-) diff --git a/src/Banquale/Banquale/App.xaml.cs b/src/Banquale/Banquale/App.xaml.cs index b23e2bb..8cadac2 100644 --- a/src/Banquale/Banquale/App.xaml.cs +++ b/src/Banquale/Banquale/App.xaml.cs @@ -13,8 +13,8 @@ public partial class App : Application { MyManager.ChargeDonnee(); - //MyManager.Persistance = new DataContractPersistance.DataContractPers(); - //MyManager.SauvegardeDonnee(); + MyManager.Persistance = new DataContractPersistance.DataContractPers(); + MyManager.SauvegardeDonnee(); InitializeComponent(); diff --git a/src/Banquale/Banquale/Banquale.csproj b/src/Banquale/Banquale/Banquale.csproj index 8939ab5..3f03349 100644 --- a/src/Banquale/Banquale/Banquale.csproj +++ b/src/Banquale/Banquale/Banquale.csproj @@ -75,6 +75,7 @@ + diff --git a/src/Banquale/Banquale/DataContractPersistance/DataContractPers.cs b/src/Banquale/Banquale/DataContractPersistance/DataContractPers.cs index a978b1c..1f1214a 100644 --- a/src/Banquale/Banquale/DataContractPersistance/DataContractPers.cs +++ b/src/Banquale/Banquale/DataContractPersistance/DataContractPers.cs @@ -1,22 +1,54 @@ -using System; - +using Banquale.Model; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.Serialization; +using System.Xml; namespace Banquale.DataContractPersistance { - public class DataContractPers + public class DataContractPers : IPersistanceManager { - //public DataContractPers() - //{ - // public string Filename { get; set; } = "PATH"; + public string FileName { get; set; } = "nomFichier.xml"; + + public string FilePath2 { get; set; } = "..\\Persistances"; + public string FilePath { get; set; } = "C:\\Users\\louve\\depot\\Banquale\\src\\Banquale\\Persistances"; + + + + public (List, List) ChargeDonnee() + { + var serializer = new DataContractSerializer(typeof(List)); + List list; + + using (Stream s = File.OpenRead(Path.Combine(FilePath, FileName))) + { + list = serializer.ReadObject(s) as List; + } - // public string FilePath { get; set; } = "PATH"; + return (list, new List()); + } - //} + public void SauvegardeDonnee(List c, List t) + { + var serializer = new DataContractSerializer (typeof(List)); + if(!Directory.Exists(FilePath)) + { + Debug.WriteLine("Directory non crée"); + Debug.WriteLine(Directory.GetDirectoryRoot(FilePath)); + Debug.WriteLine(FilePath); + Directory.CreateDirectory(FilePath); + } - //public (List, List) ChargeDonnee() - //{ - // var serializer = new DataContractSerializer(typeof(Client)); - //} - } + XmlWriterSettings settings = new XmlWriterSettings() { Indent = true }; + using (TextWriter tw = File.CreateText(Path.Combine(FilePath, FileName))) + { + using (XmlWriter writer = XmlWriter.Create(tw, settings)) + { + serializer.WriteObject(writer, t); + } + } + } + } } diff --git a/src/Banquale/Banquale/Model/Manager.cs b/src/Banquale/Banquale/Model/Manager.cs index c45cbbe..d7739f0 100644 --- a/src/Banquale/Banquale/Model/Manager.cs +++ b/src/Banquale/Banquale/Model/Manager.cs @@ -1,12 +1,15 @@ using System; +using System.Runtime.Serialization; namespace Banquale.Model { + [DataContract] public class Manager { + [DataMember] public List ListeClients { get; private set; } - + [DataMember] public List ListeTransactions { get; private set; } public IPersistanceManager Persistance { get; set; } @@ -35,7 +38,7 @@ namespace Banquale.Model return ListeClients[place]; } - public void sauvegardeDonnee() + public void SauvegardeDonnee() { Persistance.SauvegardeDonnee(ListeClients, ListeTransactions); }