1. 添加定时任务接口实现

2. 修改配置信息读取
FileMonitor
陈伟 2024-11-28 16:30:41 +08:00
parent db4bc781d1
commit 2095a8d1d6
1 changed files with 7 additions and 14 deletions

View File

@ -1,27 +1,19 @@
using System.Text; using System.Text;
using Infrastructure.Helpers; using Infrastructure.Helpers;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json; using Newtonsoft.Json;
using NUnit.Framework;
using OpenAuth.Repository.Domain; using OpenAuth.Repository.Domain;
using Quartz; using Quartz;
namespace OpenAuth.App.ServiceApp.Job; namespace OpenAuth.App.ServiceApp.Job;
class FileMonitor class FileMonitor: IJob
{ {
[Test] public async System.Threading.Tasks.Task Execute(IJobExecutionContext context)
public async System.Threading.Tasks.Task Execute()
{ {
var builder = new ConfigurationBuilder()
.SetBasePath("D:\\vs\\project_git\\Infrastructure\\OpenAuth.WebApi")
.AddJsonFile("appsettings.json"); var targetDirectory = ConfigHelper.GetConfigRoot().GetSection("Insight:Dir").Value;
// 构建配置 var tifExtensions = new[] { ".tif", ".tfw", ".ovr", ".aux"};
var configuration = builder.Build();
// 目标目录
var targetDirectory = configuration.GetSection("Insight:Dir").Value;
//var targetDirectory = ConfigHelper.GetConfigRoot().GetSection("Insight:Dir").Value;
var tifExtensions = new[] { ".tif", ".tfw", ".ovr", ".aux", ".xml" };
// 相关文件扩展名 // 相关文件扩展名
var shpExtensions = new[] { ".shp", ".shx", ".dbf", ".prj", ".cpg" }; var shpExtensions = new[] { ".shp", ".shx", ".dbf", ".prj", ".cpg" };
var targetExtensions = new[] { ".tif", ".shp" }; var targetExtensions = new[] { ".tif", ".shp" };
@ -215,4 +207,5 @@ class FileMonitor
return false; return false;
} }
} }