Restructuration de la fonction d'envoi de SMS

This commit is contained in:
Valentin Verdier 2020-12-05 18:47:13 +01:00
parent e860a03047
commit c945890625
11 changed files with 241 additions and 53 deletions

View File

@ -2,77 +2,77 @@
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework"
type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false"/>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
<entityFramework>
<providers>
<provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact"/>
<provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" />
</providers>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
<parameters>
<parameter value="System.Data.SqlServerCe.4.0"/>
<parameter value="System.Data.SqlServerCe.4.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0"/>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1"/>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Primitives" publicKeyToken="adb9793829ddae60" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.1.10.0" newVersion="3.1.10.0"/>
<assemblyIdentity name="Microsoft.Extensions.Primitives" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.1.10.0" newVersion="3.1.10.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Configuration.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.1.10.0" newVersion="3.1.10.0"/>
<assemblyIdentity name="Microsoft.Extensions.Configuration.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.1.10.0" newVersion="3.1.10.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.1.10.0" newVersion="3.1.10.0"/>
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.1.10.0" newVersion="3.1.10.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Caching.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.1.10.0" newVersion="3.1.10.0"/>
<assemblyIdentity name="Microsoft.Extensions.Caching.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.1.10.0" newVersion="3.1.10.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Options" publicKeyToken="adb9793829ddae60" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.1.10.0" newVersion="3.1.10.0"/>
<assemblyIdentity name="Microsoft.Extensions.Options" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.1.10.0" newVersion="3.1.10.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.1.10.0" newVersion="3.1.10.0"/>
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.1.10.0" newVersion="3.1.10.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1"/>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection" publicKeyToken="adb9793829ddae60" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.1.10.0" newVersion="3.1.10.0"/>
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.1.10.0" newVersion="3.1.10.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.ComponentModel.Annotations" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0"/>
<assemblyIdentity name="System.ComponentModel.Annotations" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SqlServerCe.4.0"/>
<add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0"
description=".NET Framework Data Provider for Microsoft SQL Server Compact"
type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
<remove invariant="System.Data.SqlServerCe.4.0" />
<add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</DbProviderFactories>
</system.data></configuration>

View File

@ -65,6 +65,9 @@
<Reference Include="EntityFramework.SqlServerCompact, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>packages\EntityFramework.SqlServerCompact.6.4.4\lib\net45\EntityFramework.SqlServerCompact.dll</HintPath>
</Reference>
<Reference Include="isendpro, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\iSendProSMS.1.1.3\lib\isendpro.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Office.Interop.Outlook, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Office.Interop.Outlook.15.0.4797.1003\lib\net20\Microsoft.Office.Interop.Outlook.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
@ -73,6 +76,12 @@
<HintPath>packages\Microsoft.Office.Interop.Word.15.0.4797.1003\lib\net20\Microsoft.Office.Interop.Word.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="RestSharp.Net2, Version=102.7.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\RestSharp.Net2.1.1.11\lib\net20\RestSharp.Net2.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Data" />
@ -101,9 +110,9 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Converter\NegateBoolean.cs" />
<Compile Include="Migrations\202012032233531_V1.cs" />
<Compile Include="Migrations\202012032233531_V1.designer.cs">
<DependentUpon>202012032233531_V1.cs</DependentUpon>
<Compile Include="Migrations\202012051414539_V1.cs" />
<Compile Include="Migrations\202012051414539_V1.designer.cs">
<DependentUpon>202012051414539_V1.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\Configuration.cs" />
<Compile Include="Model\Citoyen.cs" />
@ -112,6 +121,7 @@
<Compile Include="PreferencesModal.xaml.cs">
<DependentUpon>PreferencesModal.xaml</DependentUpon>
</Compile>
<Compile Include="SmsSendingStatus.cs" />
<Compile Include="SmsWindow.xaml.cs">
<DependentUpon>SmsWindow.xaml</DependentUpon>
</Compile>
@ -159,8 +169,8 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Migrations\202012032233531_V1.resx">
<DependentUpon>202012032233531_V1.cs</DependentUpon>
<EmbeddedResource Include="Migrations\202012051414539_V1.resx">
<DependentUpon>202012051414539_V1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>

View File

@ -75,15 +75,23 @@ namespace Hermes {
MessageBoxResult result = MessageBox.Show("Voulez-vous envoyer un SMS à ces citoyens ?", "Envoi de SMS", MessageBoxButton.YesNo, MessageBoxImage.Question);
if(result == MessageBoxResult.Yes) {
bool noTel = false;
List<Citoyen> rcps = new List<Citoyen>();
foreach(Citoyen citoyen in dgCitoyens.SelectedItems) {
if(String.IsNullOrWhiteSpace(citoyen.TelPort)) {
if(!String.IsNullOrWhiteSpace(citoyen.TelPort)) {
rcps.Add(citoyen);
} else {
noTel = true;
}
}
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);
if(rcps.Count > 0) {
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();
} else {
MessageBox.Show("Aucun des citoyens sélectionnés ne disposent d'un numéro de mobile", "Envoi de SMS", MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
smsModal.ShowDialog();
}
} else {
MessageBox.Show("Aucun citoyen sélectionné", "Envoi de SMS", MessageBoxButton.OK, MessageBoxImage.Exclamation);

View File

@ -13,7 +13,7 @@ namespace Hermes.Migrations
string IMigrationMetadata.Id
{
get { return "202012032233531_V1"; }
get { return "202012051414539_V1"; }
}
string IMigrationMetadata.Source

View File

@ -118,7 +118,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Target" xml:space="preserve">
<value>H4sIAAAAAAAEAO1azW7jNhC+F+g7CDpnrfzsoQ3sXSRO0gbdJG6U5E5LY4coRakkFcTPtoc+Ul+hQ/2LUhzJkYWiKHKxh5xvhsPh/MV/f/9r+vU1YNYLCElDPrOPJoe2BdwLfcrXMztWq08/2V+//PjD9NIPXq2nfN+J3oecXM7sZ6WiU8eR3jMERE4C6olQhis18cLAIX7oHB8e/uwcHTmAEDZiWdb0PuaKBpB8wa/zkHsQqZiwm9AHJjM6rrgJqnVLApAR8WBm/woCP0+SjbZ1xihBHVxgK9sinIeKKNTw9FGCq0TI126EBMIeNhHgvhVhEjLNT8vtXQ9xeKwP4ZSMOZQXSxUGPQGPTjKrOCb7Tra1C6uh3S7RvmqjT53YbmbPqQo3gMimrNM5E3pf3bKTbP+BlVIPirtHF9F/B9Y8ZioWMOMQK0HYgbWIl4x6v8HmIfwD+IzHjFV1Qq1wrUZA0kKEEQi1uYdVpum1b1tOnc8xGQu2Ck96iGuuTo5t6xaFkyWD4sorB3ZVKOAX4CCIAn9BlALBNQYkRmtIN2TN6QtlVEEuEf0MH4tt3ZDXb8DX6nlmfz48xPdxRV/Bz0mZGo+c4uNCLiVieE/SbRiMIuSWUCkJPsH9S1sI4GOc6gKvtnEsTXzAsPO+kuEKpEwe4r4V1fj3ICk6X6noeRgyILzFjbeD3RDKRlAZxhGyCIXav6DfYyIUBbF/SWe+QK8a4ZFlgs6JzrF8BBtmAi9fR5U1X4wp7YkyNsLd6Rg1F5CVAWbc6hkPNCOmc7qi3i6AU6csI7YWFxjVVyB0BJOdC4wKz/9FRkNW4m1jOPhIbu0G8iyiaOGhRW33UWwsFKF4CXmC1K6niaBDVcNTsWvInFVmsuqHSkFdUPWiGgm2VaqRtiOTouJ2toPUHk8DpbbadvDiiGXT5KRdU95d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YiQKVZjR1MeyMn+oW1fKu9OMDKEKNJq6M9NEoYpKJT2sAgOQCHqNT+N7g5EKu3PK8L0KKqXdSUV4XgUVwt6cMvpu4ZWNvblJkN2CTOS70HSU0c7TLbsQs5iiHZo19ruhZURsXtCypR+xHhab1HprkzxzDEdvPiVO4y0xgk3zder0dlWDgZ0fry2QDg/Y1tH7ecSKWLiKKIQ9OS2UPoxKHFvlVMQjH5ZGGGh2KbQX4aAR9s2yEOz90nsjJku72BYu0gs+QhiPuRupIJjoDhP3D+aCeAGxgMln/Q+DvNs14RQfQpWmcHbSVivk/3uK6o6UPutWWR89C6X6/Xg3z+xZMjCr2/yFCO+ZiJZMrST3LGYPyWwUeQeD10vVg2FbK9M+CpVRkOlmo1mpHszO1sL0kqoPFaWHsw72wqyWnAfjmhXmwcBGQXlorlk/HppfKRfvAV0Wz/YAr1XNBnUNZu23zTN8qPbbEbhT7fe/8QQatdfBtnc/h6ZRWd2R3K+Q2izPdaqUbiuTpsEkHtBliFNJzcwaZWMRPlBEbdMzRJW1GUbPnOrvXGbn+JquS4T+1QsHT9/NEpr3ueKrMN9onGXVoryL+cyCIni3ySm+NSviKWz2dGigi+xPhMXY5SJYgn/Fb2MVxeoUPVmwZLWMZeZs15+Ukus2z24j/SWHmAKaSbV7uuVnMWV+Yfdli3t6A6HPZeYK0CpXaZew3hSkm5B3BGXLdw4RcO1IHiCIGMLkLXfJC+xi26OE77Am3ibPg96GvL8R9WWfnVOyFiSQGaMcj594hv3g9es/4ocTwO4lAAA=</value>
</data>
<data name="DefaultSchema" xml:space="preserve">
<value>dbo</value>

View File

@ -26,7 +26,7 @@
<TabItem Header="Envoi de SMS">
<StackPanel Margin="5,5,5,5" VerticalAlignment="Top">
<Label>Clé API ISendPro :</Label>
<TextBox Name="cleApiISendProTextBox" HorizontalAlignment="Left" VerticalContentAlignment="Center" Height="23" Width="200"/>
<TextBox Name="cleApiISendProTextBox" HorizontalAlignment="Left" VerticalContentAlignment="Center" Height="23" Width="250"/>
</StackPanel>
</TabItem>
</TabControl>

49
SmsSendingStatus.cs Normal file
View File

@ -0,0 +1,49 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace Hermes {
class SmsSendingStatus : INotifyPropertyChanged {
private string _nom = null;
private string _prenom = null;
private string _mobile = null;
private string _status = null;
public string Nom {
get => _nom;
set {
_nom = value;
OnPropertyChanged();
}
}
public string Prenom {
get => _prenom;
set {
_prenom = value;
OnPropertyChanged();
}
}
public string Mobile {
get => _mobile;
set {
_mobile = value;
OnPropertyChanged();
}
}
public string Status {
get => _status;
set {
_status = value;
OnPropertyChanged();
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string name = null) {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
}
}

View File

@ -6,18 +6,34 @@
xmlns:local="clr-namespace:Hermes"
mc:Ignorable="d"
ResizeMode="NoResize"
Title="Envoi de SMS" Height="370" Width="500"
Title="Envoi de SMS" Height="490" Width="700"
WindowStartupLocation="CenterOwner"
Loaded="Window_Loaded"
Closing="Window_Closing">
<Grid Background="WhiteSmoke">
<Grid.RowDefinitions>
<RowDefinition Height="290"/>
<RowDefinition Height="30"/>
<RowDefinition Height="200"/>
<RowDefinition Height="30"/>
<RowDefinition Height="150"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<RichTextBox Margin="5" Grid.Row="0" FontSize="15" Block.LineHeight="2" VerticalScrollBarVisibility="Visible"/>
<WrapPanel Grid.Row="1" Margin="0,0,5,0" HorizontalAlignment="Right" VerticalAlignment="Center">
<Button Margin="0,0,10,0" Height="25" Width="100" IsDefault="True" Click="Envoyer_Click">Envoyer</Button>
<Button Height="25" Width="100" Click="Annuler_Click">Annuler</Button>
<Label Grid.Row="0" Margin="5,0,0,0" VerticalAlignment="Bottom">Entrez votre message</Label>
<RichTextBox Name="messageTextBox" Margin="5,0,5,0" Grid.Row="1" FontSize="15" Block.LineHeight="2" VerticalScrollBarVisibility="Visible"/>
<Label Grid.Row="2" Margin="5,0,0,0" VerticalAlignment="Bottom">Liste des envois</Label>
<ListView Name="lvLog" Grid.Row="3" Margin="5,0,5,0" ScrollViewer.VerticalScrollBarVisibility="Visible">
<ListView.View>
<GridView>
<GridViewColumn Header="Nom" DisplayMemberBinding="{Binding Nom}" Width="120"/>
<GridViewColumn Header="Prénom" DisplayMemberBinding="{Binding Prenom}" Width="120"/>
<GridViewColumn Header="Mobile" DisplayMemberBinding="{Binding Mobile}" Width="120"/>
<GridViewColumn Header="Statut de l'envoi" DisplayMemberBinding="{Binding Status}" Width="290"/>
</GridView>
</ListView.View>
</ListView>
<WrapPanel Grid.Row="4" Margin="0,0,5,0" HorizontalAlignment="Right" VerticalAlignment="Center">
<Button Name="envoyerButton" Margin="0,0,10,0" Height="25" Width="100" IsDefault="True" Click="Envoyer_Click">Envoyer</Button>
<Button Name="annulerButton" Height="25" Width="100" Click="Annuler_Click">Annuler</Button>
</WrapPanel>
</Grid>
</Window>

View File

@ -1,19 +1,121 @@
using System.Windows;
using Hermes.Model;
using IO.Swagger.Api;
using IO.Swagger.Client;
using IO.Swagger.Model;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Documents;
namespace Hermes {
public partial class SmsWindow : Window {
private ObservableCollection<SmsSendingStatus> status = new ObservableCollection<SmsSendingStatus>();
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);
InitializeComponent();
}
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) {
return;
}
messageTextBox.Document.Blocks.Clear();
status.Clear();
this.Hide();
}
public void LoadCitoyens(List<Citoyen> 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) {
MessageBox.Show("Erreur lors de la tentative d'envoi : Clé IsendPro invalide", "Envoi de SMS", MessageBoxButton.OK, MessageBoxImage.Error);
bool error = false;
string message = new TextRange(messageTextBox.Document.ContentStart, messageTextBox.Document.ContentEnd).Text;
string apiKey = dbContext.Preferences.Local[0].SmsApiKey;
if(String.IsNullOrWhiteSpace(apiKey)) {
MessageBox.Show("Erreur lors de la tentative d'envoi : Clé ISendPro invalide", "Envoi de SMS", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
if(String.IsNullOrWhiteSpace(message)) {
MessageBox.Show("Votre message est vide.", "Envoi de SMS", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
envoyerButton.IsEnabled = false;
annulerButton.IsEnabled = false;
messageTextBox.IsEnabled = false;
sending = true;
foreach(SmsSendingStatus stat in status) {
if(!stat.Status.Equals("Envoyé")) {
SmsUniqueRequest req = new SmsUniqueRequest();
req.Keyid = apiKey;
req.Sms = message;
req.Smslong = "999";
req.Num = stat.Mobile;
try {
SMSReponse resp = smsApi.SendSms(req);
if(resp != null && resp.Etat != null && resp.Etat.Etat != null && resp.Etat.Etat.Count > 0) {
SMSReponseEtatEtat eta = resp.Etat.Etat[0];
if(eta.Code != null && eta.Code == 0 && eta.Tel != null) {
stat.Status = "Envoyé";
} else {
error = true;
stat.Status = eta.Message;
}
} else {
error = true;
stat.Status = "Erreur technique";
}
} catch(ApiException ex) {
error = true;
SMSReponse resp = JsonConvert.DeserializeObject<SMSReponse>((String) ex.ErrorContent);
if(resp != null && resp.Etat != null && resp.Etat.Etat != null && resp.Etat.Etat.Count > 0) {
SMSReponseEtatEtat eta = resp.Etat.Etat[0];
if(eta.Code != null && eta.Code == 0 && eta.Tel != null) {
stat.Status = "Envoyé";
} else {
error = true;
stat.Status = eta.Message;
}
} else {
error = true;
stat.Status = "Erreur technique";
}
}
}
}
envoyerButton.IsEnabled = true;
annulerButton.IsEnabled = true;
messageTextBox.IsEnabled = true;
sending = false;
if(error) {
MessageBox.Show("Plusieurs envois se sont mal déroulés. Vérifiez la validité des numéros de téléphone.", "Envoi de SMS", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
public void Annuler_Click(object sender, RoutedEventArgs e) {

View File

@ -2,7 +2,10 @@
<packages>
<package id="EntityFramework" version="6.4.4" targetFramework="net48" />
<package id="EntityFramework.SqlServerCompact" version="6.4.4" targetFramework="net48" />
<package id="iSendProSMS" version="1.1.3" targetFramework="net48" />
<package id="Microsoft.Office.Interop.Outlook" version="15.0.4797.1003" targetFramework="net48" />
<package id="Microsoft.Office.Interop.Word" version="15.0.4797.1003" targetFramework="net48" />
<package id="Microsoft.SqlServer.Compact" version="4.0.8876.1" targetFramework="net48" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net48" />
<package id="RestSharp.Net2" version="1.1.11" targetFramework="net48" />
</packages>