Completamento migrazione repository MpSpecController: aggiunti MpMon, MpVoc, MpLand; migrati TranslateSrv, StatusData, LandDataService, TranslateSrv, MonDataFeeder, TabDataFeeder; 0 errori build
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Core.Conf;
|
||||
using MP.Data.Controllers;
|
||||
using MP.Data.DbModels;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
@@ -20,9 +19,10 @@ namespace MP.Data.Services
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public StatusData(IConfiguration configuration, IConnectionMultiplexer redConn)
|
||||
public StatusData(IConfiguration configuration, IConnectionMultiplexer redConn, Repository.MpMon.IMpMonRepository mpMonRepository)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_mpMonRepository = mpMonRepository;
|
||||
|
||||
// setup componenti REDIS
|
||||
this.redisConn = redConn;
|
||||
@@ -42,9 +42,8 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
dbController = new MpMonController(configuration);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine($"StatusData | MpMonController OK");
|
||||
sb.AppendLine($"StatusData | MpMonRepository OK");
|
||||
Log.Info(sb.ToString());
|
||||
}
|
||||
|
||||
@@ -70,8 +69,6 @@ namespace MP.Data.Services
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public static MpMonController dbController { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario dei tag configurati per IOB
|
||||
/// </summary>
|
||||
@@ -102,7 +99,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.ConfigGetAll();
|
||||
result = await _mpMonRepository.ConfigGetAllAsync();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, LongCache);
|
||||
@@ -186,7 +183,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await Task.FromResult(dbController.MacchineGetAll());
|
||||
result = await _mpMonRepository.MacchineGetAllAsync();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
@@ -198,7 +195,6 @@ namespace MP.Data.Services
|
||||
sw.Stop();
|
||||
Log.Debug($"MacchineGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
//return Task.FromResult(dbController.MacchineGetAll());
|
||||
}
|
||||
|
||||
public async Task<List<MacchineModel>> MacchineGetByGruppo(string CodGruppo)
|
||||
@@ -217,8 +213,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await Task.FromResult(dbController.MacchineGetFilt(CodGruppo));
|
||||
//result = dbController.MacchineGetFilt(CodGruppo);
|
||||
result = await _mpMonRepository.MacchineGetFiltAsync(CodGruppo);
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
@@ -339,7 +334,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await dbController.MseGetAllAsync(maxAge);
|
||||
result = await _mpMonRepository.MseGetAllAsync(maxAge);
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(Constants.redisMseKey, rawData, UltraFastCache);
|
||||
@@ -383,8 +378,6 @@ namespace MP.Data.Services
|
||||
MachineProdStatus.Clear();
|
||||
// REDIS dispose
|
||||
redisDb = null;
|
||||
// Clear database controller
|
||||
dbController.Dispose();
|
||||
}
|
||||
|
||||
// Free unmanaged resources here
|
||||
@@ -397,6 +390,7 @@ namespace MP.Data.Services
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration = null!;
|
||||
private readonly Repository.MpMon.IMpMonRepository _mpMonRepository;
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private bool _disposed = false;
|
||||
|
||||
@@ -512,7 +506,7 @@ namespace MP.Data.Services
|
||||
if (fileConfData.IobSetup.ContainsKey("***"))
|
||||
{
|
||||
// recupero elenco macchine...
|
||||
var elencoMacc = dbController.MacchineGetAll();
|
||||
var elencoMacc = _mpMonRepository.MacchineGetAllAsync().GetAwaiter().GetResult();
|
||||
// x ogni macchina creo le righe standard da conf...
|
||||
var baseConf = fileConfData.IobSetup.Where(x => x.Key == "***").FirstOrDefault();
|
||||
foreach (var item in elencoMacc)
|
||||
|
||||
Reference in New Issue
Block a user