разделитель Парсера строк из ЕСПП вынесен в настройки
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.EsppTemplateSync.Settings;
|
||||
using System.Globalization;
|
||||
|
||||
namespace PARR.EsppTemplateSync.Services
|
||||
@@ -9,10 +10,15 @@ namespace PARR.EsppTemplateSync.Services
|
||||
internal class ParserService : IParserService
|
||||
{
|
||||
private readonly ILogger<ParserService> logger;
|
||||
private readonly GlobalSettings globalSettings;
|
||||
|
||||
public ParserService(ILogger<ParserService> logger)
|
||||
public ParserService(
|
||||
ILogger<ParserService> logger,
|
||||
GlobalSettings globalSettings
|
||||
)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.globalSettings = globalSettings;
|
||||
}
|
||||
public async Task<bool> ParseFileAsync(string path)
|
||||
{
|
||||
@@ -29,7 +35,7 @@ namespace PARR.EsppTemplateSync.Services
|
||||
//TODO: а если формат нет тот? Все будет ок?
|
||||
|
||||
//TODO:
|
||||
var splittedContent = str.Split("<|>");
|
||||
var splittedContent = str.Split(globalSettings.ParsingSeparator);
|
||||
if (splittedContent.Length != 17)
|
||||
{
|
||||
return null;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
public StorageSettings? StorageSettings { get; set; }
|
||||
public List<string>? IgnoreTemplateFields { get; set; }
|
||||
public string ParsingSeparator { get; set; } = "<|>";
|
||||
}
|
||||
|
||||
internal class MqSettings
|
||||
|
||||
@@ -1,19 +1,50 @@
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Server=10.99.253.184;Database=parr;User Id=app_parr; Password=PosdfkhT&)%sdfligL&%5546;"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"Serilog": {
|
||||
"MinimumLevel": {
|
||||
"Default": "Debug",
|
||||
"Override": {
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Debug"
|
||||
}
|
||||
},
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "log/log-.txt",
|
||||
"rollingInterval": "Day"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"StorageSettings": {
|
||||
"StoragePath": "W:\\"
|
||||
"StoragePath": "Data",
|
||||
"EsppTemplates": {
|
||||
"AllowedExtensions": [ ".csv" ],
|
||||
"MaxFileSizeMb": 100
|
||||
}
|
||||
},
|
||||
"GlobalSettings": {
|
||||
"MqSettings": {
|
||||
"HostName": "10.99.253.216",
|
||||
"QueueName": "parr-espp-templates",
|
||||
"UserName": "espp_templates_reader",
|
||||
"Password": "P@ssReaderPtk202!"
|
||||
|
||||
},
|
||||
"StorageSettings": {
|
||||
"CheckIntervalSeconds": 5
|
||||
}
|
||||
"CheckIntervalSeconds": 30
|
||||
},
|
||||
"IgnoreTemplateFields": [ "Id", "Status", "DateCreated", "DateModified", "StatusCode" ],
|
||||
"ParsingSeparator": "<|>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
"StorageSettings": {
|
||||
"CheckIntervalSeconds": 30
|
||||
},
|
||||
"IgnoreTemplateFields": [ "Id","Status","DateCreated","DateModified","StatusCode" ]
|
||||
"IgnoreTemplateFields": [ "Id", "Status", "DateCreated", "DateModified", "StatusCode" ],
|
||||
"ParsingSeparator": "<|>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,15 +71,15 @@ namespace PARR.MockData.Services
|
||||
logger.LogInformation($"----- Создан subprocess: {subprocess.Name} -----");
|
||||
}
|
||||
|
||||
var tnk = await tnkService.Get().FirstOrDefaultAsync(p => p.EsppId == 292454);
|
||||
var tnk = await tnkService.Get().FirstOrDefaultAsync(p => p.EsppId == 292917);
|
||||
if (tnk == null)
|
||||
{
|
||||
tnk = new Tnk
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
DateCreated = DateTimeOffset.UtcNow,
|
||||
Name = "ППО Анализ прикладных журналов серверов приложений (О3.2.2.4)",
|
||||
EsppId = 292454,
|
||||
Name = "Прочее(работы)",
|
||||
EsppId = 292917,
|
||||
SubprocessId = subprocess.Id
|
||||
};
|
||||
if (!await tnkService.CreateAsync(tnk) || !await tnkService.CommitAsync())
|
||||
@@ -91,15 +91,15 @@ namespace PARR.MockData.Services
|
||||
logger.LogInformation($"----- Создан tnk: {tnk.Name} -----");
|
||||
}
|
||||
|
||||
var work = await workService.Get().FirstOrDefaultAsync(p => p.EsppId == 292454);
|
||||
var work = await workService.Get().FirstOrDefaultAsync(p => p.EsppId == 292917);
|
||||
if (work == null)
|
||||
{
|
||||
work = new Work
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
DateCreated = DateTimeOffset.UtcNow,
|
||||
Name = "ППО Анализ прикладных журналов серверов приложений (О3.2.2.4)",
|
||||
EsppId = 292454,
|
||||
Name = "Прочее(работы)",
|
||||
EsppId = 292917,
|
||||
TnkId = tnk.Id
|
||||
};
|
||||
if (!await workService.CreateAsync(work) || !await workService.CommitAsync())
|
||||
|
||||
Reference in New Issue
Block a user