mCore™ .NET SMS Library 1.2

mCore.QueueWapPushSentEventArgs Class

Description:

The QueueWapPushSentEventArgs class prepares data for the QueueWapPushSent event.

Namespace: mCore
Assembly: mCoreLib (in mCoreLib.dll)
Inherits: System.EventArgs

Exceptions:

mCore.GeneralException

Properties:

Property Description Type
DestinationNumber Destination number to which the WAP Push message was sent String
ErrorCode Error code if WAP Push message sending failed Long
ErrorDescription Error description (corresponding to ErrorCode) if WAP Push message sending failed String
MessageReference Message reference number (comma separated numbers in case of concatenated or split message) of the SMS sent (this can be compared with MessageReference of NewDeliveryReportEventArgs if DeliveryReport property was set to true while submitting the message to queue) String
QueueMessageKey Unique key as string that identifies the message in the queue String
SendResult Message sending result as a boolean value (True if sending was successful) Boolean

Usage Example:

Visual Basic
Public Class MyClass
   Public WithEvents objSMS As New mCore.SMS
   Public Sub SendQueue()
      Dim objWP As mCore.WapPush = objSMS.vCalendar
      Dim strKey As String = ""
      Try
         SetCommParameters()

         objWP.Destination = "+919873094767"
         objWP.Text = "Check your emails online"
         objWP.URL = "http://www.mobulus.com/mobile"
         objWP.Action = mCore.WapPushAction.SignalMedium
         objWP.Created = DateTime.Now
         objWP.Expiry = "1W"

         If objWP.IsLengthOK Then
            strKey = objWP.SendToQueue(mCore.QueuePriority.High)
            MsgBox("WAP Push message added to queue." & vbCrLf & _
                     "[Queue Key: " & strKey & "]")
         End If

         objWP.Destination = "+919810098765"
         If objWP.IsLengthOK Then
            'Following message is sent with normal queue priority
            strKey = objWP.SendToQueue()
            MsgBox("WAP Push message added to queue." & vbCrLf & _
                     "[Queue Key: " & strKey & "]")
         End If

         objWP.Destination = "+919811045678"
         If objWP.IsLengthOK Then
            strKey = objWP.SendToQueue(mCore.QueuePriority.Low)
            MsgBox("WAP Push message added to queue." & vbCrLf & _
                     "[Queue Key: " & strKey & "]")
         End If

         'Message queue is enabled
         objSMS.Queue.Enabled = True

         'Messages can be added to the queue even
         'when the Message queue is enabled

         objWP.Destination = "+919873012345"
         If objWP.IsLengthOK Then
            strKey = objWP.SendToQueue(mCore.QueuePriority.High)
            MsgBox("WAP Push message added to queue." & vbCrLf & _
                     "[Queue Key: " & strKey & "]")
         End If

      Catch ex As mCore.GeneralException
         MsgBox(ex.Message, MsgBoxStyle.Critical, "mCore Demo")
      Catch ex As Exception
      End Try
   End Sub

   'Event at the start of sending a queued WAP Push message
   Private Sub objSMS_QueueWapPushSending(ByVal sender As Object, _
               ByVal e As mCore.QueueWapPushSendingEventArgs) _
               Handles objSMS.QueueWapPushSending
      MsgBox("Sending WAP Push message to: " & e.DestinationNumber & vbCrLf & _
            "[Queue Key: " & e.QueueMessageKey & _
            "]", MsgBoxStyle.Information, "SENDING WAP PUSH")
   End Sub

   'Event at the end of sending a queued WAP Push message

   Private Sub objSMS_QueueWapPushSent(ByVal sender As Object, _
               ByVal e As mCore.QueueWapPushSentEventArgs) _
               Handles objSMS.QueueWapPushSent
      If e.ErrorCode > 0 Then
         MsgBox("WAP Push message sending FAILED to: " & e.DestinationNumber & _
               vbCrLf & "[ERROR: " & e.ErrorDescription & _
               "]" & vbCrLf & "[Queue Key: " & e.QueueMessageKey & _
               "]", MsgBoxStyle.Critical, "WAP PUSH FAILED")
      Else
         MsgBox("WAP Push message SENT to: " & e.DestinationNumber & vbCrLf & _
               "[Queue Key: " & e.QueueMessageKey & _
               "]", MsgBoxStyle.Information, "WAP PUSH SENT")
      End If
   End Sub

   Public Sub SetCommParameters()
      Try
         objSMS.Port = "COM1"
         objSMS.BaudRate = mCore.BaudRate.BaudRate_19200
         objSMS.DataBits = mCore.DataBits.Eight
         objSMS.StopBits = mCore.StopBits.One
         objSMS.Parity = mCore.Parity.None
         objSMS.FlowControl = mCore.FlowControl.RTS_CTS

      Catch ex As mCore.GeneralException
         MsgBox(ex.Message)
      Catch ex As Exception
      End Try
   End Function
End Class
 
C#

class MyClass
{
   public mCore.SMS objSMS = new mCore.SMS();

   public MyClass()

   {
      objSMS.QueueWapPushSending +=
         new mCore.SMS.QueueWapPushSendingEventHandler
         (objSMS_QueueWapPushSending);

      objSMS.QueueWapPushSent +=
         new mCore.SMS.QueueWapPushSentEventHandler
         (objSMS_QueueWapPushSent);
   }

   public static void SendQueue()
   {
      mCore.WapPush objWP = objSMS.WapPush();
      string strKey = "";
      try
      {

         SetCommParameters();

         objWP.Destination = "+919873094767";
         objWP.Text = "Check your emails online";
         objWP.URL = "http://www.mobulus.com/mobile";
         objWP.Action = mCore.WapPushAction.SignalMedium;
         objWP.Created = DateTime.Now;
         objWP.Expiry = "1W";

         if (objWP.IsLengthOK)
         {
            strKey = objVCAL.SendToQueue(mCore.QueuePriority.High);
            MessageBox.Show("vCalendar message added to queue.\r\n" +
                     "[Queue Key: " + strKey + "]");
         }

         objWP.Destination = "+919810098765";
         if (objWP.IsLengthOK)
         {
            //Following message is sent with normal queue priority
            strKey = objWP.SendToQueue();
            MessageBox.Show("WAP Push message added to queue.\r\n" +
                     "[Queue Key: " + strKey + "]");
         }

         objWP.Destination = "+919811045678";
         if (objWP.IsLengthOK)
         {
            strKey = objWP.SendToQueue(mCore.QueuePriority.Low);
            MessageBox.Show("WAP Push message added to queue.\r\n" +
                     "[Queue Key: " + strKey + "]");
         }

         //Message queue is enabled
         objSMS.Queue.Enabled = true;

         //Messages can be added to the queue even
         //when the Message queue is enabled
         objWP.Destination = "+919873012345";
         if (objWP.IsLengthOK)
         {
            strKey = objWP.SendToQueue(mCore.QueuePriority.High);
            MessageBox.Show("WAP Push message added to queue.\r\n" +
                     "[Queue Key: " + strKey + "]");
         }
      }

      catch (mCore.GeneralException e)
      {
         MessageBox.Show(e.ToString());
      }
      catch (Exception e)
      {
      }
   }

   //Event at the start of sending a queued WAP Push message
   private void objSMS_QueueWapPushSending
      (object sender, mCore.QueueWapPushSendingEventArgs e)
   {
      MessageBox.Show("Sending WAP Push message to: " + e.DestinationNumber + "/r/n" +
            "[Queue Key: " + e.QueueMessageKey + "]");
   }

   //Event at the end of sending a queued WAP Push message
   private void objSMS_QueueWapPushSent
      (object sender, mCore.QueueWapPushSentEventArgs e)
   {
      if (e.ErrorCode > 0)
      {
         MessageBox.Show("WAP Push message sending FAILED to: " + e.DestinationNumber +
               "/r/n" + "[ERROR: " + e.ErrorDescription + _
               "]/r/n[Queue Key: " & e.QueueMessageKey + "]");
      }
      else
      {
         MessageBox.Show("WAP Push message SENT to: " + e.DestinationNumber +
               "/r/n" + "[ERROR: " + e.ErrorDescription + _
               "]/r/n[Queue Key: " & e.QueueMessageKey + "]");
      }
   }

   public static void SetCommParameters()
   {
      try
      {
         objSMS.Port = "COM1";
         objSMS.BaudRate = mCore.BaudRate.BaudRate_19200;
         objSMS.DataBits = mCore.DataBits.Eight;
         objSMS.StopBits = mCore.StopBits.One;
         objSMS.Parity = mCore.Parity.None;
         objSMS.FlowControl = mCore.FlowControl.RTS_CTS;
      }

      catch (mCore.GeneralException e)
      {
         MessageBox.Show(e.ToString());
      }
      catch (Exception e)
      {
      }
   }
}

See Also:

mCore.SMS.QueueWapPushSent Event
mCore.SMS.QueueWapPushSentEventHandler Delegate

 

Copyright © IG Logix Softech Pvt Ltd, All Rights Reserved