///// <summary> ///// RESERVE / BAUSTELLE ///// Bisher musste ich keinen PIN eingeben, da SIM-Karte ohne PIN-Sperre ///// </summary> ///// <param name="PIN"></param> //private void SetPinCode(string PIN) //{ // //https://www.smssolutions.net/tutorials/gsm/sendsmsat/ // //AT-Commands_Samba75 Manual Seite 72ff. // string result = ExecCommand("AT+CPIN?", 300, "Failed to set PIN."); // if (result.EndsWith("\r\nOK\r\n")) return; // { // ExecCommand("AT+CPIN=\"" + PIN + "\"", 300, "Failed to set PIN."); // Syste.Threading.Thread.Sleep(5000); // } //} public static MessageCollection ParseMessages(string input) { if (input.Length == 0) { return(null); } // Log.Text(Log.Type.Internal, input+"#################"); MessageCollection messages = new MessageCollection(); System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex("\\+CMGL: (\\d+),\"(.+)\",\"(.+)\",(.*),\"(.+)\"\\r\\n(.+)"); // "\\+CMGL: (\\d+),\"(.+)\",\"(.+)\",(.*),\"(.+)\"\n(.+)\n\n\"" System.Text.RegularExpressions.Match m = r.Match(input); while (m.Success) { //string gr0 = m.Groups[0].Value; // <alles> string gr1 = m.Groups[1].Value; //6 string gr2 = m.Groups[2].Value; //STO SENT string gr3 = m.Groups[3].Value; //+49123456789 //string gr4 = m.Groups[4].Value; // -LEER- string gr5 = m.Groups[5].Value.Replace(',', ' '); //18/09/28,11:05:51 + 105 string gr6 = m.Groups[6].Value; //Nachricht string gr7 = m.Groups[7].Value; //Nachricht (notwendig?) //MessageBox.Show(string.Format("0:{0}\r\n1:{1}\r\n2:{2}\r\n3:{3}\r\n4:{4}\r\n5:{5}\r\n6:{6}\r\n7:{7}\r\n", gr0, gr1, gr2, gr3, gr4, gr5, gr6, gr7), "Rohdaten"); int.TryParse(gr1, out int smsId); DateTime.TryParse(gr5, out DateTime time); //MessageBox.Show("Zeit interpretiert: " + time.ToString("dd.MM.yyyy HH:mm:ss")); //Message Status zu MessageType MessageType type; switch (gr2) { case "REC UNREAD": case "REC READ": type = MessageType.RecievedFromSms; break; case "STO SENT": type = MessageType.SentToSms; break; default: type = MessageType.RecievedFromSms; break; } //Nachricht erstellen Message msg = new Message { Index = smsId, Status = gr2, //Alphabet -leer- Type = (ushort)type, Cellphone = HelperClass.ConvertStringToPhonenumber(gr3), SentTime = Sql.ConvertToUnixTime(time), CustomerKeyWord = GetKeyWords(gr6), Content = gr6 + gr7 }; messages.Add(msg); m = m.NextMatch(); } return(messages); }
private void Mast_Button_CreatePerson_Click(object sender, RoutedEventArgs e) { if (Mast_ComboBox_Company.SelectedItem == null) { MessageBox.Show("Wähle eine Firmenzugehörigkeit aus!", "MelBox2", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } if (Mast_TextBox_Name.Text.Length < 3) { MessageBox.Show("Der Name muss mindestens drei Zeichen lang sein!", "MelBox2", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } string name = Mast_TextBox_Name.Text; string company = Mast_ComboBox_Company.SelectedValue.ToString(); string email = Mast_TextBox_Email.Text; ulong cellphone = HelperClass.ConvertStringToPhonenumber(Mast_TextBox_Cellphone.Text); string KeyWord = Mast_TextBox_KeyWord.Text; string MaxInactive = Mast_TextBox_MaxInactivity.Text; bool recEmailChecked = (bool)Mast_CheckBox_RecievesEmail.IsChecked; bool recSmsChecked = (bool)Mast_CheckBox_RecievesSMS.IsChecked; if (recEmailChecked && !HelperClass.IsValidEmailAddress(email)) { MessageBox.Show("E-Mails können nur mit gültiger Email-Adresse gesendet / empfangen werden!", "MelBox2", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } if (recSmsChecked && cellphone == 0) { MessageBox.Show("SMS können nur mit gültiger Telefonnummer gesendet / empfangen werden!", "MelBox2", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } MessageType role = MessageType.NoCategory; if (recEmailChecked) { role = MessageType.SentToEmail; } if (recSmsChecked) { role |= MessageType.SentToSms; } uint oldPersonId = sql.GetPersonID(null, email, cellphone, KeyWord); if (oldPersonId != 0) { string oldName = sql.GetPersonNameFromId(oldPersonId); MessageBox.Show(string.Format("Die Person mit \r\nEmail\t{0}\r\nMobilnummer\t{1}\r\nKeyWord\t{2}\r\n gibt es schon unter dem Namen\r\n\t\t{3}\r\n\r\nEs wird keine neue Person erstellt.", email, cellphone, KeyWord, oldName), "MelBox2 - Diese Person gibt es schon.", MessageBoxButton.OK, MessageBoxImage.Error); return; } uint newPersonId = sql.CreatePerson(name, company, email, cellphone.ToString(), KeyWord, MaxInactive, role); Mast_TextBlock_Person_Id.Text = newPersonId.ToString(); if (newPersonId > 0) { _ = MessageBox.Show("Person neu erstellt:\r\n" + name + "\r\nvon Firma " + company, "MelBox2 - Person [" + newPersonId + "] neu erstellt.", MessageBoxButton.OK, MessageBoxImage.Information); Log.Write(Log.Type.Persons, "Person [" + newPersonId + "] neu erstellt: " + name + " von Firma " + company); } //Auswahl verfügbarerer Personen im Kalender aktualisieren. Cal_AvailablePersonal = sql.GetListFromColumn("Persons", "Name", "1=1 LIMIT 50"); }