Exemple #1
0
        /// <summary>
        /// 获取短信通道信息业务实体
        /// </summary>
        /// <param name="channelIndex">通道索引</param>
        /// <returns></returns>
        public static Eyousoft_yhq.Model.SMSChannel GetSMSChannelInfo(int channelIndex)
        {
            Eyousoft_yhq.Model.SMSChannel channel = new Eyousoft_yhq.Model.SMSChannel { Index = -1, ChannelName = "未知通道", IsLong = false };

            System.Collections.Generic.IList<Eyousoft_yhq.Model.SMSChannel> channels = GetSMSChannels();

            foreach (Eyousoft_yhq.Model.SMSChannel tmp in channels)
            {
                if (tmp.Index == channelIndex)
                {
                    channel = tmp;
                }
            }

            return channel;
        }
Exemple #2
0
        /// <summary>
        /// 获取短信通道信息集合
        /// </summary>
        /// <returns></returns>
        public static IList<Eyousoft_yhq.Model.SMSChannel> GetSMSChannels()
        {
            string channelConfig = Adpost.Common.ConfigModel.ConfigClass.GetConfigString("appSettings", "SMS_SMSChannel");

            if (string.IsNullOrEmpty(channelConfig))
            {
                throw new Exception("未配置短信发送的通道信息");
            }

            string[] channelArr = channelConfig.Split('|');

            if (channelArr == null || channelArr.Length == 0)
            {
                throw new Exception("未正确配置短信发送的通道信息");
            }

            System.Collections.Generic.IList<Eyousoft_yhq.Model.SMSChannel> channels = new System.Collections.Generic.List<Eyousoft_yhq.Model.SMSChannel>();

            foreach (string channel in channelArr)
            {
                string[] valArr = channel.Split(',');
                if (valArr != null && valArr.Length > 0)
                {
                    Eyousoft_yhq.Model.SMSChannel item = new Eyousoft_yhq.Model.SMSChannel();

                    item.Index = Convert.ToInt32(valArr[0].Split(':')[1]);
                    item.ChannelName = valArr[1].Split(':')[1];
                    item.UserName = valArr[2].Split(':')[1];
                    item.Pw = valArr[3].Split(':')[1];
                    item.PriceOne = Convert.ToDecimal(valArr[4].Split(':')[1]);

                    if (valArr[5].Split(':')[1] == "1")
                    {
                        item.IsLong = true;
                    }

                    channels.Add(item);
                }
            }

            return channels;
        }