Click or drag to resize
ZenophSMSgetSubmitStatus Method (String, Boolean, STATUSQUERY)
Gets the status of submitted destinations from a query token.

Namespace: Zenoph.SMSLib
Assembly: Zenoph.SMSLib (in Zenoph.SMSLib.dll) Version: 2015.9.30.0 (2015.09.30.0)
Syntax
public Dictionary<STATUSQUERY, List<string>> getSubmitStatus(
	string token,
	bool getrecpts,
	params STATUSQUERY[] states
)

Parameters

token
Type: SystemString
A unique key that identifies the message which can be used to query the status of submitted destinations.
getrecpts
Type: SystemBoolean
Indicates whether the recipients of the message should be returned as well or not.
states
Type: Zenoph.SMSLib.EnumsSTATUSQUERY
The states of destinations that should be returned. Each must be separated with a comma.

Return Value

Type: DictionarySTATUSQUERY, ListString
Returns the submit status of submitted destinations.
Examples
using System;
using System.Threading;
using System.Collections.Generic;
using Zenoph.SMSLib;
using Zenoph.SMSLib.Enums;

namespace SMSTest
{
    public class Program
    {
        public static void Main(String[] args)
        {
            try
            {
                ZenophSMS sms = new ZenophSMS();
                sms.setUser("account_login");
                sms.setPassword("account_password");
                sms.authenticate();

                // set the message.
                sms.setMessage("Hello there!");
                sms.setSenderId("SMSTEST");

                // add the destinations.
                sms.addRecipient("020772222");
                sms.addRecipient("233264999999");

                // extract other phone numbers.
                List<string> numbers = sms.extractPhoneNumbers("string containing phone numbers");

                // add the phone numbers.
                foreach (string num in numbers)
                    sms.addRecipient(num, true);

                // submit the message.
                List<string[]> resp = sms.submit();

                // if the total number of destinations that were submitted is greater than
                // the maximum value for a single batch submit to return status immediately,
                // then a token was returned.

                if (sms.getRecipientsCount() > ZenophSMS.getBatchSubmitMax())
                {
                    processTokenResponse(resp[0][0], sms);
                }

                else    // states of destinations were immediately returned.
                {
                    // we can show the states if there is the need.
                    foreach (string[] s in resp)
                        Console.WriteLine("Destination: {0},  Status: {1}", resp[1], resp[2]);
                }
            }

            catch (SMSException sex)
            {
                Console.WriteLine("Error: {0}", sex.Message);
            }

            catch (Exception ex)
            {
                Console.WriteLine("Error: {0}", ex.Message);
            }
        }

        static void processTokenResponse(string token, ZenophSMS sms)
        {
            if (string.IsNullOrEmpty(token))
                    throw new Exception("Invalid token for requesting submit status.");

                Dictionary<STATUSQUERY, List<string>> st = null;

            do
            {
                Thread.Sleep(5000);
                st = sms.getSubmitStatus(token, STATUSQUERY.PENDING);   // only want to know if some are pending.
            } while (Convert.ToInt32(st[STATUSQUERY.PENDING][0]) > 0);

            // at this point all message has been submitted to all destinations.
            // If we are interested in the destinations and their states, we can do that below
            st = sms.getSubmitStatus(token, true, STATUSQUERY.SUBMITTED, STATUSQUERY.REJECTED);

            // we can obtain them separately.
            List<string> submitted = st[STATUSQUERY.SUBMITTED];
            List<string> rejected  = st[STATUSQUERY.REJECTED];

            // we can do what we want to do with the returned data.
        }
    }
}
See Also