Modifica model macchine
This commit is contained in:
@@ -234,19 +234,19 @@ namespace MP.Data.Services
|
||||
/// </summary>
|
||||
/// <param name="MatrOpr"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<Macchine>> MacchineByMatrOper(int MatrOpr)
|
||||
public async Task<List<MacchineModel>> MacchineByMatrOper(int MatrOpr)
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<Macchine>? result = new List<Macchine>();
|
||||
List<MacchineModel>? result = new List<MacchineModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Macc:{MatrOpr}";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<Macchine>>($"{rawData}");
|
||||
result = JsonConvert.DeserializeObject<List<MacchineModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
@@ -258,7 +258,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<Macchine>();
|
||||
result = new List<MacchineModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"MacchineGetFilt | MatrOpr: {MatrOpr} | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
|
||||
@@ -125,14 +125,14 @@ namespace MP.Data.Services
|
||||
/// <summary>
|
||||
/// Cache elenco macchine abilitate all'utente, vuoto se scaduto reload
|
||||
/// </summary>
|
||||
public List<Macchine>? ListMachineEnabled
|
||||
public List<MacchineModel>? ListMachineEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
List<Macchine>? answ = userListMachine;
|
||||
List<MacchineModel>? answ = userListMachine;
|
||||
if (DateTime.Now.Subtract(lastUserUpd).TotalSeconds > 30)
|
||||
{
|
||||
answ = new List<Macchine>();
|
||||
answ = new List<MacchineModel>();
|
||||
Log.Debug("ListMachineEnabled unvalidated");
|
||||
}
|
||||
return answ;
|
||||
@@ -710,7 +710,7 @@ namespace MP.Data.Services
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private List<Macchine>? userListMachine { get; set; } = null;
|
||||
private List<MacchineModel>? userListMachine { get; set; } = null;
|
||||
private Dictionary<string, string> UserPrefs { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
@@ -167,18 +167,18 @@ namespace MP.Data.Services
|
||||
return outVal;
|
||||
}
|
||||
|
||||
public async Task<List<Macchine>> MacchineGetAll()
|
||||
public async Task<List<MacchineModel>> MacchineGetAll()
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
string source = "DB";
|
||||
sw.Start();
|
||||
List<Macchine>? result = new List<Macchine>();
|
||||
List<MacchineModel>? result = new List<MacchineModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{Constants.redisMacchine}:ALL";
|
||||
RedisValue rawData = redisDb.StringGet(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<Macchine>>($"{rawData}");
|
||||
result = JsonConvert.DeserializeObject<List<MacchineModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
@@ -190,7 +190,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<Macchine>();
|
||||
result = new List<MacchineModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"MacchineGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
@@ -198,18 +198,18 @@ namespace MP.Data.Services
|
||||
//return Task.FromResult(dbController.MacchineGetAll());
|
||||
}
|
||||
|
||||
public async Task<List<Macchine>> MacchineGetByGruppo(string CodGruppo)
|
||||
public async Task<List<MacchineModel>> MacchineGetByGruppo(string CodGruppo)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
string source = "DB";
|
||||
sw.Start();
|
||||
List<Macchine>? result = new List<Macchine>();
|
||||
List<MacchineModel>? result = new List<MacchineModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{Constants.redisMacchine}:{CodGruppo}";
|
||||
RedisValue rawData = redisDb.StringGet(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<Macchine>>($"{rawData}");
|
||||
result = JsonConvert.DeserializeObject<List<MacchineModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
@@ -222,7 +222,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<Macchine>();
|
||||
result = new List<MacchineModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"MacchineGetByGruppo | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
|
||||
@@ -1246,7 +1246,43 @@ namespace MP.Data.Services
|
||||
/// </summary>
|
||||
/// <param name="IdxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IOB_data> IobInfo(string IdxMacchina)
|
||||
public IOB_data IobInfo(string IdxMacchina)
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
IOB_data? result = new IOB_data();
|
||||
// cerco in redis...
|
||||
string currKey = redHashMpIO($"hM2IOB:{IdxMacchina}");
|
||||
RedisValue rawData = redisDb.StringGet(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<IOB_data>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"Errore: non trovato valore <IOB_data> valido in REDIS | key: {currKey}");
|
||||
Log.Info($"REDIS | conf: {redisConn.Configuration}");
|
||||
Log.Info($" --> Valore trovato:{Environment.NewLine}{rawData}");
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new IOB_data();
|
||||
Log.Debug($"Init valore default <IOB_data> | IdxMacchina: {IdxMacchina}");
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"IobInfo per {IdxMacchina} | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero info IOB x TAB (da info registrate IOB-WIN--> MP-IO)
|
||||
/// </summary>
|
||||
/// <param name="IdxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IOB_data> IobInfoAsync(string IdxMacchina)
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
@@ -1273,7 +1309,7 @@ namespace MP.Data.Services
|
||||
Log.Debug($"Init valore default <IOB_data> | IdxMacchina: {IdxMacchina}");
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"IobInfo per {IdxMacchina} | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
Log.Debug($"IobInfoAsync per {IdxMacchina} | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1431,11 +1467,11 @@ namespace MP.Data.Services
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Macchine dato operatore secondo gruppi (macchine/operatore)
|
||||
/// Elenco MacchineModel dato operatore secondo gruppi (macchine/operatore)
|
||||
/// </summary>
|
||||
/// <param name="MatrOpr"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<Macchine>> MacchineByMatrOper(int MatrOpr)
|
||||
public async Task<List<MacchineModel>> MacchineByMatrOper(int MatrOpr)
|
||||
{
|
||||
int rndWait = rnd.Next(0, 2);
|
||||
await Task.Delay(rndWait);
|
||||
@@ -1443,14 +1479,14 @@ namespace MP.Data.Services
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<Macchine> result = new List<Macchine>();
|
||||
List<MacchineModel> result = new List<MacchineModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:MachByMatOp:{MatrOpr}";
|
||||
RedisValue rawData = redisDb.StringGet(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<Macchine>>($"{rawData}");
|
||||
result = JsonConvert.DeserializeObject<List<MacchineModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
@@ -1462,7 +1498,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<Macchine>();
|
||||
result = new List<MacchineModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user