Esempio n. 1
0
        private static bool HaveSameReferenceNumber(SmsPdu pdu1, SmsPdu pdu2)
        {
            bool flag = false;

            if (SmartMessageDecoder.IsPartOfConcatMessage(pdu1) && SmartMessageDecoder.IsPartOfConcatMessage(pdu2))
            {
                IConcatenationInfo concatenationInfo  = SmartMessageDecoder.GetConcatenationInfo(pdu1);
                IConcatenationInfo concatenationInfo1 = SmartMessageDecoder.GetConcatenationInfo(pdu2);
                if (concatenationInfo.ReferenceNumber == concatenationInfo1.ReferenceNumber)
                {
                    flag = true;
                }
            }
            return(flag);
        }
Esempio n. 2
0
        private static SortedList <IConcatenationInfo, SmsPdu> SortConcatMessageParts(IList <SmsPdu> parts)
        {
            IConcatenationInfo concatenationInfo;
            IConcatenationInfo concatenationInfo1 = null;
            SortedList <IConcatenationInfo, SmsPdu> concatenationInfos = new SortedList <IConcatenationInfo, SmsPdu>(new ConcatInfoComparer());

            foreach (SmsPdu part in parts)
            {
                if (concatenationInfo1 != null)
                {
                    if (!SmartMessageDecoder.IsPartOfConcatMessage(part))
                    {
                        throw new ArgumentException("A non-concatenated message part is present at an invalid position.", "parts");
                    }
                    else
                    {
                        concatenationInfo = SmartMessageDecoder.GetConcatenationInfo(part);
                        if (concatenationInfo1.ReferenceNumber == concatenationInfo.ReferenceNumber)
                        {
                            if (concatenationInfo1.TotalMessages != concatenationInfo.TotalMessages)
                            {
                                throw new ArgumentException("The number of total messages differs between the message parts.", "parts");
                            }
                        }
                        else
                        {
                            throw new ArgumentException("The reference numbers differ between the message parts.", "parts");
                        }
                    }
                }
                else
                {
                    concatenationInfo = SmartMessageDecoder.GetConcatenationInfo(part);
                }
                concatenationInfos.Add(concatenationInfo, part);
                concatenationInfo1 = concatenationInfo;
            }
            return(concatenationInfos);
        }
Esempio n. 3
0
 /// <summary>
 /// Retrieves the user data of all parts of a concatenated message.
 /// </summary>
 /// <param name="parts">The parts that make up the concatenated message.</param>
 /// <param name="outputAsText">If true, formats the returned user data as text. If false, returns the user data
 /// in its binary form.</param>
 /// <param name="allowMissingParts">Specifies whether missing parts are allowed. If true, null is returned
 /// in the resulting list in place of every missing part. If false, an exception is raised when a part is
 /// missing.</param>
 /// <param name="noOutput">If set to true, does not fill the returned list with data. If set to false, the data is returned
 /// normally. Use this in conjunction with allowMissingParts set to true to verify whether all message parts are present.</param>
 /// <param name="allPartsAvailable">Is set to true if all message parts are available, false otherwise. Use this in conjunction
 /// with allowMissingParts set to true to verify whether all message parts are present.</param>
 /// <returns>A list of objects containing the user data of every part without any headers.
 /// The outputAsText parameter determines the actual data type that is returned. If outputAsText is true, the return type is a
 /// list of byte arrays, if false a list of strings is returned.
 /// </returns>
 /// <remarks>
 /// <para>The parts can be in any order.</para>
 /// <para>If the first part is a non-concatenated message, its user data is returned back, and no more parts are processed
 /// afterwards.</para>
 /// </remarks>
 /// <exception cref="T:System.ArgumentNullException">parts is null.</exception>
 /// <exception cref="T:System.ArgumentException">
 /// <para>Not all parts of the message are available and allowMissingParts is false.</para>
 /// <para> -or- </para>
 /// <para>The reference numbers differ between the message parts.</para>
 /// <para> -or- </para>
 /// <para>The number of total messages differs between the message parts.</para>
 /// <para> -or- </para>
 /// <para>A non-concatenated message part is present at an invalid position.</para>
 /// </exception>
 private static List <object> GetConcatUserData(IList <SmsPdu> parts, bool outputAsText, bool allowMissingParts, bool noOutput, out bool allPartsAvailable)
 {
     if (parts != null)
     {
         allPartsAvailable = true;
         List <object> objs = new List <object>();
         if (parts.Count > 0)
         {
             SmsPdu item = parts[0];
             if (!SmartMessageDecoder.IsPartOfConcatMessage(item))
             {
                 if (!noOutput)
                 {
                     if (!outputAsText)
                     {
                         objs.Add(item.UserData);
                     }
                     else
                     {
                         objs.Add(item.UserDataText);
                     }
                 }
             }
             else
             {
                 SortedList <IConcatenationInfo, SmsPdu> concatenationInfos = SmartMessageDecoder.SortConcatMessageParts(parts);
                 int totalMessages = concatenationInfos.Keys[0].TotalMessages;
                 int num           = 0;
                 for (int i = 1; i <= totalMessages; i++)
                 {
                     bool flag = false;
                     if (num < concatenationInfos.Count)
                     {
                         IConcatenationInfo concatenationInfo = concatenationInfos.Keys[num];
                         SmsPdu             smsPdu            = concatenationInfos.Values[num];
                         if (i == concatenationInfo.CurrentNumber)
                         {
                             if (!noOutput)
                             {
                                 if (!outputAsText)
                                 {
                                     objs.Add(smsPdu.GetUserDataWithoutHeader());
                                 }
                                 else
                                 {
                                     objs.Add(smsPdu.GetUserDataTextWithoutHeader());
                                 }
                             }
                             num++;
                         }
                         else
                         {
                             flag = true;
                         }
                     }
                     else
                     {
                         flag = true;
                     }
                     if (flag)
                     {
                         allPartsAvailable = false;
                         if (!allowMissingParts)
                         {
                             throw new ArgumentException(string.Concat("Not all parts of the message are available. Part #", i, " is missing."), "parts");
                         }
                         else
                         {
                             if (!noOutput)
                             {
                                 objs.Add(null);
                             }
                         }
                     }
                 }
             }
         }
         return(objs);
     }
     else
     {
         throw new ArgumentNullException("parts");
     }
 }