fix Синхронизации

This commit is contained in:
Mikhail Kuznetsov
2023-08-23 15:47:20 +10:00
parent 260a20e9bf
commit 906982d08d
59 changed files with 8462 additions and 2 deletions

View File

@@ -0,0 +1,39 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models.AIHIT;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Services.Interfaces.AIHIT;
namespace PARR.DAL.Services.Implementations.AIHIT
{
internal class RawDataEKService : BaseService<RawDataEK>, IRawDataEKService
{
private readonly DataContext dataContext;
private readonly ILogger<RawDataEKService> logger;
public RawDataEKService(DataContext dataContext, ILogger<RawDataEKService> logger) : base(logger)
{
this.dataContext = dataContext;
this.logger = logger;
}
public void DeleteAll()
{
var startCount = EntitySet.Count();
if (startCount > 0)
{
EntitiContext.RawDataEKs.RemoveRange(EntitySet);
logger.LogInformation($"Из таблицы RawDataEK удалено {startCount} записей");
EntitiContext.SaveChanges();
}
}
protected override DbSet<RawDataEK> EntitySet => dataContext.RawDataEKs;
protected override DataContext EntitiContext => dataContext;
}
}

View File

@@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models.AIHIT;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Services.Interfaces.AIHIT;
namespace PARR.DAL.Services.Implementations.AIHIT
{
internal class SettingService : BaseService<Setting>, ISettingService
{
private readonly DataContext dataContext;
private readonly ILogger<SettingService> logger;
public SettingService(DataContext dataContext, ILogger<SettingService> logger) : base(logger)
{
this.dataContext = dataContext;
this.logger = logger;
}
protected override DbSet<Setting> EntitySet => dataContext.Settings;
protected override DataContext EntitiContext => dataContext;
}
}

View File

@@ -0,0 +1,25 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models.V1;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Services.Interfaces.V1;
namespace PARR.DAL.Services.Implementations.V1
{
internal class V1_ApplicationInHostService : BaseService<V1_ApplicationInHost>, V1_IApplicationInHostService
{
private readonly DataContext dataContext;
private readonly ILogger<V1_ApplicationInHostService> logger;
public V1_ApplicationInHostService(DataContext dataContext, ILogger<V1_ApplicationInHostService> logger) : base(logger)
{
this.dataContext = dataContext;
this.logger = logger;
}
protected override DbSet<V1_ApplicationInHost> EntitySet => dataContext.V1_ApplicationsInHosts;
protected override DataContext EntitiContext => dataContext;
}
}

View File

@@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models.V1;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Services.Interfaces.V1;
namespace PARR.DAL.Services.Implementations.V1
{
internal class V1_ApplicationService : BaseService<V1_Application>, V1_IApplicationService
{
private readonly DataContext dataContext;
private readonly ILogger<V1_ApplicationService> logger;
public V1_ApplicationService(DataContext dataContext, ILogger<V1_ApplicationService> logger) : base(logger)
{
this.dataContext = dataContext;
this.logger = logger;
}
protected override DbSet<V1_Application> EntitySet => dataContext.V1_Applications;
protected override DataContext EntitiContext => dataContext;
public async Task<V1_Application?> GetByNameAsync(string appName)
{
return await EntitySet.FirstOrDefaultAsync(t => t.Name.ToLower() == appName.Trim().ToLower());
}
}
}

View File

@@ -0,0 +1,25 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models.V1;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Services.Interfaces.V1;
namespace PARR.DAL.Services.Implementations.V1
{
internal class V1_ApplicationTypeService : BaseService<V1_ApplicationType>, V1_IApplicationTypeService
{
private readonly DataContext dataContext;
private readonly ILogger<V1_ApplicationTypeService> logger;
public V1_ApplicationTypeService(DataContext dataContext, ILogger<V1_ApplicationTypeService> logger) : base(logger)
{
this.dataContext = dataContext;
this.logger = logger;
}
protected override DbSet<V1_ApplicationType> EntitySet => dataContext.V1_ApplicationTypes;
protected override DataContext EntitiContext => dataContext;
}
}

View File

@@ -0,0 +1,143 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.DomainModels;
using PARR.DAL.Models.V1;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Services.Interfaces.V1;
namespace PARR.DAL.Services.Implementations.V1
{
internal class V1_HostService : BaseService<V1_Host>, V1_IHostService
{
private readonly DataContext dataContext;
private readonly ILogger<V1_HostService> logger;
protected override DbSet<V1_Host> EntitySet => dataContext.V1_Hosts;
protected override DataContext EntitiContext => dataContext;
public V1_HostService(DataContext dataContext, ILogger<V1_HostService> logger) : base(logger)
{
this.dataContext = dataContext;
this.logger = logger;
}
public async Task<V1_Host?> GetHostWithAppsAsync(string IP, string RegionalEK)
{
//try
//{
// var host = await EntitySet.FirstAsync(h => h.IP == IP && h.RegionalEK == RegionalEK);
// return host;
//}
//catch
//{
// logger.LogInformation($"Не найден узел с IP адресом {IP} и региональным ЭК {RegionalEK}");
// return null;
//}
return await EntitySet
.Include(t => t.ApplicationsInHosts).ThenInclude(a => a.Application).ThenInclude(t => t.ApplicationType)
.AsSplitQuery()
.FirstOrDefaultAsync(h => h.IP == IP && h.RegionalEK == RegionalEK);
}
public async Task<V1_Host?> GetHostWithAppsAsync(string IP, string linkEK, string regionalEK)
{
return await EntitySet
.Include(t => t.ApplicationsInHosts).ThenInclude(a => a.Application).ThenInclude(t => t.ApplicationType)
.AsSplitQuery()
.FirstOrDefaultAsync(h => h.IP == IP && h.LinkEK == linkEK && h.RegionalEK == regionalEK);
}
public async Task<V1_Host?> GetHostByIPAndRegionalEKAsync(string IP, string RegionalEK)
{
return await EntitySet.FirstOrDefaultAsync(h => h.IP == IP && h.RegionalEK == RegionalEK);
}
public Task<V1_Host?> GetAsync(Guid id)
{
throw new NotImplementedException();
}
public IQueryable<V1_Host> Get()
{
throw new NotImplementedException();
}
public IQueryable<V1_Host> GetPage(IQueryable<V1_Host> query, PaginationFilter paginationFilter)
{
throw new NotImplementedException();
}
public Task<bool> CreateAsync(V1_Host obj)
{
throw new NotImplementedException();
}
public Task<bool> AddRangeAsync(List<V1_Host> objs)
{
throw new NotImplementedException();
}
public Task<bool> DeleteAsync(Guid id)
{
throw new NotImplementedException();
}
public bool Delete(V1_Host obj)
{
throw new NotImplementedException();
}
public Task<bool> CommitAsync()
{
throw new NotImplementedException();
}
//public async Task<Host?> GetHostByRegionalEKAsync(string RegionalEK)И
//{
// try
// {
// var host = await EntitySet.FirstAsync(h => h.RegionalEK == RegionalEK);
// return host;
// }
// catch
// {
// logger.LogInformation($"Не найден узел с региональным ЭК {RegionalEK}");
// return null;
// }
//}
//public async Task<bool> UpdateAsync(Host host)
//{
// var orig = await EntitySet.FirstAsync(h => h.IP == host.IP);
// if (orig == null)
// return false;
// orig.DateModified = DateTimeOffset.UtcNow;
// orig.HostName = host.HostName;
// orig.RegionalEK = host.RegionalEK;
// orig.LinkEK = host.LinkEK;
// orig.Status = host.Status;
// orig.WorkGroup = host.WorkGroup;
// orig.Responsible = host.Responsible;
// orig.OS = host.OS;
// orig.DB = host.DB;
// orig.APP = host.APP;
// if (!await CommitAsync())
// {
// logger.LogError($"Ошибка обновления узла {host.IP}");
// return false;
// }
// else
// {
// logger.LogInformation($"Обновлен узел {host.IP}");
// return true;
// }
//}
}
}

View File

@@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models.V1;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Services.Interfaces.V1;
namespace PARR.DAL.Services.Implementations.V1
{
internal class V1_JobCategoryService : BaseService<V1_JobCategory>, V1_IJobCategoryService
{
private readonly DataContext dataContext;
private readonly ILogger<V1_JobCategoryService> logger;
public V1_JobCategoryService(DataContext dataContext, ILogger<V1_JobCategoryService> logger) : base(logger)
{
this.dataContext = dataContext;
this.logger = logger;
}
protected override DbSet<V1_JobCategory> EntitySet => dataContext.JobCategories;
protected override DataContext EntitiContext => dataContext;
}
}

View File

@@ -0,0 +1,41 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Extensions;
using PARR.DAL.Models.V1;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Services.Interfaces.V1;
namespace PARR.DAL.Services.Implementations.V1
{
internal class V1_JobJournalService : BaseService<V1_JobJournal>, V1_IJobJournalService
{
private readonly DataContext dataContext;
private readonly ILogger<V1_JobJournalService> logger;
public V1_JobJournalService(DataContext dataContext, ILogger<V1_JobJournalService> logger) : base(logger)
{
this.dataContext = dataContext;
this.logger = logger;
}
protected override DbSet<V1_JobJournal> EntitySet => dataContext.JobJournals;
protected override DataContext EntitiContext => dataContext;
public async Task<V1_JobJournal?> GetLastAsync(Guid jobId, Guid hostId, DateTimeOffset date)
{
//var n=DateTimeOffset.UtcNow;
//var opers = await EntitySet
// .Where(j => j.JobId == jobId && j.HostId == hostId && (j.DateOper!=DateTimeOffset.MinValue))/*date.StartOfDay()*/// && j.DateOper < date.EndOfDay()))
// .OrderBy(t => t.DateOper)
// .LastOrDefaultAsync();
var opers = await EntitySet
.Where(j => j.JobId == jobId && j.HostId == hostId && j.DateOper.DateTime.Date == date.DateTime.Date)
.OrderBy(t => t.DateOper)
.LastOrDefaultAsync();
return opers;
}
}
}

View File

@@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models.V1;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Services.Interfaces.V1;
namespace PARR.DAL.Services.Implementations.V1
{
internal class V1_JobModeService : BaseService<V1_JobMode>, V1_IJobModeService
{
private readonly DataContext dataContext;
private readonly ILogger<V1_JobModeService> logger;
public V1_JobModeService(DataContext dataContext, ILogger<V1_JobModeService> logger) : base(logger)
{
this.dataContext = dataContext;
this.logger = logger;
}
protected override DbSet<V1_JobMode> EntitySet => dataContext.JobModes;
protected override DataContext EntitiContext => dataContext;
}
}

View File

@@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models.V1;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Services.Interfaces.V1;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PARR.DAL.Services.Implementations.V1
{
internal class V1_JobService : BaseService<V1_Job>, V1_IJobService
{
private readonly DataContext dataContext;
private readonly ILogger<V1_JobService> logger;
public V1_JobService(DataContext dataContext, ILogger<V1_JobService> logger) : base(logger)
{
this.dataContext = dataContext;
this.logger = logger;
}
protected override DbSet<V1_Job> EntitySet => dataContext.Jobs;
protected override DataContext EntitiContext => dataContext;
}
}

View File

@@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models.V1;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Services.Interfaces.V1;
namespace PARR.DAL.Services.Implementations.V1
{
internal class V1_JobStatusService : BaseService<V1_JobStatus>, V1_IJobStatusService
{
private readonly DataContext dataContext;
private readonly ILogger<V1_JobStatusService> logger;
public V1_JobStatusService(DataContext dataContext, ILogger<V1_JobStatusService> logger) : base(logger)
{
this.dataContext = dataContext;
this.logger = logger;
}
protected override DbSet<V1_JobStatus> EntitySet => dataContext.JobStatuses;
protected override DataContext EntitiContext => dataContext;
}
}

View File

@@ -0,0 +1,22 @@
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.V1
{
//internal class SchedulerService : BaseService<Scheduler>, ISchedulerService
//{
// private readonly DataContext dataContext;
// public SchedulerService(DataContext dataContext, ILogger<SchedulerService> logger) : base(logger)
// {
// this.dataContext = dataContext;
// }
// protected override DbSet<Scheduler> EntitySet => dataContext.Schedulers;
// protected override DataContext EntitiContext => dataContext;
//}
}