Как отправить delivery_sm_resp в качестве подтверждения SMS C? - PullRequest
0 голосов
/ 25 февраля 2020

Ниже приведен мой код, по которому я получаю MO и DR, может кто-нибудь подсказать, как мне нужно остановить несколько вставок для одного и того же номера в моей базе данных. Я использую режим трансивера и INETLab. Проблема в том, что я не понимаю, как я могу назначить последовательность перед отправкой, поскольку я использую массовую отправку сообщений, а также как я могу остановить многократную доставку одних и тех же сообщений с различной последовательностью.

private void _recvClient_evDeliverSm(object sender, DeliverSm data)
    {
        try
        {

            //Check if we received Delivery Receipt
            if (data.MessageType == MessageTypes.SMSCDeliveryReceipt)
            {
                logger.InfoFormat("Inside SMSCDelivery Reciept Case for data {0}", data.DestinationAddress);
                //Get MessageId of delivered message                   
                try
                {
                  //store in database for SMS History maintenance
                }
                catch (Exception ex)
                {
                    logger.ErrorFormat("Exception occcured in SMS Delivery Reciept Save at time {0}, {1}", DateTime.Now.ToString(), ex.InnerException!=null ?  ex.InnerException.Message : ex.Message);
                }

            }
            else
            {
                //IF its a MO insert msg in database and auto reply customer after some action

                // Receive incoming message and try to concatenate all parts
                if (data.Concatenation != null)
                {
                    logger.Info(string.Format("Concat Message recieved from source {0} at time {1}", data.SourceAddress.Address, DateTime.Now.ToShortDateString()));
                    _messageComposer.AddMessage(data);
                    myMessages.CreatedDate = DateTime.Now;
                    myMessages.Message = _recvClient.EncodingMapper.GetMessageText(data);
                    myMessages.SourceAddres = data.DestinationAddress.Address;
                    myMessages.Status = data.Receipt != null ? Convert.ToInt32(data.Receipt.State) : 0;
                    NotificationHelperService.AddRecievedNotification(myMessages, _connectionString);
                    //_log.Info("DeliverSm part received: Sequence: {0}, SourceAddress: {1}, Concatenation ( {2} )" +
                    //        " Coding: {3}, Text: {4}",
                    //        data.Header.Sequence, data.SourceAddress, data.Concatenation, data.DataCoding, _recvClient.EncodingMapper.GetMessageText(data));
                }
                else
                {
                    logger.Info(string.Format("Message recieved from source {0} at time {1}", data.SourceAddress.Address, DateTime.Now.ToShortDateString()));
                    myMessages.CreatedDate = DateTime.Now;
                    myMessages.Message = _recvClient.EncodingMapper.GetMessageText(data);
                    myMessages.SourceAddres = data.SourceAddress.Address;
                    myMessages.Status = data.Receipt != null ? Convert.ToInt32(data.Receipt.State) : 0;
                    NotificationHelperService.AddRecievedNotification(myMessages, _connectionString);
                    //Perform Recieve Action here

                   AutoReplyConfigurations(myMessages);


                }

                //Check if an ESME acknowledgement is required
                if (data.Acknowledgement != SMEAcknowledgement.NotRequested)
                {
                    // You have to clarify with SMSC support what kind of information they request in ESME acknowledgement.
                    try
                    {
                       //Send an acknowledgment here if its requested
                    }
                    catch (Exception ex)
                    {
                        logger.ErrorFormat("Exception occcured in SMS Delivery Acknowledgement at time {0}, {1}", DateTime.Now.ToString(), ex.InnerException != null ? ex.InnerException.Message : ex.Message);
                    }

                }
            }
        }
        catch (Exception ex)
        {
            data.Response.Header.Status = CommandStatus.ESME_RX_T_APPN;
            logger.Error(string.Format("Message Deliver event failed at time {0}, the exception is {1}", DateTime.Now.ToShortDateString(), ex.Message));
        }
    }
...