CenIT.NotifyLib
1.1.0
dotnet add package CenIT.NotifyLib --version 1.1.0
NuGet\Install-Package CenIT.NotifyLib -Version 1.1.0
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="CenIT.NotifyLib" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CenIT.NotifyLib" Version="1.1.0" />
<PackageReference Include="CenIT.NotifyLib" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CenIT.NotifyLib --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CenIT.NotifyLib, 1.1.0"
#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.
#:package CenIT.NotifyLib@1.1.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CenIT.NotifyLib&version=1.1.0
#tool nuget:?package=CenIT.NotifyLib&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
NotifyLib v1.1.0
Giới thiệu
NotifyLib là thư viện C# (.NET Framework 4.8) hỗ trợ gửi thông báo đa kênh như Email, SMS/ZNS, Firebase, có thể mở rộng thêm các kênh khác.
Thư viện được thiết kế theo kiến trúc DI + Strategy + Retry + Pipeline, hỗ trợ gửi song song, fallback, retry theo từng recipient, tránh spam notify.
Tính năng chính
- Gửi đa kênh: Email, SMS/ZNS, Firebase
- Gửi nhiều channel cùng lúc
- Strategy gửi:
- Fallback
- ParallelAll
- ParallelFirst
- Retry per recipient
- Log chi tiết từng lần retry
- Trả kết quả gửi (
NotifyExecutionReport) - Observer/Event
NotifyCompleted - JSON Config auto-load
- Dễ mở rộng thêm notifier mới
Cài đặt
- .NET Framework 4.8
- Thêm project
NotifyLibvào solution - Tham chiếu từ Web / API / Console App
Cấu hình (appsettings.json)
{
"Email": {
"Enable": true,
"SmtpServer": "",
"Port": 587,
"EnableSsl": false,
"User": "",
"Password": "",
"From": ""
},
"Firebase": {
"Enable": false,
"ProjectId": "",
"ApiUrl": "",
"ServiceAccountJson": ""
},
//"Zalo": { // Tạm ẩn do chưa có thông tin
// "ServiceUrl": null,
// "OAId": null,
// "Enable": false
//},
"ZNS": {
"ServiceUrl": "",
"AppId": "",
"SecrectKey": "",
"AccessToken": "",
"RefreshToken": "",
"Enable": true
},
"Sms": {
"Enable": true,
"ServiceUrl": "",
"AgentId": "",
"UserService": "",
"UserPassService": "",
"LabelId": "",
"ContractId": "",
"ContractTypeId": "",
"UserName": ""
},
"ChannelPolicy": [
{
"Channel": "Email",
"Priority": 1,
"Enable": true
},
{
"Channel": "Firebase",
"Priority": 2,
"Enable": false
},
//{
// "Channel": "Zalo",
// "Priority": 3,
// "Enable": false
//},
{
"Channel": "Sms",
"Priority": 4,
"Enable": true
},
{
"Channel": "ZNS",
"Priority": 5,
"Enable": true
}
]
}
Sử dụng cơ bản
Khởi tạo DI
var services = new ServiceCollection();
services.AddNotifyByJsonPath("notify.json");
var provider = services.BuildServiceProvider();
var notify = provider.GetRequiredService<NotifyService>();
Gửi notify đa kênh
var report = notifyService.Send(new NotifyContext
{
SendMode = NotifySendMode.ParallelAll,
Channels = new Dictionary<string, object>
{
{
ChannelTypes.EMAIL,
new EmailNotifyData
{
Recipients = new [] { "user@mail.com" },
Subject = "Test",
BodyHtml = "Hello"
}
},
{
ChannelTypes.SMS,
new SmsNotifyData
{
Recipients = new List<string> {"0843466804", "0974463353" },
TemplateId = "5431422",
Params = new List<string>{ "AAAAA", "https://asdasf.com/" }
}
}
}
});
Versioning
- v1.1.0
- Chỉnh sửa hàm load config Notify từ path
- Bổ sung hàm load config Notify từ chuỗi json
- Fixbug
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net48 is compatible. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
- BouncyCastle (>= 1.7.0)
- Google.Apis.Auth (>= 1.73.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.2)
- Newtonsoft.Json (>= 13.0.4)
- RestSharp (>= 106.12.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial stable release