Exemplo n.º 1
0
        /// <summary>
        /// 获得短信通道设置信息
        /// </summary>
        /// <returns></returns>
        public SmsChannelInfo GetChannelInfo()
        {
            SmsChannelDal  dal            = new SmsChannelDal();
            SmsChannelInfo smsChannelInfo = dal.GetChannelInfo();

            if (smsChannelInfo.SendMode == 2)
            {
                //运营商绑定模式
                smsChannelInfo.SmsOperator.SmsSystem.ChinaMobile.ChannelName  = Enum.GetName(typeof(smsEnum.smsChannel), smsChannelInfo.SmsOperator.SmsSystem.ChinaMobile.ChannelId);
                smsChannelInfo.SmsOperator.SmsSystem.ChinaUnicom.ChannelName  = Enum.GetName(typeof(smsEnum.smsChannel), smsChannelInfo.SmsOperator.SmsSystem.ChinaUnicom.ChannelId);
                smsChannelInfo.SmsOperator.SmsSystem.ChinaTelecom.ChannelName = Enum.GetName(typeof(smsEnum.smsChannel), smsChannelInfo.SmsOperator.SmsSystem.ChinaTelecom.ChannelId);

                smsChannelInfo.SmsOperator.SmsFast.ChinaMobile.ChannelName  = Enum.GetName(typeof(smsEnum.smsChannel), smsChannelInfo.SmsOperator.SmsFast.ChinaMobile.ChannelId);
                smsChannelInfo.SmsOperator.SmsFast.ChinaUnicom.ChannelName  = Enum.GetName(typeof(smsEnum.smsChannel), smsChannelInfo.SmsOperator.SmsFast.ChinaUnicom.ChannelId);
                smsChannelInfo.SmsOperator.SmsFast.ChinaTelecom.ChannelName = Enum.GetName(typeof(smsEnum.smsChannel), smsChannelInfo.SmsOperator.SmsFast.ChinaTelecom.ChannelId);

                smsChannelInfo.SmsOperator.SmsGroup.ChinaMobile.ChannelName  = Enum.GetName(typeof(smsEnum.smsChannel), smsChannelInfo.SmsOperator.SmsGroup.ChinaMobile.ChannelId);
                smsChannelInfo.SmsOperator.SmsGroup.ChinaUnicom.ChannelName  = Enum.GetName(typeof(smsEnum.smsChannel), smsChannelInfo.SmsOperator.SmsGroup.ChinaUnicom.ChannelId);
                smsChannelInfo.SmsOperator.SmsGroup.ChinaTelecom.ChannelName = Enum.GetName(typeof(smsEnum.smsChannel), smsChannelInfo.SmsOperator.SmsGroup.ChinaTelecom.ChannelId);
            }
            else
            {
                //通道绑定模式
                smsChannelInfo.SmsPriority.SysPriority.ChannelName   = Enum.GetName(typeof(smsEnum.smsChannel), smsChannelInfo.SmsPriority.SysPriority.ChannelId);
                smsChannelInfo.SmsPriority.FastPriority.ChannelName  = Enum.GetName(typeof(smsEnum.smsChannel), smsChannelInfo.SmsPriority.FastPriority.ChannelId);
                smsChannelInfo.SmsPriority.GroupPriority.ChannelName = Enum.GetName(typeof(smsEnum.smsChannel), smsChannelInfo.SmsPriority.GroupPriority.ChannelId);
            }
            return(smsChannelInfo);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获得短信通道设置信息
        /// </summary>
        /// <returns></returns>
        public SmsChannelInfo GetChannelInfo()
        {
            SmsConfigInfoTmp tmpResult      = new SmsConfigInfoTmp();
            SmsChannelInfo   smsChannelInfo = new SmsChannelInfo();
            StringBuilder    strSql         = new StringBuilder();

            strSql.Append("declare @SendMode int;");
            strSql.Append(" select @SendMode=Value from T_SysConfig where Item='sms_SendMode';");
            strSql.Append(" if(@SendMode=1)");
            strSql.Append(" begin");
            strSql.Append("   SELECT @SendMode as sendmode,max(case when Item='sms_channel_sys' then Value end) as sms_channel_sys,max(case when Item='sms_channel_f' then Value end) as sms_channel_f,max(case when Item='sms_channel_s' then Value end) as sms_channel_s FROM T_SysConfig where Item='sms_channel_f' or Item='sms_channel_s' or Item='sms_channel_sys';");
            strSql.Append(" end");
            strSql.Append(" else");
            strSql.Append(" begin");
            strSql.Append("  SELECT @SendMode as sendmode,Value from T_SysConfig where Item='sms_option';");
            strSql.Append(" end");


            try
            {
                tmpResult = HelperForFrontend.Query <SmsConfigInfoTmp>(strSql.ToString()).ToList()[0];
            }
            catch (Exception ex)
            {
                tmpResult = null;
            }

            if (tmpResult != null)
            {
                if (tmpResult.sendmode != null)
                {
                    smsChannelInfo.SendMode = tmpResult.sendmode;

                    if (smsChannelInfo.SendMode == 2)
                    {
                        //运营商绑定模式
                        if (tmpResult.Value != null)
                        {
                            string     objVal     = tmpResult.Value.ToString();
                            SmsChannel smsChannel = new SmsChannel();
                            smsChannel = Helper.JsonDeserializeObject <SmsChannel>(objVal.Trim());
                            smsChannelInfo.SmsOperator = smsChannel;
                        }
                    }
                    else
                    {
                        //通道绑定模式

                        SmsPriorityItem smsPriorityItem     = new SmsPriorityItem();
                        SmsChannelUnit  smsChannelUnitSys   = new SmsChannelUnit();
                        SmsChannelUnit  smsChannelUnitFast  = new SmsChannelUnit();
                        SmsChannelUnit  smsChannelUnitGroup = new SmsChannelUnit();
                        smsPriorityItem.SysPriority   = smsChannelUnitSys;
                        smsPriorityItem.FastPriority  = smsChannelUnitFast;
                        smsPriorityItem.GroupPriority = smsChannelUnitGroup;

                        smsPriorityItem.SysPriority.ChannelId   = tmpResult.sms_channel_sys;
                        smsPriorityItem.FastPriority.ChannelId  = tmpResult.sms_channel_f;
                        smsPriorityItem.GroupPriority.ChannelId = tmpResult.sms_channel_s;

                        smsChannelInfo.SmsPriority = smsPriorityItem;
                    }
                }
            }

            return(smsChannelInfo);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 更新运营商绑定通道设置
        /// </summary>
        /// <param name="typeName">通道名称</param>
        /// <param name="channelId">通道ID</param>
        /// <returns></returns>
        public bool SetSmsChannelOption(string typeName, int channelId)
        {
            bool           bResult        = false;
            SmsChannelDal  dal            = new SmsChannelDal();
            SmsChannelInfo smsChannelInfo = GetChannelInfo();

            switch (typeName)
            {
            case "sys_mobile":
                //系统_移动
                smsChannelInfo.SmsOperator.SmsSystem.ChinaMobile.ChannelId   = channelId;
                smsChannelInfo.SmsOperator.SmsSystem.ChinaMobile.ChannelName = null;
                break;

            case "sys_unicom":
                //系统_联通
                smsChannelInfo.SmsOperator.SmsSystem.ChinaUnicom.ChannelId   = channelId;
                smsChannelInfo.SmsOperator.SmsSystem.ChinaUnicom.ChannelName = null;
                break;

            case "sys_telecom":
                //系统_电信
                smsChannelInfo.SmsOperator.SmsSystem.ChinaTelecom.ChannelId   = channelId;
                smsChannelInfo.SmsOperator.SmsSystem.ChinaTelecom.ChannelName = null;
                break;

            case "fast_mobile":
                //普通_移动
                smsChannelInfo.SmsOperator.SmsFast.ChinaMobile.ChannelId   = channelId;
                smsChannelInfo.SmsOperator.SmsFast.ChinaMobile.ChannelName = null;
                break;

            case "fast_unicom":
                //普通_移动
                smsChannelInfo.SmsOperator.SmsFast.ChinaUnicom.ChannelId   = channelId;
                smsChannelInfo.SmsOperator.SmsFast.ChinaUnicom.ChannelName = null;
                break;

            case "fast_telecom":
                //普通_电信
                smsChannelInfo.SmsOperator.SmsFast.ChinaTelecom.ChannelId   = channelId;
                smsChannelInfo.SmsOperator.SmsFast.ChinaTelecom.ChannelName = null;
                break;

            case "group_mobile":
                //广告_移动
                smsChannelInfo.SmsOperator.SmsGroup.ChinaMobile.ChannelId   = channelId;
                smsChannelInfo.SmsOperator.SmsGroup.ChinaMobile.ChannelName = null;
                break;

            case "group_unicom":
                //广告_联通
                smsChannelInfo.SmsOperator.SmsGroup.ChinaUnicom.ChannelId   = channelId;
                smsChannelInfo.SmsOperator.SmsGroup.ChinaUnicom.ChannelName = null;
                break;

            case "group_telecom":
                //广告_电信
                smsChannelInfo.SmsOperator.SmsGroup.ChinaTelecom.ChannelId   = channelId;
                smsChannelInfo.SmsOperator.SmsGroup.ChinaTelecom.ChannelName = null;
                break;
            }

            SmsChannel smsChannel = smsChannelInfo.SmsOperator;

            return(dal.SetSmsChannelOption(smsChannel));
        }