Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int    pgNow      = 1;
        int    pgSize     = 10;
        string NameOrIdNo = Request.Form["NameOrIdNo"] ?? "";

        int.TryParse(Request.Form["pgNow"], out pgNow);
        int.TryParse(Request.Form["pgSize"], out pgSize);
        pgNow  = (pgNow == 0 ? 1 : pgNow);
        pgSize = (pgSize == 0 ? 10 : pgSize);

        string SearchName  = "";
        string SearchIdNo  = "";
        string SearchResNo = "";

        if (NumberValidate.IsIdNo(NameOrIdNo) || (NameOrIdNo.StartsWith("99") && NameOrIdNo.Length == 10))
        {
            SearchIdNo = NameOrIdNo;
        }
        else

        if (NumberValidate.IsResNo(NameOrIdNo))
        {
            SearchResNo = NameOrIdNo;
        }
        else
        {
            SearchName = NameOrIdNo;
        }


        DataTableCollection dtc = (DataTableCollection)DBUtil.DBOp("ConnDB"
                                                                   , " exec dbo.usp_CaseUser_xGetContactList {0},{1},{2},{3},{4}  "
                                                                   , new string[] { pgNow.ToString(), pgSize.ToString(), SearchName, SearchIdNo, SearchResNo }
                                                                   , NSDBUtil.CmdOpType.ExecuteReaderReturnDataTableCollection);

        List <UserProfileListVM> list = new List <UserProfileListVM>();
        PageVM rtn = new PageVM();

        EntityS.FillModel(list, dtc[0]);
        EntityS.FillModel(rtn, dtc[1]);
        rtn.message = list;

        Response.ContentType = "application/json; charset=utf-8";
        Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(rtn));
        Response.End();
    }
Exemplo n.º 2
0
        private void  load(string data)
        {
            DataTable t = CreateTable();

            if (data == "")
            {
                Message.Alert(this, "文件是空的", "null");
                return;
            }
            string[] arr = data.Split(',');
            if (arr.Length > 0)
            {
                string errNum = "";
                Session["errorNum"] = "";
                int errorCount = 0;
                for (int i = 0; i < arr.Length; i++)
                {
                    DataRow row = t.NewRow();

                    if (arr[i] != "")
                    {
                        if (NumberValidate.IsValidMobileNo(arr[i]))
                        {
                            row["phone"] = arr[i];

                            t.Rows.Add(row);
                        }
                        else
                        {
                            errNum += arr[i] + ",";
                            errorCount++;
                            if (errorCount % 10 == 0)
                            {
                                errNum += "\r\n";
                            }
                        }
                    }
                }
                if (!string.IsNullOrWhiteSpace(errNum))
                {
                    Session["errorNum"]   = errNum;
                    Session["errorCount"] = errorCount;
                    // Message.Alert(this, "", "null");
                }
            }
            Session["dt"] = t;
        }
Exemplo n.º 3
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string[]      dest;
            List <string> num = new List <string>();

            Model.EnterpriseUser user = (Model.EnterpriseUser)Session["Login"];
            //DataTable dataTabe = (DataTable)Session["dt"];
            if (!Page.IsValid)
            {
                return;
            }

            dest = Regex.Split(txt_phone.Value, ",");
            if ((!string.IsNullOrWhiteSpace(txt_phone.Value)) && dest.Count() > 0)
            {
                //if (dest.Count() > 1000)
                //{
                //    Message.Alert(this, "单次提交最多不超过1000个号码");
                //    return;
                //}

                //简单判断是否包含非手机号码
                foreach (string destnum in dest)
                {
                    if (!NumberValidate.IsValidMobileNo(destnum))
                    {
                        Message.Alert(this, "请输入正确的手机号码", "null");
                        return;
                    }
                    else
                    {
                        num.Add(destnum);
                    }
                }
            }
            else
            {
                DataTable dt1 = (DataTable)Session["dt"];
                if (dt1.Rows.Count <= 1000)
                {
                    foreach (ListItem li in CheckBoxList1.Items)
                    {
                        if (li.Selected == true)
                        {
                            num.Add(li.Text);
                        }
                    }
                    if (num.Count == 0)
                    {
                        Message.Alert(this, "请输入或选择电话号码", "null");
                        return;
                    }
                }
                else
                {
                    //记录数多于1000 时,从dt1中读取
                    var q =
                        from c in dt1.AsEnumerable()
                        select c["phone"].ToString();

                    num = q.ToList();
                }

                /*  if (num.Count > 1000)
                 * {
                 *    Message.Alert(this, "单次提交最多不超过1000个号码");
                 *    return;
                 * }*/
            }

            if (txt_Content.Value.ToString().Trim() == "")
            {
                Message.Alert(this, "请输入短信内容", "null");
                return;
            }

            Encoding gb = System.Text.Encoding.GetEncoding("gb2312"); //转换编码

            byte[] bytes = gb.GetBytes(txt_Content.Value.ToString()); //获取字节数组
            if (bytes.Length > 1000)
            {
                Message.Alert(this, "短信内容不能超过500中文字符", "null");
                return;
            }

            SMSModel.SMS sms = new SMS();
            bool         tt  = false;

            if (txt_SendTime.Value != "")
            {
                sms.SMSTimer = Convert.ToDateTime(txt_SendTime.Value);
                tt           = true;
            }
            RPCResult <Guid> r = null;

            if (num.Count > 1000)
            {
                int fail = 0;
                int succ = 0;
                int step = 1000;
                for (int i = 0; i * step < num.Count; i++)
                {
                    int start   = i * step;
                    int count   = (i + 1) * step - 1 < num.Count - 1 ? step : num.Count - i * step - 1;
                    var subList = num.GetRange(start, count);

                    r = ZHSMSProxy.GetZKD().SendSMS(user.AccountCode, user.Password, txt_Content.Value.ToString().Trim(), txt_wapURL.Value.ToString(), subList, tt, sms.SMSTimer);

                    if (r.Success)
                    {
                        succ++;
                        sms.SerialNumber = r.Value;
                        sms.Account      = user.AccountCode;
                        sms.Content      = txt_Content.Value;
                        sms.Number       = subList;
                        sms.SendTime     = DateTime.Now;
                        sms.WapURL       = txt_wapURL.Value;

                        BLL.SMSdo.SMSAdd(sms);
                    }
                    else
                    {
                        fail++;
                        Message.Alert(this, r.Message);
                        //  Message.Error(this, r.Message, "null");
                    }
                    //Thread.Sleep(100);
                }
                if (fail == 0)
                {
                    Message.Success(this, "短信已全部成功加入到发送队列", "null");
                }
                else
                {
                    Message.Success(this, "因记录数太多,拆分发送,其中成功次数:" + succ + ",失败次数:" + fail, "null");
                }
            }
            else
            {
                r = ZHSMSProxy.GetZKD().SendSMS(user.AccountCode, user.Password, txt_Content.Value.ToString().Trim(), txt_wapURL.Value.ToString(), num, tt, sms.SMSTimer);

                if (r.Success)
                {
                    sms.SerialNumber = r.Value;
                    sms.Account      = user.AccountCode;
                    sms.Content      = txt_Content.Value;
                    sms.Number       = num;
                    sms.SendTime     = DateTime.Now;
                    sms.WapURL       = txt_wapURL.Value;

                    BLL.SMSdo.SMSAdd(sms);
                    Message.Success(this, r.Message, "null");
                }
                else
                {
                    Message.Error(this, r.Message, "null");
                }
            }
        }