From 3efd7948a0be827cc3946a4b980e1a6b23d2ae50 Mon Sep 17 00:00:00 2001 From: Valentin VERDIER Date: Sun, 6 Dec 2020 21:54:59 +0100 Subject: [PATCH] Traitement des tickets : #2 , #6 , #7 , #8 --- CitoyenModal.xaml => CitoyenWindow.xaml | 6 +- CitoyenModal.xaml.cs => CitoyenWindow.xaml.cs | 62 +++---- Hermes.csproj | 19 ++- Hermes.sln | 2 + InputWindow.xaml | 25 +++ InputWindow.xaml.cs | 26 +++ Installer/Installer.vdproj | 161 +++++++++++++++++- MainWindow.xaml | 6 +- MainWindow.xaml.cs | 58 +++++-- ...rencesModal.xaml => PreferencesWindow.xaml | 2 +- ...Modal.xaml.cs => PreferencesWindow.xaml.cs | 20 ++- Properties/AssemblyInfo.cs | 4 +- SmsWindow.xaml | 1 - SmsWindow.xaml.cs | 39 ++--- 14 files changed, 320 insertions(+), 111 deletions(-) rename CitoyenModal.xaml => CitoyenWindow.xaml (98%) rename CitoyenModal.xaml.cs => CitoyenWindow.xaml.cs (57%) create mode 100644 InputWindow.xaml create mode 100644 InputWindow.xaml.cs rename PreferencesModal.xaml => PreferencesWindow.xaml (97%) rename PreferencesModal.xaml.cs => PreferencesWindow.xaml.cs (83%) diff --git a/CitoyenModal.xaml b/CitoyenWindow.xaml similarity index 98% rename from CitoyenModal.xaml rename to CitoyenWindow.xaml index 0a3d31a..660417f 100644 --- a/CitoyenModal.xaml +++ b/CitoyenWindow.xaml @@ -1,4 +1,4 @@ - + WindowStartupLocation="CenterOwner"> diff --git a/CitoyenModal.xaml.cs b/CitoyenWindow.xaml.cs similarity index 57% rename from CitoyenModal.xaml.cs rename to CitoyenWindow.xaml.cs index c570c6a..e80c30e 100644 --- a/CitoyenModal.xaml.cs +++ b/CitoyenWindow.xaml.cs @@ -6,30 +6,27 @@ using System.Windows.Controls; using System.Windows.Data; namespace Hermes { - public partial class CitoyenModal : Window { - private ModelContext dbContext = null; - private Citoyen citoyen = null; + public partial class CitoyenWindow : Window { + private Citoyen editRef = null; private List _isInvalidElements = new List(); - private bool _modeCreate = true; - - public static List Civilites = new List(); - - public CitoyenModal() { - dbContext = ModelContext.Getinstance(); - DataContext = new Citoyen(); - Civilites.Add("M"); - Civilites.Add("Mme"); + public CitoyenWindow(Window parent, Citoyen context = null) { InitializeComponent(); - } - private void Window_Loaded(object sender, RoutedEventArgs e) { - civiliteComboBox.ItemsSource = Civilites; - } + DataContext = new Citoyen(); + Owner = parent; - private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { - e.Cancel = true; - this.Hide(); + if(context != null) { + editRef = context; + editRef.Copyto((Citoyen) DataContext); + } else { + ((Citoyen) DataContext).Civilite = "Monsieur"; + } + + List civilites = new List(); + civilites.Add("Monsieur"); + civilites.Add("Madame"); + civiliteComboBox.ItemsSource = civilites; } private void ValidationError(object sender, ValidationErrorEventArgs e) { @@ -50,20 +47,6 @@ namespace Hermes { } } - public void EnableCreateMode() { - DataContext = new Citoyen(); - civiliteComboBox.SelectedIndex = 0; - _modeCreate = true; - } - - public void EnableEditMode(Citoyen citoyen) { - this.citoyen = citoyen; - Citoyen citoyenContext = new Citoyen(); - this.citoyen.Copyto(citoyenContext); - DataContext = citoyenContext; - _modeCreate = false; - } - public void Save_Click(object sender, RoutedEventArgs e) { nomTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource(); nomNaissanceTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource(); @@ -71,25 +54,22 @@ namespace Hermes { ageTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource(); adresseTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource(); if(_isInvalidElements.Count == 0) { - if(_modeCreate) { + ModelContext dbContext = ModelContext.Getinstance(); + if(editRef == null) { ((Citoyen) DataContext).DateCreation = DateTime.Now; ((Citoyen) DataContext).DateModification = DateTime.Now; dbContext.CitoyenSet.Add((Citoyen) DataContext); } else { - Citoyen citoyenContext = (Citoyen) DataContext; - citoyenContext.Copyto(citoyen); - citoyen.DateModification = DateTime.Now; - citoyen = null; + Citoyen context = (Citoyen) DataContext; + context.Copyto(editRef); + editRef.DateModification = DateTime.Now; } - DataContext = null; dbContext.SaveChanges(); Close(); } } public void Cancel_Click(object sender, RoutedEventArgs e) { - DataContext = null; - citoyen = null; Close(); } } diff --git a/Hermes.csproj b/Hermes.csproj index 398884d..67fe605 100644 --- a/Hermes.csproj +++ b/Hermes.csproj @@ -110,6 +110,9 @@ Designer + + InputWindow.xaml + 202012051414539_V1.cs @@ -118,8 +121,8 @@ - - PreferencesModal.xaml + + PreferencesWindow.xaml @@ -127,7 +130,11 @@ - + + Designer + MSBuild:Compile + + Designer MSBuild:Compile @@ -139,14 +146,14 @@ App.xaml Code - - CitoyenModal.xaml + + CitoyenWindow.xaml MainWindow.xaml Code - + Designer MSBuild:Compile diff --git a/Hermes.sln b/Hermes.sln index 42a0d99..c1d4eb3 100644 --- a/Hermes.sln +++ b/Hermes.sln @@ -18,7 +18,9 @@ Global {2F7FDF03-5F05-438E-9C90-F926B40DCC6D}.Release|Any CPU.ActiveCfg = Release|Any CPU {2F7FDF03-5F05-438E-9C90-F926B40DCC6D}.Release|Any CPU.Build.0 = Release|Any CPU {F2D85CBF-A3A1-41CE-BE80-502C0DD4024D}.Debug|Any CPU.ActiveCfg = Debug + {F2D85CBF-A3A1-41CE-BE80-502C0DD4024D}.Debug|Any CPU.Build.0 = Debug {F2D85CBF-A3A1-41CE-BE80-502C0DD4024D}.Release|Any CPU.ActiveCfg = Release + {F2D85CBF-A3A1-41CE-BE80-502C0DD4024D}.Release|Any CPU.Build.0 = Release EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/InputWindow.xaml b/InputWindow.xaml new file mode 100644 index 0000000..12b2073 --- /dev/null +++ b/InputWindow.xaml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + diff --git a/InputWindow.xaml.cs b/InputWindow.xaml.cs new file mode 100644 index 0000000..23a326c --- /dev/null +++ b/InputWindow.xaml.cs @@ -0,0 +1,26 @@ +using System.Windows; + +namespace Hermes { + public partial class InputWindow : Window { + private string inputText = null; + + public InputWindow(string title, string message, Window parent) { + InitializeComponent(); + msgTextBlock.Text = message; + Title = title; + Owner = parent; + } + + private void Valider_Click(object sender, RoutedEventArgs e) { + inputText = inputTextBox.Text; + DialogResult = true; + Close(); + } + + private void Annuler_Click(object sender, RoutedEventArgs e) { + Close(); + } + + public string InputText => inputText; + } +} diff --git a/Installer/Installer.vdproj b/Installer/Installer.vdproj index 7492d94..b28d986 100644 --- a/Installer/Installer.vdproj +++ b/Installer/Installer.vdproj @@ -99,12 +99,30 @@ } "Entry" { + "MsmKey" = "8:_A0F83BCCDBA77804851DAAE18F54AC65" + "OwnerKey" = "8:_C4AD2B19587A5D3179211CF729B66A33" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_A0F83BCCDBA77804851DAAE18F54AC65" + "OwnerKey" = "8:_EDA497A114444E23814EEE023731C727" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { "MsmKey" = "8:_A3A39C8B97A947A09D3B1660AC88FF5E" "OwnerKey" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED" } "Entry" { + "MsmKey" = "8:_C4AD2B19587A5D3179211CF729B66A33" + "OwnerKey" = "8:_EDA497A114444E23814EEE023731C727" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { "MsmKey" = "8:_C767BE5A43214C2C9E31CD47DB92AA96" "OwnerKey" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED" @@ -147,6 +165,24 @@ } "Entry" { + "MsmKey" = "8:_F434633E0B073F068C7E19B9E5AB2EC4" + "OwnerKey" = "8:_C4AD2B19587A5D3179211CF729B66A33" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_F434633E0B073F068C7E19B9E5AB2EC4" + "OwnerKey" = "8:_EDA497A114444E23814EEE023731C727" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_F434633E0B073F068C7E19B9E5AB2EC4" + "OwnerKey" = "8:_A0F83BCCDBA77804851DAAE18F54AC65" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { "MsmKey" = "8:_UNDEFINED" "OwnerKey" = "8:_EDA497A114444E23814EEE023731C727" "MsmSig" = "8:_UNDEFINED" @@ -154,6 +190,24 @@ "Entry" { "MsmKey" = "8:_UNDEFINED" + "OwnerKey" = "8:_C4AD2B19587A5D3179211CF729B66A33" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_UNDEFINED" + "OwnerKey" = "8:_A0F83BCCDBA77804851DAAE18F54AC65" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_UNDEFINED" + "OwnerKey" = "8:_F434633E0B073F068C7E19B9E5AB2EC4" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_UNDEFINED" "OwnerKey" = "8:_F0A5B43231BDF6E8358EE22CD3E2D5F2" "MsmSig" = "8:_UNDEFINED" } @@ -208,10 +262,10 @@ "ComponentsUrl" = "8:" "Items" { - "{EDC2488A-8267-493A-A98E-7D9C3B36CDF3}:.NETFramework,Version=v4.7.2" + "{EDC2488A-8267-493A-A98E-7D9C3B36CDF3}:.NETFramework,Version=v4.8" { - "Name" = "8:Microsoft .NET Framework 4.7.2 (x86 and x64)" - "ProductCode" = "8:.NETFramework,Version=v4.7.2" + "Name" = "8:Microsoft .NET Framework 4.8 (x86 et x64)" + "ProductCode" = "8:.NETFramework,Version=v4.8" } } } @@ -549,6 +603,37 @@ "IsDependency" = "11:FALSE" "IsolateTo" = "8:" } + "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_A0F83BCCDBA77804851DAAE18F54AC65" + { + "AssemblyRegister" = "3:1" + "AssemblyIsInGAC" = "11:FALSE" + "AssemblyAsmDisplayName" = "8:RestSharp.Net2, Version=102.7.0.0, Culture=neutral, processorArchitecture=MSIL" + "ScatterAssemblies" + { + "_A0F83BCCDBA77804851DAAE18F54AC65" + { + "Name" = "8:RestSharp.Net2.dll" + "Attributes" = "3:512" + } + } + "SourcePath" = "8:RestSharp.Net2.dll" + "TargetName" = "8:" + "Tag" = "8:" + "Folder" = "8:_358759A83B6F4CD5AEAA9CCDB02A52A0" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:TRUE" + "IsolateTo" = "8:" + } "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_A3A39C8B97A947A09D3B1660AC88FF5E" { "SourcePath" = "8:..\\bin\\Release\\amd64\\sqlcecompact40.dll" @@ -569,6 +654,37 @@ "IsDependency" = "11:FALSE" "IsolateTo" = "8:" } + "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_C4AD2B19587A5D3179211CF729B66A33" + { + "AssemblyRegister" = "3:1" + "AssemblyIsInGAC" = "11:FALSE" + "AssemblyAsmDisplayName" = "8:isendpro, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL" + "ScatterAssemblies" + { + "_C4AD2B19587A5D3179211CF729B66A33" + { + "Name" = "8:isendpro.dll" + "Attributes" = "3:512" + } + } + "SourcePath" = "8:isendpro.dll" + "TargetName" = "8:" + "Tag" = "8:" + "Folder" = "8:_358759A83B6F4CD5AEAA9CCDB02A52A0" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:TRUE" + "IsolateTo" = "8:" + } "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_C767BE5A43214C2C9E31CD47DB92AA96" { "SourcePath" = "8:..\\bin\\Release\\amd64\\sqlceqp40.dll" @@ -691,6 +807,37 @@ "IsDependency" = "11:TRUE" "IsolateTo" = "8:" } + "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_F434633E0B073F068C7E19B9E5AB2EC4" + { + "AssemblyRegister" = "3:1" + "AssemblyIsInGAC" = "11:FALSE" + "AssemblyAsmDisplayName" = "8:Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL" + "ScatterAssemblies" + { + "_F434633E0B073F068C7E19B9E5AB2EC4" + { + "Name" = "8:Newtonsoft.Json.dll" + "Attributes" = "3:512" + } + } + "SourcePath" = "8:Newtonsoft.Json.dll" + "TargetName" = "8:" + "Tag" = "8:" + "Folder" = "8:_358759A83B6F4CD5AEAA9CCDB02A52A0" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:TRUE" + "IsolateTo" = "8:" + } } "FileType" { @@ -769,15 +916,15 @@ { "Name" = "8:Microsoft Visual Studio" "ProductName" = "8:Hermes" - "ProductCode" = "8:{458A9AC9-956F-44DC-86F1-6C59FCEC0001}" - "PackageCode" = "8:{C3692850-4A0E-43FE-B6D1-0FFE749C3562}" + "ProductCode" = "8:{D2CA66FB-020C-41EF-BD0D-991FFC306669}" + "PackageCode" = "8:{89CBF16D-49D3-4DE5-9CEE-4CE55ADD05AE}" "UpgradeCode" = "8:{A8FB75F3-57A5-4B7D-A0AE-9E87F69529B0}" "AspNetVersion" = "8:2.0.50727.0" "RestartWWWService" = "11:FALSE" "RemovePreviousVersions" = "11:TRUE" "DetectNewerInstalledVersion" = "11:TRUE" "InstallAllUsers" = "11:FALSE" - "ProductVersion" = "8:0.9.0" + "ProductVersion" = "8:0.9.1" "Manufacturer" = "8:Aztrom" "ARPHELPTELEPHONE" = "8:" "ARPHELPLINK" = "8:" @@ -1319,7 +1466,7 @@ { "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_EDA497A114444E23814EEE023731C727" { - "SourcePath" = "8:..\\obj\\Release\\Hermes.exe" + "SourcePath" = "8:..\\obj\\Debug\\Hermes.exe" "TargetName" = "8:" "Tag" = "8:" "Folder" = "8:_358759A83B6F4CD5AEAA9CCDB02A52A0" diff --git a/MainWindow.xaml b/MainWindow.xaml index 112af4c..bb136b1 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -22,8 +22,12 @@ - + + + + + diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 014764e..dff6313 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -12,9 +12,6 @@ using Microsoft.Win32; namespace Hermes { public partial class MainWindow : Window { private ModelContext dbContext = null; - private CitoyenModal citoyenModal = new CitoyenModal(); - private PreferencesModal preferencesModal = new PreferencesModal(); - private SmsWindow smsModal = new SmsWindow(); private CollectionViewSource citoyenCollectionViewSource = null; private bool isEnabledFilter = false; @@ -27,9 +24,6 @@ namespace Hermes { } private void Window_Loaded(object sender, RoutedEventArgs e) { - citoyenModal.Owner = this; - preferencesModal.Owner = this; - smsModal.Owner = this; dbContext.CitoyenSet.Load(); dbContext.Preferences.Load(); citoyenCollectionViewSource = (CollectionViewSource) this.FindResource("citoyenCollectionViewSource"); @@ -37,19 +31,51 @@ namespace Hermes { if(dbContext.Preferences.Local.Count == 0) { MessageBox.Show("Il s'agit du premier lancement de Hermes. Veuillez renseigner les informations sur votre commune.", "Premier lancement", MessageBoxButton.OK, MessageBoxImage.None); - preferencesModal.LoadPreferences(); - preferencesModal.ShowDialog(); + PreferencesWindow preferencesWindow = new PreferencesWindow(this); + preferencesWindow.ShowDialog(); } } private void Options_Click(object sender, RoutedEventArgs e) { - preferencesModal.LoadPreferences(); - preferencesModal.ShowDialog(); + PreferencesWindow preferencesWindow = new PreferencesWindow(this); + preferencesWindow.ShowDialog(); } private void Ajouter_Click(object sender, RoutedEventArgs e) { - citoyenModal.EnableCreateMode(); - citoyenModal.ShowDialog(); + CitoyenWindow citoyenWindow = new CitoyenWindow(this); + citoyenWindow.ShowDialog(); + } + + private void GroupEdit_Batiment(object sender, RoutedEventArgs e) { + if(dgCitoyens.SelectedItems.Count == 0) { + MessageBox.Show("Aucun citoyen sélectionné", "Édition groupée", MessageBoxButton.OK, MessageBoxImage.Exclamation); + return; + } + + InputWindow inputBox = new InputWindow("Associer un bâtiment :", "Entrez le nom d'un bâtiment :", this); + if(inputBox.ShowDialog() == true) { + foreach(Citoyen citoyen in dgCitoyens.SelectedItems) { + citoyen.AdresseBatiment = inputBox.InputText; + citoyen.DateModification = DateTime.Now; + } + dbContext.SaveChanges(); + } + } + + private void GroupEdit_Quartier(object sender, RoutedEventArgs e) { + if(dgCitoyens.SelectedItems.Count == 0) { + MessageBox.Show("Aucun citoyen sélectionné", "Édition groupée", MessageBoxButton.OK, MessageBoxImage.Exclamation); + return; + } + + InputWindow inputBox = new InputWindow("Associer un quartier :", "Entrez le nom d'un quartier :", this); + if(inputBox.ShowDialog() == true) { + foreach(Citoyen citoyen in dgCitoyens.SelectedItems) { + citoyen.Quartier = inputBox.InputText; + citoyen.DateModification = DateTime.Now; + } + dbContext.SaveChanges(); + } } private void Supprimer_Click(object sender, RoutedEventArgs e) { @@ -87,8 +113,8 @@ namespace Hermes { if(noTel) { MessageBox.Show("Certains des citoyens sélectionnés ne disposent pas d'un numéro de mobile", "Envoi de SMS", MessageBoxButton.OK, MessageBoxImage.Exclamation); } - smsModal.LoadCitoyens(rcps); - smsModal.ShowDialog(); + SmsWindow smsWindow = new SmsWindow(this, rcps); + smsWindow.ShowDialog(); } else { MessageBox.Show("Aucun des citoyens sélectionnés ne disposent d'un numéro de mobile", "Envoi de SMS", MessageBoxButton.OK, MessageBoxImage.Exclamation); } @@ -183,8 +209,8 @@ namespace Hermes { private void DgCitoyen_DoubleClick(object sender, MouseButtonEventArgs e) { if(dgCitoyens.SelectedItem != null) { - citoyenModal.EnableEditMode((Citoyen) dgCitoyens.SelectedItem); - citoyenModal.ShowDialog(); + CitoyenWindow citoyenWindow = new CitoyenWindow(this, (Citoyen) dgCitoyens.SelectedItem); + citoyenWindow.ShowDialog(); } } diff --git a/PreferencesModal.xaml b/PreferencesWindow.xaml similarity index 97% rename from PreferencesModal.xaml rename to PreferencesWindow.xaml index 9c52eff..f71ca7b 100644 --- a/PreferencesModal.xaml +++ b/PreferencesWindow.xaml @@ -1,4 +1,4 @@ - 0) { Preferences pref = dbContext.Preferences.Local[0]; villeTextBox.Text = pref.Ville; @@ -25,6 +20,13 @@ namespace Hermes { } } + private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { + if(dbContext.Preferences.Local.Count == 0) { + MessageBox.Show("La saisie d'information sur la commune est obligatoire.", "Saisie obligatoire", MessageBoxButton.OK, MessageBoxImage.Warning); + e.Cancel = true; + } + } + public void Enregistrer_Click(object sender, RoutedEventArgs e) { if(String.IsNullOrWhiteSpace(villeCPTextBox.Text) || String.IsNullOrWhiteSpace(villeTextBox.Text)) { MessageBox.Show("La saisie d'information sur la commune est obligatoire.", "Saisie obligatoire", MessageBoxButton.OK, MessageBoxImage.Warning); diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index cdeefc7..4619c6a 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -51,6 +51,6 @@ using System.Windows; // Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut // en utilisant '*', comme indiqué ci-dessous : // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.9.0.0")] -[assembly: AssemblyFileVersion("0.9.0.0")] +[assembly: AssemblyVersion("0.9.1.0")] +[assembly: AssemblyFileVersion("0.9.1.0")] [assembly: NeutralResourcesLanguage("fr-FR")] diff --git a/SmsWindow.xaml b/SmsWindow.xaml index a84e1f1..eb4bed0 100644 --- a/SmsWindow.xaml +++ b/SmsWindow.xaml @@ -8,7 +8,6 @@ ResizeMode="NoResize" Title="Envoi de SMS" Height="490" Width="700" WindowStartupLocation="CenterOwner" - Loaded="Window_Loaded" Closing="Window_Closing"> diff --git a/SmsWindow.xaml.cs b/SmsWindow.xaml.cs index 3170963..8c9c0bb 100644 --- a/SmsWindow.xaml.cs +++ b/SmsWindow.xaml.cs @@ -12,43 +12,33 @@ using System.Windows.Documents; namespace Hermes { public partial class SmsWindow : Window { private ObservableCollection status = new ObservableCollection(); - private ModelContext dbContext = null; - private ApiClient apiClient = new ApiClient(); - private SmsApi smsApi = null; private bool sending = false; - public SmsWindow() { - dbContext = ModelContext.Getinstance(); - smsApi = new SmsApi(apiClient); + public SmsWindow(Window parent, List rcps) { InitializeComponent(); - } + Owner = parent; + + foreach(Citoyen rcp in rcps) { + SmsSendingStatus s = new SmsSendingStatus(); + s.Nom = rcp.Nom; + s.Prenom = rcp.Prenom; + s.Mobile = rcp.TelPort.Replace(" ", ""); + s.Status = "En attente"; + status.Add(s); + } - private void Window_Loaded(object sender, RoutedEventArgs e) { lvLog.ItemsSource = status; } private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { - e.Cancel = true; if(sending) { + e.Cancel = true; return; } - messageTextBox.Document.Blocks.Clear(); - status.Clear(); - this.Hide(); - } - - public void LoadCitoyens(List citoyens) { - foreach(Citoyen citoyen in citoyens) { - SmsSendingStatus s = new SmsSendingStatus(); - s.Nom = citoyen.Nom; - s.Prenom = citoyen.Prenom; - s.Mobile = citoyen.TelPort.Replace(" ", ""); - s.Status = "En attente"; - status.Add(s); - } } public void Envoyer_Click(object sender, RoutedEventArgs e) { + ModelContext dbContext = ModelContext.Getinstance(); bool error = false; string message = new TextRange(messageTextBox.Document.ContentStart, messageTextBox.Document.ContentEnd).Text; string apiKey = dbContext.Preferences.Local[0].SmsApiKey; @@ -68,6 +58,9 @@ namespace Hermes { messageTextBox.IsEnabled = false; sending = true; + ApiClient apiClient = new ApiClient(); + SmsApi smsApi = new SmsApi(apiClient); + foreach(SmsSendingStatus stat in status) { if(!stat.Status.Equals("Envoyé")) { SmsUniqueRequest req = new SmsUniqueRequest();