示例#1
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnEnter_Click(object sender, EventArgs e)
        {
            //分类
            int sortId = Convert.ToInt32(ddlTpye.SelectedValue);
            //联系人
            List <Song.Entities.AddressList> addr = Business.Do <IAddressList>().AddressAll(sortId);
            string moibles = "";

            foreach (Song.Entities.AddressList l in addr)
            {
                if (l.Adl_MobileTel != string.Empty)
                {
                    moibles += l.Adl_MobileTel + ",";
                }
            }
            if (moibles.Length > 0 && moibles.Substring(moibles.Length - 1) == ",")
            {
                moibles = moibles.Substring(0, moibles.Length - 1);
            }
            //发送
            DateTime time = tbSendTime.Text.Trim() == "" ? DateTime.Now : Convert.ToDateTime(tbSendTime.Text);

            WeiSha.SMS.SmsState state = WeiSha.SMS.Gatway.Service.Send(moibles, tbContext.Text.Trim(), time);
            if (state.Success)
            {
                lblSend.Text = "恭喜,短信群发成功!";
                Song.Entities.SmsMessage sms = new SmsMessage();
                sms.Sms_Context = tbContext.Text.Trim();
                //2为已经发送
                sms.Sms_MailBox = 2;
                //针对的类型,1针对分类
                sms.Sms_Type     = 1;
                sms.Sms_SendId   = Convert.ToInt32(ddlTpye.SelectedValue);
                sms.Sms_SendName = ddlTpye.SelectedItem.Text.Replace("-", "").Trim();

                if (state.FailList.Trim() != "")
                {
                    lblSend.Text += "其中,发送失败的号码为:" + state.FailList + "。";
                    //3为部分失败
                    sms.Sms_State = 3;
                }
                else
                {
                    sms.Sms_State = 1;
                }
                Business.Do <ISMS>().MessageAdd(sms);
            }
            else
            {
                lblSend.Text = "发送失败,原因可能是:" + state.Description + "。";
            }
        }
示例#2
0
        /// <summary>
        /// 发送短信验证码
        /// </summary>
        /// <param name="keyname">写入cookis的key值名称</param>
        public bool SendVcode(string phone, string keyname)
        {
            //获取短信接口
            string smsCurr = Business.Do <ISystemPara>().GetValue("SmsCurrent");

            WeiSha.SMS.ISMS sms = WeiSha.SMS.Gatway.GetService(smsCurr);
            sms.Current.User = Business.Do <ISystemPara>().GetValue(smsCurr + "SmsAcc");
            //生成短信内容
            string rnd = WeiSha.Common.Request.Random(6, 1);    //验证码,随机四位数字
            string msg = Business.Do <ISystemPara>().GetValue(smsCurr + "_SmsTemplate");

            msg = this.MessageFormat(msg, rnd);
            if (string.IsNullOrWhiteSpace(msg))
            {
                return(false);
            }
            //发送状态
            try
            {
                //密码
                string smspw = Business.Do <ISystemPara>().GetValue(smsCurr + "SmsPw");
                smspw = WeiSha.Common.DataConvert.DecryptForBase64(smspw);    //将密码解密
                sms.Current.Password = smspw;

                WeiSha.SMS.SmsState state   = sms.Send(phone, msg);
                HttpContext         context = System.Web.HttpContext.Current;
                if (state.Success)
                {
                    //存储随机数
                    HttpCookie cookie = new HttpCookie(keyname);
                    //将随机字符转用MD5加密
                    cookie.Value = new WeiSha.Common.Param.Method.ConvertToAnyValue(rnd).MD5;
                    //如果是多机构,又不用IP访问,则用根域写入cookie
                    int multi = Business.Do <ISystemPara>()["MultiOrgan"].Int32 ?? 0;
                    if (multi == 0 && !WeiSha.Common.Server.IsLocalIP)
                    {
                        cookie.Domain = WeiSha.Common.Server.MainName;
                    }
                    cookie.Expires = DateTime.Now.AddMinutes(10);
                    context.Response.Cookies.Add(cookie);
                    return(true);
                }
                else
                {
                    throw new Exception(state.Description + ";状态码" + state.Code);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#3
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnEnter_Click(object sender, EventArgs e)
        {
            //电话号码
            string mobile = lbMobile.Text;
            //发送
            DateTime time = tbSendTime.Text.Trim() == "" ? DateTime.Now : Convert.ToDateTime(tbSendTime.Text);

            WeiSha.SMS.SmsState state = WeiSha.SMS.Gatway.Service.Send(mobile, tbContext.Text.Trim(), time);
            if (state.Success)
            {
                lblSend.Text = "恭喜,短信群发成功!";
                Song.Entities.SmsMessage sms = new SmsMessage();
                sms.Sms_Context = tbContext.Text.Trim();
                //2为已经发送
                sms.Sms_MailBox = 2;
                //针对的类型,1针对分类
                if (addrid > -1)
                {
                    sms.Sms_Type     = 2;
                    sms.Sms_SendId   = addrid;
                    sms.Sms_SendName = lbName.Text;
                }
                if (empid > -1)
                {
                    sms.Sms_Type     = 3;
                    sms.Sms_SendId   = empid;
                    sms.Sms_SendName = lbName.Text;
                }

                if (state.FailList.Trim() != "")
                {
                    lblSend.Text += "其中,发送失败的号码为:" + state.FailList + "。";
                    //3为部分失败
                    sms.Sms_State = 3;
                }
                else
                {
                    sms.Sms_State = 1;
                }
                Business.Do <ISMS>().MessageAdd(sms);
            }
            else
            {
                lblSend.Text = "发送失败,原因可能是:" + state.Description + "。";
            }
        }