/// <summary> /// Lese Statusreport-SMS Modemspeicher, melde und lösche den Statusreport anschließend. /// ACHTUNG: Überprüfung des Reports /// </summary> /// <param name="input"></param> private static void ParseStatusReport(string input) { if (input == null) { return; } try { //+CMGL: < index > , < stat > , < fo > , < mr > , [ < ra > ], [ < tora > ], < scts > , < dt > , < st > //[... ] //OK //<st> 0-31 erfolgreich versandt; 32-63 versucht weiter zu senden: 64-127 Sendeversuch abgebrochen //z.B.: +CMGL: 1,"REC READ",6,34,,,"20/11/06,16:08:45+04","20/11/06,16:08:50+04",0 //Regex r = new Regex(@"\+CMGL: (\d+),""(.+)"",(\d+),(\d+),,,""(.+)"",""(.+)"",(\d+)\r\n"); Regex r = new Regex(@"\+CMGL: (\d+),""(.+)"",(\d+),(\d+),,,""(.+)"",""(.+)"",(\d+)"); Match m = r.Match(input); while (m.Success) { Sms smsReport = new Sms(); smsReport.SetIndex(m.Groups[1].Value); //<index> smsReport.Status = m.Groups[2].Value; //<stat> smsReport.FirstOctet = byte.Parse(m.Groups[3].Value); //<fo> smsReport.MessageReference = byte.Parse(m.Groups[4].Value); //<mr> //sms.SmsProviderTimeStamp = GsmConverter.ReadDateTime(m.Groups[5].Value); //<scts: ServiceCenterTimeStamp> smsReport.SmsProviderTimeStamp = GsmConverter.ReadDateTime(m.Groups[6].Value); //<dt: DischargeTime> smsReport.SendStatus = byte.Parse(m.Groups[7].Value); //<st> //Für Wiedererkennung Werte aus 'Orignal-SMS' einfügen Sms smsTracking = SmsTrackingQueue.Find(x => x.MessageReference == smsReport.MessageReference); if (smsTracking != null) { smsReport.Message = smsTracking.Message; smsReport.Phone = smsTracking.Phone; SmsTrackingQueue.Remove(smsTracking); MelBox2.GlobalProperty.SmsPendingReports = SmsTrackingQueue.Count; } if (smsReport.Status == "REC UNREAD" || smsReport.Status == "REC READ") { RaiseSmsStatusreportEvent(smsReport); #if DEBUG DebugShowSms(smsReport, "Sendebestätigung von Modem"); #endif SmsToDelete.Add(smsReport.Index); } m = m.NextMatch(); } SmsDeletePending(); } catch (Exception ex) { throw new Exception(string.Format("ParseStatusReport() {0}\r\n{1}\r\n{2}", ex.GetType(), ex.Message, ex.InnerException)); } }
/// <summary> /// TP-Discharge-Time in time-string format: "yy/MM/dd,hh:mm:ss+zz", where characters indicate year /// (two last digits), month, day, hour, minutes, seconds and time zone.For example, 6th of May 1994, 22:10:00 /// GMT+2 hours equals "94/05/06,22:10:00+08" /// </summary> /// <param name="strDateTime"></param> public void SetTimeStamp(string strDateTime) { SmsProviderTimeStamp = GsmConverter.ReadDateTime(strDateTime); }