Вроде все ошибки устранил. не запускал.
This commit is contained in:
@@ -25,7 +25,7 @@ namespace PARR.AIHIT
|
|||||||
private readonly IApplicationTypeService appTypeService;
|
private readonly IApplicationTypeService appTypeService;
|
||||||
private readonly IApplicationInHostService appInHostService;
|
private readonly IApplicationInHostService appInHostService;
|
||||||
|
|
||||||
public List<ApplicationType> AppTypes { get; private set; }
|
public List<ApplicationType> AppTypes { get; private set; } = new List<ApplicationType>();
|
||||||
|
|
||||||
public Syncher(
|
public Syncher(
|
||||||
ILogger<Syncher> logger,
|
ILogger<Syncher> logger,
|
||||||
@@ -332,7 +332,7 @@ namespace PARR.AIHIT
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(appName)) return null;
|
if (string.IsNullOrEmpty(appName)) return null;
|
||||||
|
|
||||||
var existApp = await appService.GetByName(appName);
|
var existApp = await appService.GetByNameAsync(appName);
|
||||||
if (existApp != null)
|
if (existApp != null)
|
||||||
return existApp;
|
return existApp;
|
||||||
|
|
||||||
|
|||||||
30
PARR.DAL/Extensions/GeneralExtesions.cs
Normal file
30
PARR.DAL/Extensions/GeneralExtesions.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using System.Text.Encodings.Web;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Unicode;
|
||||||
|
|
||||||
|
namespace PARR.DAL.Extensions
|
||||||
|
{
|
||||||
|
public static class GeneralExtesions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Преобразует объект в Json, с учетом Cyrillic
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string? ToJson(this object value)
|
||||||
|
{
|
||||||
|
if (value == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return JsonSerializer.Serialize(value, new JsonSerializerOptions { Encoder = JavaScriptEncoder.Create(UnicodeRanges.All, UnicodeRanges.Cyrillic) }); ;
|
||||||
|
}
|
||||||
|
catch// (Exception ex)
|
||||||
|
{
|
||||||
|
// todo: писать лог??? или и так пойдет
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,6 @@
|
|||||||
using PARR.DAL.Models.Base;
|
using PARR.DAL.Models.Base;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace PARR.DAL.Models
|
namespace PARR.DAL.Models
|
||||||
{
|
{
|
||||||
@@ -26,4 +21,3 @@ namespace PARR.DAL.Models
|
|||||||
public ICollection<ApplicationInHost> ApplicationsInHosts { get; set; } = new HashSet<ApplicationInHost>();
|
public ICollection<ApplicationInHost> ApplicationsInHosts { get; set; } = new HashSet<ApplicationInHost>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
using PARR.DAL.Models.Base;
|
using PARR.DAL.Models.Base;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace PARR.DAL.Models
|
namespace PARR.DAL.Models
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace PARR.DAL.Models
|
|||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
public DateTimeOffset DateCreated { get; set; }
|
public DateTimeOffset DateCreated { get; set; }
|
||||||
public DateTimeOffset? DateModified { get; set; }
|
public DateTimeOffset? DateModified { get; set; }
|
||||||
public string HostName { get; set; }
|
public string? HostName { get; set; }
|
||||||
public required string IP { get; set; }
|
public required string IP { get; set; }
|
||||||
public string? RegionalEK { get; set; }
|
public string? RegionalEK { get; set; }
|
||||||
public string? LinkEK { get; set; }
|
public string? LinkEK { get; set; }
|
||||||
|
|||||||
@@ -16,8 +16,10 @@ namespace PARR.DAL
|
|||||||
);
|
);
|
||||||
|
|
||||||
services.AddTransient<IHostService, HostService>();
|
services.AddTransient<IHostService, HostService>();
|
||||||
//services.AddTransient<IUsersInLayersService, UsersInLayersService>();
|
services.AddTransient<IApplicationService, ApplicationService>();
|
||||||
//services.AddTransient<IAreaService, AreaService>();
|
services.AddTransient<IApplicationTypeService, ApplicationTypeService>();
|
||||||
|
services.AddTransient<IApplicationInHostService, ApplicationInHostService>();
|
||||||
|
|
||||||
//services.AddTransient<IAreasInLayerService, AreasInLayerService>();
|
//services.AddTransient<IAreasInLayerService, AreasInLayerService>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PARR.DAL.Context;
|
||||||
|
using PARR.DAL.Models;
|
||||||
|
using PARR.DAL.Services.Abstracts;
|
||||||
|
using PARR.DAL.Services.Interfaces;
|
||||||
|
|
||||||
|
namespace PARR.DAL.Services.Implementations
|
||||||
|
{
|
||||||
|
internal class ApplicationInHostService : BaseService<ApplicationInHost>, IApplicationInHostService
|
||||||
|
{
|
||||||
|
private readonly DataContext dataContext;
|
||||||
|
private readonly ILogger<ApplicationInHostService> logger;
|
||||||
|
|
||||||
|
public ApplicationInHostService(DataContext dataContext, ILogger<ApplicationInHostService> logger) : base(logger)
|
||||||
|
{
|
||||||
|
this.dataContext = dataContext;
|
||||||
|
this.logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override DbSet<ApplicationInHost> EntitySet => dataContext.ApplicationsInHosts;
|
||||||
|
|
||||||
|
protected override DataContext EntitiContext => dataContext;
|
||||||
|
}
|
||||||
|
}
|
||||||
30
PARR.DAL/Services/Implementations/ApplicationService.cs
Normal file
30
PARR.DAL/Services/Implementations/ApplicationService.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PARR.DAL.Context;
|
||||||
|
using PARR.DAL.Models;
|
||||||
|
using PARR.DAL.Services.Abstracts;
|
||||||
|
using PARR.DAL.Services.Interfaces;
|
||||||
|
|
||||||
|
namespace PARR.DAL.Services.Implementations
|
||||||
|
{
|
||||||
|
internal class ApplicationService : BaseService<Application>, IApplicationService
|
||||||
|
{
|
||||||
|
private readonly DataContext dataContext;
|
||||||
|
private readonly ILogger<ApplicationService> logger;
|
||||||
|
|
||||||
|
public ApplicationService(DataContext dataContext, ILogger<ApplicationService> logger) : base(logger)
|
||||||
|
{
|
||||||
|
this.dataContext = dataContext;
|
||||||
|
this.logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override DbSet<Application> EntitySet => dataContext.Applications;
|
||||||
|
|
||||||
|
protected override DataContext EntitiContext => dataContext;
|
||||||
|
|
||||||
|
public async Task<Application?> GetByNameAsync(string appName)
|
||||||
|
{
|
||||||
|
return await EntitySet.FirstOrDefaultAsync(t => t.Name.ToLower() == appName.Trim().ToLower());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
25
PARR.DAL/Services/Implementations/ApplicationTypeService.cs
Normal file
25
PARR.DAL/Services/Implementations/ApplicationTypeService.cs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PARR.DAL.Context;
|
||||||
|
using PARR.DAL.Models;
|
||||||
|
using PARR.DAL.Services.Abstracts;
|
||||||
|
using PARR.DAL.Services.Interfaces;
|
||||||
|
|
||||||
|
namespace PARR.DAL.Services.Implementations
|
||||||
|
{
|
||||||
|
internal class ApplicationTypeService : BaseService<ApplicationType>, IApplicationTypeService
|
||||||
|
{
|
||||||
|
private readonly DataContext dataContext;
|
||||||
|
private readonly ILogger<ApplicationTypeService> logger;
|
||||||
|
|
||||||
|
public ApplicationTypeService(DataContext dataContext, ILogger<ApplicationTypeService> logger) : base(logger)
|
||||||
|
{
|
||||||
|
this.dataContext = dataContext;
|
||||||
|
this.logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override DbSet<ApplicationType> EntitySet => dataContext.ApplicationTypes;
|
||||||
|
|
||||||
|
protected override DataContext EntitiContext => dataContext;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,21 +21,38 @@ namespace PARR.DAL.Services.Implementations
|
|||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Host?> GetHostWithAppsAsync(string IP, string RegionalEK)//TODO
|
public async Task<Host?> GetHostWithAppsAsync(string IP, string RegionalEK)
|
||||||
{
|
{
|
||||||
try
|
|
||||||
{
|
//try
|
||||||
var host = await EntitySet.FirstAsync(h => h.IP == IP && h.RegionalEK == RegionalEK);
|
//{
|
||||||
return host;
|
// var host = await EntitySet.FirstAsync(h => h.IP == IP && h.RegionalEK == RegionalEK);
|
||||||
}
|
// return host;
|
||||||
catch
|
//}
|
||||||
{
|
//catch
|
||||||
logger.LogInformation($"Не найден узел с IP адресом {IP} и региональным ЭК {RegionalEK}");
|
//{
|
||||||
return null;
|
// logger.LogInformation($"Не найден узел с IP адресом {IP} и региональным ЭК {RegionalEK}");
|
||||||
}
|
// return null;
|
||||||
|
//}
|
||||||
|
return await EntitySet
|
||||||
|
.Include(t => t.ApplicationsInHosts).ThenInclude(a => a.Application).ThenInclude(t => t.ApplicationType)
|
||||||
|
.FirstOrDefaultAsync(h => h.IP == IP && h.RegionalEK == RegionalEK);
|
||||||
}
|
}
|
||||||
|
|
||||||
//public async Task<Host?> GetHostByRegionalEKAsync(string RegionalEK)
|
public async Task<Host?> GetHostWithAppsAsync(string IP, string linkEK, string regionalEK)
|
||||||
|
{
|
||||||
|
return await EntitySet
|
||||||
|
.Include(t => t.ApplicationsInHosts).ThenInclude(a => a.Application).ThenInclude(t => t.ApplicationType)
|
||||||
|
.FirstOrDefaultAsync(h => h.IP == IP && h.LinkEK == linkEK && h.RegionalEK == regionalEK);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<Host?> GetHostByIPAndRegionalEKAsync(string IP, string RegionalEK)
|
||||||
|
{
|
||||||
|
return await EntitySet.FirstOrDefaultAsync(h => h.IP == IP && h.RegionalEK == RegionalEK);
|
||||||
|
}
|
||||||
|
|
||||||
|
//public async Task<Host?> GetHostByRegionalEKAsync(string RegionalEK)И
|
||||||
//{
|
//{
|
||||||
// try
|
// try
|
||||||
// {
|
// {
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using PARR.DAL.Models;
|
||||||
|
using PARR.DAL.Services.Interfaces.Base;
|
||||||
|
|
||||||
|
namespace PARR.DAL.Services.Interfaces
|
||||||
|
{
|
||||||
|
public interface IApplicationInHostService : IBaseService<ApplicationInHost>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
10
PARR.DAL/Services/Interfaces/IApplicationService.cs
Normal file
10
PARR.DAL/Services/Interfaces/IApplicationService.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using PARR.DAL.Models;
|
||||||
|
using PARR.DAL.Services.Interfaces.Base;
|
||||||
|
|
||||||
|
namespace PARR.DAL.Services.Interfaces
|
||||||
|
{
|
||||||
|
public interface IApplicationService : IBaseService<Application>
|
||||||
|
{
|
||||||
|
Task<Application?> GetByNameAsync(string appName);
|
||||||
|
}
|
||||||
|
}
|
||||||
9
PARR.DAL/Services/Interfaces/IApplicationTypeService.cs
Normal file
9
PARR.DAL/Services/Interfaces/IApplicationTypeService.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
using PARR.DAL.Models;
|
||||||
|
using PARR.DAL.Services.Interfaces.Base;
|
||||||
|
|
||||||
|
namespace PARR.DAL.Services.Interfaces
|
||||||
|
{
|
||||||
|
public interface IApplicationTypeService : IBaseService<ApplicationType>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ namespace PARR.DAL.Services.Interfaces
|
|||||||
public interface IHostService : IBaseService<Host>
|
public interface IHostService : IBaseService<Host>
|
||||||
{
|
{
|
||||||
Task<Host?> GetHostByIPAndRegionalEKAsync(string IP, string RegionalEK);
|
Task<Host?> GetHostByIPAndRegionalEKAsync(string IP, string RegionalEK);
|
||||||
|
Task<Host?> GetHostWithAppsAsync(string IP, string linkEK, string regionalEK);
|
||||||
//Task<Host?> GetHostByRegionalEKAsync(string LinkEK);
|
//Task<Host?> GetHostByRegionalEKAsync(string LinkEK);
|
||||||
//Task<bool> UpdateAsync(Host host);
|
//Task<bool> UpdateAsync(Host host);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user