public void SendSubmit(SMSModel.SMS sms) { }
public void SendSMS(SMSModel.SMS sms) { try { string post = ""; post = "action=send&userid=" + userId + "&account=" + account + "&password="******"&mobile=" + string.Join(",", sms.Number) + "&content=" + sms.Content + sms.Signature + "&sendTime=&extno=" + scrId + sms.SPNumber; // Console.WriteLine("发送字符串 " + post); string t = HTTPRequest.PostWebRequest(sendUrl, post, Encoding.UTF8); //<? xml version = "1.0" encoding = "utf-8" ?> //< returnsms > //< returnstatus > status </ returnstatus > ----------返回状态值:成功返回Success 失败返回:Faild //<message> message</ message > ----------返回信息:见下表 //<remainpoint> remainpoint</ remainpoint > ----------返回余额 //< taskID > taskID </ taskID > -----------返回本次任务的序列ID //< successCounts > successCounts </ successCounts > --成功短信数:当成功后返回提交成功短信数 //</ returnsms > // Console.WriteLine("发送返回消息 " + t); bool ok = true; string rmsg = ""; string msgid = ""; XmlDocument doc = new XmlDocument(); doc.LoadXml(t); XmlElement root = null; root = doc.DocumentElement; XmlNodeList listNodes = root.ChildNodes; foreach (XmlNode node in listNodes) { switch (node.Name) { case "returnstatus": ok = (node.InnerText == "Success") ? true : false; break; case "message": if (node.InnerText == "OK") { rmsg = "短信提交成功."; } else { rmsg = node.InnerText; } break; case "remainpoint": break; case "taskID": msgid = node.InnerText; break; case "successCounts": break; } } int r = 1; if (!ok) { r = 99; } int i = 0; MessageHelper.Instance.WirteTest("短信提交一次 " + string.Join(",", sms.Number) + " " + rmsg); foreach (string num in sms.Number) { SMS s = new SMS(); s.Account = sms.Account; s.Audit = sms.Audit; s.Channel = sms.Channel; s.Content = sms.Content; s.Filter = sms.Filter; s.Level = sms.Level; s.Number = new List <string> { num }; s.SendTime = sms.SendTime; s.SerialNumber = sms.SerialNumber; s.StatusReport = sms.StatusReport; s.Signature = sms.Signature; s.SPNumber = sms.SPNumber; s.WapURL = sms.WapURL; i++; SendEventArgs se = new SendEventArgs(s, msgid + i.ToString().PadLeft(5, '0'), ok, (ushort)(2000 + r), rmsg, 1, 1); ExSendEventArgs ese = new ExSendEventArgs(se); if (SendEvent != null) { SendEvent(this, se); } if (ok) { lock (locker) { sends.Add(se.Serial, ese); } } } } catch (Exception ex) { Console.WriteLine(ex.Message); LogClient.LogHelper.LogInfo("ZS3WG", "SendSMS Error ->", ex.Message); } }
public void SendSMS(SMSModel.SMS sms) { try { string post = ""; for (int i = 0; i < sms.Number.Count; i++) { int phone, mobile; if (sms.Number[i].Length >= 11 && sms.Number[i].Substring(0, 1) == "1") { mobile = 1; phone = 0; } else { mobile = 0; phone = 1; } post = "action=send&userid=" + userId + "&account=" + account + "&password="******"&mobile=" + sms.Number[i] + "&content=" + sms.Content + sms.Signature + "&sendTime=&taskName=&checkcontent=1&countnumber=1&mobilenumber=" + mobile + "&telephonenumber=" + phone; string t = HTTPRequest.PostWebRequest(sendUrl, post, System.Text.Encoding.UTF8); //<? xml version = "1.0" encoding = "utf-8" ?> //< returnsms > //< returnstatus > status </ returnstatus > ----------返回状态值:成功返回Success 失败返回:Faild //<message> message</ message > ----------返回信息:见下表 //<remainpoint> remainpoint</ remainpoint > ----------返回余额 //< taskID > taskID </ taskID > -----------返回本次任务的序列ID //< successCounts > successCounts </ successCounts > --成功短信数:当成功后返回提交成功短信数 //</ returnsms > bool ok = true; string rmsg = ""; string msgid = ""; XmlDocument doc = new XmlDocument(); doc.LoadXml(t); XmlElement root = null; root = doc.DocumentElement; XmlNodeList listNodes = root.ChildNodes; foreach (XmlNode node in listNodes) { switch (node.Name) { case "returnstatus": ok = (node.InnerText == "Success") ?true:false; break; case "message": if (node.InnerText == "ok") { rmsg = "短信提交成功."; } else { rmsg = node.InnerText; } break; case "remainpoint": break; case "taskID": msgid = node.InnerText; break; case "successCounts": break; } } int r = 1;//原来默认0 ,应为1 by lmw 1 代表已发送 if (!ok) { // r = 101; r = 99;//提交失败 错误码应该在100以内吧 by lmw } SendEventArgs se = new SendEventArgs(sms, msgid, ok, (ushort)(2000 + r), rmsg, 1, 1); string result = JsonSerialize.Instance.Serialize <SendEventArgs>(se); Console.WriteLine("短信发送结果:" + result); ExSendEventArgs ese = new ExSendEventArgs(se); if (ok) { sends.Add(se.Serial, ese); LogClient.LogHelper.LogInfo("DXWG", "SendSMS OK ->", result); } else { LogClient.LogHelper.LogInfo("DXWG", "SendSMS Fail ->", result); } if (SendEvent != null) { SendEvent(this, se); } } } catch (Exception ex) { Console.WriteLine(ex.Message); LogClient.LogHelper.LogInfo("DXWG", "SendSMS Error ->", ex.Message); } Thread.Sleep(5); }
public void SendSMS(SMSModel.SMS sms) { try { for (int i = 0; i < sms.Number.Count; i++) { string t = client.SendMsg(account, password, sms.Number[i], sms.Content + sms.Signature, ""); long r = long.Parse(t); bool ok = r > 0 ? true : false; string rmsg = "发送成功."; switch (r) { case -1: rmsg = "提交接口错误。"; break; case -3: rmsg = "用户名或密码错误。"; break; case -4: rmsg = "短信内容和备案的模板不一样。"; break; case -5: rmsg = "签名不正确。"; break; case -7: rmsg = "余额不足。"; break; case -8: rmsg = "通道错误。"; break; case -9: rmsg = "无效号码。"; break; case -10: rmsg = "签名内容不符合长度。"; break; case -11: rmsg = "用户有效期过期。"; break; case -12: rmsg = "黑名单。"; break; case -13: rmsg = "语音验证码的 Amount 参数必须是整形字符串。"; break; case -14: rmsg = "语音验证码的内容只能为数字和字母。"; break; case -15: rmsg = "语音验证码的内容最长为 6 位。"; break; } if (r < 0) { //发送失败时,网关自己生成serial t = System.Guid.NewGuid().ToString(); } SendEventArgs se = new SendEventArgs(sms, t, ok, (ushort)(2000 - r), rmsg, 1, 1); string result = JsonSerialize.Instance.Serialize <SendEventArgs>(se); Console.WriteLine("短信发送结果:" + result); ExSendEventArgs ese = new ExSendEventArgs(se); if (ok) { sends.Add(se.Serial, ese); LogClient.LogHelper.LogInfo("TPYX", "SendSMS OK ->", result); } else { LogClient.LogHelper.LogInfo("TPYX", "SendSMS Fail ->", result); } if (SendEvent != null) { SendEvent(this, se); } } } catch (Exception ex) { Console.WriteLine(ex.Message); LogClient.LogHelper.LogInfo("TPYX", "SendSMS Error ->", ex.Message); } }