|
|
@@ -10,7 +10,7 @@ using Newtonsoft.Json; |
|
|
|
|
|
|
|
namespace Quanjiang.DigitalScholl.SendSms |
|
|
|
{ |
|
|
|
public class AliyunSms:ISms |
|
|
|
public class AliyunSms : ISms |
|
|
|
{ |
|
|
|
private static readonly string RegionIdForPop = ConfigManager.AppSettings["regionIdForPop"].Value; |
|
|
|
private static readonly string AccessId = ConfigManager.AppSettings["accessId"].Value; |
|
|
@@ -25,9 +25,9 @@ namespace Quanjiang.DigitalScholl.SendSms |
|
|
|
/// <param name="phoneNumber">手机号</param> |
|
|
|
/// <param name="st">短信通知类型</param> |
|
|
|
/// <returns>发送结果</returns> |
|
|
|
public async Task<(string code,string randomNum, string message,string errorType)> SendSmsToSingle(string phoneNumber, SmsType st, List<string> sendParams = null) |
|
|
|
public async Task<(string code, string randomNum, string message, string errorType)> SendSmsToSingle(string phoneNumber, SmsType st, List<string> sendParams = null) |
|
|
|
{ |
|
|
|
(string code, string randomNum, string message,string errorType) result; |
|
|
|
(string code, string randomNum, string message, string errorType) result; |
|
|
|
IClientProfile profile = DefaultProfile.GetProfile(RegionIdForPop, AccessId, AccessSecret); |
|
|
|
DefaultProfile.AddEndpoint(RegionIdForPop, RegionIdForPop, Product, Domain); |
|
|
|
IAcsClient acsClient = new DefaultAcsClient(profile); |
|
|
@@ -40,15 +40,15 @@ namespace Quanjiang.DigitalScholl.SendSms |
|
|
|
request.TemplateCode = templatecode; |
|
|
|
request.TemplateParam = templateparam; |
|
|
|
var sendSmsResponse = await Task.FromResult(acsClient.GetAcsResponse(request)); |
|
|
|
result=(sendSmsResponse.Code, randomNum, sendSmsResponse.Message,""); |
|
|
|
result = (sendSmsResponse.Code, randomNum, sendSmsResponse.Message, ""); |
|
|
|
} |
|
|
|
catch (ServerException e) |
|
|
|
{ |
|
|
|
result = (e.ErrorCode,"",e.ErrorMessage,Enum.GetName(typeof(ErrorType),e.ErrorType)); |
|
|
|
result = (e.ErrorCode, "", e.ErrorMessage, Enum.GetName(typeof(ErrorType), e.ErrorType)); |
|
|
|
} |
|
|
|
catch (ClientException e) |
|
|
|
{ |
|
|
|
result = (e.ErrorCode,"", e.ErrorMessage, Enum.GetName(typeof(ErrorType), e.ErrorType)); |
|
|
|
result = (e.ErrorCode, "", e.ErrorMessage, Enum.GetName(typeof(ErrorType), e.ErrorType)); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
@@ -64,9 +64,9 @@ namespace Quanjiang.DigitalScholl.SendSms |
|
|
|
/// </summary> |
|
|
|
/// <param name="st"></param> |
|
|
|
/// <returns></returns> |
|
|
|
private (string templateCode, string templateParam, string randomNum) GetSmsTemplateBySmsType(SmsType st) |
|
|
|
private (string templateCode, string templateParam, string randomNum) GetSmsTemplateBySmsType(SmsType st) |
|
|
|
{ |
|
|
|
(string templateCode, string templateParam,string randomNum) result; |
|
|
|
(string templateCode, string templateParam, string randomNum) result; |
|
|
|
var randomNum = CommonHelper.RandNum(6); |
|
|
|
switch (st) |
|
|
|
{ |
|
|
@@ -79,15 +79,6 @@ namespace Quanjiang.DigitalScholl.SendSms |
|
|
|
case SmsType.ForgetPassWord: |
|
|
|
result = ("SMS_137485060", JsonConvert.SerializeObject(new { code = randomNum }), randomNum); |
|
|
|
break; |
|
|
|
case SmsType.LessionNotification: |
|
|
|
result = ("SMS_137485060", JsonConvert.SerializeObject(new { code = randomNum }), randomNum); |
|
|
|
break; |
|
|
|
case SmsType.LeaveNotification: |
|
|
|
result = ("SMS_137485060", JsonConvert.SerializeObject(new { code = randomNum }), randomNum); |
|
|
|
break; |
|
|
|
case SmsType.MakeUpMissedLessonsNotification: |
|
|
|
result = ("SMS_137485060", JsonConvert.SerializeObject(new { code = randomNum }), randomNum); |
|
|
|
break; |
|
|
|
default: |
|
|
|
throw new ArgumentOutOfRangeException(nameof(st), st, null); |
|
|
|
} |
|
|
|