예제 #1
0
        /// <summary> Called to send a query </summary>
        /// <param name="messageId"></param>
        /// <returns> 1 - Successful / 0 - Failed </returns>
        public QuerySm SendQuery(string messageId)
        {
            QuerySm querySm = null;

            try
            {
                if (Client.Status != ConnectionStatus.Bound)
                {
                    WriteLog("ESMEConnection : SendQuery : Warning : Not Connected To The SMPP Server");

                    return(querySm);
                }

                // Prepare the query
                querySm = QuerySm.Create(Client.DefaultEncoding, messageId, (byte)Ton.NetworkSpecific, (byte)Npi.Unknown, ShortLongCode);

                // Send the query
                QuerySmResp querySmResp = Client.Query(querySm);

                // Log the send call
                WriteLog("ESMEConnection : SendQueryThroughSMPP : Send : MessageId[{0}] Sequence[{1}] Status[{2}]", messageId, querySm.Sequence, querySmResp.Status);

                // Was it successful
                if (querySmResp.Status != CommandStatus.ESME_ROK)
                {
                    WriteLog("ESMEConnection : SendQueryThroughSMPP : ERROR : Failed For Unknown Reason");

                    querySm = null;
                }
            }

            catch (Exception exception)
            {
                WriteLog(LogEventNotificationTypes.Email, "ESMEConnection : SendQueryThroughSMPP : ERROR : {0}", exception.ToString());
            }

            return(querySm);
        }