您目前尚未登陆,请选择【登陆】或【注册
首页->行政办公->星幻短信群发平台Web源码>>NewSms.aspx.cs>>代码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:星幻短信群发平台Web源码


当前文件路径:XingHuanWebSms/NewSms.aspx.cs 文件类型
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Collections; 5using System.Web; 6using System.Web.Security; 7using System.Web.UI; 8using System.Web.UI.WebControls; 9using System.Web.UI.WebControls.WebParts; 10using System.Web.UI.HtmlControls; 11using DBLibrary; 12using SMS_Lib; 13using System.Text.RegularExpressions; 14using AjaxPro; 15public partial class SMS_NewSms : SMS_PageBase 16{ 17 private DBLibrary.DBClass db = new DBClass(); 18 public string RealName = ""; 19 protected void Page_Load(object sender, EventArgs e) 20 { 21 AjaxPro.Utility.RegisterTypeForAjax(typeof(SMS_NewSms)); 22 RealName =Session["SMS_NAME"] == null ? "" : Session["SMS_NAME"].ToString().Trim(); 23 this.SelfName.Text = RealName; 24 } 25 26 private bool IsRegEx(string regExValue, string itemValue) 27 { 28 29 try 30 { 31 Regex regex = new System.Text.RegularExpressions.Regex(regExValue); 32 if (regex.IsMatch(itemValue)) 33 { 34 return true; 35 } 36 else 37 { 38 return false; 39 } 40 } 41 catch (Exception) 42 { 43 return false; 44 } 45 finally 46 { 47 } 48 } 49 50 51 /// <summary> 52 /// 发送短信息, 53 /// </summary> 54 /// <param name="receive">接收者</param> 55 /// <param name="type">短信类型</param> 56 /// <param name="smemo">短信内容</param> 57 /// <returns>10返回失败,20,成功,30异常</returns> 58 [AjaxPro.AjaxMethod(HttpSessionStateRequirement.ReadWrite)] 59 public string SendNewSms(string receive, string type, string smemo,string time_type,string sendtime) 60 { 61 int Fail = 0; 62 int snRet = 0; 63 int Success = 0; 64 string nRet = ""; 65 string SmsRealName = Session["SMS_NAME"] == null ? "星幻短信:" : Session["SMS_NAME"].ToString().Trim()+":"; 66 string memo = smemo.Trim(); 67 if (smemo.IndexOf("|") > 0 && smemo.IndexOf("|") < 5) 68 { 69 SmsRealName = smemo.Substring(0, smemo.IndexOf("|")) + ":"; 70 memo = memo.Substring(smemo.IndexOf("|")+1); 71 } 72 else 73 { 74 SmsRealName = ""; 75 memo = memo.Substring(1); 76 } 77 if (time_type.ToString() == "1") 78 { 79 if (DateTime.Parse(sendtime) <= DateTime.Now) 80 { 81 nRet = "提交失败,定时发送日期必须大于当前时间!"; 82 return nRet; 83 } 84 } 85 if (!NString.ChcekStr(receive, "0123456789;")) 86 { 87 nRet = "发送失败,接收者格式有误.请重新输入!"; 88 return nRet; 89 } 90 string[] relist = receive.ToString().Trim().Split(';'); 91 //if (!this.CheckMoney(relist.Length.ToString())) 92 //{ 93 // nRet = "发送失败,余额不足.请充值后再发送!"; 94 // return nRet; //金额不足 95 //} 96 string sendmsg = ""; 97 for (int j = 0; j < relist.Length; j++) //手机号数组 98 { 99 if (relist[j].Trim().Length <= 0) 100 { 101 continue; 102 } 103 //不符合号码格式过滤 移动 104 if (relist[j].ToString().Trim().StartsWith("1")) 105 { 106 if (!IsRegEx("(^15[3|8|9]{1}[0-9]{8}$)|(^13[0-9]{9}$)", relist[j].ToString().Trim())) 107 { 108 nRet = "发送失败,接收者格式有误.请重新输入!"; 109 Fail++; 110 continue; 111 } 112 } 113 else if(relist[j].ToString().Trim().StartsWith("0")) //小灵通 114 { 115 if (!IsRegEx("^0[0-9]{10,11}$", relist[j].ToString().Trim())) 116 { 117 Fail++; 118 nRet = "发送失败,接收者格式有误.请重新输入!"; 119 continue; 120 } 121 122 } 123 else 124 { 125 Fail++; 126 nRet = "发送失败,接收者格式有误.请重新输入!"; 127 continue; 128 } 129 for (int i = 0; i < memo.Length; i += 65) //内容拆分 130 { 131 if (memo.Length > 65) 132 { 133 if ((memo.Length - i) < 65) 134 { 135 sendmsg = memo.Substring(i, memo.Length - i); 136 } 137 else 138 { 139 sendmsg = memo.Substring(i, 65); 140 } 141 } 142 else 143 { 144 sendmsg = memo; 145 } 146 if (sendmsg.Trim().Length <= 0) 147 { 148 nRet = "短信内容不能为空.请重新输入!"; 149 continue; 150 } 151 //发送到网关 152 Success++; 153 if (time_type.ToString().Trim() == "0")//立即发送 154 { 155 System.Data.SqlClient.SqlParameter[] para = 156 { 157 db.MakeInputParameter("@smsid",SqlDbType.BigInt,8,Session["SMS_ID"].ToString().Trim()), 158 db.MakeInputParameter("@receiver",SqlDbType.NVarChar,50,relist[j].Trim()), 159 db.MakeInputParameter("@flag",SqlDbType.Int,4,type), 160 db.MakeInputParameter("@memo",SqlDbType.NVarChar,200,SmsRealName+sendmsg.Trim()), 161 db.MakeInputParameter("@remark",SqlDbType.NVarChar,100,Session["SMS_ID"].ToString().Trim()+"_0") 162 }; 163 try 164 { 165 snRet = db.RunProcedureForInt("SMS_Web_AddNewSMS", para); 166 if (snRet == 10) 167 { 168 nRet = "发送终止,余额不足。已发送:" + Success.ToString() + "条,已过滤无效号码:" + Fail.ToString() + "条!"; 169 return nRet; 170 } 171 172 } 173 catch 174 { 175 nRet = "发送错误,出现异常。已发送:" + Success.ToString() + "条,已过滤无效号码:" + Fail.ToString() + "条!"; 176 return nRet; 177 178 } 179 } 180 else if(time_type.ToString().Trim()=="1") 181 { 182 /*[dbo].[SMS_Web_Destine_Add] -- 功能定制 1代表成功,10失败-金币不足,11失败,天气不存在'*/ 183 System.Data.SqlClient.SqlParameter[] para = 184 { 185 db.MakeInputParameter("@Smsid",SqlDbType.BigInt,8,Session["SMS_ID"].ToString().Trim()), 186 db.MakeInputParameter("@smsNo",SqlDbType.NVarChar,50,relist[j].Trim()), 187 db.MakeInputParameter("@SmSType",SqlDbType.Int,4,type), 188 db.MakeInputParameter("@SmSMemo",SqlDbType.NVarChar,200,SmsRealName+sendmsg.Trim()), 189 db.MakeInputParameter("@funid",SqlDbType.Int,4,"2"), 190 db.MakeInputParameter("@endtime",SqlDbType.DateTime,8,sendtime) 191 192 }; 193 try 194 { 195 snRet = db.RunProcedureForInt("SMS_Web_Destine_Add", para); 196 if (snRet == 10) 197 { 198 nRet = "操作终止,余额不足。已提交:" + Success.ToString() + "条,已过滤无效号码:" + Fail.ToString() + "条!"; 199 return nRet; 200 } 201 202 } 203 catch 204 { 205 nRet = "操作错误,出现异常。已提交:" + Success.ToString() + "条,已过滤无效号码:" + Fail.ToString() + "条!"; 206 return nRet; 207 208 } 209 210 211 } 212 213 } 214 215 } 216 if (snRet == 1) 217 { 218 nRet = "操作成功。已提交:" + Success.ToString() + "条放入定时作业队列,已过滤无效号码:" + Fail.ToString() + "条!"; 219 } 220 else if (snRet == 20) 221 { 222 nRet = "操作成功。已发送:" + Success.ToString() + "条,已过滤无效号码:" + Fail.ToString() + "条!"; 223 } 224 225 return nRet; 226 } 227 228 [AjaxPro.AjaxMethod(HttpSessionStateRequirement.ReadWrite)] 229 public DataTable GetLatelySms(int top) 230 { 231 DataTable dt = null; 232 System.Data.SqlClient.SqlParameter []para = 233 { 234 db.MakeInputParameter("@sid",SqlDbType.BigInt,8,Session["SMS_ID"].ToString().Trim()), 235 db.MakeInputParameter("@top",SqlDbType.Int,4,top) 236 }; 237 try 238 { 239 dt = db.RunProcedureForDataSet("SMS_Web_GetLatelySMS", para).Tables[0]; 240 } 241 catch 242 { 243 } 244 return dt; 245 } 246} 247
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:星幻短信群发平台Web源码

- BugNet0.7.881.0汉化免安装版..

- 51aspx可拖曳简单新闻系统

- asp.net2.0将word转换为html..

- Asp.net邮件系统(在线收发)源码

- NBear+NBear开发BBS系统源码

- 51aspx简单入门新闻系统(Asp..

- 某数码公司网站系统源码

- 达达电子书下载系统(生成sht..

51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号