private void sendErrorLog(string message, string[] receivers, SmsInformation information) { _logger.Error(new { message = "发送短信失败", exception = message, receivers = receivers, information = information }); }
/// <summary> /// 发送短信 /// </summary> /// <param name="receivers">接收者手机号码</param> /// <param name="information">信息内容</param> /// <remarks> /// author:catdemon /// data:2019-05-15 /// opt:create /// </remarks> /// <exception cref="System.IO.IOException">调用网络错误</exception> /// <exception cref="Ccshis.AuthorizeExcpetion">阿里云授权异常</exception>" /// <exception cref="Ccshis.BizException">业务异常</exception> public async Task SendAsync(List <string> receivers, SmsInformation information) { await Task.Run(() => { ///todo 发送短信逻辑 // }); throw new NotImplementedException(); }
private async Task send(string[] receivers, SmsInformation information) { await Task.Run(() => { IClientProfile profile = DefaultProfile.GetProfile(_profile_default, _aliYunApiSetting.accessKeyId, _aliYunApiSetting.secret); DefaultAcsClient client = new DefaultAcsClient(profile); CommonRequest request = new CommonRequest(); request.Method = MethodType.POST; request.Domain = _aliApiDomain; request.Version = _aliApiVersion; request.Action = _AliApiAction; // request.Protocol = ProtocolType.HTTP; string phoneNumbers = StringUtil.SplitJoint(receivers); request.AddQueryParameters(_param_PhoneNumbers, phoneNumbers); request.AddQueryParameters(_param_SignName, information.SignName); request.AddQueryParameters(_param_TemplateCode, information.TemplateCode); request.AddQueryParameters(_param_TemplateParam, information.TemplateParam); try { CommonResponse response = client.GetCommonResponse(request); var apiResult = JsonConvert.DeserializeObject <AliApiResult>(response.Data); if (apiResult.Code != _ApiResult_OK) { sendErrorLog(Localization.Sy000100.ToString(), receivers, information); } } catch (ServerException e) { sendErrorLog(e.Message, receivers, information); } catch (ClientException e) { sendErrorLog(e.Message, receivers, information); } }); }
/// <summary> /// 发送短信 /// </summary> /// <param name="receivers">接收者手机号码</param> /// <param name="information">信息内容</param> /// <remarks> /// author:catdemon /// data:2019-05-15 /// opt:create /// </remarks> /// <exception cref="System.IO.IOException">调用网络错误</exception> /// <exception cref="Ccshis.AuthorizeExcpetion">阿里云授权异常</exception>" /// <exception cref="Ccshis.BizException">业务异常</exception> public async Task SendAsync(string[] receivers, SmsInformation information) { await send(receivers, information); }
async Task ISmsSender.SendAsync(string receivers, SmsInformation information) { await SendAsync(receivers, information); }
/// <summary> /// 发送短信 /// </summary> /// <param name="receivers">接收者手机号码</param> /// <param name="information">信息内容</param> /// <remarks> /// author:catdemon /// data:2019-05-15 /// opt:create /// </remarks> /// <exception cref="System.IO.IOException">调用网络错误</exception> /// <exception cref="Ccshis.AuthorizeExcpetion">阿里云授权异常</exception>" /// <exception cref="Ccshis.BizException">业务异常</exception> public void Send(List <string> receivers, SmsInformation information) { ///todo 发送短信逻辑 throw new NotImplementedException(); }