diff --git a/README.md b/README.md
index 4d1c84d..0face04 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# Cons'Eco
[![Build Status](https://codefirst.iut.uca.fr/api/badges/hugo.livet/ConsEco/status.svg)](https://codefirst.iut.uca.fr/hugo.livet/ConsEco)
-[![Csharp](https://img.shields.io/badge/-CSharp-50C878?style=for-the-badge&logo=csharp)](https://learn.microsoft.com/fr-fr/dotnet/csharp/) [![Xaml](https://img.shields.io/badge/-XAML-6495ED?style=for-the-badge&logo=xaml)](https://learn.microsoft.com/fr-fr/dotnet/desktop/wpf/xaml/?view=netdesktop-6.0) [![.NET/MAUI](https://img.shields.io/badge/-.NET/WPF-B87333?style=for-the-badge&logo=dotnet)](https://learn.microsoft.com/fr-fr/dotnet/maui/what-is-maui?view=net-maui-7.0)
+[![Csharp](https://img.shields.io/badge/-CSharp-50C878?style=for-the-badge&logo=csharp)](https://learn.microsoft.com/fr-fr/dotnet/csharp/) [![Xaml](https://img.shields.io/badge/-XAML-6495ED?style=for-the-badge&logo=xaml)](https://learn.microsoft.com/fr-fr/dotnet/desktop/wpf/xaml/?view=netdesktop-6.0) [![.NET/WPF](https://img.shields.io/badge/-.NET/WPF-B87333?style=for-the-badge&logo=dotnet)](https://learn.microsoft.com/fr-fr/dotnet/desktop/wpf/?view=netdesktop-6.0)
diff --git a/Sources/Data/PersLinqToPgSQL.cs b/Sources/Data/PersLinqToPgSQL.cs
index 2927b13..d6fa114 100644
--- a/Sources/Data/PersLinqToPgSQL.cs
+++ b/Sources/Data/PersLinqToPgSQL.cs
@@ -13,14 +13,34 @@ using System.Threading;
using Model;
using System.Runtime.CompilerServices;
using System.Data.Common;
+using System.Reflection.PortableExecutable;
namespace LinqToPgSQL
{
public class PersLinqToPgSQL : IPersistanceManager
{
private Hash hash = new Hash();
- string connexionBDD = String.Format("Server=90.114.135.116; Username=postgres; Database=conseco; Port=5432; Password=lulu; SSLMode=Prefer");
-
+ 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);
+ public bool TestConnexionAsDatabase()
+ {
+ bool isOk = true;
+ try
+ {
+ dbAccess.Open();
+ }
+ catch(NpgsqlException ex)
+ {
+ isOk = false;
+ Debug.WriteLine("Problème de connection à la base de données. - " + ex.Message);
+ }
+ finally
+ {
+ dbAccess.Close();
+ }
+ return isOk;
+ }
+
public string LoadInscrit(string id, string mdp)
{
int resultat=0;
@@ -53,7 +73,11 @@ namespace LinqToPgSQL
{
var conn = new NpgsqlConnection(connexionBDD);
Console.Out.WriteLine("Ouverture de la connection");
- try
+
+ conn.Open();
+
+
+ /*try
{
conn.Open();
}
@@ -62,7 +86,7 @@ namespace LinqToPgSQL
conn.Close();
Debug.WriteLine("Problème de connection à la base de données. Aprés fermeture, l'application se fermera automatiquement.");
Environment.Exit(-1);
- }
+ }*/
NpgsqlDataReader dbReader = new NpgsqlCommand("SELECT mail FROM Inscrit", conn).ExecuteReader();
@@ -335,5 +359,22 @@ namespace LinqToPgSQL
// attente des autres supression
}
+
+ public IList
ImportBanques()
+ {
+ IList bquesDispo = new List();
+ dbAccess.Open();
+
+ NpgsqlCommand cmd = new NpgsqlCommand($"SELECT * FROM Banque", dbAccess);
+ NpgsqlDataReader dbReader = cmd.ExecuteReader();
+ while (dbReader.Read())
+ {
+ bquesDispo.Add(new Banque(dbReader.GetString(0), dbReader.GetString(1), dbReader.GetString(2)));
+ }
+ dbAccess.Close();
+ return bquesDispo;
+ }
+
+
}
}
\ No newline at end of file
diff --git a/Sources/IHM/AppShell.xaml b/Sources/IHM/AppShell.xaml
index f5e6baf..87ab094 100644
--- a/Sources/IHM/AppShell.xaml
+++ b/Sources/IHM/AppShell.xaml
@@ -7,11 +7,6 @@
Shell.FlyoutBehavior="Disabled"
Shell.NavBarIsVisible="False">
-
-
+
+
+
+
+
+
diff --git a/Sources/IHM/AppShell.xaml.cs b/Sources/IHM/AppShell.xaml.cs
index e82d776..1001ddd 100644
--- a/Sources/IHM/AppShell.xaml.cs
+++ b/Sources/IHM/AppShell.xaml.cs
@@ -14,12 +14,16 @@ namespace IHM
Routing.RegisterRoute("Inscription", typeof(Inscription));
Routing.RegisterRoute("ForgetPassword", typeof(ForgetPassword));
Routing.RegisterRoute("ChangePassword", typeof(ChangePassword));
+ Routing.RegisterRoute("GestionBanques", typeof(GestionBanques));
+ Routing.RegisterRoute("AjoutBanques", typeof(AjoutBanques));
+
+ Routing.RegisterRoute("ErrorPage", typeof(ErrorPage));
+
-
}
-
-
-
+
+
+
}
}
\ No newline at end of file
diff --git a/Sources/IHM/Composant/BanqueDispo.xaml b/Sources/IHM/Composant/BanqueDispo.xaml
new file mode 100644
index 0000000..cce516c
--- /dev/null
+++ b/Sources/IHM/Composant/BanqueDispo.xaml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Sources/IHM/Composant/BanqueDispo.xaml.cs b/Sources/IHM/Composant/BanqueDispo.xaml.cs
new file mode 100644
index 0000000..127c945
--- /dev/null
+++ b/Sources/IHM/Composant/BanqueDispo.xaml.cs
@@ -0,0 +1,23 @@
+namespace IHM.Composant;
+
+public partial class BanqueDispo : ViewCell
+{
+ public BanqueDispo()
+ {
+ InitializeComponent();
+ }
+
+ public static readonly BindableProperty ImageBanqueProperty =
+ BindableProperty.Create("ImageBanque", typeof(string), typeof(BanqueDispo), "");
+
+ public string ImageBanque
+ {
+ get { return (string)GetValue(ImageBanqueProperty); }
+ set { SetValue(ImageBanqueProperty, value); }
+ }
+
+ private void Banque_Clicked(object sender, EventArgs e)
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/Sources/IHM/Composant/BanqueVC.xaml b/Sources/IHM/Composant/BanqueVC.xaml
new file mode 100644
index 0000000..ed21f6b
--- /dev/null
+++ b/Sources/IHM/Composant/BanqueVC.xaml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Sources/IHM/Composant/BanqueVC.xaml.cs b/Sources/IHM/Composant/BanqueVC.xaml.cs
new file mode 100644
index 0000000..73f8023
--- /dev/null
+++ b/Sources/IHM/Composant/BanqueVC.xaml.cs
@@ -0,0 +1,32 @@
+namespace IHM.Composant;
+
+public partial class BanqueVC : ViewCell
+{
+ public BanqueVC()
+ {
+ InitializeComponent();
+ }
+
+ public static readonly BindableProperty NomBanqueProperty =
+ BindableProperty.Create("NomBanque", typeof(string), typeof(BanqueVC), "");
+
+ public string NomBanque
+ {
+ get { return (string)GetValue(NomBanqueProperty); }
+ set { SetValue(NomBanqueProperty, value); }
+ }
+
+ public static readonly BindableProperty DateLastReloadProperty =
+ BindableProperty.Create("DateLastReload", typeof(string), typeof(BanqueVC), "");
+
+ public string DateLastReload
+ {
+ get { return (string)GetValue(DateLastReloadProperty); }
+ set { SetValue(DateLastReloadProperty, value); }
+ }
+
+ private void MaBanque_Clicked(object sender, EventArgs e)
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/Sources/IHM/IHM.csproj b/Sources/IHM/IHM.csproj
index 768f160..ca89c1b 100644
--- a/Sources/IHM/IHM.csproj
+++ b/Sources/IHM/IHM.csproj
@@ -35,6 +35,12 @@
PreserveNewest
+
+ PreserveNewest
+
+
+ PreserveNewest
+
@@ -61,6 +67,7 @@
+
@@ -85,6 +92,9 @@
MainPage.xaml
+
+ ErrorPage.xaml
+
@@ -94,9 +104,24 @@
MSBuild:Compile
+
+ MSBuild:Compile
+
+
+ MSBuild:Compile
+
MSBuild:Compile
+
+ MSBuild:Compile
+
+
+ MSBuild:Compile
+
+
+ MSBuild:Compile
+
MSBuild:Compile
diff --git a/Sources/IHM/Mobile/AjoutBanques.xaml b/Sources/IHM/Mobile/AjoutBanques.xaml
new file mode 100644
index 0000000..6e7f411
--- /dev/null
+++ b/Sources/IHM/Mobile/AjoutBanques.xaml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Sources/IHM/Mobile/AjoutBanques.xaml.cs b/Sources/IHM/Mobile/AjoutBanques.xaml.cs
new file mode 100644
index 0000000..cb1a297
--- /dev/null
+++ b/Sources/IHM/Mobile/AjoutBanques.xaml.cs
@@ -0,0 +1,9 @@
+namespace IHM.Mobile;
+
+public partial class AjoutBanques : ContentPage
+{
+ public AjoutBanques()
+ {
+ InitializeComponent();
+ }
+}
\ No newline at end of file
diff --git a/Sources/IHM/Mobile/Dashboard.xaml b/Sources/IHM/Mobile/Dashboard.xaml
index b59756e..b4a674f 100644
--- a/Sources/IHM/Mobile/Dashboard.xaml
+++ b/Sources/IHM/Mobile/Dashboard.xaml
@@ -21,10 +21,11 @@
-
+ BackgroundColor="{StaticResource Primary}"
+ Clicked="Banques_Clicked"/>
diff --git a/Sources/IHM/Mobile/Dashboard.xaml.cs b/Sources/IHM/Mobile/Dashboard.xaml.cs
index 1fc73a5..a6fc1ea 100644
--- a/Sources/IHM/Mobile/Dashboard.xaml.cs
+++ b/Sources/IHM/Mobile/Dashboard.xaml.cs
@@ -13,15 +13,25 @@ public partial class DashBoard : ContentPage
if (Mgr.SelectedInscrit == null)
{
- loadInscription();
+ loadPage(new MainPage());
+
}
-
+ if (!Mgr.testConnexionAsDatabase())
+ {
+ loadPage(new ErrorPage());
+
+ }
}
- public async void loadInscription()
+ public async void loadPage(Page p)
+ {
+ await Navigation.PushModalAsync(p);
+ }
+
+ private void Banques_Clicked(object sender, EventArgs e)
{
- await Navigation.PushModalAsync(new MainPage());
+ loadPage(new GestionBanques());
}
}
\ No newline at end of file
diff --git a/Sources/IHM/Mobile/ErrorPage.xaml b/Sources/IHM/Mobile/ErrorPage.xaml
new file mode 100644
index 0000000..96b64d6
--- /dev/null
+++ b/Sources/IHM/Mobile/ErrorPage.xaml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Sources/IHM/Mobile/ErrorPage.xaml.cs b/Sources/IHM/Mobile/ErrorPage.xaml.cs
new file mode 100644
index 0000000..711e406
--- /dev/null
+++ b/Sources/IHM/Mobile/ErrorPage.xaml.cs
@@ -0,0 +1,46 @@
+using Model;
+using System.Diagnostics;
+
+namespace IHM.Mobile;
+
+public partial class ErrorPage : ContentPage
+{
+ public Manager Mgr => (App.Current as App).Manager;
+
+ public const int TIME_TEST_DB = 15000;
+
+ public ErrorPage()
+ {
+ InitializeComponent();
+ startTestConnexion();
+ }
+
+ protected override bool OnBackButtonPressed()
+ {
+ return true;
+ }
+
+ public void conIsActive()
+ {
+ while (!Mgr.testConnexionAsDatabase())
+ {
+ Thread.Sleep(TIME_TEST_DB);
+ }
+
+ ConnexionValide();
+ return;
+ }
+
+ public void startTestConnexion()
+ {
+ Task testConnexion = new Task(() => conIsActive());
+ testConnexion.Start();
+ }
+
+ private async void ConnexionValide()
+ {
+ await Navigation.PopModalAsync();
+ }
+
+
+}
\ No newline at end of file
diff --git a/Sources/IHM/Mobile/GestionBanques.xaml b/Sources/IHM/Mobile/GestionBanques.xaml
new file mode 100644
index 0000000..78d9348
--- /dev/null
+++ b/Sources/IHM/Mobile/GestionBanques.xaml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Sources/IHM/Mobile/GestionBanques.xaml.cs b/Sources/IHM/Mobile/GestionBanques.xaml.cs
new file mode 100644
index 0000000..3dc2a99
--- /dev/null
+++ b/Sources/IHM/Mobile/GestionBanques.xaml.cs
@@ -0,0 +1,16 @@
+using Model;
+
+namespace IHM.Mobile;
+
+public partial class GestionBanques : ContentPage
+{
+ public Manager Mgr => (App.Current as App).Manager;
+
+ public GestionBanques()
+ {
+ InitializeComponent();
+ BindingContext= Mgr;
+ //Mgr.BanquesDisponibleInApp=Mgr.importBanques();
+
+ }
+}
\ No newline at end of file
diff --git a/Sources/IHM/Mobile/MainPage.xaml.cs b/Sources/IHM/Mobile/MainPage.xaml.cs
index e507f48..ab1ae77 100644
--- a/Sources/IHM/Mobile/MainPage.xaml.cs
+++ b/Sources/IHM/Mobile/MainPage.xaml.cs
@@ -12,9 +12,11 @@ namespace IHM.Mobile
BindingContext = this;
}
+
+
public void ConnectionOnClicked(object sender, EventArgs e)
{
- if(EntryMail.Text == null || EntryPassworld.Text == null)
+ if (EntryMail.Text == null || EntryPassworld.Text == null)
{
AffichError("Champ invalide", "Veuillez compléter tout les champs", "OK");
}
diff --git a/Sources/IHM/Resources/Images/GestionBanques/reload_banks.png b/Sources/IHM/Resources/Images/GestionBanques/reload_banks.png
new file mode 100644
index 0000000..14e8c00
Binary files /dev/null and b/Sources/IHM/Resources/Images/GestionBanques/reload_banks.png differ
diff --git a/Sources/Modele/IPersistanceManager.cs b/Sources/Modele/IPersistanceManager.cs
index 207b624..8a6b3c1 100644
--- a/Sources/Modele/IPersistanceManager.cs
+++ b/Sources/Modele/IPersistanceManager.cs
@@ -17,5 +17,7 @@ namespace Model
bool ExistEmail(string mail);
void ChangePasswordBdd(string mail, string newMdp);
string RecupMdpBdd(string mail);
+ bool TestConnexionAsDatabase();
+ public IList ImportBanques();
}
}
diff --git a/Sources/Modele/Manager.cs b/Sources/Modele/Manager.cs
index f771a24..66d61c9 100644
--- a/Sources/Modele/Manager.cs
+++ b/Sources/Modele/Manager.cs
@@ -1,4 +1,5 @@
-using System.ComponentModel;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
namespace Model
{
@@ -25,6 +26,8 @@ namespace Model
}
private Banque selectedBanque;
+ public ObservableCollection BanquesDisponibleInApp { get; set; } = new ObservableCollection();
+
void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
public Manager(IPersistanceManager persistance)
@@ -76,6 +79,16 @@ namespace Model
{
return hash.IsEqualHash(mdpBdd, mdpSent);
}
+
+ public bool testConnexionAsDatabase()
+ {
+ return Pers.TestConnexionAsDatabase();
+ }
+
+ public IList importBanques()
+ {
+ return Pers.ImportBanques();
+ }
}
}
diff --git a/Sources/Modele/Stub.cs b/Sources/Modele/Stub.cs
index 91a19d0..8b1acd3 100644
--- a/Sources/Modele/Stub.cs
+++ b/Sources/Modele/Stub.cs
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Model
{
- public class Stub
+ public class Stub //la classe n'implémante pas IPersistanceManager
{
public List Banques = new();
public List Inscrits = new();