群发短信
来源:互联网 发布:异常数据的检测方法 编辑:程序博客网 时间:2024/04/29 22:17
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.IO;
using System.Xml;
using System.Data;
using System.Net;
using System.Threading;
using System.Data.OleDb;
public partial class admin9h_adduser : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//if (string.IsNullOrEmpty(admins.isadmin()))
//{
// Response.Write("<script>window.parent.location='../login.aspx';</script>");
// Response.End();
//}
if (!IsPostBack)
pagebind();
}
protected void pagebind()
{
}
protected void Button_Click(object sender, EventArgs e)
{
//Response.Write(sendsns("【圣域传奇】最火爆的国战网游今日16时震撼开启。升级领Q币登陆发现金sycq.xkyx.com", "13910687714"));
//Response.End();
string FILE_NAME = Server.MapPath("./") + "tel_sns_" + System.DateTime.Now.ToString("hh_MM_ss") + ".txt";
if (!File.Exists(FILE_NAME))
{
StreamWriter sr = File.CreateText(FILE_NAME);
sr.Close();
}
StreamWriter x = new StreamWriter(FILE_NAME, true, System.Text.Encoding.Default);
x.Write("开始发送");
//Encoding encode = System.Text.Encoding.GetEncoding("gb2312");
//HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("http://202.85.214.57:30002/shttp.recmt?ua=9hservice&pw=753peach&mobile=18610810873&msg='" + Server.UrlEncode("uuu编码后") + "'");
//myReq.Method = "GET";
//myReq.ContentType = "application/x-www-form-urlencoded";
////接收HTTP做出的响应
//WebResponse myResp = myReq.GetResponse();
//Stream ReceiveStream = myResp.GetResponseStream();
//StreamReader readStream = new StreamReader(ReceiveStream, encode);
//Char[] read = new Char[256];
//int count = readStream.Read(read, 0, 256);
//string str = null;
//while (count > 0)
//{
// str += new String(read, 0, count);
// count = readStream.Read(read, 0, 256);
//}
//readStream.Close();
//myResp.Close();
string str = "-1";
string strCon;
strCon = Server.MapPath("./") + "tele.xls";
if (!System.IO.File.Exists(strCon))
{
Response.Write("请检查是否存在xls");
x.Close();
}
else
{
string sql = "";
DataSet rs = ExcelToDS(strCon);
int zol = 0;
for (int i = 0; i < rs.Tables[0].Rows.Count; i++)
{
if (!string.IsNullOrEmpty(rs.Tables[0].Rows[i][0].ToString()))
zol = i + 1;
}
string temp = "";
bool pas = false;
for (int i = 0; i < zol; i++)//100 zol
{
Thread.Sleep(100);//1000
// zzz = Convert.ToInt16((i + 1 * 1.00) / zol * 100);
try
{
//qingma(sendsns("【圣域传奇】最火爆的国战网游今日16时震撼开启。升级领Q币登陆发现金sycq.xkyx.com", rs.Tables[0].Rows[i][0].ToString().Trim());
if (qingma(sendsns("【圣域传奇】最火爆的国战网游今日16时震撼开启。升级领Q币登陆发现金sycq.xkyx.com", rs.Tables[0].Rows[i][0].ToString().Trim())).ToString().Substring(0, 1) != "1")
{
x.Write("\r\n" + "第 " + i + " 条数据出问题,返回电话号码:" + rs.Tables[0].Rows[i][0].ToString());
pas = true;
break;
}
else
{
x.Write("\r\n" + rs.Tables[0].Rows[i][0].ToString());
}
}
catch
{
Thread.Sleep(2000);
try
{
if (qingma(sendsns("【圣域传奇】最火爆的国战网游今日16时震撼开启。升级领Q币登陆发现金sycq.xkyx.com", rs.Tables[0].Rows[i][0].ToString().Trim())).ToString().Substring(0, 1) != "1")
{
x.Write("\r\n" + "第 " + i + " 条数据出问题,返回电话号码:" + rs.Tables[0].Rows[i][0].ToString());
pas = true;
break;
}
else
{
x.Write("\r\n" + rs.Tables[0].Rows[i][0].ToString());
}
}
catch
{
pas = true;
x.Write("\r\n" + "第 " + i + " 条数据超时,返回电话号码:" + rs.Tables[0].Rows[i][0].ToString());
break;
}
}
}
if (!pas)
{
x.Write("\r\n" + "发送成功");
x.Close();
}
else
{
x.Write("\r\n" + "失败");
x.Close();
}
}
}
public DataSet ExcelToDS(string Path)
{
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Path + ";" + "Extended Properties=Excel 8.0;";
OleDbConnection conn = new OleDbConnection(strConn);
conn.Open();
string strExcel = "";
OleDbDataAdapter myCommand = null;
DataSet ds = null;
strExcel = "select * from [sheet1$]";
myCommand = new OleDbDataAdapter(strExcel, strConn);
ds = new DataSet();
myCommand.Fill(ds, "table1");
return ds;
}
public static int GetCharInStringCount(string Char, string String)
{
string str = String.Replace(Char, "");
return (String.Length - str.Length) / Char.Length;
}
private string sendsns(string str1,string tel)
{
Encoding encode = System.Text.Encoding.GetEncoding("gb2312");
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("http://1111111111:30002/shttp.recmt?ua=2222222&pw=3333333&mobile=" + tel + "&msg=" + Server.UrlEncode(str1) + "");
myReq.Method = "GET";
myReq.ContentType = "application/x-www-form-urlencoded";
//接收HTTP做出的响应
WebResponse myResp = myReq.GetResponse();
Stream ReceiveStream = myResp.GetResponseStream();
StreamReader readStream = new StreamReader(ReceiveStream, encode);
Char[] read = new Char[256];
int count = readStream.Read(read, 0, 256);
string str = null;
while (count > 0)
{
str += new String(read, 0, count);
count = readStream.Read(read, 0, 256);
}
readStream.Close();
myResp.Close();
return str;
}
private string qingma(string str)
{
str = str.ToLower();
str=str.Replace("<root><result>","");
str=str.Replace("</i></root>","");
str = str.Replace("</result></root>", "");
str = str.Replace("</result><i>", "|");
return str;
// return "1|0007727884";
}
}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.IO;
using System.Xml;
using System.Data;
using System.Net;
using System.Threading;
using System.Data.OleDb;
public partial class admin9h_adduser : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//if (string.IsNullOrEmpty(admins.isadmin()))
//{
// Response.Write("<script>window.parent.location='../login.aspx';</script>");
// Response.End();
//}
if (!IsPostBack)
pagebind();
}
protected void pagebind()
{
}
protected void Button_Click(object sender, EventArgs e)
{
//Response.Write(sendsns("【圣域传奇】最火爆的国战网游今日16时震撼开启。升级领Q币登陆发现金sycq.xkyx.com", "13910687714"));
//Response.End();
string FILE_NAME = Server.MapPath("./") + "tel_sns_" + System.DateTime.Now.ToString("hh_MM_ss") + ".txt";
if (!File.Exists(FILE_NAME))
{
StreamWriter sr = File.CreateText(FILE_NAME);
sr.Close();
}
StreamWriter x = new StreamWriter(FILE_NAME, true, System.Text.Encoding.Default);
x.Write("开始发送");
//Encoding encode = System.Text.Encoding.GetEncoding("gb2312");
//HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("http://202.85.214.57:30002/shttp.recmt?ua=9hservice&pw=753peach&mobile=18610810873&msg='" + Server.UrlEncode("uuu编码后") + "'");
//myReq.Method = "GET";
//myReq.ContentType = "application/x-www-form-urlencoded";
////接收HTTP做出的响应
//WebResponse myResp = myReq.GetResponse();
//Stream ReceiveStream = myResp.GetResponseStream();
//StreamReader readStream = new StreamReader(ReceiveStream, encode);
//Char[] read = new Char[256];
//int count = readStream.Read(read, 0, 256);
//string str = null;
//while (count > 0)
//{
// str += new String(read, 0, count);
// count = readStream.Read(read, 0, 256);
//}
//readStream.Close();
//myResp.Close();
string str = "-1";
string strCon;
strCon = Server.MapPath("./") + "tele.xls";
if (!System.IO.File.Exists(strCon))
{
Response.Write("请检查是否存在xls");
x.Close();
}
else
{
string sql = "";
DataSet rs = ExcelToDS(strCon);
int zol = 0;
for (int i = 0; i < rs.Tables[0].Rows.Count; i++)
{
if (!string.IsNullOrEmpty(rs.Tables[0].Rows[i][0].ToString()))
zol = i + 1;
}
string temp = "";
bool pas = false;
for (int i = 0; i < zol; i++)//100 zol
{
Thread.Sleep(100);//1000
// zzz = Convert.ToInt16((i + 1 * 1.00) / zol * 100);
try
{
//qingma(sendsns("【圣域传奇】最火爆的国战网游今日16时震撼开启。升级领Q币登陆发现金sycq.xkyx.com", rs.Tables[0].Rows[i][0].ToString().Trim());
if (qingma(sendsns("【圣域传奇】最火爆的国战网游今日16时震撼开启。升级领Q币登陆发现金sycq.xkyx.com", rs.Tables[0].Rows[i][0].ToString().Trim())).ToString().Substring(0, 1) != "1")
{
x.Write("\r\n" + "第 " + i + " 条数据出问题,返回电话号码:" + rs.Tables[0].Rows[i][0].ToString());
pas = true;
break;
}
else
{
x.Write("\r\n" + rs.Tables[0].Rows[i][0].ToString());
}
}
catch
{
Thread.Sleep(2000);
try
{
if (qingma(sendsns("【圣域传奇】最火爆的国战网游今日16时震撼开启。升级领Q币登陆发现金sycq.xkyx.com", rs.Tables[0].Rows[i][0].ToString().Trim())).ToString().Substring(0, 1) != "1")
{
x.Write("\r\n" + "第 " + i + " 条数据出问题,返回电话号码:" + rs.Tables[0].Rows[i][0].ToString());
pas = true;
break;
}
else
{
x.Write("\r\n" + rs.Tables[0].Rows[i][0].ToString());
}
}
catch
{
pas = true;
x.Write("\r\n" + "第 " + i + " 条数据超时,返回电话号码:" + rs.Tables[0].Rows[i][0].ToString());
break;
}
}
}
if (!pas)
{
x.Write("\r\n" + "发送成功");
x.Close();
}
else
{
x.Write("\r\n" + "失败");
x.Close();
}
}
}
public DataSet ExcelToDS(string Path)
{
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Path + ";" + "Extended Properties=Excel 8.0;";
OleDbConnection conn = new OleDbConnection(strConn);
conn.Open();
string strExcel = "";
OleDbDataAdapter myCommand = null;
DataSet ds = null;
strExcel = "select * from [sheet1$]";
myCommand = new OleDbDataAdapter(strExcel, strConn);
ds = new DataSet();
myCommand.Fill(ds, "table1");
return ds;
}
public static int GetCharInStringCount(string Char, string String)
{
string str = String.Replace(Char, "");
return (String.Length - str.Length) / Char.Length;
}
private string sendsns(string str1,string tel)
{
Encoding encode = System.Text.Encoding.GetEncoding("gb2312");
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("http://1111111111:30002/shttp.recmt?ua=2222222&pw=3333333&mobile=" + tel + "&msg=" + Server.UrlEncode(str1) + "");
myReq.Method = "GET";
myReq.ContentType = "application/x-www-form-urlencoded";
//接收HTTP做出的响应
WebResponse myResp = myReq.GetResponse();
Stream ReceiveStream = myResp.GetResponseStream();
StreamReader readStream = new StreamReader(ReceiveStream, encode);
Char[] read = new Char[256];
int count = readStream.Read(read, 0, 256);
string str = null;
while (count > 0)
{
str += new String(read, 0, count);
count = readStream.Read(read, 0, 256);
}
readStream.Close();
myResp.Close();
return str;
}
private string qingma(string str)
{
str = str.ToLower();
str=str.Replace("<root><result>","");
str=str.Replace("</i></root>","");
str = str.Replace("</result></root>", "");
str = str.Replace("</result><i>", "|");
return str;
// return "1|0007727884";
}
}
0 0
- 群发短信
- 群发短信
- 定时群发短信
- 定时群发短信
- Android 群发短信
- 收到骗子的群发短信
- 通过短信猫群发短信
- 使用SmsManager服务群发短信
- android 调用系统,群发短信
- Android 群发短信的实现
- Android 群发短信试列
- PendingIntent 群发短信获取发送结果
- 群发短信并监控成功与否
- 群发短信 发短信(带图片)
- 如何使用阿里云群发短信
- Android群发短信草稿保存与发送机制
- 背景信息在网上轻松群发短信程序
- 短信群发短信和短代码运动
- ListView学习
- PTA-基础巩固2
- iOS 把模拟器中的的.app文件给其他小伙伴,放到他们的模拟器中运行的方法
- 程序员必备技能
- 改变ant变量的值<var>
- 群发短信
- sqrt()函数
- Android中资源文件assets和res下面raw文件的使用不同点
- CSDN网站系统升级公告
- Authentication Error errorcode: 230 uid: -1 appid -1 msg: APP Scode码校验失败
- Entity Framework 全面教程详解
- vs2013调用不了Ajax,或者是不走HttpHandler类
- [Andorid开发艺术探索 读书笔记]Activity的生命周期和启动模式 (一)
- Oracle 模式对象