Структура

This commit is contained in:
Mikhail Kuznetsov
2023-08-31 12:04:05 +10:00
parent db47a670c3
commit ffb95ccf41
19 changed files with 159 additions and 26 deletions

View File

@@ -0,0 +1,12 @@
{
"profiles": {
"PARR.AIHIT": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:1090;http://localhost:1092"
}
}
}

View File

@@ -9,7 +9,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PARR.DAL", "PARR.DAL\PARR.D
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PARR.Mail", "PARR.Mail\PARR.Mail\PARR.Mail.csproj", "{228C8124-69E4-4AE0-8C33-0438E54FF1BA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PARR.Worker", "PARR.Worker\PARR.Worker\PARR.Worker.csproj", "{D15F308C-9F63-4D69-B06E-DDA26FEE9BAB}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PARR.AIHITWorker", "PARR.Worker\PARR.Worker\PARR.AIHITWorker.csproj", "{D15F308C-9F63-4D69-B06E-DDA26FEE9BAB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PARR.AIHIT", "PARR.AIHIT\AIHIT\PARR.AIHIT.csproj", "{3ED4E1CE-2AF5-4EB3-B7DF-B77CCC242B9E}"
EndProject
@@ -24,9 +24,11 @@ Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-co
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PARR.BLL", "PARR.BLL\PARR.BLL.csproj", "{7BAB9170-743D-4542-8881-9B161EE81BB6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PARR.EsppTemplateSyncWorker", "PARR.EsppTemplateSyncWorker\PARR.EsppTemplateSyncWorker.csproj", "{7FBD65FE-26FE-4E60-AD1F-20AAC6F88C7A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PARR.EsppTemplateSyncWorker", "PARR.EsppTemplateSyncWorker\PARR.EsppTemplateSyncWorker.csproj", "{7FBD65FE-26FE-4E60-AD1F-20AAC6F88C7A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PARR.EsppTemplateSync", "PARR.EsppTemplateSync\PARR.EsppTemplateSync.csproj", "{39FD9AAD-0792-46B2-A935-42486A993C32}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PARR.EsppTemplateSync", "PARR.EsppTemplateSync\PARR.EsppTemplateSync.csproj", "{39FD9AAD-0792-46B2-A935-42486A993C32}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PARR.MockData", "PARR.MockData\PARR.MockData.csproj", "{B02E5B16-59BD-4F02-9CC4-6873409DBD84}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -68,6 +70,10 @@ Global
{39FD9AAD-0792-46B2-A935-42486A993C32}.Debug|Any CPU.Build.0 = Debug|Any CPU
{39FD9AAD-0792-46B2-A935-42486A993C32}.Release|Any CPU.ActiveCfg = Release|Any CPU
{39FD9AAD-0792-46B2-A935-42486A993C32}.Release|Any CPU.Build.0 = Release|Any CPU
{B02E5B16-59BD-4F02-9CC4-6873409DBD84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B02E5B16-59BD-4F02-9CC4-6873409DBD84}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B02E5B16-59BD-4F02-9CC4-6873409DBD84}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B02E5B16-59BD-4F02-9CC4-6873409DBD84}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -0,0 +1,12 @@
{
"profiles": {
"PARR.DAL": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:1086;http://localhost:1095"
}
}
}

View File

@@ -18,8 +18,10 @@ namespace PARR.EsppTemplateSync
configuration.GetSection(nameof(GlobalSettings)).Bind(globalSettings);
services.AddSingleton(globalSettings);
services.AddTransient<ITemplateSyncer, TemplateSyncer>();
//services.AddTransient<ITemplateSyncer, TemplateFileSyncer>();
services.AddTransient<ITemplateSyncer, TemplateMQSyncer>();
services.AddTransient<IParserService, ParserService>();
services.AddTransient<IManager, Manager>();
}
}
}

View File

@@ -2,7 +2,7 @@
{
public interface ITemplateSyncer
{
Task StartWatchingAsync();
void StopWatching();
Task StartAsync();
void Stop();
}
}

View File

@@ -0,0 +1,8 @@
namespace PARR.EsppTemplateSync.Services
{
internal interface IManager
{
Task<bool> ManageFileAsync(string path);
Task<bool> ManageStringAsync(string str);
}
}

View File

@@ -2,6 +2,7 @@
{
internal interface IParserService
{
Task<bool> ParseAsync(string path);
Task<bool> ParseStringAsync(string str);
}
}

View File

@@ -0,0 +1,15 @@
namespace PARR.EsppTemplateSync.Services
{
internal class Manager : IManager
{
public Task<bool> ManageFileAsync(string path)
{
throw new NotImplementedException();
}
public Task<bool> ManageStringAsync(string str)
{
throw new NotImplementedException();
}
}
}

View File

@@ -2,7 +2,17 @@
{
internal class ParserService : IParserService
{
public async Task<bool> ParseAsync(string path)
public async Task<bool> ParseFileAsync(string path)
{
//TODO:
bool isSuccess = true;
return isSuccess;
}
public async Task<bool> ParseStringAsync(string str)
{
//TODO:

View File

@@ -1,6 +1,18 @@
namespace PARR.EsppTemplateSync.Settings
{
internal class GlobalSettings
{
public MqSettings? MqSettings { get; set; }
public StorageSettings? StorageSettings { get; set; }
}
internal class MqSettings
{
}
internal class StorageSettings
{
public int CheckIntervalSeconds { get; set; } = 5;
}

View File

@@ -6,29 +6,29 @@ using PARR.EsppTemplateSync.Settings;
namespace PARR.EsppTemplateSync
{
internal class TemplateSyncer : ITemplateSyncer
internal class TemplateFileSyncer : ITemplateSyncer
{
private readonly ILogger<TemplateSyncer> logger;
private readonly IParserService parserService;
private readonly ILogger<TemplateFileSyncer> logger;
private readonly IFileService fileService;
private readonly GlobalSettings globalSettings;
private readonly IManager manager;
private readonly string dirPath;
private readonly string filterExtensions;
//private FileSystemWatcher? watcher;
public TemplateSyncer(
StorageSettings storageSettings,
ILogger<TemplateSyncer> logger,
IParserService parserService,
public TemplateFileSyncer(
BLL.Settings.StorageSettings storageSettings,
ILogger<TemplateFileSyncer> logger,
IFileService fileService,
GlobalSettings globalSettings
GlobalSettings globalSettings,
IManager manager
)
{
this.logger = logger;
this.parserService = parserService;
this.fileService = fileService;
this.globalSettings = globalSettings;
this.manager = manager;
if (storageSettings.EsppTemplates == null)
{
logger.LogError("Нет секции настроек хранилища. StorageSettings, EsppTemplates");
@@ -41,7 +41,7 @@ namespace PARR.EsppTemplateSync
filterExtensions = string.Join(",", storageSettings.EsppTemplates!.AllowedExtensions).Replace(".", "*.");
}
public async Task StartWatchingAsync()
public async Task StartAsync()
{
//смотрим, доступна ли папка
if (!Directory.Exists(dirPath))
@@ -50,12 +50,12 @@ namespace PARR.EsppTemplateSync
throw new Exception($"Не найдена папка: {dirPath}.");
}
logger.LogInformation($"Запущена проверка директории. Интервал: {globalSettings.CheckIntervalSeconds} секунд. Фильтр: {filterExtensions}");
logger.LogInformation($"Запущена проверка директории. Интервал: {globalSettings.StorageSettings!.CheckIntervalSeconds} секунд. Фильтр: {filterExtensions}");
while (true)
{
await GetFilesAsync();
await Task.Delay(globalSettings.CheckIntervalSeconds * 1000);
await Task.Delay(globalSettings.StorageSettings!.CheckIntervalSeconds * 1000);
}
@@ -81,7 +81,7 @@ namespace PARR.EsppTemplateSync
}
public void StopWatching()
public void Stop()
{
//watcher?.Dispose();
logger.LogInformation($"=== === === FileWatcher остановлен === === ===");
@@ -120,7 +120,7 @@ namespace PARR.EsppTemplateSync
private async Task ParseFileAsync(string path)
{
logger.LogInformation($"--- --- Найден файл. Готов для парсинга {path} --- ---");
var parseResult = await parserService.ParseAsync(path);
var parseResult = await manager.ManageFileAsync(path);//parserService.ParseFileAsync(path);
if (parseResult)
{

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PARR.EsppTemplateSync
{
internal class TemplateMQSyncer : ITemplateSyncer
{
public async Task StartAsync()
{
// throw new NotImplementedException();
}
public void Stop()
{
//throw new NotImplementedException();
}
}
}

View File

@@ -15,7 +15,7 @@ namespace PARR.EsppTemplateSyncWorker
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
await templateSyncer.StartWatchingAsync();
await templateSyncer.StartAsync();
//while (!stoppingToken.IsCancellationRequested)
//{
@@ -26,7 +26,7 @@ namespace PARR.EsppTemplateSyncWorker
public override Task StopAsync(CancellationToken cancellationToken)
{
templateSyncer.StopWatching();
templateSyncer.Stop();
return base.StopAsync(cancellationToken);
}

View File

@@ -9,6 +9,11 @@
"StoragePath": "W:\\"
},
"GlobalSettings": {
"CheckIntervalSeconds": 5
"MqSettings": {
},
"StorageSettings": {
"CheckIntervalSeconds": 5
}
}
}

View File

@@ -32,6 +32,11 @@
}
},
"GlobalSettings": {
"CheckIntervalSeconds": 30
"MqSettings": {
},
"StorageSettings": {
"CheckIntervalSeconds": 30
}
}
}

View File

@@ -0,0 +1,12 @@
{
"profiles": {
"PARR.Mail": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:1096;http://localhost:1103"
}
}
}

View File

@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

2
PARR.MockData/Program.cs Normal file
View File

@@ -0,0 +1,2 @@
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");