Ejemplo n.º 1
0
 internal SmsMessage(int index, SmsMessageStatus status, string senderPhoneNumber, 
     AddressType addrType, DateTime timestamp, string body)
 {
     this.Index = index;
     this.Status = status;
     this.Number = senderPhoneNumber;
     this.Timestamp = timestamp;
     this.AddressType = addrType;
     this.Body = body;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Get a summarized report of sent messages
        /// </summary>
        /// <param name="dateFrom">The start date for the report time interval</param>
        /// <param name="dateTo">The end date for the report time interval</param>
        /// <param name="senderId">Filter messages report according to a specific sender ID</param>
        /// <param name="status">Filter messages report according to a specific message status, "Sent", "Queued", "Rejected" or "Failed"</param>
        /// <param name="dlr">Message delivery status returned by networks, the possible values are "Delivered" or "Undeliverable", and are available for advanced plans</param>
        /// <param name="country">Filter messages report according to a specific destination country</param>
        public virtual SmsMessagesReportResult GetSmsMessagesReport(DateTime? dateFrom = null,
            DateTime? dateTo = null, string senderId = null, SmsMessageStatus? status = null, 
            DlrStatus? dlr = null, string country = null)
        {
            var request = new RestRequest(Method.POST) { Resource = "Messages/GetMessagesReport" };
            if (dateFrom.HasValue) request.AddParameter("DateFrom", dateFrom.Value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture));
            if (dateTo.HasValue) request.AddParameter("DateTo", dateTo.Value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture));
            if (senderId.HasValue()) request.AddParameter("SenderID", senderId);

            if (status.HasValue) request.AddParameter("Status",status.Value);
            if (dlr.HasValue) request.AddParameter("DLR", dlr);
            if (country.HasValue()) request.AddParameter("Country", country);

            return Execute<SmsMessagesReportResult>(request);
        }
Ejemplo n.º 3
0
 internal static extern int SetSmsMsgStatus(IntPtr handle, int index, SmsMessageStatus status, TapiResponseCallback cb, IntPtr userData);
Ejemplo n.º 4
0
 internal static string ConvertToStatString(SmsMessageStatus status)
 {
     switch (status)
     {
         case SmsMessageStatus.ReceivedUnread:
             return "REC UNREAD";
         case SmsMessageStatus.ReceivedRead:
             return "REC READ";
         case SmsMessageStatus.StoredUnsent:
             return "STO UNSENT";
         case SmsMessageStatus.StoredSent:
             return "STO SENT";
         case SmsMessageStatus.All:
             return "ALL";
         default:
             return "";
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Get all sms messages by message status
        /// </summary>
        /// <param name="status">The set of messages to retrieve. For instance, read vs unread vs all.</param>
        /// <param name="fClearUnreadFlag"></param>
        /// <returns></returns>
        public SmsMessage[] GetSmsMessages(SmsMessageStatus status, bool fClearUnreadFlag)
        {
            lock (_lockCommand)
            {
                ArrayList result = new ArrayList();
                // Text mode
                SendAndExpect(SetSmsMode + "1", OK);
                // Show all parameters
                SendAndExpect(SetSmsTextModeOutput + "1", OK);

                SendCommand(ListSmsMessagesCommand + '"' + SmsMessage.ConvertToStatString(status) + "\"," +
                            (fClearUnreadFlag ? "1" : "0"));
                var reply = GetReplyWithTimeout(DefaultCommandTimeout).Trim();
                while (reply != OK)
                {
                    var info = reply.Substring(ListSmsMessagesReply.Length);
                    var tokens = info.Split(',');
                    var body = GetReplyWithTimeout(DefaultCommandTimeout);

                    var index = int.Parse(tokens[0]);
                    var msgStat = SmsMessage.ParseMessageStatus(Unquote(tokens[1]));
                    var addrType = (AddressType) int.Parse(Unquote(tokens[6]));

                    // tokens 3 and 4 are a date and time with an embedded quote. Remove the quote remnants
                    if (tokens[4][0] == '"')
                        tokens[4] = tokens[4].Substring(1);
                    if (tokens[5][tokens[5].Length - 1] == '"')
                        tokens[5] = tokens[5].Substring(0, tokens[5].Length - 1);
                    var timestamp = ParseDateString(tokens[4], tokens[5]);

                    result.Add(new SmsMessage(index, msgStat, Unquote(tokens[2]), addrType, timestamp, body));

                    // Keep going until we eat an 'ok'
                    reply = GetReplyWithTimeout(DefaultCommandTimeout).Trim();
                }

                return (SmsMessage[]) result.ToArray(typeof (SmsMessage));
            }
        }