Correction de nommage de données de paramétrage + correction de la fonction d'import
This commit is contained in:
@@ -15,7 +15,8 @@ namespace Hermes {
|
||||
public partial class SmsWindow : Window {
|
||||
private ObservableCollection<SmsSendingStatus> status = new ObservableCollection<SmsSendingStatus>();
|
||||
private bool sending = false;
|
||||
private Regex numPrefixRgx = new Regex(@"^0");
|
||||
private static Regex telFrRgx = new Regex(@"^0\d{9}");
|
||||
private static Regex telFrPrefixRgx = new Regex(@"^0");
|
||||
|
||||
|
||||
public static string HashSHA1(string input) {
|
||||
@@ -38,7 +39,12 @@ namespace Hermes {
|
||||
SmsSendingStatus s = new SmsSendingStatus();
|
||||
s.Nom = rcp.Nom;
|
||||
s.Prenom = rcp.Prenom;
|
||||
s.Mobile = numPrefixRgx.Replace(rcp.TelPort.Replace(" ", ""), "+33");
|
||||
s.Mobile = rcp.TelPort.Replace(" ", "").Replace(".", "");
|
||||
Match m = telFrRgx.Match(s.Mobile);
|
||||
if(m.Success) {
|
||||
// numéro FR (+33)
|
||||
s.Mobile = telFrPrefixRgx.Replace(s.Mobile, "+33");
|
||||
}
|
||||
s.Status = "En attente";
|
||||
status.Add(s);
|
||||
}
|
||||
@@ -60,8 +66,8 @@ namespace Hermes {
|
||||
Preferences pref = dbContext.Preferences.Local[0];
|
||||
|
||||
|
||||
if(String.IsNullOrWhiteSpace(pref.ovhSmsServiceName) || String.IsNullOrWhiteSpace(pref.ovhSmsApplicationName)
|
||||
|| String.IsNullOrWhiteSpace(pref.ovhSmsApplicationKey) || String.IsNullOrWhiteSpace(pref.ovhSmsConsumerKey)) {
|
||||
if(String.IsNullOrWhiteSpace(pref.ovhSmsServiceName) || String.IsNullOrWhiteSpace(pref.ovhSmsApplicationKey)
|
||||
|| String.IsNullOrWhiteSpace(pref.ovhSmsApplicationSecret) || String.IsNullOrWhiteSpace(pref.ovhSmsConsumerKey)) {
|
||||
MessageBox.Show("Erreur lors de la tentative d'envoi : Clés d'accès invalides.", "Envoi de SMS", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return;
|
||||
}
|
||||
@@ -91,12 +97,12 @@ namespace Hermes {
|
||||
string bodyStr = JsonConvert.SerializeObject(body);
|
||||
|
||||
string ts = ((Int32) DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds).ToString();
|
||||
string signature = "$1$" + HashSHA1(pref.ovhSmsApplicationKey + "+" + pref.ovhSmsConsumerKey + "+" + "POST" + "+" + query + "+" + bodyStr + "+" + ts);
|
||||
string signature = "$1$" + HashSHA1(pref.ovhSmsApplicationSecret + "+" + pref.ovhSmsConsumerKey + "+" + "POST" + "+" + query + "+" + bodyStr + "+" + ts);
|
||||
|
||||
HttpWebRequest req = (HttpWebRequest) HttpWebRequest.Create(query);
|
||||
req.Method = "POST";
|
||||
req.ContentType = "application/json";
|
||||
req.Headers.Add("X-Ovh-Application:" + pref.ovhSmsApplicationName);
|
||||
req.Headers.Add("X-Ovh-Application:" + pref.ovhSmsApplicationKey);
|
||||
req.Headers.Add("X-Ovh-Consumer:" + pref.ovhSmsConsumerKey);
|
||||
req.Headers.Add("X-Ovh-Signature:" + signature);
|
||||
req.Headers.Add("X-Ovh-Timestamp:" + ts);
|
||||
|
||||
Reference in New Issue
Block a user