Skip to content

Commit

Permalink
Merge pull request #4 from viazure/feature_通过配置文件修改同步频率间隔天数
Browse files Browse the repository at this point in the history
Feature 通过配置文件修改同步频率间隔天数 #3
  • Loading branch information
viazure authored Oct 5, 2024
2 parents 82d3fe8 + a14bf95 commit f5f2b14
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
4. 打开 Windows 的「服务」管理器。
5. 找到并启动「Eudic Sync To MaiMemo Service」。

当设置为 Windows 服务时,程序将自动每 7 天同步一次。
**程序支持通过配置文件中的 SyncInterval 参数自定义同步间隔。此参数的值表示同步的频率(以天为单位)。默认情况下,同步间隔为每 7 天一次。**

### 修改配置文件

Expand Down Expand Up @@ -140,8 +140,8 @@ https://api.anpush.com/push/[your_token]?title=单词同步&content={content}&ch

## Todo

- [X] MVP 版本:默认词库自动同步(控制台程序)
- [X] 可注册为 Windows 服务,并定期执行
- [X] 接入消息通知服务
- [x] MVP 版本:默认词库自动同步(控制台程序)
- [x] 可注册为 Windows 服务,并定期执行
- [x] 接入消息通知服务
- [ ] 接入 墨墨开放 API,替换现有的网页解析方案
- [ ] 接入 Telegram Bot,用于手动选择词库同步
2 changes: 1 addition & 1 deletion src/EudicSyncToMaiMemo.Installer/Package.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- Define the variables in "$(var.*) expressions" -->
<?define Name = "Eudic Sync To MaiMemo Service" ?>
<?define Manufacturer = "viazure" ?>
<?define Version = "1.1.0.0" ?>
<?define Version = "1.1.1.0" ?>
<?define Source = "W:\_publish\EudicSyncToMaiMemo" ?>
<?define UpgradeCode = "FD9B9913-E79C-47E2-9B47-84F19D8388B3" ?>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using EudicSyncToMaiMemo.Infrastructure.Exceptions;
using EudicSyncToMaiMemo.Services.Interfaces;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
Expand All @@ -12,6 +13,7 @@ namespace EudicSyncToMaiMemo.Services.BackgroundServices
public class SyncBackgroundService(
IServiceScopeFactory serviceScopeFactory,
INotificationService notificationService,
IConfiguration configuration,
ILogger<SyncBackgroundService> logger) : BackgroundService
{

Expand All @@ -25,8 +27,8 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
await DoWorkAsync(stoppingToken);

// 一周同步一次
await Task.Delay(TimeSpan.FromDays(7), stoppingToken);
int interval = configuration.GetValue<int>("SyncInterval");
await Task.Delay(TimeSpan.FromDays(interval), stoppingToken);
}
}
catch (OperationCanceledException)
Expand Down
2 changes: 1 addition & 1 deletion src/EudicSyncToMaiMemo/EudicSyncToMaiMemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
<UserSecretsId>dotnet-EudicSyncToMaiMemo-0a41e9fe-77a9-486e-b0d8-c7051eda840d</UserSecretsId>
<Version>1.1.0</Version>
<Version>1.1.1</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
3 changes: 2 additions & 1 deletion src/EudicSyncToMaiMemo/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@
"Url": "",
"RequestBody": "",
"Headers": ""
}
},
"SyncInterval": 7
}

0 comments on commit f5f2b14

Please sign in to comment.