Ejemplo n.º 1
0
    /// <summary>
    /// 短信余额查询  只能平台查询
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSel_Click(object sender, EventArgs e)
    {
        try
        {
            string msg = "";

            if (mCompany.RoleType == 1)
            {
                cn.woxp.gateway.WebSMS webSMS = new cn.woxp.gateway.WebSMS();
                msg  = "账号条数(GetBalanceCount):" + webSMS.GetBalanceCount("10416-ltj023-e076c91e4abca0b569beba646e3ef0ad-300");
                msg += " / ";
                msg += "账号余额(GetMoney):" + webSMS.GetMoney("10416-ltj023-e076c91e4abca0b569beba646e3ef0ad-300");
            }
            else
            {
                msg = "不能查询";
            }

            ScriptManager.RegisterStartupScript(this, GetType(), "", "showdialog('" + msg + "');", true);
        }
        catch (Exception)
        {
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 信息发送
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btsendmsg_Click(object sender, EventArgs e)
    {
        string msg = "";

        try
        {
            bool     rs     = false;
            string[] phones = txtnum.Value.ToString().Replace("\r\n", "").Trim().Replace(',', ',').Split(new char[] { ',' });
            if (txtnum.Value.Trim().Length > 0)
            {
                for (int i = 0; i < phones.Length; i++)
                {
                    if (!Regex.IsMatch(phones[i], "(^(0\\d{2,3}-?\\d{7,8})$)|(^1[358]\\d{9}$)"))
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "key", "<script>alert('手机号长度有误:" + phones[i] + "多个号码之间请用英文逗号隔开')</script>", false);
                        return;
                    }
                    else if (phones.Length > 100)
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "key", "<script>alert('手机号码最多为100个')</script>", false);
                        return;
                    }
                    else
                    {
                        rs = true;
                    }
                }
            }
            if (txtnum.Value.Trim().ToString().Length < 1)
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "key", "<script>alert('请输入手机号')</script>", false);
                return;
            }
            if (txtContents.Value.Length > 400 || txtContents.Value.Trim().Length < 1)
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "key", "<script>alert('短信内容为空或字符过长,最多400个汉字!')</script>", false);
                return;
            }
            if (txthz.Text.ToString().Length > 25 || txthz.Text.ToString().Length < 1)
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "key", "<script>alert('后缀为空或字符过长,最多25个汉字!')</script>", false);
                return;
            }
            //string cheackkeyword = PiaoBao.BLLLogic.Common.SelectKeyWord(txtContents.Value.ToString()).ToString();
            //if (cheackkeyword.Length > 0 && cheackkeyword != "nulls")
            //{
            //    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "key", "<script>alert('内容存在非法字词![" + cheackkeyword + "]')</script>", false);
            //    return;
            //}
            if (rs == true)
            {
                //判断剩余条数是否足够发送
                int                 tcount        = txtContents.Value.Length;
                decimal             count         = tcount / 64m;
                int                 count2        = (tcount / 64) + 1;
                decimal             newCount      = count2 > count ? count2 : count;
                decimal             newTotalCount = newCount * phones.Length;
                IList <Tb_Sms_User> smsuser       = baseDataManage.CallMethod("Tb_Sms_User", "GetList", null, new Object[] { "CpyNo='" + mUser.CpyNo + "'" }) as List <Tb_Sms_User>;
                #region 发送记录
                Tb_Sms_SendInfo sendinfo = new Tb_Sms_SendInfo();
                sendinfo.CpyNo          = mUser.CpyNo;
                sendinfo.SmsSendContent = txtContents.Value.ToString();
                sendinfo.SmsSuffix      = txthz.Text.ToString();
                sendinfo.SmsUnit        = mCompany.UninAllName;
                sendinfo.SmsUserCount   = short.Parse(newCount.ToString());
                #endregion
                if ((smsuser != null && smsuser.Count > 0) || mCompany.RoleType == 1)
                {
                    if ((smsuser != null && smsuser.Count > 0 && smsuser[0].SmsRemainCount >= newTotalCount) || mCompany.RoleType == 1)
                    {
                        cn.woxp.gateway.WebSMS mess2 = new cn.woxp.gateway.WebSMS();
                        string[] PhoneNums = txtnum.Value.ToString().Replace(",", ",").Trim().Split(',');
                        int      countok = 0, counterr = 0;
                        for (int i = 0; i < PhoneNums.Length; i++)
                        {
                            sendinfo.SmsAcceptMobilePhone = PhoneNums[i].ToString();
                            cn.woxp.gateway.SendResult res = mess2.FastSendLongSMS("10416-ltj023-e076c91e4abca0b569beba646e3ef0ad-300", PhoneNums[i].ToString(), txtContents.Value.ToString() + "【" + this.txthz.Text.ToString() + "】", "", "");
                            if (res.ErrorDesc.ToString() == "提交成功")
                            {
                                if (mCompany.RoleType != 1)
                                {
                                    smsuser[0].SmsRemainCount = Convert.ToInt16(smsuser[0].SmsRemainCount - newCount);
                                    new PbProject.Logic.SQLEXBLL.SQLEXBLL_Base().ExecuteNonQuerySQLInfo("update Tb_Sms_User set SmsRemainCount=" + smsuser[0].SmsRemainCount + " where CpyNo='" + mUser.CpyNo + "'");
                                }
                                sendinfo.SmsCreateDate = DateTime.Parse(DateTime.Now.ToString());
                                sendinfo.SmsSendState  = 1;//发送状态
                                baseDataManage.CallMethod("Tb_Sms_SendInfo", "Insert", null, new Object[] { sendinfo });
                                countok++;
                            }
                            else
                            {
                                sendinfo.SmsCreateDate = DateTime.Parse(DateTime.Now.ToString());
                                sendinfo.SmsSendState  = 0;//发送状态 失败
                                baseDataManage.CallMethod("Tb_Sms_SendInfo", "Insert", null, new Object[] { sendinfo });
                                counterr++;
                            }
                        }
                        msg = "成功发送:" + countok + "条,发送失败:" + counterr + "条";
                    }
                    else
                    {
                        msg = "短信条数不足";
                    }
                }
                else
                {
                    msg = "发送失败";
                }
            }
        }
        catch (Exception ex)
        {
            msg = "发送失败";
        }
        ScriptManager.RegisterStartupScript(this, GetType(), "", "showdialog('" + msg + "');", true);
    }