EasyAbp.NotificationService.Provider.Dingtalk.Abstractions
1.0.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package EasyAbp.NotificationService.Provider.Dingtalk.Abstractions --version 1.0.1
NuGet\Install-Package EasyAbp.NotificationService.Provider.Dingtalk.Abstractions -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EasyAbp.NotificationService.Provider.Dingtalk.Abstractions" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EasyAbp.NotificationService.Provider.Dingtalk.Abstractions --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: EasyAbp.NotificationService.Provider.Dingtalk.Abstractions, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install EasyAbp.NotificationService.Provider.Dingtalk.Abstractions as a Cake Addin
#addin nuget:?package=EasyAbp.NotificationService.Provider.Dingtalk.Abstractions&version=1.0.1
// Install EasyAbp.NotificationService.Provider.Dingtalk.Abstractions as a Cake Tool
#tool nuget:?package=EasyAbp.NotificationService.Provider.Dingtalk.Abstractions&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
EasyAbp.NotificationService.Dingtalk
基于EasyAbp.NotificationService的钉钉机器人消息通知
使用方式:
安装EasyAbp
安装EasyAbp.NotificationService.Provider.Dingtalk
dotnet add package EasyAbp.NotificationService.Provider.Dingtalk
- 添加module依赖
[DependsOn(
typeof(NotificationServiceProviderDingtalkModule)
)]
- 配置钉钉,appsettings.json中添加:
"Dingtalk": {
"AppKey": "你的appkey",
"AppSecret": "你的appsecret",
"RedirectUri": "忽略",
"WebHookAesKey": "忽略",
"WebHookToken": "忽略",
"RobotCode": "你的钉钉机器人RobotCode"
}
- 实现IDingtalkUserIdProvider
[Dependency(ReplaceServices = true, TryRegister = true)]
public class DingtalkUserIdProvider : IDingtalkUserIdProvider , ITransientDependency
{
public DingtalkUserIdProvider(r)
{
}
public async Task<string> GetOrNullAsync(string appId, Guid userId)
{
//实现业务系统用户和钉钉用户的转换
}
public async Task<string> GetOrNullAsync(Guid userId)
{
// 实现业务系统用户和钉钉用户的转换
}
}
- 发送消息, 实现工厂类并使用:
public class YourNotificationFactory : NotificationFactory<YourData, CreateDingtalkRobotInteractiveCardNotificationEto>, ITransientDependency
{
private ICurrentTenant _currentTenant;
private readonly IDingtalkInteractiveCardNotificationDataModelJsonSerializer _jsonSerializer;
public SampleErrorDingtalkRobotInteractiveCardNotificationFactory(ICurrentTenant currentTenant, IDingtalkInteractiveCardNotificationDataModelJsonSerializer jsonSerializer)
{
_currentTenant = currentTenant;
_jsonSerializer = jsonSerializer;
}
public override async Task<CreateDingtalkRobotInteractiveCardNotificationEto> CreateAsync(YourData model,
IEnumerable<Guid> userIds)
{
var departments = await _openUserService.QueryDepartmentNamesAsync(new Guid[] { model.SampleErrorNotification.CreatorId!.Value });
var eto = new CreateDingtalkRobotInteractiveCardNotificationEto(_currentTenant.Id.GetValueOrDefault(),
userIds,
new DingtalkRobotInteractiveCardDataModel()
{
CardBizId = "your notification id",
CardData = new
{
config = new
{
autoLayout = true,
enableForward = true,
},
header = new
{
title = new
{
type = "text",
text = $"消息标题"
},
logo = "@lALPDfJ6V_FPDmvNAfTNAfQ"
},
contents = new List<object>()
{
new
{
type = "section",
fields = new
{
list = new List<object>
{
new
{
type = "text",
text = $"消息正文段落1",
},
new
{
type = "text",
text = $"消息正文段落2",
},
new
{
type = "text",
text = $"消息正文段落3",
},
new
{
type = "text",
text = $"消息正文段落4",
}
}
}
}
}
}
}
}, _jsonSerializer);
return eto;
}
}
- 在业务层中调用YourNotificationFactory.CreateAsync(),得到eto并发布
通知效果:
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0
- AlibabaCloud.SDK.Dingtalk (>= 2.0.28)
- EasyAbp.NotificationService.Domain.Shared (>= 2.3.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on EasyAbp.NotificationService.Provider.Dingtalk.Abstractions:
Package | Downloads |
---|---|
EasyAbp.NotificationService.Provider.Dingtalk
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.