Пример #1
0
        /// <summary> Called to send the message </summary>
        /// <param name="phoneNumber"></param>
        /// <param name="serviceType"></param>
        /// <param name="destinationTon"></param>
        /// <param name="destinationNpi"></param>
        /// <param name="submitDataCoding"></param>
        /// <param name="encodeDataCoding"></param>
        /// <param name="message"></param>
        /// <param name="submitSmList"></param>
        /// <param name="submitSmRespList"></param>
        /// <returns> 0 - Successful / 1 - Failed / 2 - Not Connected </returns>
        public int SendMessageLarge(string phoneNumber, string serviceType, Ton destinationTon, Npi destinationNpi, DataCodings submitDataCoding, DataCodings encodeDataCoding, string message, out List <SubmitSm> submitSmList, out List <SubmitSmResp> submitSmRespList)
        {
            int retVal = 1;

            submitSmList     = null;
            submitSmRespList = null;

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

                    return(2);
                }

                // Prepare the message, I have made sure there is only ever one message
                // with the trunacting above
                submitSmList = Client.PrepareSubmitLarge(
                    SubmitMode.ShortMessage,
                    serviceType,
                    (byte)Ton.NetworkSpecific,
                    (byte)Npi.Unknown,
                    ShortLongCode,
                    (byte)destinationTon,
                    (byte)destinationNpi,
                    phoneNumber,
                    submitDataCoding,
                    encodeDataCoding,
                    message);

                // Send the message
                submitSmRespList = Client.Submit(submitSmList);

                foreach (SubmitSmResp submitSmResp in submitSmRespList)
                {
                    // Log the send call
                    WriteLog("ESMEConnection : SendMessage : Send : Sequence[{0}] Phone[{1}] Status[{2}]", submitSmResp.Sequence, phoneNumber, submitSmResp.Status);

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

                // Success
                retVal = 0;
            }

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

                retVal = 1;
            }

            return(retVal);
        }