private void ShowMessage(SmsPdu pdu) { if (pdu is SmsSubmitPdu) { // Stored (sent/unsent) message SmsSubmitPdu data = (SmsSubmitPdu)pdu; Output("SENT/UNSENT MESSAGE"); Output("Recipient: " + data.DestinationAddress); Output("Message text: " + data.UserDataText); Output("-------------------------------------------------------------------"); return; } if (pdu is SmsDeliverPdu) { // Received message SmsDeliverPdu data = (SmsDeliverPdu)pdu; Output("RECEIVED MESSAGE"); Output("Sender: " + data.OriginatingAddress); Output("Sent: " + data.SCTimestamp.ToString()); Output("Message text: " + data.UserDataText); Output("-------------------------------------------------------------------"); BindGrid(pdu); return; } if (pdu is SmsStatusReportPdu) { // Status report SmsStatusReportPdu data = (SmsStatusReportPdu)pdu; Output("STATUS REPORT"); Output("Recipient: " + data.RecipientAddress); Output("Status: " + data.Status.ToString()); Output("Timestamp: " + data.DischargeTime.ToString()); Output("Message ref: " + data.MessageReference.ToString()); Output("-------------------------------------------------------------------"); return; } Output("Unknown message type: " + pdu.GetType().ToString()); }
private void ShowMessage(SmsPdu pdu) { if (pdu is SmsSubmitPdu) { // Stored (sent/unsent) message SmsSubmitPdu data = (SmsSubmitPdu)pdu; Output("SENT/UNSENT MESSAGE"); Output("Recipient: " + data.DestinationAddress); Output("Message text: " + data.UserDataText); Output("-------------------------------------------------------------------"); return; } if (pdu is SmsDeliverPdu) { // Received message SmsDeliverPdu data = (SmsDeliverPdu)pdu; Output("Mensaje Recibido"); Output("Emisor: " + data.OriginatingAddress); Output("Hora de envio: " + data.SCTimestamp.ToString()); Output("Texto del mensaje: " + data.UserDataText); Output("-------------------------------------------------------------------"); try { var request = (HttpWebRequest)WebRequest.Create(Constants.getServer() + "/api/v1/sms/create"); var postData = MessageToJson(data.SCTimestamp.ToString(),data.OriginatingAddress, data.UserDataText,DateTime.Now.Ticks.ToString()); var data2 = Encoding.UTF8.GetBytes(postData); request.Method = "POST"; request.ContentType = "application/json"; request.ContentLength = data2.Length; using (var stream = request.GetRequestStream()) { stream.Write(data2, 0, data2.Length); } var response = (HttpWebResponse)request.GetResponse(); var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); response.Close(); } catch (System.Net.WebException wx) { MessageBox.Show(wx.Message); } CommSetting.comm.DeleteMessages(DeleteScope.All, PhoneStorageType.Sim); return; } if (pdu is SmsStatusReportPdu) { // Status report SmsStatusReportPdu data = (SmsStatusReportPdu)pdu; Output("STATUS REPORT"); Output("Recipient: " + data.RecipientAddress); Output("Status: " + data.Status.ToString()); Output("Timestamp: " + data.DischargeTime.ToString()); Output("Message ref: " + data.MessageReference.ToString()); Output("-------------------------------------------------------------------"); return; } Output("Unknown message type: " + pdu.GetType().ToString()); }