public void SendSMS(PlainSMS sms) { try { SendResult sr = Gateway.SendSMS(sms); ReportEventArgs re = new ReportEventArgs(); int i = 0; re.StatusReports.AddRange(sms.Numbers.Split(',').Select(n => new StatusReport() { SMSID = sms.ID, SerialNumber = sr.SerialNumber + (++i).ToString().PadLeft(5, '0'), SendTime = sms.SendTime.Value, StatusCode = 2000 + sr.StatusCode, Succeed = sr.Success, Channel = sms.Channel, Description = sr.Message, Number = n, ResponseTime = null })); SendEvent(this, re); if (sr.Success) { lock (locker) { sends.Add(sr.SerialNumber, re); } } } catch (Exception ex) { MessageHelper.Instance.WirteError(ex.ToString()); LogClient.LogHelper.LogInfo(Gateway.Config.GatewayName, "SendSMS Error ->", ex.Message); } }
public void SendSMS(PlainSMS sms) { try { MessageHelper.Instance.WirteTest("提交短信:" + JsonConvert.SerializeObject(sms)); SendResult sr = Gateway.SendSMS(sms); if (string.IsNullOrWhiteSpace(sr.SerialNumber)) { sr.SerialNumber = System.Guid.NewGuid().ToString(); } MessageHelper.Instance.WirteTest("提交短信返回结果:" + JsonConvert.SerializeObject(sr)); ReportEventArgs re = new ReportEventArgs(); int i = 0; re.StatusReports.AddRange(sms.Numbers.Split(',').Select(n => new StatusReport() { SMSID = sms.ID, SerialNumber = sr.SerialNumber + (++i).ToString().PadLeft(5, '0'), SendTime = sms.SendTime.Value, StatusCode = sr.StatusCode, Succeed = sr.Success, Channel = sms.Channel, Description = sr.Message, Number = n, ResponseTime = null, Gateway = Gateway.Config.GatewayName, AccountID = sms.AccountID, StatusReportType = (StatusReportType)sms.StatusReportType })); SendEvent(this, re); if (sr.Success) { lock (locker) { sends.Add(sr.SerialNumber, re); } } if (this.Gateway.Config.EnableTrafficControl > 0) { tc.AddCountAndCheckTraffic(sms.NumberCount); } } catch (Exception ex) { MessageHelper.Instance.WirteError(ex.ToString()); LogClient.LogHelper.LogInfo(Gateway.Config.GatewayName, "SendSMS Error ->", ex.Message); } }