Bitzsoft.Integrations.Calendar
1.0.2
dotnet add package Bitzsoft.Integrations.Calendar --version 1.0.2
NuGet\Install-Package Bitzsoft.Integrations.Calendar -Version 1.0.2
<PackageReference Include="Bitzsoft.Integrations.Calendar" Version="1.0.2" />
<PackageVersion Include="Bitzsoft.Integrations.Calendar" Version="1.0.2" />
<PackageReference Include="Bitzsoft.Integrations.Calendar" />
paket add Bitzsoft.Integrations.Calendar --version 1.0.2
#r "nuget: Bitzsoft.Integrations.Calendar, 1.0.2"
#:package Bitzsoft.Integrations.Calendar@1.0.2
#addin nuget:?package=Bitzsoft.Integrations.Calendar&version=1.0.2
#tool nuget:?package=Bitzsoft.Integrations.Calendar&version=1.0.2
Bitzsoft.Integrations.Calendar
日历抽象层 — 统一接口定义、基础模型与结果包装。
屏蔽 Google Calendar、Microsoft 365 等供应商差异,提供一致的日历事件创建、查询、更新、删除、列表与邀请响应 API。
功能特性
- 统一供应商接口
ICalendarService:8 个异步方法覆盖日历事件全生命周期,含邀请接受/拒绝 - 统一结果包装
CalendarResult:携带成功标志与错误信息 - 统一异常
CalendarException:封装供应商标识、错误码与请求 ID - 统一模型设计:集合返回
List<T>,覆盖全天事件、时区、参会人、在线会议与重复规则
安装
dotnet add package Bitzsoft.Integrations.Calendar
<PackageReference Include="Bitzsoft.Integrations.Calendar" Version="1.0.0" />
接口
ICalendarService
统一的日历服务供应商接口。
| 方法 | 返回类型 | 说明 |
|---|---|---|
ProviderName |
string |
供应商标识(如 Google、Microsoft365) |
CreateEventAsync |
Task<CalendarEvent> |
创建日历事件,返回事件信息 |
GetEventAsync |
Task<CalendarEvent> |
查询单个事件详情 |
UpdateEventAsync |
Task<CalendarResult> |
更新事件信息 |
DeleteEventAsync |
Task<CalendarResult> |
删除事件 |
ListEventsAsync |
Task<List<CalendarEvent>> |
分页查询事件列表 |
AcceptInvitationAsync |
Task<CalendarResult> |
接受事件邀请 |
DeclineInvitationAsync |
Task<CalendarResult> |
拒绝事件邀请(可附原因) |
核心模型
| 类 | 关键字段 | 说明 |
|---|---|---|
CreateEventRequest |
Title、Description、Location、StartDateTime、EndDateTime、IsAllDay、TimeZone、Attendees、OnlineMeetingUrl、RecurrenceRule |
创建事件请求 |
UpdateEventRequest |
EventId、Title、Description、Location、StartDateTime、EndDateTime |
更新事件请求 |
ListEventsRequest |
CalendarId、StartDate、EndDate、PageIndex、PageSize、PageToken |
事件列表查询参数(PageToken 为分页游标,Google 等供应商使用) |
CalendarEvent |
EventId、Title、Description、Location、StartDateTime、EndDateTime、IsAllDay、TimeZone、Organizer、Attendees、Status、OnlineMeetingUrl |
日历事件信息 |
CalendarAttendee |
Email、Name、ResponseStatus、Optional |
参会人信息 |
CalendarResult |
Success、ErrorMessage |
操作结果 |
CalendarException |
— | 统一异常(继承 IntegrationException) |
枚举
| 枚举 | 说明 |
|---|---|
CalendarEventStatus |
事件状态:Confirmed / Tentative / Cancelled |
CalendarResponseStatus |
参会人响应状态:NeedsAction / Accepted / Declined / Tentative |
使用示例
抽象层本身只定义接口与模型,具体实现由各供应商包提供。以下示例假设已注册某个供应商实现:
public class EventService(ICalendarService calendar)
{
public async Task<string> CreateAsync(string title, DateTimeOffset start, DateTimeOffset end)
{
var evt = await calendar.CreateEventAsync(new CreateEventRequest
{
Title = title,
StartDateTime = start,
EndDateTime = end,
Attendees =
[
new() { Email = "zhangsan@example.com", Name = "张三" }
]
});
return evt.EventId;
}
public Task<CalendarResult> DeclineAsync(string eventId, string reason)
=> calendar.DeclineInvitationAsync(eventId, reason);
}
多供应商解析
同一应用注册多个供应商时,通过 IIntegrationProviderResolver<ICalendarService> 按供应商 ID 解析:
var resolver = serviceProvider.GetRequiredService<IIntegrationProviderResolver<ICalendarService>>();
var google = resolver.GetRequired("Google");
var evt = await google.CreateEventAsync(request);
依赖
- Bitzsoft.Integrations.Core:公共基座(
IntegrationException、IIntegrationProviderResolver<T>)
相关包
| 供应商 | 包名 |
|---|---|
| 统一抽象 | Bitzsoft.Integrations.Calendar |
| Google Calendar | Bitzsoft.Integrations.Calendar.Google |
| Microsoft 365 | Bitzsoft.Integrations.Calendar.Microsoft365 |
| 聚合包 | Bitzsoft.Integrations.Calendar.All |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. 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 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Bitzsoft.Integrations.Core (>= 1.0.2)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Options (>= 10.0.10)
-
net5.0
- Bitzsoft.Integrations.Core (>= 1.0.2)
- Microsoft.Extensions.Logging.Abstractions (>= 5.0.0)
- Microsoft.Extensions.Options (>= 5.0.0)
-
net8.0
- Bitzsoft.Integrations.Core (>= 1.0.2)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Options (>= 10.0.10)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Bitzsoft.Integrations.Calendar:
| Package | Downloads |
|---|---|
|
Bitzsoft.Integrations.Calendar.Google
Google Calendar 实现 — Bearer / API Key 鉴权 + HttpClient,实现 ICalendarService 统一接口,支持事件创建/查询/更新/删除/列表/接受邀请/拒绝邀请 |
|
|
Bitzsoft.Integrations.Calendar.Microsoft365
Microsoft 365 Calendar 实现 — Azure AD Client Credentials Bearer 鉴权 + HttpClient,实现 ICalendarService 统一接口,支持事件创建/查询/更新/删除/列表/接受邀请/拒绝邀请 |
|
|
Bitzsoft.Integrations.Calendar.All
日历服务聚合包 — 包含全部供应商实现(Google / Microsoft 365) |
GitHub repositories
This package is not used by any popular GitHub repositories.