Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="center"></param>
        /// <param name="phone"></param>
        /// <param name="count"></param>
        /// <param name="i"></param>
        /// <param name="content"></param>
        /// <param name="length"></param>
        /// <returns></returns>
        public static string EncodingSMS(string center, string phone, int count, int i, string content, out string length)
        {
            string message  = string.Empty;
            int    msgcount = PDUdecoding.GetMaxEncodeCharCount() * 2;//固定

            if (i == count)
            {
                message = content.Substring((i - 1) * msgcount); //共可发送134个编码
            }
            else
            {
                message = content.Substring((i - 1) * msgcount, msgcount);
            }

            center = DecodingCenter(center);

            //string result = string.Format("005100{0}{1}0008A7{2:X2}05000304{3:D2}{4:D2}{5}",
            //                            center,
            //                            DecodingPhone(phone),
            //                            (message.Length + 12) / 2,
            //                            count,
            //                            i,
            //                            message);

            //length = String.Format("{0:D2}", result.Length / 2 - center.Length / 2);//获取短信内容加上手机号码长度

            ////string ph = phone;
            ////phone = DecodingPhone(phone).Substring(2);

            ////string result = string.Format("005100{0}{1}0008A7{2:X2}05000304{3:D2}{4:D2}{5}",
            ////                              string.Format("{0:X2}A1", ph.Length),
            ////                            phone,
            ////                            (message.Length + 12) / 2,
            ////                            count,
            ////                            i,
            ////                            message);

            string result = String.Format("{0}51000D91{1}000800{2:X2}05000304{4:D2}{5:D2}{3}",
                                          center,
                                          DecodingPhone(phone),
                                          message.Length / 2 + 6,
                                          message,
                                          count,
                                          i
                                          );

            length = String.Format("{0:D2}", result.Length / 2 - center.Length / 2);//获取短信内容加上手机号码长度

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 超长短信
        /// </summary>
        /// <param name="center"></param>
        /// <param name="phone"></param>
        /// <param name="content"></param>
        /// <param name="count"></param>
        /// <param name="i"></param>
        /// <param name="length"></param>
        /// <returns></returns>
        public static string EncodingSMS(string center, string phone, string content, int count, int i, out string length)
        {
            if (content.Length <= PDUdecoding.MAX_CHAR_COUNT)
            {
                return(PDUdecoding.EncodingSMS(center, phone, content, out length));
            }
            else
            {
                if (count - 1 == i)
                {
                    content = content.Substring(i * (PDUdecoding.MAX_CHAR_COUNT - 6));
                }
                else
                {
                    content = content.Substring(i * (PDUdecoding.MAX_CHAR_COUNT - 6), PDUdecoding.MAX_CHAR_COUNT - 6);
                }

                center  = DecodingCenter(center);
                content = Encoding(content);

                string result = "";

                DateTime tm = DateTime.Now;

                //result = string.Format("{0}44000D91{1}0008{2}{3:X2}05000304{4:D2}{5:D2}{6}",
                //                        center,
                //                        DecodingPhone(phone),
                //                        ParityChange(string.Format("{0:X2}{1:X2}{2:X2}{3:X2}{4:X2}{5:X2}08", tm.Year - 2000, tm.Month, tm.Day, tm.Hour, tm.Minute, tm.Second)),
                //                        (content.Length + 12) / 2,
                //                        count,
                //                        i + 1,
                //                        content
                //                        );

                result = string.Format("005100{0}{1}0008A7{2:X2}05000304{3:D2}{4:D2}{5}",
                                       center,
                                       DecodingPhone(phone),
                                       (content.Length + 12) / 2,
                                       count,
                                       i + 1,
                                       content);

                length = String.Format("{0:D2}", result.Length / 2 - center.Length / 2);//获取短信内容加上手机号码长度
                return(result);
            }
        }