Skip to content

Commit

Permalink
加强 TimeSpan 配置项检查
Browse files Browse the repository at this point in the history
  • Loading branch information
bianyukun1213 committed Aug 31, 2024
1 parent 3e5c7b5 commit 507f4b1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@

  对于**黑龙江科技大学**,签到坐标和地址在校外时,应填写 `Photo``Reason` 字段——尽管服务端可能并不验证照片和原因,但在 App 内这两项为必填信息。

  `TimeSpan` 字段配置签到时间段,按顺序分别填开始小时、开始分钟、结束小时、结束分钟。程序运行时读取系统时间,若其不在此字段设定的时间段内,则跳过此用户的签到任务创建。另外,签到时也会动态获取当前时间,与校本化接口返回的签到时间段比对,若不在允许的时间段内,同样也会跳过签到。
  `TimeSpan` 字段配置签到时间段,以系统时间为准,按顺序分别填开始小时、开始分钟、结束小时、结束分钟,且开始时间必须早于结束时间。程序运行时读取系统时间,若其不在此字段设定的时间段内,则跳过此用户的签到任务创建。另外,签到时也会动态获取后端服务的时间检查结果,若不在允许的时间段内,同样也会跳过签到。

## 使用的库

Expand Down
12 changes: 11 additions & 1 deletion YBNAS/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,17 @@ string getSignInConfigSkippedStr(string reason)
continue;
}
}
if (conf.TimeSpan?.Count != 4)
if (conf.TimeSpan?.Count != 4 ||
conf.TimeSpan[0] < 0 ||
conf.TimeSpan[0] > 23 ||
conf.TimeSpan[1] < 0 ||
conf.TimeSpan[1] > 59 ||
conf.TimeSpan[2] < 0 ||
conf.TimeSpan[2] > 23 ||
conf.TimeSpan[3] < 0 ||
conf.TimeSpan[3] > 59 ||
(conf.TimeSpan[0] > conf.TimeSpan[2]) ||
(conf.TimeSpan[0] == conf.TimeSpan[2] && conf.TimeSpan[1] > conf.TimeSpan[3]))
{
logger.Warn(getSignInConfigSkippedStr("签到时间段格式错误"));
continue;
Expand Down
2 changes: 1 addition & 1 deletion YBNAS/YBNAS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>1.15.2</Version>
<Version>1.15.3</Version>
<PackageProjectUrl>https://github.com/bianyukun1213/YBNAS</PackageProjectUrl>
<PublishAot>False</PublishAot>
<Authors>Hollis</Authors>
Expand Down

0 comments on commit 507f4b1

Please sign in to comment.