Синхронизация данных АИХ ИТ с ПАРР

This commit is contained in:
Mikhail Kuznetsov
2023-08-14 15:24:57 +10:00
parent e16eecaeba
commit 260a20e9bf
26 changed files with 475 additions and 329 deletions

View File

@@ -1,13 +1,13 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models.V1;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class ApplicationInHostService : BaseService<V1_ApplicationInHost>, IApplicationInHostService
internal class ApplicationInHostService : BaseService<ApplicationInHost>, IApplicationInHostService
{
private readonly DataContext dataContext;
private readonly ILogger<ApplicationInHostService> logger;
@@ -18,7 +18,7 @@ namespace PARR.DAL.Services.Implementations
this.logger = logger;
}
protected override DbSet<V1_ApplicationInHost> EntitySet => dataContext.ApplicationsInHosts;
protected override DbSet<ApplicationInHost> EntitySet => dataContext.ApplicationsInHosts;
protected override DataContext EntitiContext => dataContext;
}

View File

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

View File

@@ -1,13 +1,13 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models.V1;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
namespace PARR.DAL.Services.Implementation
{
internal class ApplicationTypeService : BaseService<V1_ApplicationType>, IApplicationTypeService
internal class ApplicationTypeService : BaseService<ApplicationType>, IApplicationTypeService
{
private readonly DataContext dataContext;
private readonly ILogger<ApplicationTypeService> logger;
@@ -18,7 +18,7 @@ namespace PARR.DAL.Services.Implementations
this.logger = logger;
}
protected override DbSet<V1_ApplicationType> EntitySet => dataContext.ApplicationTypes;
protected override DbSet<ApplicationType> EntitySet => dataContext.ApplicationTypes;
protected override DataContext EntitiContext => dataContext;
}

View File

@@ -1,18 +1,18 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models.V1;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class HostService : BaseService<V1_Host>, IHostService
internal class HostService : BaseService<Host>, IHostService
{
private readonly DataContext dataContext;
private readonly ILogger<HostService> logger;
protected override DbSet<V1_Host> EntitySet => dataContext.Hosts;
protected override DbSet<Host> EntitySet => dataContext.Hosts;
protected override DataContext EntitiContext => dataContext;
public HostService(DataContext dataContext, ILogger<HostService> logger) : base(logger)
@@ -21,7 +21,7 @@ namespace PARR.DAL.Services.Implementations
this.logger = logger;
}
public async Task<V1_Host?> GetHostWithAppsAsync(string IP, string RegionalEK)
public async Task<Host?> GetHostWithAppsAsync(string IP)
{
//try
@@ -37,21 +37,7 @@ namespace PARR.DAL.Services.Implementations
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);
.FirstOrDefaultAsync(h => h.IP == IP);
}
//public async Task<Host?> GetHostByRegionalEKAsync(string RegionalEK)И

View File

@@ -1,24 +0,0 @@
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;
namespace PARR.DAL.Services.Implementations
{
internal class JobCategoryService : BaseService<V1_JobCategory>, IJobCategoryService
{
private readonly DataContext dataContext;
private readonly ILogger<JobCategoryService> logger;
public JobCategoryService(DataContext dataContext, ILogger<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

@@ -1,41 +0,0 @@
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;
namespace PARR.DAL.Services.Implementations
{
internal class JobJournalService : BaseService<V1_JobJournal>, IJobJournalService
{
private readonly DataContext dataContext;
private readonly ILogger<JobJournalService> logger;
public JobJournalService(DataContext dataContext, ILogger<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

@@ -1,24 +0,0 @@
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;
namespace PARR.DAL.Services.Implementations
{
internal class JobModeService : BaseService<V1_JobMode>, IJobModeService
{
private readonly DataContext dataContext;
private readonly ILogger<JobModeService> logger;
public JobModeService(DataContext dataContext, ILogger<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

@@ -1,30 +0,0 @@
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;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PARR.DAL.Services.Implementations
{
internal class JobService : BaseService<V1_Job>, IJobService
{
private readonly DataContext dataContext;
private readonly ILogger<JobService> logger;
public JobService(DataContext dataContext,ILogger<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

@@ -1,24 +0,0 @@
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;
namespace PARR.DAL.Services.Implementations
{
internal class JobStatusService : BaseService<V1_JobStatus>, IJobStatusService
{
private readonly DataContext dataContext;
private readonly ILogger<JobStatusService> logger;
public JobStatusService(DataContext dataContext, ILogger<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

@@ -1,22 +0,0 @@
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 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;
//}
}