Update decoder
- gestione nuovo tipo di allarmi - db doppia registrazione
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Platforms>AnyCPU;x86;x64</Platforms>
|
||||
<Version>1.12206.1915</Version>
|
||||
<Version>1.12206.1919</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>MAPO-MONO</i>
|
||||
<h4>Version: 1.12206.1915</h4>
|
||||
<h4>Version: 1.12206.1919</h4>
|
||||
<br /> Release Note:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.12206.1915
|
||||
1.12206.1919
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>1.12206.1915</version>
|
||||
<version>1.12206.1919</version>
|
||||
<url>http://nexus.steamware.net/repository/SWS/MP.MONO.ANALYZER/stable/LAST/MP.Mon.zip</url>
|
||||
<changelog>http://nexus.steamware.net/repository/SWS/MP.MONO.ANALYZER/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace MP.MONO.Core
|
||||
// Configurazioni
|
||||
public static readonly string ACTLOG_CONF_KEY = $"{BASE_HASH}:Conf:ActLog";
|
||||
public static readonly string ALARMS_CONF_KEY = $"{BASE_HASH}:Conf:Alarms";
|
||||
public static readonly string ALARMS_LREC_KEY = $"{BASE_HASH}:Conf:AlarmsListRec";
|
||||
public static readonly string ALARMS_MODE_KEY = $"{BASE_HASH}:Conf:AlarmMode";
|
||||
public static readonly string MODE_CONF_KEY = $"{BASE_HASH}:Conf:Mode";
|
||||
public static readonly string PARAMS_CONF_KEY = $"{BASE_HASH}:Conf:Params";
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Platforms>AnyCPU;x86;x64</Platforms>
|
||||
<Version>1.12206.1915</Version>
|
||||
<Version>1.12206.1919</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
+203
-51
@@ -10,6 +10,7 @@ using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using NLua;
|
||||
using StackExchange.Redis;
|
||||
using static MP.MONO.Core.Enums;
|
||||
|
||||
// See https://aka.ms/new-console-template for more information
|
||||
|
||||
@@ -69,7 +70,11 @@ ConnectionMultiplexer redisConn = ConnectionMultiplexer.Connect(config.GetConnec
|
||||
IDatabase? redisDb = redisConn.GetDatabase();
|
||||
|
||||
// preparo oggetti da configurare
|
||||
List<BaseAlarmBankConf>? alarmsConf = new List<BaseAlarmBankConf>();
|
||||
AlarmReportingMode alarmMode = AlarmReportingMode.ND;
|
||||
List<BaseAlarmBankConf>? alarmsBankBitConf = new List<BaseAlarmBankConf>();
|
||||
List<BaseAlarmRawConf>? alarmsRawConf = new List<BaseAlarmRawConf>();
|
||||
List<string>? activeAlarmList = new List<string>();
|
||||
List<AlarmListModel>? alarmsRecorded = new List<AlarmListModel>();
|
||||
List<MachineMode>? machineModeConf = new List<MachineMode>();
|
||||
List<MachineStatus>? machineStatusConf = new List<MachineStatus>();
|
||||
// gestione configurazioni da redis
|
||||
@@ -126,13 +131,30 @@ void setupConf()
|
||||
machineModeConf = JsonConvert.DeserializeObject<List<MachineMode>>(rawData);
|
||||
}
|
||||
|
||||
// allarmi, versione base...
|
||||
// allarmi..
|
||||
rawData = redisDb.StringGet(Constants.ALARMS_MODE_KEY);
|
||||
alarmMode = JsonConvert.DeserializeObject<AlarmReportingMode>(rawData);
|
||||
// elenco allarmi già registrati (cache DB)
|
||||
rawData = redisDb.StringGet(Constants.ALARMS_LREC_KEY);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
alarmsRecorded = JsonConvert.DeserializeObject<List<AlarmListModel>>(rawData);
|
||||
}
|
||||
// ora la conf specifica
|
||||
rawData = redisDb.StringGet(Constants.ALARMS_CONF_KEY);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
alarmsConf = JsonConvert.DeserializeObject<List<BaseAlarmBankConf>>(rawData);
|
||||
if (alarmMode == AlarmReportingMode.RawList)
|
||||
{
|
||||
alarmsRawConf = JsonConvert.DeserializeObject<List<BaseAlarmRawConf>>(rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
alarmsBankBitConf = JsonConvert.DeserializeObject<List<BaseAlarmBankConf>>(rawData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gestione evento ricezione messaggi allarmi secondo tipologia attiva...
|
||||
/// </summary>
|
||||
@@ -143,83 +165,213 @@ void AlarmsValPipe_EA_NewMessage(object? sender, EventArgs e)
|
||||
if (!string.IsNullOrEmpty(currArgs.newMessage))
|
||||
{
|
||||
DateTime adesso = DateTime.Now;
|
||||
try
|
||||
if (alarmMode == AlarmReportingMode.RawList)
|
||||
{
|
||||
// verifico codici allarmi ricevuti
|
||||
var alarmList = JsonConvert.DeserializeObject<Dictionary<string, uint>>(currArgs.newMessage);
|
||||
if (alarmList != null)
|
||||
try
|
||||
{
|
||||
// variabili accessorie
|
||||
List<string> activeAlarmList = new List<string>();
|
||||
// decodifico allarmi ricevuti
|
||||
var alarmList = JsonConvert.DeserializeObject<List<string>>(currArgs.newMessage);
|
||||
List<AlarmRecModel> alarmRecList = new List<AlarmRecModel>();
|
||||
List<AlarmLogModel> alarmLogList = new List<AlarmLogModel>();
|
||||
|
||||
// rileggo da REDIS la conf attuale allarmi da area ALARMS_SETT_KEY, altrimenti uso quella letta inizialmente da conf base
|
||||
List<BaseAlarmBankConf>? currAlarmsConf = new List<BaseAlarmBankConf>();
|
||||
string rawData = redisDb.StringGet(Constants.ALARMS_SETT_KEY);
|
||||
// rileggo da REDIS la conf attuale allarmi attivi da area ALARM_CURR_KEY
|
||||
List<string>? lastAlarms = new List<string>();
|
||||
string rawData = redisDb.StringGet(Constants.ALARM_CURR_KEY);
|
||||
// se trovati uso questi...
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
currAlarmsConf = JsonConvert.DeserializeObject<List<BaseAlarmBankConf>>(rawData);
|
||||
lastAlarms = JsonConvert.DeserializeObject<List<string>>(rawData);
|
||||
}
|
||||
// altrimenti uso quelli di default inizialmente letti
|
||||
// altrimenti parto da vuoto
|
||||
else
|
||||
{
|
||||
currAlarmsConf = alarmsConf;
|
||||
lastAlarms = new List<string>();
|
||||
}
|
||||
if (currAlarmsConf != null)
|
||||
// ciclo x ogni allarme ricevuto x vedere se sia INIZIATO
|
||||
if (alarmList != null)
|
||||
{
|
||||
// ciclo x ogni bank di allarmi configurato
|
||||
foreach (var alarmData in currAlarmsConf)
|
||||
// ciclo x ogni allarme attivo x verificare se si sia CHIUSO
|
||||
foreach (var newAlarm in alarmList)
|
||||
{
|
||||
// recupero valore allarme
|
||||
var bankVal = alarmList.FirstOrDefault(x => x.Key == alarmData.memAddr);
|
||||
uint actVal = !string.IsNullOrEmpty(bankVal.Key) ? bankVal.Value : 0;
|
||||
// valutare se dividere in 2 da 16... FIXME TODO
|
||||
var bankAlarmList = AlarmsManager.processData(alarmData.memAddr, alarmData.messages, alarmData.silenceMask[0], alarmData.disableMask[0], alarmData.alarmsState[0], ref actVal);
|
||||
// salvo nuovo valore in oggetto...
|
||||
if (alarmData.alarmsState[0] != actVal)
|
||||
if (!lastAlarms.Contains(newAlarm))
|
||||
{
|
||||
alarmData.alarmsState[0] = actVal;
|
||||
// aggiungo...
|
||||
activeAlarmList.AddRange(bankAlarmList);
|
||||
|
||||
AlarmLogModel newAlarm = new AlarmLogModel()
|
||||
// cerco l'allarme nell'elenco degli allarmi dal DB
|
||||
var foundAlarm = alarmsRecorded
|
||||
.Where(x => x.FullValue == newAlarm)
|
||||
.FirstOrDefault();
|
||||
// se non lo trovo --> chiamo procedura che verifica su DB, eventualmente inserisce, restituisce nuovo elenco
|
||||
if (foundAlarm == null)
|
||||
{
|
||||
MachineId = MachineId,
|
||||
DtRif = adesso,
|
||||
MemAddress = bankVal.Key,
|
||||
Index = alarmData != null ? alarmData.index : 0,
|
||||
Status = alarmData != null ? (uint)bankVal.Value & alarmData.silenceMask[0] & alarmData.disableMask[0] : (uint)bankVal.Value,
|
||||
ValDecoded = bankAlarmList.Count > 0 ? string.Join(", ", bankAlarmList) : "All OK"
|
||||
};
|
||||
alarmLogList.Add(newAlarm);
|
||||
// salvo sul DB
|
||||
foundAlarm = dbController.AlarmListInsert(newAlarm);
|
||||
}
|
||||
if (foundAlarm != null)
|
||||
{
|
||||
// ora rileggo ed aggiorno redis e cerco di nuovo record...
|
||||
alarmsRecorded = dbController.AlarmListGetAll();
|
||||
redisDb.StringSet(Constants.ALARMS_LREC_KEY, JsonConvert.SerializeObject(alarmsRecorded));
|
||||
|
||||
// segno come iniziato...
|
||||
AlarmRecModel newAlarmRec = new AlarmRecModel()
|
||||
{
|
||||
MachineId = MachineId,
|
||||
DtStart = adesso,
|
||||
DtEnd = adesso,
|
||||
AlarmId = foundAlarm.AlarmId
|
||||
};
|
||||
alarmRecList.Add(newAlarmRec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// salvo status aggiornato allarme...
|
||||
redisDb.StringSet(Constants.ALARMS_SETT_KEY, JsonConvert.SerializeObject(currAlarmsConf));
|
||||
|
||||
// processo elenco allarmi già presenti
|
||||
if (lastAlarms != null)
|
||||
{
|
||||
// ciclo x ogni allarme attivo x verificare se si sia CHIUSO
|
||||
foreach (var oldData in lastAlarms)
|
||||
{
|
||||
var trovato = alarmList.Contains(oldData);
|
||||
if (!trovato)
|
||||
{
|
||||
// se non lo trovo
|
||||
var foundAlarm = alarmsRecorded
|
||||
.Where(x => x.FullValue == oldData)
|
||||
.FirstOrDefault();
|
||||
if (foundAlarm != null)
|
||||
{
|
||||
// salvo sul DB
|
||||
_ = dbController.AlarmRecCloseActive(foundAlarm.AlarmId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// verifico se devo scrivere
|
||||
bool wALog = lastAlarms.Count != alarmList.Count;
|
||||
if (!wALog)
|
||||
{
|
||||
// verifico se ci siano differenze...
|
||||
wALog = alarmList.Union(lastAlarms).Count() != lastAlarms.Count;
|
||||
}
|
||||
|
||||
// salvo se c'è stata variazione...
|
||||
if (wALog)
|
||||
{
|
||||
// preparo dati x alarmLog
|
||||
AlarmLogModel newAlarmLog = new AlarmLogModel()
|
||||
{
|
||||
MachineId = MachineId,
|
||||
DtRif = adesso,
|
||||
MemAddress = "ND",
|
||||
Index = 0,
|
||||
Status = (uint)alarmList.Count,
|
||||
ValDecoded = alarmList.Count > 0 ? string.Join(", ", alarmList) : "All OK"
|
||||
};
|
||||
alarmLogList.Add(newAlarmLog);
|
||||
}
|
||||
|
||||
// serializzo l'elenco allarmi...
|
||||
string serAlarms = "[]";
|
||||
serAlarms = JsonConvert.SerializeObject(activeAlarmList);
|
||||
serAlarms = JsonConvert.SerializeObject(alarmList);
|
||||
// invio sulla message pipeline corretta TUTTI gli allarmi serializzati
|
||||
alarmsPipe.saveAndSendMessage(Constants.ALARM_CURR_KEY, serAlarms);
|
||||
// verifico NON ci sia veto di scrittura... 60 sec...
|
||||
if (adesso.Subtract(lastExecAlarms).TotalSeconds > 60)
|
||||
|
||||
// salvo sul DB
|
||||
_ = dbController.AlarmRecInsertMany(alarmRecList).Result;
|
||||
_ = dbController.AlarmLogInsertMany(alarmLogList).Result;
|
||||
|
||||
// salvo nuovo elenco allarmi
|
||||
lastAlarms = alarmList;
|
||||
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
// verifico codici allarmi ricevuti
|
||||
var alarmList = JsonConvert.DeserializeObject<Dictionary<string, uint>>(currArgs.newMessage);
|
||||
if (alarmList != null)
|
||||
{
|
||||
lastExecAlarms = adesso;
|
||||
if (dbController != null)
|
||||
// variabili accessorie
|
||||
List<string> activeAlarmList = new List<string>();
|
||||
List<AlarmLogModel> alarmLogList = new List<AlarmLogModel>();
|
||||
|
||||
// rileggo da REDIS la conf attuale allarmi da area ALARMS_SETT_KEY, altrimenti uso quella letta inizialmente da conf base
|
||||
List<BaseAlarmBankConf>? currAlarmsBankConf = new List<BaseAlarmBankConf>();
|
||||
string rawData = redisDb.StringGet(Constants.ALARMS_SETT_KEY);
|
||||
// se trovati uso questi...
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
// salvo sul DB
|
||||
_ = dbController.AlarmLogInsertMany(alarmLogList).Result;
|
||||
currAlarmsBankConf = JsonConvert.DeserializeObject<List<BaseAlarmBankConf>>(rawData);
|
||||
}
|
||||
// altrimenti uso quelli di default inizialmente letti
|
||||
else
|
||||
{
|
||||
currAlarmsBankConf = alarmsBankBitConf;
|
||||
}
|
||||
if (currAlarmsBankConf != null)
|
||||
{
|
||||
// ciclo x ogni bank di allarmi configurato
|
||||
foreach (var alarmData in currAlarmsBankConf)
|
||||
{
|
||||
// recupero valore allarme
|
||||
var bankVal = alarmList.FirstOrDefault(x => x.Key == alarmData.memAddr);
|
||||
uint actVal = !string.IsNullOrEmpty(bankVal.Key) ? bankVal.Value : 0;
|
||||
// valutare se dividere in 2 da 16... FIXME TODO
|
||||
var bankAlarmList = AlarmsManager.processData(alarmData.memAddr, alarmData.messages, alarmData.silenceMask[0], alarmData.disableMask[0], alarmData.alarmsState[0], ref actVal);
|
||||
// salvo nuovo valore in oggetto...
|
||||
if (alarmData.alarmsState[0] != actVal)
|
||||
{
|
||||
alarmData.alarmsState[0] = actVal;
|
||||
// aggiungo...
|
||||
activeAlarmList.AddRange(bankAlarmList);
|
||||
|
||||
AlarmLogModel newAlarmLog = new AlarmLogModel()
|
||||
{
|
||||
MachineId = MachineId,
|
||||
DtRif = adesso,
|
||||
MemAddress = bankVal.Key,
|
||||
Index = alarmData != null ? alarmData.index : 0,
|
||||
Status = alarmData != null ? (uint)bankVal.Value & alarmData.silenceMask[0] & alarmData.disableMask[0] : (uint)bankVal.Value,
|
||||
ValDecoded = bankAlarmList.Count > 0 ? string.Join(", ", bankAlarmList) : "All OK"
|
||||
};
|
||||
alarmLogList.Add(newAlarmLog);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// salvo status aggiornato allarme...
|
||||
redisDb.StringSet(Constants.ALARMS_SETT_KEY, JsonConvert.SerializeObject(currAlarmsBankConf));
|
||||
|
||||
// serializzo l'elenco allarmi...
|
||||
string serAlarms = "[]";
|
||||
serAlarms = JsonConvert.SerializeObject(activeAlarmList);
|
||||
// invio sulla message pipeline corretta TUTTI gli allarmi serializzati
|
||||
alarmsPipe.saveAndSendMessage(Constants.ALARM_CURR_KEY, serAlarms);
|
||||
// verifico NON ci sia veto di scrittura... 60 sec...
|
||||
if (adesso.Subtract(lastExecAlarms).TotalSeconds > 60)
|
||||
{
|
||||
lastExecAlarms = adesso;
|
||||
if (dbController != null)
|
||||
{
|
||||
// salvo sul DB
|
||||
_ = dbController.AlarmLogInsertMany(alarmLogList).Result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in AlarmsValPipe_EA_NewMessage:{Environment.NewLine}{exc}");
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in AlarmsValPipe_EA_NewMessage, mode {alarmMode}:{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>MAPO-MONO</i>
|
||||
<h4>Version: 1.12206.1915</h4>
|
||||
<h4>Version: 1.12206.1919</h4>
|
||||
<br /> Release Note:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.12206.1915
|
||||
1.12206.1919
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>1.12206.1915</version>
|
||||
<version>1.12206.1919</version>
|
||||
<url>http://nexus.steamware.net/repository/SWS/MP.MONO.DECODER/stable/LAST/MP.Mon.zip</url>
|
||||
<changelog>http://nexus.steamware.net/repository/SWS/MP.MONO.DECODER/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace MP.MONO.Data.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserimento di un record AlarmLog
|
||||
/// Inserimento di una lista record AlarmLog
|
||||
/// </summary>
|
||||
/// <param name="newItems">Lista Record da inserire (senza ID...)</param>
|
||||
/// <returns></returns>
|
||||
@@ -99,6 +99,214 @@ namespace MP.MONO.Data.Controllers
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco records anagrafica allarmi
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<AlarmListModel> AlarmListGetAll()
|
||||
{
|
||||
List<AlarmListModel>? dbResult = new List<AlarmListModel>();
|
||||
using (MapoMonoContext localDbCtx = new MapoMonoContext())
|
||||
{
|
||||
try
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetAlarmList
|
||||
.OrderBy(x => x.FullValue)
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante AlarmListGetAll{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserimento di un record anagrafica allarmi (o se esiste restituisce quello esistente)
|
||||
/// </summary>
|
||||
/// <param name="newItem">Record da inserire (senza ID...)</param>
|
||||
/// <returns></returns>
|
||||
public AlarmListModel? AlarmListInsert(string alarmText)
|
||||
{
|
||||
AlarmListModel? foundRec = new AlarmListModel();
|
||||
using (MapoMonoContext localDbCtx = new MapoMonoContext())
|
||||
{
|
||||
try
|
||||
{
|
||||
// verifico che NON esista con pèari descrizione...
|
||||
foundRec = localDbCtx
|
||||
.DbSetAlarmList
|
||||
.FirstOrDefault(x => x.FullValue == alarmText);
|
||||
// se non c'è aggiungo
|
||||
if (foundRec == null)
|
||||
{
|
||||
foundRec = new AlarmListModel()
|
||||
{
|
||||
FullValue = alarmText
|
||||
};
|
||||
localDbCtx
|
||||
.DbSetAlarmList
|
||||
.Add(foundRec);
|
||||
localDbCtx.SaveChanges();
|
||||
// rifaccio search
|
||||
foundRec = localDbCtx
|
||||
.DbSetAlarmList
|
||||
.FirstOrDefault(x => x.FullValue == alarmText);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante AlarmListInsert{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return foundRec;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserimento di una lista record anagrafica allarmi
|
||||
/// </summary>
|
||||
/// <param name="newItems">Lista Record da inserire (senza ID...)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AlarmListInsertMany(List<AlarmListModel> newItems)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (MapoMonoContext localDbCtx = new MapoMonoContext())
|
||||
{
|
||||
try
|
||||
{
|
||||
await localDbCtx
|
||||
.DbSetAlarmList
|
||||
.AddRangeAsync(newItems);
|
||||
await localDbCtx.SaveChangesAsync();
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante AlarmListInsertMany{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Recupero elenco allarmi Rec (ultimi dato "skip")
|
||||
/// </summary>
|
||||
/// <param name="MachineId"></param>
|
||||
/// <param name="skipRec"></param>
|
||||
/// <param name="numRec"></param>
|
||||
/// <returns></returns>
|
||||
public List<AlarmRecModel> AlarmRecGetFilt(int MachineId, int skipRec, int numRec)
|
||||
{
|
||||
List<AlarmRecModel> dbResult = new List<AlarmRecModel>();
|
||||
using (MapoMonoContext localDbCtx = new MapoMonoContext())
|
||||
{
|
||||
try
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetAlarmRec
|
||||
.Where(x => x.MachineId == MachineId)
|
||||
.Include(m => m.MachineNav)
|
||||
.Include(m => m.AlarmListNav)
|
||||
.OrderByDescending(x => x.DtStart)
|
||||
.Skip(skipRec)
|
||||
.Take(numRec)
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante AlarmRecGetFilt{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserimento di un record AlarmRec
|
||||
/// </summary>
|
||||
/// <param name="newItem">Record da inserire (senza ID...)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AlarmRecInsert(AlarmRecModel newItem)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (MapoMonoContext localDbCtx = new MapoMonoContext())
|
||||
{
|
||||
try
|
||||
{
|
||||
localDbCtx
|
||||
.DbSetAlarmRec
|
||||
.Add(newItem);
|
||||
await localDbCtx.SaveChangesAsync();
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante AlarmRecInsert{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Chiude ultimo record dato Id (se fossero + di 1 chiude tutti...)
|
||||
/// </summary>
|
||||
/// <param name="AlarmId">Id Allarme</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AlarmRecCloseActive(int AlarmId)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (MapoMonoContext localDbCtx = new MapoMonoContext())
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime adesso = DateTime.Now;
|
||||
var candList = localDbCtx
|
||||
.DbSetAlarmRec
|
||||
.Where(x => x.AlarmId==AlarmId)
|
||||
.ToList();
|
||||
foreach (var item in candList)
|
||||
{
|
||||
item.DtEnd = adesso;
|
||||
}
|
||||
await localDbCtx.SaveChangesAsync();
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante AlarmRecCloseActive{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserimento di una lista record AlarmRec
|
||||
/// </summary>
|
||||
/// <param name="newItems">Lista Record da inserire (senza ID...)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AlarmRecInsertMany(List<AlarmRecModel> newItems)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (MapoMonoContext localDbCtx = new MapoMonoContext())
|
||||
{
|
||||
try
|
||||
{
|
||||
await localDbCtx
|
||||
.DbSetAlarmRec
|
||||
.AddRangeAsync(newItems);
|
||||
await localDbCtx.SaveChangesAsync();
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante AlarmRecInsertMany{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero record DataLog data condizione filtro
|
||||
/// </summary>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Platforms>AnyCPU;x86;x64</Platforms>
|
||||
<Version>1.12206.1916</Version>
|
||||
<Version>1.12206.1919</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -113,12 +113,10 @@ void setupConf()
|
||||
ConfigManager configManager = new ConfigManager(redisConf, confPath);
|
||||
if (alarmMode == AlarmReportingMode.RawList)
|
||||
{
|
||||
//redisDb.StringSetAsync(Constants.ALARMS_MODE_KEY, "RawList");
|
||||
alarmsRawConf = configManager.getAlarmsRawConf();
|
||||
}
|
||||
else
|
||||
{
|
||||
//redisDb.StringSetAsync(Constants.ALARMS_MODE_KEY, "BankBit");
|
||||
alarmsBankBitConf = configManager.getAlarmsBankConf();
|
||||
}
|
||||
machineModeConf = configManager.getMachineModeConf();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>MAPO-MONO</i>
|
||||
<h4>Version: 1.12206.1916</h4>
|
||||
<h4>Version: 1.12206.1919</h4>
|
||||
<br /> Release Note:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.12206.1916
|
||||
1.12206.1919
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>1.12206.1916</version>
|
||||
<version>1.12206.1919</version>
|
||||
<url>http://nexus.steamware.net/repository/SWS/MP.MONO.SIM/stable/LAST/MP.Mon.zip</url>
|
||||
<changelog>http://nexus.steamware.net/repository/SWS/MP.MONO.SIM/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
@@ -95,11 +95,59 @@ namespace MP.MONO.UI.Data
|
||||
|
||||
#region Public Methods
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Elenco records anagrafica allarmi
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<AlarmListModel>> AlarmListGetAll()
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
var dbResult = dbController.AlarmListGetAll();
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB AlarmListGetAll: {ts.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserisce nuovo record in anagrafica allarmi dato testo (o restituisce se esistente)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<AlarmListModel?> AlarmListInsert(string AlarmText)
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
var dbResult = dbController.AlarmListInsert(AlarmText);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB AlarmListInsert: {ts.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Chiude ultimo record dato Id (se fossero + di 1 chiude tutti...)
|
||||
/// </summary>
|
||||
/// <param name="AlarmId">Id Allarme</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AlarmRecCloseActive(int AlarmId)
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
var dbResult = await dbController.AlarmRecCloseActive(AlarmId);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB AlarmRecCloseActive: {ts.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
public async Task<List<AlarmLogModel>> AlarmLogGetFilt(int machineId, int skipRec, int numRec)
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
List<AlarmLogModel>? dbResult = dbController.AlarmLogGetFilt(machineId, skipRec, numRec);
|
||||
var dbResult = dbController.AlarmLogGetFilt(machineId, skipRec, numRec);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB AlarmLogGetFilt: {ts.TotalMilliseconds} ms");
|
||||
@@ -110,7 +158,7 @@ namespace MP.MONO.UI.Data
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
List<DataLogModel>? dbResult = dbController.DataLogGetFilt(machineId, fluxType, inizio, fine);
|
||||
var dbResult = dbController.DataLogGetFilt(machineId, fluxType, inizio, fine);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB ParamLogGetFilt: {ts.TotalMilliseconds} ms");
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Platforms>AnyCPU;x86;x64</Platforms>
|
||||
<Version>1.12206.1915</Version>
|
||||
<Version>1.12206.1919</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>MAPO-MONO</i>
|
||||
<h4>Version: 1.12206.1915</h4>
|
||||
<h4>Version: 1.12206.1919</h4>
|
||||
<br /> Release Note:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.12206.1915
|
||||
1.12206.1919
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>1.12206.1915</version>
|
||||
<version>1.12206.1919</version>
|
||||
<url>http://nexus.steamware.net/repository/SWS/MP.MONO.UI/stable/LAST/MP.Mon.zip</url>
|
||||
<changelog>http://nexus.steamware.net/repository/SWS/MP.MONO.UI/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
Reference in New Issue
Block a user