From faca3741a1d129289451af7bd0706b795aca6d62 Mon Sep 17 00:00:00 2001 From: hulivet1 Date: Thu, 5 Jan 2023 16:52:06 +0100 Subject: [PATCH 01/10] Netoyage --- Sources/Modele/Manager.cs | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/Sources/Modele/Manager.cs b/Sources/Modele/Manager.cs index 59e2912..7b7ef81 100644 --- a/Sources/Modele/Manager.cs +++ b/Sources/Modele/Manager.cs @@ -13,21 +13,6 @@ namespace Model public Hash hash = new Hash(); - public int Solde - { - get => solde; - set - { - if (solde != value) - { - solde = value; - OnPropertyChanged(nameof(Solde)); - } - } - } - - private int solde; - private Inscrit user; public Inscrit User { @@ -72,16 +57,15 @@ namespace Model } private List banquesDisponibleInApp; - void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - public Manager(IPersistanceManager persistance) { Pers = persistance; } - + void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + - public bool isEqualHash(string mdpBdd, string mdpSent) + public bool CompareHash(string mdpBdd, string mdpSent) { return hash.IsEqualHash(mdpBdd, mdpSent); } -- 2.36.3 From 782d82eb74a6b2cd98275f900f02d431b3c144d2 Mon Sep 17 00:00:00 2001 From: hulivet1 Date: Thu, 5 Jan 2023 17:24:28 +0100 Subject: [PATCH 02/10] =?UTF-8?q?Remise=20en=20=C3=A9tat=20avec=20le=20nou?= =?UTF-8?q?vel=20IPersistanceManager?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/Data/LoadOperation.cs | 4 ++-- Sources/Data/PersAPI.cs | 5 +++++ Sources/IHM/Mobile/AjoutBanques.xaml.cs | 8 ++++---- Sources/IHM/Mobile/Dashboard.xaml.cs | 4 ++-- Sources/IHM/Mobile/ErrorPage.xaml.cs | 4 ++-- Sources/IHM/Mobile/GestionBanques.xaml.cs | 2 +- Sources/Modele/IPersistanceManager.cs | 1 + Sources/Modele/Manager.cs | 11 ++++++----- 8 files changed, 23 insertions(+), 16 deletions(-) diff --git a/Sources/Data/LoadOperation.cs b/Sources/Data/LoadOperation.cs index cd95fa0..a47c7b9 100644 --- a/Sources/Data/LoadOperation.cs +++ b/Sources/Data/LoadOperation.cs @@ -12,7 +12,7 @@ using static System.Net.Mime.MediaTypeNames; namespace Data { - public class LoadOperation + public static class LoadOperation { public static IList LoadOperationsFromOFX(string ofx) { @@ -112,7 +112,7 @@ namespace Data } - public static string[] CutRow(string row) + private static string[] CutRow(string row) { string[] cutRow; if (row == null) throw new ArgumentNullException(); diff --git a/Sources/Data/PersAPI.cs b/Sources/Data/PersAPI.cs index baad602..e050a2e 100644 --- a/Sources/Data/PersAPI.cs +++ b/Sources/Data/PersAPI.cs @@ -129,5 +129,10 @@ namespace Data { return ClientAPI.GetStateApi().GetAwaiter().GetResult(); } + + public IList GetDataFromOFX(string path) + { + return LoadOperation.LoadOperationsFromOFX(path); + } } } \ No newline at end of file diff --git a/Sources/IHM/Mobile/AjoutBanques.xaml.cs b/Sources/IHM/Mobile/AjoutBanques.xaml.cs index 50011ff..6d7e9c1 100644 --- a/Sources/IHM/Mobile/AjoutBanques.xaml.cs +++ b/Sources/IHM/Mobile/AjoutBanques.xaml.cs @@ -11,7 +11,7 @@ public partial class AjoutBanques : ContentPage { InitializeComponent(); BindingContext = Mgr; - //Mgr.importBanques(); + Mgr.importBanques(); if (OperatingSystem.IsIOS()) { boutonRetour.IsVisible = true; @@ -29,12 +29,12 @@ public partial class AjoutBanques : ContentPage { if (result.FileName.EndsWith("ofx", StringComparison.OrdinalIgnoreCase)) { - //IList lesComptes = Mgr.getCompteFromOFX(result.FullPath); - /*Debug.WriteLine(lesComptes.Count); + IList lesComptes = Mgr.Pers.GetDataFromOFX(result.FullPath); + Debug.WriteLine(lesComptes.Count); foreach(Compte compte in lesComptes) { Mgr.User.LesBanques.First().AjouterCompte(compte); - }*/ + } } } diff --git a/Sources/IHM/Mobile/Dashboard.xaml.cs b/Sources/IHM/Mobile/Dashboard.xaml.cs index 6be0d67..cf3538e 100644 --- a/Sources/IHM/Mobile/Dashboard.xaml.cs +++ b/Sources/IHM/Mobile/Dashboard.xaml.cs @@ -17,11 +17,11 @@ public partial class DashBoard : ContentPage } - /* if (!Mgr.testConnexionAsDatabase()) + if (!Mgr.Pers.TestConnexion()) { loadPage(new ErrorPage()); - }*/ + } } diff --git a/Sources/IHM/Mobile/ErrorPage.xaml.cs b/Sources/IHM/Mobile/ErrorPage.xaml.cs index 7809cb6..9863e1e 100644 --- a/Sources/IHM/Mobile/ErrorPage.xaml.cs +++ b/Sources/IHM/Mobile/ErrorPage.xaml.cs @@ -22,10 +22,10 @@ public partial class ErrorPage : ContentPage public void conIsActive() { - /*while (!Mgr.testConnexionAsDatabase()) + while (!Mgr.Pers.TestConnexion()) { Thread.Sleep(TIME_TEST_DB); - }*/ + } ConnexionValide(); return; diff --git a/Sources/IHM/Mobile/GestionBanques.xaml.cs b/Sources/IHM/Mobile/GestionBanques.xaml.cs index 04681a8..6d1001a 100644 --- a/Sources/IHM/Mobile/GestionBanques.xaml.cs +++ b/Sources/IHM/Mobile/GestionBanques.xaml.cs @@ -11,7 +11,7 @@ public partial class GestionBanques : ContentPage { InitializeComponent(); BindingContext= Mgr; - //Mgr.LoadBanques(); + Mgr.LoadBanques(); if (OperatingSystem.IsIOS()) { boutonRetour.IsVisible = true; diff --git a/Sources/Modele/IPersistanceManager.cs b/Sources/Modele/IPersistanceManager.cs index cfbd58e..5d6992a 100644 --- a/Sources/Modele/IPersistanceManager.cs +++ b/Sources/Modele/IPersistanceManager.cs @@ -52,6 +52,7 @@ namespace Model //actions utilitaire bool TestConnexion(); + IList GetDataFromOFX(string path); } } diff --git a/Sources/Modele/Manager.cs b/Sources/Modele/Manager.cs index 7b7ef81..1f374f4 100644 --- a/Sources/Modele/Manager.cs +++ b/Sources/Modele/Manager.cs @@ -43,7 +43,7 @@ namespace Model } } private Banque selectedBanque; - public List BanquesDisponibleInApp + public IList BanquesDisponibleInApp { get => banquesDisponibleInApp; set @@ -55,7 +55,7 @@ namespace Model } } } - private List banquesDisponibleInApp; + private IList banquesDisponibleInApp; public Manager(IPersistanceManager persistance) { @@ -70,14 +70,15 @@ namespace Model return hash.IsEqualHash(mdpBdd, mdpSent); } - - public void deconnexion() { User = null; } - + public void LoadBanques() + { + BanquesDisponibleInApp = Pers.RecupererBanquesDisponible(); + } } } -- 2.36.3 From c7bee1a4d6c20f270d47ebbe01fa868fce1719d7 Mon Sep 17 00:00:00 2001 From: Vincent ASTOLFI Date: Thu, 5 Jan 2023 21:14:26 +0100 Subject: [PATCH 03/10] refactoring du manager pour la page MainWindow --- Sources/Data/PersLinqToPgSQL.cs | 6 ++---- Sources/Data/PersStub.cs | 3 +-- Sources/IHM/Mobile/AjoutBanques.xaml.cs | 2 +- Sources/IHM/Mobile/MainPage.xaml.cs | 8 ++++---- Sources/Modele/Hash.cs | 19 ++++--------------- Sources/Modele/Inscrit.cs | 2 -- Sources/Modele/Manager.cs | 14 +++++++++++--- 7 files changed, 23 insertions(+), 31 deletions(-) diff --git a/Sources/Data/PersLinqToPgSQL.cs b/Sources/Data/PersLinqToPgSQL.cs index 52a82a9..3790c61 100644 --- a/Sources/Data/PersLinqToPgSQL.cs +++ b/Sources/Data/PersLinqToPgSQL.cs @@ -19,7 +19,6 @@ namespace LinqToPgSQL { public class PersLinqToPgSQL /*: IPersistanceManager*/ { - private Hash hash = new Hash(); private static string connexionBDD = String.Format("Server=2.3.8.130; Username=postgres; Database=conseco; Port=5432; Password=lulu; SSLMode=Prefer"); private static NpgsqlConnection dbAccess = new NpgsqlConnection(connexionBDD); @@ -100,8 +99,7 @@ namespace LinqToPgSQL public async void ChangePasswordBdd(string mail, string newMdp) { - Hash hash = new Hash(); - string hashedMdp = hash.CreateHashCode(newMdp); + string hashedMdp = Hash.CreateHashCode(newMdp); var conn = new NpgsqlConnection(connexionBDD); Console.Out.WriteLine("Ouverture de la connection"); try @@ -151,7 +149,7 @@ namespace LinqToPgSQL public async void CreateInscrit(Inscrit inscrit) { - string mdpHash = hash.CreateHashCode(inscrit.Mdp); + string mdpHash = Hash.CreateHashCode(inscrit.Mdp); Console.WriteLine("AAAAAA"+mdpHash.Length); var conn = new NpgsqlConnection(connexionBDD); conn.Open(); diff --git a/Sources/Data/PersStub.cs b/Sources/Data/PersStub.cs index 57a6162..e990814 100644 --- a/Sources/Data/PersStub.cs +++ b/Sources/Data/PersStub.cs @@ -90,12 +90,11 @@ namespace Data } public string RecupMdpBdd(string mail) { - Hash hash = new Hash(); foreach(Inscrit i in lesInscrits) { if(i.Mail == mail) { - return hash.CreateHashCode(i.Mdp); + return Hash.CreateHashCode(i.Mdp); } } return "inexistant"; diff --git a/Sources/IHM/Mobile/AjoutBanques.xaml.cs b/Sources/IHM/Mobile/AjoutBanques.xaml.cs index 6d7e9c1..fd4e7d6 100644 --- a/Sources/IHM/Mobile/AjoutBanques.xaml.cs +++ b/Sources/IHM/Mobile/AjoutBanques.xaml.cs @@ -11,7 +11,7 @@ public partial class AjoutBanques : ContentPage { InitializeComponent(); BindingContext = Mgr; - Mgr.importBanques(); + //Mgr.importBanques(); if (OperatingSystem.IsIOS()) { boutonRetour.IsVisible = true; diff --git a/Sources/IHM/Mobile/MainPage.xaml.cs b/Sources/IHM/Mobile/MainPage.xaml.cs index 8d020b6..a92fc19 100644 --- a/Sources/IHM/Mobile/MainPage.xaml.cs +++ b/Sources/IHM/Mobile/MainPage.xaml.cs @@ -21,9 +21,9 @@ namespace IHM.Mobile AffichError("Champ invalide", "Veuillez compléter tout les champs", "OK"); } else { - /* if (Mgr.existEmail(EntryMail.Text)) + if (Mgr.Pers.EmailDisponible(EntryMail.Text)) { - if (Mgr.isEqualHash(Mgr.recupMdpBdd(EntryMail.Text), EntryPassworld.Text)) + if (Mgr.CompareHash(Mgr.getPassword(EntryMail.Text), EntryPassworld.Text)) { Mgr.createUser(EntryMail.Text); ConnexionValide(); @@ -36,13 +36,13 @@ namespace IHM.Mobile else { AffichError("Compte inexistant", "Email ou mot de passe invalide", "OK"); - }*/ + } } } private async void ConnexionValide() { - //Mgr.LoadBanques(); + Mgr.LoadBanques(); await Navigation.PopModalAsync(); } diff --git a/Sources/Modele/Hash.cs b/Sources/Modele/Hash.cs index 2488f66..1ec1c95 100644 --- a/Sources/Modele/Hash.cs +++ b/Sources/Modele/Hash.cs @@ -7,9 +7,9 @@ using System.Text; namespace Model { - public class Hash + public static class Hash { - public string CreateHashCode(string mdp) + public static string CreateHashCode(string mdp) { string hashString = ""; @@ -25,21 +25,10 @@ namespace Model return hashString; } - public bool IsEqualHash(string mdpBdd, string mdpSent) + public static bool IsEqualHash(string mdpBdd, string mdpSent) { - string hashedMdpSent = CreateHashCode(mdpSent); + string hashedMdpSent = Hash.CreateHashCode(mdpSent); return hashedMdpSent.Equals(mdpBdd); } - - private string ByteArrayToString(byte[] arrInput) - { - int i; - StringBuilder sOutput = new StringBuilder(arrInput.Length); - for (i = 0; i < arrInput.Length; i++) - { - sOutput.Append(arrInput[i].ToString("X2")); - } - return sOutput.ToString(); - } } } diff --git a/Sources/Modele/Inscrit.cs b/Sources/Modele/Inscrit.cs index 00c7d0e..6f5ccb5 100644 --- a/Sources/Modele/Inscrit.cs +++ b/Sources/Modele/Inscrit.cs @@ -12,8 +12,6 @@ namespace Model { public class Inscrit:INotifyPropertyChanged { - public Hash hash = new Hash(); - public event PropertyChangedEventHandler PropertyChanged; public int Id { get; set; } diff --git a/Sources/Modele/Manager.cs b/Sources/Modele/Manager.cs index 1f374f4..8a0e98e 100644 --- a/Sources/Modele/Manager.cs +++ b/Sources/Modele/Manager.cs @@ -11,8 +11,6 @@ namespace Model public int SelectedInscrit { get; set; } - public Hash hash = new Hash(); - private Inscrit user; public Inscrit User { @@ -67,7 +65,7 @@ namespace Model public bool CompareHash(string mdpBdd, string mdpSent) { - return hash.IsEqualHash(mdpBdd, mdpSent); + return Hash.IsEqualHash(mdpBdd, mdpSent); } public void deconnexion() @@ -80,6 +78,16 @@ namespace Model BanquesDisponibleInApp = Pers.RecupererBanquesDisponible(); } + public string getPassword(string email) + { + Inscrit inscrit = Pers.RecupererInscrit(email); + return inscrit.Mdp; + } + + public void createUser(string mail) + { + User = Pers.RecupererInscrit(mail); + } } } -- 2.36.3 From 6b06e3f909f52a70c16204df66f927c81ef25d72 Mon Sep 17 00:00:00 2001 From: Vincent ASTOLFI Date: Thu, 5 Jan 2023 21:30:28 +0100 Subject: [PATCH 04/10] Refactoring de toute les methodes des pages lies a la conenction afin de les rendres toute fonctionnelle avec l'API --- Sources/IHM/Mobile/ChangePassword.xaml.cs | 2 +- Sources/IHM/Mobile/ForgetPassword.xaml.cs | 4 ++-- Sources/IHM/Mobile/Inscription.xaml.cs | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Sources/IHM/Mobile/ChangePassword.xaml.cs b/Sources/IHM/Mobile/ChangePassword.xaml.cs index 73dfd20..6c682f8 100644 --- a/Sources/IHM/Mobile/ChangePassword.xaml.cs +++ b/Sources/IHM/Mobile/ChangePassword.xaml.cs @@ -25,7 +25,7 @@ public partial class ChangePassword : ContentPage } else { - //Mgr.changePasswordBdd(MailUser, EntryNewMdp.Text); + Mgr.Pers.ModifierMdpInscrit(MailUser, EntryNewMdp.Text); AffichError("mdp changé", "mot de passe bien changé", "ok"); NavigateTo("../.."); } diff --git a/Sources/IHM/Mobile/ForgetPassword.xaml.cs b/Sources/IHM/Mobile/ForgetPassword.xaml.cs index 69c7b15..174ec8c 100644 --- a/Sources/IHM/Mobile/ForgetPassword.xaml.cs +++ b/Sources/IHM/Mobile/ForgetPassword.xaml.cs @@ -20,7 +20,7 @@ public partial class ForgetPassword : ContentPage { AffichError("Email inconnue", "Aucun compte existant portant cette adresse mail", "OK"); } - /*if (Mgr.existEmail(EntryMail.Text)){ + if (Mgr.Pers.EmailDisponible(EntryMail.Text)){ Random generator = new Random(); code = generator.Next(0, 1000000).ToString("D6"); Email.CreateMail(EntryMail.Text, code); @@ -31,7 +31,7 @@ public partial class ForgetPassword : ContentPage else { AffichError("Mail inexistant", "Aucun compte possédant cette adresse email trouvé", "OK"); - }*/ + } } private async void AffichError(string s, string s1, string s2) { diff --git a/Sources/IHM/Mobile/Inscription.xaml.cs b/Sources/IHM/Mobile/Inscription.xaml.cs index 3a5ddc5..425e93b 100644 --- a/Sources/IHM/Mobile/Inscription.xaml.cs +++ b/Sources/IHM/Mobile/Inscription.xaml.cs @@ -20,8 +20,8 @@ public partial class Inscription : ContentPage } else { - /*if(EntryNewPassword.Text.Equals(EntryConfirmationPassword.Text)) { - if (Mgr.existEmail(EntryNewMail.Text)) + if(EntryNewPassword.Text.Equals(EntryConfirmationPassword.Text)) { + if (Mgr.Pers.EmailDisponible(EntryNewMail.Text)) { AffichError("Mail existant", "un compte porte déjà cette adresse mail, veuillez en changer", "OK"); } @@ -43,15 +43,15 @@ public partial class Inscription : ContentPage else { AffichError("Mot de passe de confirmation invalide", "Veuillez mettre deux mots de passe identiques", "OK"); - }*/ + } } } private void ValideCode(object sender, EventArgs e) { if (EntryCodeRecept.Text == code) { - //Inscrit inscrit = new Inscrit(Mgr.lastInscrit() + 1, EntryNewName.Text, EntryNewMail.Text, EntryNewSurname.Text, EntryNewPassword.Text); - //Mgr.createInscrit(inscrit); + Inscrit inscrit = new Inscrit(1, EntryNewName.Text, EntryNewMail.Text, EntryNewSurname.Text, EntryNewPassword.Text); + Mgr.Pers.AjouterInscrit(inscrit); AffichError("compte créé", "Compte bien créé", "OK"); NavigateTo(".."); } -- 2.36.3 From f2ae2d41ccc1e4ea3d0294f47a63f61700388a7a Mon Sep 17 00:00:00 2001 From: hulivet1 Date: Fri, 6 Jan 2023 09:02:07 +0100 Subject: [PATCH 05/10] Probleme --- Sources/Data/PersStub.cs | 123 ++++++++++++++++++++++++++-- Sources/IHM/IHM.csproj | 4 +- Sources/IHM/Mobile/MainPage.xaml | 18 ++-- Sources/IHM/Mobile/MainPage.xaml.cs | 3 +- 4 files changed, 131 insertions(+), 17 deletions(-) diff --git a/Sources/Data/PersStub.cs b/Sources/Data/PersStub.cs index e990814..fb5c37c 100644 --- a/Sources/Data/PersStub.cs +++ b/Sources/Data/PersStub.cs @@ -2,9 +2,9 @@ namespace Data { - public class PersStub /*: IPersistanceManager*/ + public class PersStub : IPersistanceManager { - private List lesInscrits = new List(); + /*private List lesInscrits = new List(); public PersStub() { @@ -63,10 +63,7 @@ namespace Data public void CreateInscrit(Inscrit inscrit){ lesInscrits.Add(inscrit); } - /*public string LastInscrit() - { - return lesInscrits[lesInscrits.Count - 1].Id; - }*/ + public bool ExistEmail(string mail) { foreach(Inscrit i in lesInscrits) @@ -156,6 +153,120 @@ namespace Data public List LoadBanqueId(int id) + { + throw new NotImplementedException(); + }*/ + public bool AjouterBanque(Banque banque, Inscrit inscrit) + { + throw new NotImplementedException(); + } + + public bool AjouterCompte(Compte compte, Inscrit inscrit) + { + throw new NotImplementedException(); + } + + public bool AjouterEcheance(Compte compte, Echeance echeance) + { + throw new NotImplementedException(); + } + + public bool AjouterInscrit(Inscrit inscrit) + { + throw new NotImplementedException(); + } + + public bool AjouterOperation(Compte compte, Operation operation) + { + throw new NotImplementedException(); + } + + public bool AjouterPlanification(Compte compte, Planification planification) + { + throw new NotImplementedException(); + } + + public bool EmailDisponible(string mail) + { + throw new NotImplementedException(); + } + + public IList GetDataFromOFX(string path) + { + throw new NotImplementedException(); + } + + public bool ModifierMdpInscrit(string mail, string nouveauMdp) + { + throw new NotImplementedException(); + } + + public IList RecupererBanques(Inscrit inscrit) + { + throw new NotImplementedException(); + } + + public IList RecupererBanquesDisponible() + { + throw new NotImplementedException(); + } + + public IList RecupererCompte(Banque banque, Inscrit inscrit) + { + throw new NotImplementedException(); + } + + public IList RecupererEcheance(Compte compte) + { + throw new NotImplementedException(); + } + + public Inscrit RecupererInscrit(string mail) + { + throw new NotImplementedException(); + } + + public IList RecupererOperation(Compte compte) + { + throw new NotImplementedException(); + } + + public IList RecupererPlanification(Compte compte) + { + throw new NotImplementedException(); + } + + public bool SupprimerBanque(Banque banque, Inscrit inscrit) + { + throw new NotImplementedException(); + } + + public bool SupprimerCompte(Compte compte, Inscrit inscrit) + { + throw new NotImplementedException(); + } + + public bool SupprimerEcheance(Compte compte, Echeance echeance) + { + throw new NotImplementedException(); + } + + public bool SupprimerInscrit(Inscrit inscrit) + { + throw new NotImplementedException(); + } + + public bool SupprimerOperation(Compte compte, Operation operation) + { + throw new NotImplementedException(); + } + + public bool SupprimerPlanification(Compte compte, Planification planification) + { + throw new NotImplementedException(); + } + + public bool TestConnexion() { throw new NotImplementedException(); } diff --git a/Sources/IHM/IHM.csproj b/Sources/IHM/IHM.csproj index b512e9e..262fcf6 100644 --- a/Sources/IHM/IHM.csproj +++ b/Sources/IHM/IHM.csproj @@ -57,7 +57,7 @@ - + @@ -169,4 +169,6 @@ + + diff --git a/Sources/IHM/Mobile/MainPage.xaml b/Sources/IHM/Mobile/MainPage.xaml index a245547..e5f143e 100644 --- a/Sources/IHM/Mobile/MainPage.xaml +++ b/Sources/IHM/Mobile/MainPage.xaml @@ -18,7 +18,7 @@ - + - + - +