Beispiel #1
0
        /// <summary> Called to add the message segment to the collector dictionary </summary>
        /// <param name="data"></param>
        private void AddMessageSegmentToCollector(DeliverSm data)
        {
            try
            {
                SmppClient.UserDataControl userDataControl = null;
                string key = data.SourceAddr + data.MessageReferenceNumber;

                lock (Collector)
                {
                    if (Collector.ContainsKey(key))
                    {
                        userDataControl = Collector[key];
                    }
                    else
                    {
                        userDataControl = new SmppClient.UserDataControl(data.TotalSegments);
                        Collector.Add(key, userDataControl);
                    }
                }

                // Add the segment to the current
                userDataControl.UserData.Add(data.UserData);
                --userDataControl.SegmentsLeftToReceived;
            }

            catch (Exception exception)
            {
                WriteLog(LogEventNotificationTypes.Email, "ESMEConnection : AddMessageSegmentToCollector : ERROR : {0}", exception.ToString());
            }
        }
Beispiel #2
0
        /// <summary> Called to verify we received the last segment of data </summary>
        /// <param name="data"></param>
        /// <returns> True or False </returns>
        private bool IsLastSegment(DeliverSm data)
        {
            bool finished = false;

            try
            {
                SmppClient.UserDataControl userDataControl = null;
                string key = data.SourceAddr + data.MessageReferenceNumber;

                lock (Collector)
                {
                    if (Collector.ContainsKey(key))
                    {
                        userDataControl = Collector[key];
                    }
                }

                if (userDataControl != null)
                {
                    if (userDataControl.SegmentsLeftToReceived <= 0)
                    {
                        finished = true;
                    }
                }
                else
                {
                    WriteLog(LogEventNotificationTypes.Email, "ESMEConnection : IsLastSegment : ERROR : No User Data Found");
                }
            }

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

            return(finished);
        }
Beispiel #3
0
        /// <summary> Called to retrieve the full message </summary>
        /// <param name="data"></param>
        /// <returns> The message </returns>
        private string RetrieveFullMessage(DeliverSm data)
        {
            string message = null;

            try
            {
                SmppClient.UserDataControl userDataControl = null;
                string key = data.SourceAddr + data.MessageReferenceNumber;

                lock (Collector)
                {
                    if (Collector.ContainsKey(key))
                    {
                        userDataControl = Collector[key];

                        Collector.Remove(key);
                    }
                }

                if (userDataControl != null)
                {
                    message = userDataControl.UserData.ShortMessageText(data.DefaultEncoding, data.DataCoding);
                }
                else
                {
                    WriteLog(LogEventNotificationTypes.Email, "ESMEConnection : RetrieveFullMessage : ERROR : No User Data Found");
                }
            }

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

            return(message);
        }