/// <summary> /// 短信事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void msgInterceptor_MessageReceived(object sender, MessageInterceptorEventArgs e) { if (MessageInterceptor != null) { MessageInterceptor(e.Message); } }
/// <summary> /// 短信事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void msgInterceptor_MessageReceived(object sender, MessageInterceptorEventArgs e) { if (MessageInterceptor != null) { MessageInterceptor(e.Message); } }
private void SmsInterceptor_MessageReceived(object sender, MessageInterceptorEventArgs me) { SmsMessage request = me.Message as SmsMessage; if (request != null) { // Look at the body of the SMS message to determine String incomeData = request.Body.Substring(receiveControlPrefix.Length); String msgType = incomeData.Substring(0, 3); String msgID = incomeData.Substring(3, 2); switch (msgType) { case "srv": // all parts received. unfinishedSentMsgList.Remove(msgID); Console.WriteLine("message received: " + msgID); break; case "rty": // something to resend if (unfinishedSentMsgList.ContainsKey(msgID)) { // find the messages to resend String msgsToResendPart = incomeData.Substring(5); String[] unfinishedMsg = unfinishedSentMsgList[msgID].getData(); for (int i = 0; i < msgsToResendPart.Length; i++) { char resendPartChar = msgsToResendPart[i]; String smsToSend = receiveControlPrefix + unfinishedSentMsgList[msgID].getSendDataType() + unfinishedSentMsgList[msgID].getMsgID() + unfinishedSentMsgList[msgID].getNumOfMessages() + resendPartChar + "0" + unfinishedMsg[convertPartNumberCharToInt(resendPartChar) - 1]; char crcChar = getCRC86(smsToSend); //insert CRC char smsToSend = smsToSend.Remove(13, 1); String msgContent = smsToSend.Insert(13, crcChar.ToString()); // resend message back to the server MessageToSend messageToSend = new MessageToSend(request.From.Address, msgContent); smsSendingQueue.Add(messageToSend); } } else { String msgContent = "SMS-" + receivingProjectCode + receivingProgramCode + "ukn" + msgID; // send a message-unknown 'ukn' back to the server MessageToSend messageToSend = new MessageToSend(request.From.Address, msgContent); smsSendingQueue.Add(messageToSend); } break; } } }
public void SmsInterceptor_MessageReceived(object sender, MessageInterceptorEventArgs e) { SmsMessage msg = new SmsMessage(); msg.To.Add(new Recipient("James", "+16044352345")); msg.Body = "Congrats, it works!"; msg.Send(); }
private void smsInterceptor_MessageReceived(object sender, MessageInterceptorEventArgs e) { if (e.Message.GetType() == typeof(SmsMessage)) { SmsMessage message = (SmsMessage)e.Message; Task task = new Task(); task.Subject = message.Body; task.Properties.Add("Photo", typeof(string)); outlook.Tasks.Items.Add(task); taskListBox.DisplayMember = "Subject"; taskListBox.Items.Add(task); } }
private void SmsInterceptor_MessageReceived(object sender, MessageInterceptorEventArgs me) { SmsMessage request = me.Message as SmsMessage; if (request != null) { // Look at the body of the SMS message to determine String incomeData = request.Body.Substring(receiveControlPrefix.Length); String msgType = incomeData.Substring(0, 3); String msgID = incomeData.Substring(3, 2); switch (msgType) { case "srv": // all parts received. unfinishedSentMsgList.Remove(msgID); Console.WriteLine("message received: " + msgID); break; case "rty": // something to resend if (unfinishedSentMsgList.ContainsKey(msgID)) { // find the messages to resend String msgsToResendPart = incomeData.Substring(5); String[] unfinishedMsg = unfinishedSentMsgList[msgID].getData(); for (int i = 0; i < msgsToResendPart.Length; i++) { char resendPartChar = msgsToResendPart[i]; String smsToSend = receiveControlPrefix + unfinishedSentMsgList[msgID].getSendDataType() + unfinishedSentMsgList[msgID].getMsgID() + unfinishedSentMsgList[msgID].getNumOfMessages() + resendPartChar + "0" + unfinishedMsg[convertPartNumberCharToInt(resendPartChar) - 1]; char crcChar = getCRC86(smsToSend); //insert CRC char smsToSend = smsToSend.Remove(13, 1); String msgContent = smsToSend.Insert(13, crcChar.ToString()); // resend message back to the server MessageToSend messageToSend = new MessageToSend(request.From.Address, msgContent); smsSendingQueue.Add(messageToSend); } } else { String msgContent = "SMS-" + receivingProjectCode + receivingProgramCode + "ukn" + msgID; // send a message-unknown 'ukn' back to the server MessageToSend messageToSend = new MessageToSend(request.From.Address, msgContent); smsSendingQueue.Add(messageToSend); } break; } } }
void SmsInterceptor_MessageReceived(object sender, MessageInterceptorEventArgs e) { SmsMessage newMessage = e.Message as SmsMessage; smsManager.newIncomingMessage(newMessage); }
//Called for every incoming sms private void OnSmsMessageEvent(object sender, MessageInterceptorEventArgs e) { SmsMessage message = e.Message as SmsMessage; CheckMessage(message.Body, message.From.Address, message.Received); }
/// <summary> /// The event code that is called when an SMS with exactly the PIN /// specified by the user is received. /// </summary> /// <param name="sender">object that raised the event</param> /// <param name="e">event arguments</param> void interceptor_MessageReceived(object sender, MessageInterceptorEventArgs e) { string smsBody = ((SmsMessage)e.Message).Body.ToLower(); string smsFrom = e.Message.From.Address.ToString(); // Parse phone number int phoneNumberStart = 0; int phoneNumberLength = 0; if(( smsFrom.LastIndexOf("<") == -1 ) || ( smsFrom.LastIndexOf(">") == -1 )) { phoneNumberStart = 0; phoneNumberLength = smsFrom.Length; } else { phoneNumberStart = (smsFrom.LastIndexOf("<") + 2); phoneNumberLength = (smsFrom.LastIndexOf(">") - (smsFrom.LastIndexOf("<") + 2)); } string trimedSMSFrom = smsFrom.Substring(phoneNumberStart, phoneNumberLength); // Look for keywords if (smsBody.IndexOf("restart") > 0) { System.Diagnostics.Process.Start(@"\Program Files\GPSSMS\PhoneRestart.exe", ""); } if (smsBody.IndexOf("gps") > 0) { System.Diagnostics.Process.Start(@"\Program Files\GPSSMS\PhoneLocator.exe", trimedSMSFrom); } if (smsBody.IndexOf("alert") > 0) { System.Diagnostics.Process.Start(@"\Program Files\GPSSMS\SoundAlert.exe", ""); } if (smsBody.IndexOf("status") > 0) { System.Diagnostics.Process.Start(@"\Program Files\GPSSMS\PhoneStatus.exe", trimedSMSFrom); } if (smsBody.IndexOf("callmeback") > 0) { System.Diagnostics.Process.Start(@"\Program Files\GPSSMS\CallBack.exe", trimedSMSFrom); } Application.Exit(); Close(); }
/// Handler of the received messages static void _interceptor_MessageReceived(object sender, MessageInterceptorEventArgs e) { SmsMessage sms = (SmsMessage)e.Message; if (OnSMSReceived != null) { OnSMSReceived(sms); } }
static void msgInterceptor_MessageReceived(object sender, MessageInterceptorEventArgs e) { if ( e.Message is SmsMessage ) AfterMsgReceivingEvent(e.Message as SmsMessage); }
private void smsInterceptor_MessageReceived(object sender, MessageInterceptorEventArgs e) { try { // Increment the SMS count COUNT = COUNT + 1; SmsMessage sms = (SmsMessage)e.Message; // If Prompt is enabled if (dbManager.CanPrompt()) { string text = sms.Body; if (sms.Body.Length > 90) { text = sms.Body.Substring(0, 90) + " ..."; } if (MessageBox.Show("From : " + sms.From.Address + "\r\n" + "Text : " + text, "Forward via SMS to Email ?" + " (" + COUNT.ToString() + ")", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { // Forward the SMS message this.ForwardSms(sms); } } else { // Forward the SMS message this.ForwardSms(sms); } } catch (StackOverflowException) { } catch (Exception) { } finally { // Decrement the COUNT once an SMS has been processed COUNT = COUNT - 1; // If all pending SMS messages have been processed, dispose and close. if (COUNT <= 0) { // If we sent an SMS message if (this.bSent) { // Sync the Outbox now if we can if (this.dbManager.CanSynchronize()) { MessagingApplication.Synchronize(this.emailAccount); } } // Remove the MessageReceived event handler smsInterceptor.MessageReceived -= smsInterceptor_MessageReceived; // Dispose of the MessageInterceptor smsInterceptor.Dispose(); // Close and Exit this.Close(); } } }