Пример #1
0
        /// <summary> Called when the SMPP query is returned </summary>
        /// <param name="sender"></param>
        /// <param name="data"></param>
        private void ClientEventQuerySmResp(object sender, QuerySmResp data)
        {
            try
            {
                WriteLog("ESMEConnection : ClientEventQuerySmResp : Info : MessageId[{0}] MessageState[{1}] Status[{2}]", data.MessageId, data.MessageState, data.Status);

                if (QueryMessageHandler != null)
                {
                    QueryMessageHandler(LogKey, (int)data.Sequence, data.MessageId, data.FinalDate, (int)data.MessageState, (long)data.ErrorCode);
                }
            }

            catch (Exception exception)
            {
                WriteLog(LogEventNotificationTypes.Email, "ESMEConnection : ClientEventQuerySmResp : ERROR : {0}", exception.ToString());
            }
        }
Пример #2
0
        /// <summary> Called to create a QuerySmResp object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="buf"></param>
        /// <param name="offset"></param>
        /// <returns> QuerySmResp </returns>
        public static QuerySmResp Create(DataCodings defaultEncoding, SmppBuffer buf, ref int offset)
        {
            QuerySmResp querySmResp = new QuerySmResp(defaultEncoding);

            try
            {
                buf.ExtractHeader(querySmResp, ref offset);

                querySmResp.MessageId       = buf.ExtractCString(ref offset);
                querySmResp.FinalDateString = buf.ExtractCString(ref offset);
                querySmResp.MessageState    = (MessageState)buf.ExtractByte(ref offset);
                querySmResp.ErrorCode       = buf.ExtractByte(ref offset);
            }

            catch
            {
                querySmResp = null;
            }

            return(querySmResp);
        }
Пример #3
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);
        }
Пример #4
0
        /// <summary> Called when the SMPP query is returned </summary>
        /// <param name="sender"></param>
        /// <param name="data"></param>
        private void ClientEventQuerySmResp(object sender, QuerySmResp data)
        {
            try
            {
                WriteLog("ESMEConnection : ClientEventQuerySmResp : Info : MessageId[{0}] MessageState[{1}] Status[{2}]", data.MessageId, data.MessageState, data.Status);

                if (QueryMessageHandler != null)
                {
                    QueryMessageHandler(LogKey, (int) data.Sequence, data.MessageId, data.FinalDate, (int) data.MessageState, (long) data.ErrorCode);
                }
            }

            catch (Exception exception)
            {
                WriteLog(LogEventNotificationTypes.Email, "ESMEConnection : ClientEventQuerySmResp : ERROR : {0}", exception.ToString());
            }
        }
Пример #5
0
        /// <summary> Called to create a QuerySmResp object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="buf"></param>
        /// <param name="offset"></param>
        /// <returns> QuerySmResp </returns>
        public static QuerySmResp Create(DataCodings defaultEncoding, SmppBuffer buf, ref int offset)
        {
            QuerySmResp querySmResp = new QuerySmResp(defaultEncoding);

            try
            {
                buf.ExtractHeader(querySmResp, ref offset);

                querySmResp.MessageId = buf.ExtractCString(ref offset);
                querySmResp.FinalDateString = buf.ExtractCString(ref offset);
                querySmResp.MessageState = (MessageState) buf.ExtractByte(ref offset);
                querySmResp.ErrorCode = buf.ExtractByte(ref offset);
            }

            catch
            {
                querySmResp = null;
            }

            return querySmResp;
        }
Пример #6
0
        /// <summary> Called to fire the query resp pdu event </summary>
        /// <param name="data"></param>
        internal void OnQuerySmResp(QuerySmResp data)
        {
            try
            {
                if (QuerySmRespEvent != null)
                {
                    QuerySmRespEvent(this, data);
                }
            }

            catch
            {
            }
        }