diff --git a/CitoyenWindow.xaml b/CitoyenWindow.xaml
index 660417f..2b5a2de 100644
--- a/CitoyenWindow.xaml
+++ b/CitoyenWindow.xaml
@@ -37,15 +37,7 @@
-
-
-
-
-
-
-
-
-
+
@@ -69,17 +61,11 @@
-
-
-
-
-
-
-
-
-
+
+
+
diff --git a/CitoyenWindow.xaml.cs b/CitoyenWindow.xaml.cs
index e80c30e..3170e81 100644
--- a/CitoyenWindow.xaml.cs
+++ b/CitoyenWindow.xaml.cs
@@ -49,10 +49,7 @@ namespace Hermes {
public void Save_Click(object sender, RoutedEventArgs e) {
nomTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
- nomNaissanceTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
- prenomTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
ageTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
- adresseTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
if(_isInvalidElements.Count == 0) {
ModelContext dbContext = ModelContext.Getinstance();
if(editRef == null) {
diff --git a/Hermes.csproj b/Hermes.csproj
index 67fe605..9fd4fec 100644
--- a/Hermes.csproj
+++ b/Hermes.csproj
@@ -65,8 +65,9 @@
packages\EntityFramework.SqlServerCompact.6.4.4\lib\net45\EntityFramework.SqlServerCompact.dll
-
- packages\iSendProSMS.1.1.3\lib\isendpro.dll
+
+ packages\Microsoft.Office.Interop.Excel.15.0.4795.1000\lib\net20\Microsoft.Office.Interop.Excel.dll
+ True
packages\Microsoft.Office.Interop.Outlook.15.0.4797.1003\lib\net20\Microsoft.Office.Interop.Outlook.dll
@@ -79,9 +80,6 @@
packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll
-
- packages\RestSharp.Net2.1.1.11\lib\net20\RestSharp.Net2.dll
-
@@ -110,6 +108,9 @@
Designer
+
+ ImportWindow.xaml
+
InputWindow.xaml
@@ -117,10 +118,20 @@
202012051414539_V1.cs
+
+
+ 202012271642572_V2.cs
+
+
+
+ 202012272059415_V3.cs
+
+
+
PreferencesWindow.xaml
@@ -134,6 +145,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
@@ -179,6 +194,12 @@
202012051414539_V1.cs
+
+ 202012271642572_V2.cs
+
+
+ 202012272059415_V3.cs
+
ResXFileCodeGenerator
Resources.Designer.cs
diff --git a/ImportWindow.xaml b/ImportWindow.xaml
new file mode 100644
index 0000000..18cefef
--- /dev/null
+++ b/ImportWindow.xaml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ImportWindow.xaml.cs b/ImportWindow.xaml.cs
new file mode 100644
index 0000000..2dabc5d
--- /dev/null
+++ b/ImportWindow.xaml.cs
@@ -0,0 +1,151 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Runtime.InteropServices;
+using System.Text.RegularExpressions;
+using System.Windows;
+using Hermes.Model;
+using Excel = Microsoft.Office.Interop.Excel;
+
+namespace Hermes {
+ public partial class ImportWindow : Window {
+ private bool importing = false;
+ private Excel.Application xlApp;
+ private Excel.Workbook xlWb;
+ private static Regex communeRgx = new Regex(@"(\d{5})(.*)");
+
+ private static string prepareValue(object value, bool notNull = false) {
+ if(value != null) {
+ return value.ToString().Trim();
+ }
+ if(notNull) {
+ return "";
+ } else {
+ return null;
+ }
+ }
+
+ public ImportWindow(Window parent, string filepath) {
+ InitializeComponent();
+ Owner = parent;
+ List sheets = new List();
+
+ adresseTextBox.Text = Path.GetFileNameWithoutExtension(filepath);
+
+ xlApp = new Excel.Application();
+ xlWb = xlApp.Workbooks.Open(filepath);
+ for(int i = 1; i <= xlWb.Sheets.Count; i++) {
+ Excel.Worksheet sheet = xlWb.Sheets.Item[i];
+ sheets.Add(sheet.Name);
+ }
+ sheetComboBox.ItemsSource = sheets;
+
+ if(sheets.Count == 0) {
+ importButton.IsEnabled = false;
+ } else {
+ sheetComboBox.SelectedIndex = 0;
+ }
+ }
+
+ private void Importer_Click(object sender, RoutedEventArgs e) {
+ importing = true;
+ Excel.Worksheet sheet = xlWb.Sheets.Item[sheetComboBox.SelectedIndex + 1];
+ string cell = prepareValue(sheet.Cells[1, "J"].Value);
+ bool complement = false;
+ string rue = adresseTextBox.Text == null ? "" : adresseTextBox.Text;
+ if(!string.IsNullOrEmpty(cell)) {
+ complement = true;
+ }
+
+ for(int i = 2; string.IsNullOrEmpty(prepareValue(sheet.Cells[i, "A"].Value)) != true ; i++) {
+ Citoyen citoyen = new Citoyen();
+ citoyen.Nom = prepareValue(sheet.Cells[i, "A"].Value);
+ citoyen.Prenom = prepareValue(sheet.Cells[i, "B"].Value);
+ if(complement) {
+ string num = prepareValue(sheet.Cells[i, "D"].Value);
+ if(residenceCheckBox.IsChecked == true) {
+ citoyen.Adresse = rue;
+ citoyen.AdresseNumeroBatiment = num;
+ } else {
+ citoyen.Adresse = $"{num} {rue}";
+ }
+ citoyen.Mail = prepareValue(sheet.Cells[i, "E"].Value);
+ citoyen.Tel = prepareValue(sheet.Cells[i, "F"].Value);
+ if(citoyen.Tel != null) {
+ citoyen.Tel = citoyen.Tel.Replace(".", " ");
+ }
+ citoyen.TelPort = prepareValue(sheet.Cells[i, "G"].Value);
+ if(citoyen.TelPort != null) {
+ citoyen.TelPort = citoyen.TelPort.Replace(".", " ");
+ }
+ string res = prepareValue(sheet.Cells[i, "H"].Value, true);
+ if(res.ToLower().Equals("r.principale")) {
+ citoyen.TypeResidence = false;
+ } else {
+ citoyen.TypeResidence = true;
+ }
+ if(citoyen.TypeResidence == true) {
+ citoyen.AdresseExt = prepareValue(sheet.Cells[i, "I"].Value);
+ Match m = communeRgx.Match(prepareValue(sheet.Cells[i, "J"].Value, true));
+ if(m.Success) {
+ citoyen.AdresseExtCP = m.Groups[1].Value.Trim();
+ citoyen.AdresseExtVille = m.Groups[2].Value.Trim();
+ }
+ }
+ } else {
+ string num = prepareValue(sheet.Cells[i, "C"].Value);
+ if(residenceCheckBox.IsChecked == true) {
+ citoyen.Adresse = rue;
+ citoyen.AdresseNumeroBatiment = num;
+ } else {
+ citoyen.Adresse = $"{num} {rue}";
+ }
+ citoyen.Mail = prepareValue(sheet.Cells[i, "D"].Value);
+ citoyen.Tel = prepareValue(sheet.Cells[i, "E"].Value);
+ if(citoyen.Tel != null) {
+ citoyen.Tel = citoyen.Tel.Replace(".", " ");
+ }
+ citoyen.TelPort = prepareValue(sheet.Cells[i, "F"].Value);
+ if(citoyen.TelPort != null) {
+ citoyen.TelPort = citoyen.TelPort.Replace(".", " ");
+ }
+ string res = prepareValue(sheet.Cells[i, "G"].Value, true);
+ if(res.ToLower().Equals("r.principale")) {
+ citoyen.TypeResidence = false;
+ } else {
+ citoyen.TypeResidence = true;
+ }
+ if(citoyen.TypeResidence == true) {
+ citoyen.AdresseExt = prepareValue(sheet.Cells[i, "H"].Value);
+ Match m = communeRgx.Match(prepareValue(sheet.Cells[i, "I"].Value, true));
+ if(m.Success) {
+ citoyen.AdresseExtCP = m.Groups[1].Value.Trim();
+ citoyen.AdresseExtVille = m.Groups[2].Value.Trim();
+ }
+ }
+ }
+ citoyen.AdresseBatiment = batimentTextBox.Text;
+ citoyen.Quartier = quartierTextBox.Text;
+ citoyen.DateCreation = DateTime.Now;
+ citoyen.DateModification = DateTime.Now;
+ ModelContext.Getinstance().CitoyenSet.Add(citoyen);
+ }
+
+ ModelContext.Getinstance().SaveChanges();
+ Marshal.FinalReleaseComObject(sheet);
+ importing = false;
+ }
+
+ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
+ if(importing) {
+ e.Cancel = true;
+ return;
+ }
+
+ xlWb.Close();
+ Marshal.FinalReleaseComObject(xlWb);
+ xlApp.Quit();
+ Marshal.FinalReleaseComObject(xlApp);
+ }
+ }
+}
diff --git a/Installer/Installer.vdproj b/Installer/Installer.vdproj
index b28d986..ce49657 100644
--- a/Installer/Installer.vdproj
+++ b/Installer/Installer.vdproj
@@ -99,30 +99,12 @@
}
"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"
@@ -166,37 +148,13 @@
"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"
}
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
- "OwnerKey" = "8:_C4AD2B19587A5D3179211CF729B66A33"
- "MsmSig" = "8:_UNDEFINED"
- }
- "Entry"
- {
- "MsmKey" = "8:_UNDEFINED"
- "OwnerKey" = "8:_A0F83BCCDBA77804851DAAE18F54AC65"
+ "OwnerKey" = "8:_EDA497A114444E23814EEE023731C727"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
@@ -287,7 +245,7 @@
"InstallerBootstrapper" = "3:2"
"BootstrapperCfg:{63ACBE69-63AA-4F98-B2B6-99F9E24495F2}"
{
- "Enabled" = "11:TRUE"
+ "Enabled" = "11:FALSE"
"PromptEnabled" = "11:TRUE"
"PrerequisitesLocation" = "2:1"
"Url" = "8:"
@@ -603,37 +561,6 @@
"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"
@@ -654,37 +581,6 @@
"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"
@@ -916,15 +812,15 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:Hermes"
- "ProductCode" = "8:{D2CA66FB-020C-41EF-BD0D-991FFC306669}"
- "PackageCode" = "8:{89CBF16D-49D3-4DE5-9CEE-4CE55ADD05AE}"
+ "ProductCode" = "8:{47E0BBDE-B1C6-4BF8-8164-6E09BD69DBC8}"
+ "PackageCode" = "8:{AC7DFDAB-2DF2-41B7-9066-3253344EBC79}"
"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.1"
+ "ProductVersion" = "8:1.0.0"
"Manufacturer" = "8:Aztrom"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:"
@@ -1466,7 +1362,7 @@
{
"{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_EDA497A114444E23814EEE023731C727"
{
- "SourcePath" = "8:..\\obj\\Debug\\Hermes.exe"
+ "SourcePath" = "8:..\\obj\\Release\\Hermes.exe"
"TargetName" = "8:"
"Tag" = "8:"
"Folder" = "8:_358759A83B6F4CD5AEAA9CCDB02A52A0"
diff --git a/MainWindow.xaml b/MainWindow.xaml
index eb3ff44..5f1f493 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -20,11 +20,13 @@