public virtual async Task Send_HW(string phoneNum, string msg) { SendSMSReq req = new SendSMSReq { phoneNum = phoneNum, msg = msg }; using (var http = new HttpClient()) { RestTemplate rest = new RestTemplate(http); var resp = await rest.PostAsync("http://MsgService/api/SMS/Send_HW", req); if (resp.StatusCode != System.Net.HttpStatusCode.OK) { throw new Exception("发送错误,状态码" + resp.StatusCode); } } }
private void ButtonSend_Click(object sender, RoutedEventArgs e) { List <ValidationEntity> ValidationForMessage = new List <ValidationEntity>(); List <ValidationEntity> ValidationForCellPhone = new List <ValidationEntity>(); List <ValidationEntity> ValidationForSoSysNo = new List <ValidationEntity>(); ValidationForMessage.Add(new ValidationEntity(ValidationEnum.IsNotEmpty, null, ResSendSMS.validmsg_SMSMessage)); ValidationForCellPhone.Add(new ValidationEntity(ValidationEnum.IsNotEmpty, null, ResSendSMS.validmsg_Cellphone)); ValidationForSoSysNo.Add(new ValidationEntity(ValidationEnum.IsNotEmpty, null, ResSendSMS.validmsg_SoSysNo)); //tbSendResults.Text = string.Empty; if (tabSelect.SelectedIndex == 0) //按照手机号发送 { if (!(ValidationHelper.Validation(this.tbTelNumber, ValidationForCellPhone) && ValidationHelper.Validation(this.tbSMSContent, ValidationForMessage))) { return; } List <string> list = PerHandle(tbTelNumber.Text, @"^\d{11}$", false); if (list != null && list.Count > 0) { SendSMSReq request = new SendSMSReq(); request.Numbers = list; request.Message = tbSMSContent.Text.Trim(); new SMSFacade(CPApplication.Current.CurrentPage).SendSMSByCellphone(request, (obj, args) => { if (args.FaultsHandle()) { return; } if (args.Result.Count > 0) { List <string> fomateErrorList = new List <string>(); args.Result.ForEach(item => { fomateErrorList.Add(item + ResSendSMS.msg_Fail); }); ShowResult(fomateErrorList); } else { CPApplication.Current.CurrentPage.Context.Window.Alert(ResSendSMS.msg_Success); tbSMSContent.Text = string.Empty; tbSendResults.Text = string.Empty; tbSendResults.Visibility = Visibility.Collapsed; } }); } //else //{ // CPApplication.Current.CurrentPage.Context.Window.MessageBox.Show("请核对手机号码是否正确"); // return; //} } else if (tabSelect.SelectedIndex == 1) //按照订单号发送 { if (!(ValidationHelper.Validation(this.tbSMSContent, ValidationForMessage) && ValidationHelper.Validation(this.tbSONumber, ValidationForSoSysNo))) { return; } List <string> list = PerHandle(tbSONumber.Text, @"^\d*$", true); if (list != null && list.Count > 0) { SendSMSReq request = new SendSMSReq(); request.Numbers = list; request.Message = tbSMSContent.Text.Trim(); new SMSFacade(CPApplication.Current.CurrentPage).SendSMSBySOSysNo(request, (obj, args) => { if (args.FaultsHandle()) { return; } if (args.Result.Count > 0) { List <string> fomateErrorList = new List <string>(); args.Result.ForEach(item => { fomateErrorList.Add(item + ResSendSMS.msg_Fail); }); ShowResult(fomateErrorList); } else { CPApplication.Current.CurrentPage.Context.Window.Alert(ResSendSMS.msg_Success); tbSMSContent.Text = string.Empty; tbSendResults.Text = string.Empty; tbSendResults.Visibility = Visibility.Collapsed; } }); } //else //{ // CPApplication.Current.CurrentPage.Context.Window.MessageBox.Show("请核对订单号是否正确"); // return; //} } }
public List <string> SendBySOSysNo(SendSMSReq request) { return(ObjectFactory <SendSMSAndEmailService> .Instance.SendBySOSysNo(request.Numbers, request.Message)); }
public void SendSMSBySOSysNo(SendSMSReq request, EventHandler <RestClientEventArgs <List <string> > > callback) { string relativeUrl = "/CustomerService/SMS/SendBySOSysNo"; restClient.Create(relativeUrl, request, callback); }