Beispiel #1
0
        /// <summary>
        /// 查看短信模板状态。
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public Task <QuerySmsTemplateResult> QuerySmsTemplateAsync(QuerySmsTemplateInput input)
        {
            var client    = new AliyunSmsClient();
            var acsClient = client.AcsClient;
            var request   = new QuerySmsTemplateRequest();
            var result    = new QuerySmsTemplateResult();

            try
            {
                request.TemplateCode = input.TemplateCode;

                //请求失败这里会抛ClientException异常
                var QuerySmsTemplateResponse = acsClient.GetAcsResponse(request);
                //发送成功判断
                if ("OK".Equals(QuerySmsTemplateResponse.Code, StringComparison.CurrentCultureIgnoreCase))
                {
                    result.Success        = true;
                    result.TemplateStatus = QuerySmsTemplateResponse.TemplateStatus;
                    result.Reason         = QuerySmsTemplateResponse.Reason;
                }
                else
                {
                    result.Success      = false;
                    result.ErrorMessage = QuerySmsTemplateResponse.Message;
                }
            }
            catch (ClientException e)
            {
                AliyunSmsHelper.LoggerAction("Error", e.ToString());
                result.Success      = false;
                result.ErrorMessage = e.ErrorMessage;
            }
            catch (Exception e)
            {
                AliyunSmsHelper.LoggerAction("Error", e.ToString());
                result.Success      = false;
                result.ErrorMessage = e.Message;
            }
            return(Task.FromResult(result));
        }
 /// <summary>
 /// 查看短信模板状态。
 /// </summary>
 /// <param name="input"></param>
 /// <returns></returns>
 public async Task <QuerySmsTemplateResult> QuerySmsTemplateAsync(QuerySmsTemplateInput input)
 {
     return(await SmsService.QuerySmsTemplateAsync(input));
 }