mirror of https://github.com/abpframework/abp.git
10 changed files with 217 additions and 0 deletions
@ -0,0 +1,3 @@ |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<ConfigureAwait ContinueOnCapturedContext="false"/> |
|||
</Weavers> |
|||
@ -0,0 +1,30 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
|||
<xs:element name="Weavers"> |
|||
<xs:complexType> |
|||
<xs:all> |
|||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
|||
<xs:complexType> |
|||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:all> |
|||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
|||
<xs:annotation> |
|||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:schema> |
|||
@ -0,0 +1,3 @@ |
|||
{ |
|||
"role": "lib.framework" |
|||
} |
|||
@ -0,0 +1,63 @@ |
|||
{ |
|||
"name": "Volo.Abp.Sms.TencentCloud", |
|||
"hash": "", |
|||
"contents": [ |
|||
{ |
|||
"namespace": "Volo.Abp.Sms.TencentCloud", |
|||
"dependsOnModules": [ |
|||
{ |
|||
"declaringAssemblyName": "Volo.Abp.Sms", |
|||
"namespace": "Volo.Abp.Sms", |
|||
"name": "AbpSmsModule" |
|||
} |
|||
], |
|||
"implementingInterfaces": [ |
|||
{ |
|||
"name": "IAbpModule", |
|||
"namespace": "Volo.Abp.Modularity", |
|||
"declaringAssemblyName": "Volo.Abp.Core", |
|||
"fullName": "Volo.Abp.Modularity.IAbpModule" |
|||
}, |
|||
{ |
|||
"name": "IOnPreApplicationInitialization", |
|||
"namespace": "Volo.Abp.Modularity", |
|||
"declaringAssemblyName": "Volo.Abp.Core", |
|||
"fullName": "Volo.Abp.Modularity.IOnPreApplicationInitialization" |
|||
}, |
|||
{ |
|||
"name": "IOnApplicationInitialization", |
|||
"namespace": "Volo.Abp", |
|||
"declaringAssemblyName": "Volo.Abp.Core", |
|||
"fullName": "Volo.Abp.IOnApplicationInitialization" |
|||
}, |
|||
{ |
|||
"name": "IOnPostApplicationInitialization", |
|||
"namespace": "Volo.Abp.Modularity", |
|||
"declaringAssemblyName": "Volo.Abp.Core", |
|||
"fullName": "Volo.Abp.Modularity.IOnPostApplicationInitialization" |
|||
}, |
|||
{ |
|||
"name": "IOnApplicationShutdown", |
|||
"namespace": "Volo.Abp", |
|||
"declaringAssemblyName": "Volo.Abp.Core", |
|||
"fullName": "Volo.Abp.IOnApplicationShutdown" |
|||
}, |
|||
{ |
|||
"name": "IPreConfigureServices", |
|||
"namespace": "Volo.Abp.Modularity", |
|||
"declaringAssemblyName": "Volo.Abp.Core", |
|||
"fullName": "Volo.Abp.Modularity.IPreConfigureServices" |
|||
}, |
|||
{ |
|||
"name": "IPostConfigureServices", |
|||
"namespace": "Volo.Abp.Modularity", |
|||
"declaringAssemblyName": "Volo.Abp.Core", |
|||
"fullName": "Volo.Abp.Modularity.IPostConfigureServices" |
|||
} |
|||
], |
|||
"contentType": "abpModule", |
|||
"name": "AbpSmsTencentCloudModule", |
|||
"summary": null |
|||
} |
|||
] |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
<Import Project="..\..\..\configureawait.props" /> |
|||
<Import Project="..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0;net9.0</TargetFrameworks> |
|||
<Nullable>enable</Nullable> |
|||
<WarningsAsErrors>Nullable</WarningsAsErrors> |
|||
<AssemblyName>Volo.Abp.Sms.TencentCloud</AssemblyName> |
|||
<PackageId>Volo.Abp.Sms.TencentCloud</PackageId> |
|||
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> |
|||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
|||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
|||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Volo.Abp.Sms\Volo.Abp.Sms.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="TencentCloudSDK" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageVersion Update="TencentCloudSDK" Version="3.0.1142" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,15 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.Sms.TencentCloud; |
|||
|
|||
[DependsOn(typeof(AbpSmsModule))] |
|||
public class AbpSmsTencentCloudModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
var configuration = context.Services.GetConfiguration(); |
|||
|
|||
Configure<AbpTencentCloudSmsOptions>(configuration.GetSection("AbpTencentCloudSms")); |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
namespace Volo.Abp.Sms.TencentCloud; |
|||
|
|||
public class AbpTencentCloudSmsOptions |
|||
{ |
|||
public string SmsSdkAppId { get; set; } = default!; |
|||
public string SecretKey { get; set; } = default!; |
|||
public string SecretId { get; set; } = default!; |
|||
public string Endpoint { get; set; } = "sms.tencentcloudapi.com"; |
|||
public string Region { get; set; } = "ap-guangzhou"; |
|||
|
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
namespace Volo.Abp.Sms.TencentCloud; |
|||
|
|||
public static class TencentCloudSmsProperties |
|||
{ |
|||
public const string SignName = "SignName"; |
|||
public const string TemplateId = "TemplateId"; |
|||
} |
|||
@ -0,0 +1,48 @@ |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.Options; |
|||
using TencentCloud.Common; |
|||
using TencentCloud.Common.Profile; |
|||
using TencentCloud.Sms.V20210111; |
|||
using TencentCloud.Sms.V20210111.Models; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.Sms.TencentCloud; |
|||
|
|||
public class TencentCloudSmsSender : ISmsSender, ITransientDependency |
|||
{ |
|||
protected AbpTencentCloudSmsOptions Options { get; } |
|||
|
|||
public TencentCloudSmsSender(IOptionsMonitor<AbpTencentCloudSmsOptions> options) |
|||
{ |
|||
Options = options.CurrentValue; |
|||
} |
|||
|
|||
public async Task SendAsync(SmsMessage smsMessage) |
|||
{ |
|||
var client = CreateClient(); |
|||
|
|||
await client.SendSms(new SendSmsRequest |
|||
{ |
|||
SmsSdkAppId = Options.SmsSdkAppId, |
|||
SignName = smsMessage.Properties.GetOrDefault(TencentCloudSmsProperties.SignName) as string, |
|||
TemplateId = smsMessage.Properties.GetOrDefault(TencentCloudSmsProperties.TemplateId) as string, |
|||
TemplateParamSet = smsMessage.Text.Split(','), |
|||
PhoneNumberSet = [smsMessage.PhoneNumber] |
|||
}); |
|||
} |
|||
|
|||
protected virtual SmsClient CreateClient() |
|||
{ |
|||
var cred = new Credential { |
|||
SecretId = Options.SecretId, |
|||
SecretKey = Options.SecretKey |
|||
}; |
|||
var clientProfile = new ClientProfile(); |
|||
clientProfile.HttpProfile = new HttpProfile() |
|||
{ |
|||
Endpoint = Options.Endpoint |
|||
}; |
|||
return new SmsClient(cred,Options.Region,clientProfile); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue