Aggiunta metodo getTask2Exe con gestione async estesa
This commit is contained in:
@@ -26,13 +26,17 @@ namespace MP.IOC.Data
|
||||
redisConnAdmin = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("RedisAdmin"));
|
||||
redisDb = redisConn.GetDatabase();
|
||||
BroadastMsgPipe = new MessagePipe(redisConn, Constants.BROADCAST_M_PIPE);
|
||||
// leggo cache lungo periodo
|
||||
// leggo cache (lungo periodo e corto periodo)
|
||||
int.TryParse(_configuration.GetValue<string>("ServerConf:redisLongTimeCache"), out redisLongTimeCache);
|
||||
int.TryParse(_configuration.GetValue<string>("ServerConf:redisShortTimeCache"), out redisShortTimeCache);
|
||||
|
||||
_logger.LogInformation("Redis INIT");
|
||||
// conf base x servizi condivisi IO/IOC
|
||||
MpIoNS = _configuration.GetValue<string>("ServerConf:MpIoNS") ?? "MP";
|
||||
|
||||
_logger.LogInformation($"Redis INIT | redisLongTimeCache: {redisLongTimeCache} min | redisShortTimeCache {redisShortTimeCache} min");
|
||||
|
||||
// conf DB
|
||||
string connStr = _configuration.GetConnectionString("MP.Data");
|
||||
string connStr = _configuration.GetConnectionString("MP.Data") ?? "";
|
||||
if (string.IsNullOrEmpty(connStr))
|
||||
{
|
||||
_logger.LogError("DbController: ConnString empty!");
|
||||
@@ -62,11 +66,8 @@ namespace MP.IOC.Data
|
||||
#region Public Properties
|
||||
|
||||
public static MP.Data.Controllers.MpIocController IocDbController { get; set; } = null!;
|
||||
|
||||
public static MP.Data.Controllers.MpMongoController mongoController { get; set; } = null!;
|
||||
|
||||
public static MP.Data.Controllers.MpSpecController SpecDbController { get; set; } = null!;
|
||||
|
||||
public MessagePipe BroadastMsgPipe { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
@@ -1116,6 +1117,49 @@ namespace MP.IOC.Data
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restitusice elenco KVP dei TASK (da passare a IOB-WIN) per l'impianto indicato
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public Dictionary<string, string> mTaskMacchina(string idxMacchina)
|
||||
{
|
||||
// hard coded dimensione vettore DatiMacchine
|
||||
Dictionary<string, string> answ = new Dictionary<string, string>();
|
||||
// ORA recupero da memoria redis...
|
||||
try
|
||||
{
|
||||
var currHash = Utils.taskMaccHash(idxMacchina, MpIoNS);
|
||||
answ = RedisGetHashDict(currHash);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Info(string.Format("Errore in mTaskMacchina | idxMacchina {2}:{0}{1}", Environment.NewLine, exc, idxMacchina));
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Restitusice elenco KVP dei TASK (da passare a IOB-WIN) per l'impianto indicato
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Dictionary<string, string>> GetTask2ExeMacchinaAsync(string idxMacchina)
|
||||
{
|
||||
// hard coded dimensione vettore DatiMacchine
|
||||
Dictionary<string, string> answ = new Dictionary<string, string>();
|
||||
// ORA recupero da memoria redis...
|
||||
try
|
||||
{
|
||||
var currHash = Utils.taskMaccHash(idxMacchina, MpIoNS);
|
||||
answ = RedisGetHashDict(currHash);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Info(string.Format("Errore in GetTask2ExeMacchinaAsync | idxMacchina {2}:{0}{1}", Environment.NewLine, exc, idxMacchina));
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco ODL dato batch selezionato
|
||||
/// </summary>
|
||||
@@ -1730,6 +1774,14 @@ namespace MP.IOC.Data
|
||||
var result = rawData.Where(x => !x.Name.IsNull).ToDictionary(x => x.Name.ToString(), x => x.Value.ToString());
|
||||
return result;
|
||||
}
|
||||
public async Task<Dictionary<string, string>> RedisGetHashDictAsync(RedisKey hashKey)
|
||||
{
|
||||
HashEntry[] rawData = await redisDb.HashGetAllAsync(hashKey);
|
||||
var result = rawData
|
||||
.Where(x => !x.Name.IsNull)
|
||||
.ToDictionary(x => x.Name.ToString(), x => x.Value.ToString());
|
||||
return result;
|
||||
}
|
||||
|
||||
public string RedisGetHashField(RedisKey key, string hashField)
|
||||
{
|
||||
@@ -2208,10 +2260,9 @@ namespace MP.IOC.Data
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration = null!;
|
||||
|
||||
private static ILogger<MpDataService> _logger = null!;
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private string MpIoNS = "";
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto vocabolario x uso continuo traduzione
|
||||
|
||||
Reference in New Issue
Block a user