protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        string nums = hiddenNumList.Value;
        string txt = txtContent.Text;

        XBase.Model.Personal.MessageBox.MobileMsgMonitor entity;
        XBase.Business.Personal.MessageBox.MobileMsgMonitor bll = new XBase.Business.Personal.MessageBox.MobileMsgMonitor();
        
        DataTable userInfos = XBase.Business.Office.CustManager.LinkManBus.GetLinkManListEx(UserInfo.CompanyCD);
        DataRow[] users = userInfos.Select("ID IN("+nums+")");
        
        //check nums      
        if (users.Length > int.Parse(smCnt.Text))
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(), "ddfx", "alert('超过可以发送数量限制');document.location.href='SendSMBatch.aspx';", true);
            return;
        }

        nums = "";
        foreach (DataRow user in users)
        {
            string phonenum = user["Handset"].ToString();
            if (!mobileNo.IsMatch(phonenum))
            {
                continue;
            }

            if (nums != "")
                nums += ",";
            nums += phonenum;

            entity = new XBase.Model.Personal.MessageBox.MobileMsgMonitor();
            entity.CompanyCD = UserInfo.CompanyCD;
            entity.Content = txt;
            entity.CreateDate = DateTime.Now;
            entity.ReceiveMobile = phonenum;
            entity.ReceiveUserID = int.Parse(user["ID"].ToString());
            entity.ReceiveUserName = user["LinkManName"].ToString();
            entity.SendDate = DateTime.Now;
            entity.SendUserID = UserInfo.EmployeeID;
            entity.SendUserName = UserInfo.EmployeeName;
            entity.Status = "1";
            entity.MsgType = "2";

            bll.Add(entity);

            if(cbAddtionalInfo.Checked)
            {
                string prefixName = "";
                var sex = user["Sex"].ToString().Trim();
                if (sex == "1" || sex == "2")
                {
                    prefixName = entity.ReceiveUserName + (sex == "1" ? " 先生:" : "女士:");
                }
                XBase.Common.SMSender.InternalSend(phonenum, prefixName+txt);
            }
        }

        if (!cbAddtionalInfo.Checked)
        {
           XBase.Common.SMSender.SendBatch(nums, txt);
        }

        int reCount = int.Parse(smCnt.Text) - nums.Split(',').Length;
        //
        XBase.Business.SystemManager.CompanyOpenServBus.UpdateCompanyManMsgNum(UserInfo.CompanyCD, reCount);

        ClientScript.RegisterClientScriptBlock(this.GetType(), "ddf", "alert('发送成功');document.location.href='SendSMBatch.aspx';", true);
    }
Example #2
0
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        string nums = hiddenNumList.Value;
        string txt  = txtContent.Text;

        XBase.Model.Personal.MessageBox.MobileMsgMonitor    entity;
        XBase.Business.Personal.MessageBox.MobileMsgMonitor bll = new XBase.Business.Personal.MessageBox.MobileMsgMonitor();

        DataTable userInfos = XBase.Business.Office.CustManager.LinkManBus.GetLinkManListEx(UserInfo.CompanyCD);

        DataRow[] users = userInfos.Select("ID IN(" + nums + ")");

        //check nums
        if (users.Length > int.Parse(smCnt.Text))
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(), "ddfx", "alert('超过可以发送数量限制');document.location.href='SendSMBatch.aspx';", true);
            return;
        }

        nums = "";
        foreach (DataRow user in users)
        {
            string phonenum = user["Handset"].ToString();
            if (!mobileNo.IsMatch(phonenum))
            {
                continue;
            }

            if (nums != "")
            {
                nums += ",";
            }
            nums += phonenum;

            entity                 = new XBase.Model.Personal.MessageBox.MobileMsgMonitor();
            entity.CompanyCD       = UserInfo.CompanyCD;
            entity.Content         = txt;
            entity.CreateDate      = DateTime.Now;
            entity.ReceiveMobile   = phonenum;
            entity.ReceiveUserID   = int.Parse(user["ID"].ToString());
            entity.ReceiveUserName = user["LinkManName"].ToString();
            entity.SendDate        = DateTime.Now;
            entity.SendUserID      = UserInfo.EmployeeID;
            entity.SendUserName    = UserInfo.EmployeeName;
            entity.Status          = "1";
            entity.MsgType         = "2";

            bll.Add(entity);

            if (cbAddtionalInfo.Checked)
            {
                string prefixName = "";
                var    sex        = user["Sex"].ToString().Trim();
                if (sex == "1" || sex == "2")
                {
                    prefixName = entity.ReceiveUserName + (sex == "1" ? " 先生:" : "女士:");
                }
                XBase.Common.SMSender.InternalSend(phonenum, prefixName + txt);
            }
        }

        if (!cbAddtionalInfo.Checked)
        {
            XBase.Common.SMSender.SendBatch(nums, txt);
        }

        int reCount = int.Parse(smCnt.Text) - nums.Split(',').Length;

        //
        XBase.Business.SystemManager.CompanyOpenServBus.UpdateCompanyManMsgNum(UserInfo.CompanyCD, reCount);

        ClientScript.RegisterClientScriptBlock(this.GetType(), "ddf", "alert('发送成功');document.location.href='SendSMBatch.aspx';", true);
    }