Exemplo n.º 1
0
        /// <summary>
        /// 修改短信模板。
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public Task <SmsResult> ModifySmsTemplateAsync(ModifySmsTemplateInput input)
        {
            var client    = new AliyunSmsClient();
            var acsClient = client.AcsClient;
            var request   = new ModifySmsTemplateRequest();
            var result    = new SmsResult();

            try
            {
                request.TemplateCode    = input.TemplateCode;
                request.TemplateType    = input.TemplateType;
                request.TemplateName    = input.TemplateName;
                request.TemplateContent = input.TemplateContent;
                request.Remark          = input.Remark;

                //请求失败这里会抛ClientException异常
                var ModifySmsTemplateResponse = acsClient.GetAcsResponse(request);
                //发送成功判断
                if ("OK".Equals(ModifySmsTemplateResponse.Code, StringComparison.CurrentCultureIgnoreCase))
                {
                    result.Success = true;
                }
                else
                {
                    result.Success      = false;
                    result.ErrorMessage = ModifySmsTemplateResponse.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 <SmsResult> ModifySmsTemplateAsync(ModifySmsTemplateInput input)
 {
     return(await SmsService.ModifySmsTemplateAsync(input));
 }