Compare commits
45 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 66d27fd95a | |||
| e64051126f | |||
| d75bdfb7c0 | |||
| ff2b83164d | |||
| 303d08a229 | |||
| 31097ccee0 | |||
| e576f94348 | |||
| c13d2f135b | |||
| 866319a311 | |||
| f93f18561f | |||
| ca7b26b9bc | |||
| aea30b6502 | |||
| 8b506c54e5 | |||
| cae04d8851 | |||
| 8b84fa0016 | |||
| 5381f8a175 | |||
| bd5d48587d | |||
| 53cb7e8a4c | |||
| 12f553d703 | |||
| f5c4503fc2 | |||
| 4ada317928 | |||
| 5e17621470 | |||
| af2713be14 | |||
| 6f0b6e4f8c | |||
| de5bbe0e53 | |||
| 26b01d5f9b | |||
| 667747e4a2 | |||
| 179d19cd94 | |||
| 1d9ed73677 | |||
| aa8e52c32d | |||
| b5050ab449 | |||
| 571b40f058 | |||
| 46a8c8bee9 | |||
| d8919ccda6 | |||
| 28c7e51d64 | |||
| 7e9b264284 | |||
| e23cbbb36d | |||
| 499c91a57a | |||
| de2cd9279c | |||
| 513fa6cd91 | |||
| 887c7747a0 | |||
| f018c0474d | |||
| 5c1d4776ca | |||
| fa77860a50 | |||
| 8f88c42a71 |
@@ -136,6 +136,19 @@ namespace GWMS.Data.Controllers
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Calcola DataOra arrotondata per eccesso secondo intervallo minuti indicato
|
||||
/// </summary>
|
||||
/// <param name="dateOrig"></param>
|
||||
/// <param name="minInt"></param>
|
||||
/// <returns></returns>
|
||||
public DateTime DateRoundEnd(DateTime dateOrig, int minInt)
|
||||
{
|
||||
int minRound = (int)Math.Ceiling((double)dateOrig.Minute / minInt) * minInt;
|
||||
DateTime roundDate = dateOrig.Date.AddHours(dateOrig.Hour).AddMinutes(minRound);
|
||||
return roundDate;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database context
|
||||
@@ -212,14 +225,34 @@ namespace GWMS.Data.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
public List<PlantDTO> GetPlantsDTO()
|
||||
public List<PlantDTO> GetPlantsDTO(int maxRecords)
|
||||
{
|
||||
var plantList = dbCtx
|
||||
.DbSetPlant
|
||||
.ToList();
|
||||
|
||||
var dbResult = plantList
|
||||
.Select(x => PlantDTO(x.PlantId))
|
||||
.Select(x => PlantDTO(x.PlantId, maxRecords))
|
||||
.ToList();
|
||||
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce ultimi eventi rebootlog
|
||||
/// </summary>
|
||||
/// <param name="maxNum">num eventi, se 0 = tutti</param>
|
||||
/// <returns></returns>
|
||||
public List<RebootLogModel> GetRebootLog(int maxNum = 100)
|
||||
{
|
||||
if (maxNum == 0)
|
||||
{
|
||||
maxNum = dbCtx.DbRebootLog.Count();
|
||||
}
|
||||
var dbResult = dbCtx
|
||||
.DbRebootLog
|
||||
.OrderByDescending(x => x.DtEvent)
|
||||
.Take(maxNum)
|
||||
.ToList();
|
||||
|
||||
return dbResult;
|
||||
@@ -314,9 +347,10 @@ namespace GWMS.Data.Controllers
|
||||
/// <summary>
|
||||
/// Recupero info PLANT modalità DTO
|
||||
/// </summary>
|
||||
/// <param name="PlantId"></param>
|
||||
/// <param name="PlantId">Impianto</param>
|
||||
/// <param name="PlantId">Max numero di record da recuperare</param>
|
||||
/// <returns></returns>
|
||||
public PlantDTO PlantDTO(int PlantId)
|
||||
public PlantDTO PlantDTO(int PlantId, int maxRecords)
|
||||
{
|
||||
var currPlant = GetPlant(PlantId);
|
||||
|
||||
@@ -332,30 +366,35 @@ namespace GWMS.Data.Controllers
|
||||
.DbSetPlantLog
|
||||
.Where(x => x.FluxType == "Level" && x.PlantId == PlantId)
|
||||
.OrderBy(x => x.DtEvent)
|
||||
.Take(maxRecords)
|
||||
.ToList();
|
||||
|
||||
var rawMainPressData = dbCtx
|
||||
.DbSetPlantLog
|
||||
.Where(x => x.FluxType == "MainPress" && x.PlantId == PlantId)
|
||||
.OrderBy(x => x.DtEvent)
|
||||
.Take(maxRecords)
|
||||
.ToList();
|
||||
|
||||
var rawBHPressData = dbCtx
|
||||
.DbSetPlantLog
|
||||
.Where(x => x.FluxType == "PressBH" && x.PlantId == PlantId)
|
||||
.OrderBy(x => x.DtEvent)
|
||||
.Take(maxRecords)
|
||||
.ToList();
|
||||
|
||||
var rawBLPressData = dbCtx
|
||||
.DbSetPlantLog
|
||||
.Where(x => x.FluxType == "PressBL" && x.PlantId == PlantId)
|
||||
.OrderBy(x => x.DtEvent)
|
||||
.Take(maxRecords)
|
||||
.ToList();
|
||||
|
||||
var rawOrderData = dbCtx
|
||||
.DbSetOrders
|
||||
.Where(x => x.PlantId == PlantId)
|
||||
.OrderBy(x => x.DtOrder)
|
||||
.Take(maxRecords)
|
||||
.ToList();
|
||||
|
||||
LevelTS = rawLevelData
|
||||
@@ -377,16 +416,21 @@ namespace GWMS.Data.Controllers
|
||||
PressTS.Add("BH", PressBHTS);
|
||||
PressTS.Add("BL", PressBLTS);
|
||||
|
||||
PressAct.Add("Main", PressMainTS.OrderByDescending(x => x.DtEvent).Take(1).FirstOrDefault().ValDouble);
|
||||
PressAct.Add("BH", PressBHTS.OrderByDescending(x => x.DtEvent).Take(1).FirstOrDefault().ValDouble);
|
||||
PressAct.Add("BL", PressBLTS.OrderByDescending(x => x.DtEvent).Take(1).FirstOrDefault().ValDouble);
|
||||
double actLevel = LevelTS.Count > 0 ? LevelTS.OrderByDescending(x => x.DtEvent).Take(1).FirstOrDefault().ValDouble : 0;
|
||||
double valMain = PressMainTS.Count > 0 ? PressMainTS.OrderByDescending(x => x.DtEvent).Take(1).FirstOrDefault().ValDouble : 0;
|
||||
double valBH = PressBHTS.Count > 0 ? PressBHTS.OrderByDescending(x => x.DtEvent).Take(1).FirstOrDefault().ValDouble : 0;
|
||||
double valBL = PressBLTS.Count > 0 ? PressBLTS.OrderByDescending(x => x.DtEvent).Take(1).FirstOrDefault().ValDouble : 0;
|
||||
|
||||
PressAct.Add("Main", valMain);
|
||||
PressAct.Add("BH", valBH);
|
||||
PressAct.Add("BL", valBL);
|
||||
|
||||
PlantDTO answ = new PlantDTO()
|
||||
{
|
||||
PlantId = PlantId,
|
||||
PlantCode = currPlant.PlantCode,
|
||||
PlantDesc = currPlant.PlantDesc,
|
||||
LevelAct = currPlant.LevelAct,
|
||||
LevelAct = actLevel,
|
||||
LevelMax = currPlant.LevelMax,
|
||||
PressAct = PressAct,
|
||||
LevelTS = LevelTS,
|
||||
@@ -397,36 +441,58 @@ namespace GWMS.Data.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserimento di un novo record x plant log
|
||||
/// Recupero da DB l'ultimo record per ogni flusso
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<PlantLogModel> PlantLogGetLastByFlux(int PlantId)
|
||||
{
|
||||
List<PlantLogModel> lastRec = dbCtx
|
||||
.DbSetPlantLog
|
||||
.Where(x => x.PlantId == PlantId)
|
||||
.OrderByDescending(o => o.DtEvent)
|
||||
.Take(1000)
|
||||
.AsEnumerable()
|
||||
.GroupBy(g => g.FluxType)
|
||||
.Select(s => s.First())
|
||||
.ToList();
|
||||
return lastRec;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserimento di un set di record x plant log
|
||||
/// </summary>
|
||||
/// <param name="PlantLogModel">Record da inserire (senza ID...)</param>
|
||||
/// <returns></returns>
|
||||
public bool PlantLogInsertNew(List<PlantLogModel> newItems)
|
||||
{
|
||||
bool fatto = false;
|
||||
|
||||
//List<PlantLogModel> newList = new List<PlantLogModel>();
|
||||
|
||||
//foreach (var item in newItems)
|
||||
//{
|
||||
// newList.Add(new PlantLogModel()
|
||||
// {
|
||||
// DtEvent = item.DtEvent,
|
||||
// FluxType = item.FluxType,
|
||||
// PlantId = item.PlantId,
|
||||
// ValNumber = item.ValNumber,
|
||||
// ValString = item.ValString
|
||||
// });
|
||||
//}
|
||||
try
|
||||
{
|
||||
dbCtx
|
||||
.DbSetPlantLog
|
||||
.AddRange(newItems);
|
||||
//.AddRange(newList);
|
||||
|
||||
dbCtx.SaveChanges();
|
||||
fatto = true;
|
||||
|
||||
#if false
|
||||
// ogni 10 insert faccio chiamata x pulizia per le ultime 3h... FARE!!!!
|
||||
Dictionary<string, int> flux2prox = new Dictionary<string, int>();
|
||||
foreach (var item in newItems)
|
||||
{
|
||||
if (!flux2prox.ContainsKey(item.FluxType))
|
||||
{
|
||||
flux2prox.Add(item.FluxType, item.PlantId);
|
||||
}
|
||||
}
|
||||
// ciclo x ogni flusso
|
||||
foreach (var item in flux2prox)
|
||||
{
|
||||
DateTime adesso = DateTime.Now;
|
||||
DateTime startTime = DateTime.Today.AddHours(adesso.Hour - 2);
|
||||
string sqlQuery = $"CALL DecimateLog('{startTime}', {item.Value}, 15, '{item.Key}')";
|
||||
var table = dbCtx.DbSetPlantLog.FromSqlRaw(sqlQuery);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
@@ -436,6 +502,22 @@ namespace GWMS.Data.Controllers
|
||||
return fatto;
|
||||
}
|
||||
|
||||
public bool RecordRebootLog(RebootLogModel newItem)
|
||||
{
|
||||
bool done = false;
|
||||
try
|
||||
{
|
||||
dbCtx
|
||||
.DbRebootLog
|
||||
.Add(newItem);
|
||||
dbCtx.SaveChanges();
|
||||
done = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{ }
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rigenera intero DB se riceve ID di un plant SIM...
|
||||
/// </summary>
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace GWMS.Data.DTO
|
||||
public string PlantCode { get; set; } = "";
|
||||
public string PlantDesc { get; set; } = "";
|
||||
|
||||
public double LevelMax { get; set; } = 9999;
|
||||
public double LevelMax { get; set; } = 99999;
|
||||
|
||||
public double LevelAct { get; set; } = 0;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace GWMS.Data.DTO
|
||||
{
|
||||
int answ = 0;
|
||||
double denom = LevelMax == 0 ? 1 : LevelMax;
|
||||
answ = (int)(LevelAct *100/ denom);
|
||||
answ = (int)(LevelAct * 100 / denom);
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
|
||||
namespace GWMS.Data.DatabaseModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Tabella dati Plant (log storico)
|
||||
/// </summary>
|
||||
[Table("RebootLog")]
|
||||
public class RebootLogModel
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int RecordId { get; set; }
|
||||
|
||||
public DateTime DtEvent { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto di cui si registra il reboot log
|
||||
/// </summary>
|
||||
[MaxLength(250)]
|
||||
public string Item { get; set; } = "ND";
|
||||
|
||||
/// <summary>
|
||||
/// Payload associato (IP/Mac address)
|
||||
/// </summary>
|
||||
[MaxLength(250)]
|
||||
public string Payload { get; set; } = "";
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
@@ -10,31 +10,16 @@ namespace GWMS.Data
|
||||
{
|
||||
public class DbAdmin : IDisposable
|
||||
{
|
||||
#if false
|
||||
private AdminContext adbCtx;
|
||||
#endif
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Singleton gestione
|
||||
/// </summary>
|
||||
public static DbAdmin man = new DbAdmin();
|
||||
#endif
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public DbAdmin()
|
||||
{
|
||||
#if false
|
||||
// Initialize database context for ADMIN
|
||||
adbCtx = new AdminContext();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
@@ -46,16 +46,20 @@ namespace GWMS.Data
|
||||
return DbAdmin.checkCreateUser(DATABASE_USER, DATABASE_PWD);
|
||||
}
|
||||
|
||||
public static async Task<bool> ExecMigrationIdentity()
|
||||
public static bool ExecMigrationIdentity()
|
||||
{
|
||||
// esecuzione migrazione
|
||||
return await DbAdmin.migrateDbIdentity();
|
||||
var migrateTask = Task.Run(async () => await DbAdmin.migrateDbIdentity());
|
||||
migrateTask.Wait();
|
||||
return migrateTask.Result;
|
||||
}
|
||||
|
||||
public static async Task<bool> ExecMigrationMain()
|
||||
public static bool ExecMigrationMain()
|
||||
{
|
||||
// esecuzione migrazione
|
||||
return await DbAdmin.migrateDbMain();
|
||||
var migrateTask = Task.Run(async () => await DbAdmin.migrateDbMain());
|
||||
migrateTask.Wait();
|
||||
return migrateTask.Result;
|
||||
}
|
||||
|
||||
public static void InitDb(string server, string nKey, string sKey)
|
||||
|
||||
@@ -2,6 +2,47 @@
|
||||
|
||||
namespace GWMS.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Elenco dei tipi di valore gestiti da PLC (inizialmente SIEMENS)
|
||||
/// </summary>
|
||||
public enum plcDataType
|
||||
{
|
||||
/// <summary>
|
||||
/// Tipo boolean
|
||||
/// </summary>
|
||||
Boolean,
|
||||
|
||||
/// <summary>
|
||||
/// Tipo Int16 intero 16bit
|
||||
/// </summary>
|
||||
Int,
|
||||
|
||||
/// <summary>
|
||||
/// Tipo Int32 intero 32bit
|
||||
/// </summary>
|
||||
DInt,
|
||||
|
||||
/// <summary>
|
||||
/// Tipo UInt16, intero 16bit
|
||||
/// </summary>
|
||||
Word,
|
||||
|
||||
/// <summary>
|
||||
/// Tipo UInt32, intero Unsigned 32bit
|
||||
/// </summary>
|
||||
DWord,
|
||||
|
||||
/// <summary>
|
||||
/// Tipo REAL 32 bit
|
||||
/// </summary>
|
||||
Real,
|
||||
|
||||
/// <summary>
|
||||
/// Tipo stringa
|
||||
/// </summary>
|
||||
String
|
||||
}
|
||||
|
||||
public enum UserLevel
|
||||
{
|
||||
ND = 0,
|
||||
@@ -10,4 +51,30 @@ namespace GWMS.Data
|
||||
User = 3,
|
||||
UserExt = 4
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tipologia di elaborazione/funzione da applicare a VC
|
||||
/// </summary>
|
||||
public enum VC_func
|
||||
{
|
||||
/// <summary>
|
||||
/// Valore puntuale
|
||||
/// </summary>
|
||||
POINT = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Valore medio del periodo
|
||||
/// </summary>
|
||||
AVG,
|
||||
|
||||
/// <summary>
|
||||
/// Valore massimo del periodo
|
||||
/// </summary>
|
||||
MAX,
|
||||
|
||||
/// <summary>
|
||||
/// Valore minimo del periodo
|
||||
/// </summary>
|
||||
MIN
|
||||
}
|
||||
}
|
||||
@@ -26,8 +26,4 @@
|
||||
<PackageReference Include="NLog" Version="4.7.10" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Resources\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -42,6 +42,7 @@ namespace GWMS.Data
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public virtual DbSet<RebootLogModel> DbRebootLog { get; set; }
|
||||
public virtual DbSet<ConfigModel> DbSetConfig { get; set; }
|
||||
|
||||
public virtual DbSet<ItemModel> DbSetItems { get; set; }
|
||||
|
||||
@@ -0,0 +1,241 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GWMS.Data
|
||||
{
|
||||
public class IobObjects
|
||||
{
|
||||
#region Public Classes
|
||||
|
||||
/// <summary>
|
||||
/// Struttura conf tipo dati
|
||||
/// </summary>
|
||||
public class dataConf
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// DESCRIZIONE parametro
|
||||
/// </summary>
|
||||
public string description { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Fattore per eventuale divisione (es leggo 1234 --> 12,34 con factor=100)
|
||||
/// </summary>
|
||||
public int factor { get; set; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Indice nell'area di memoria (da valore iniziale = 0)
|
||||
/// </summary>
|
||||
public int index { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Valore massimo ammesso (ove usato, es simulazione)
|
||||
/// </summary>
|
||||
public int maxVal { get; set; } = 9999;
|
||||
|
||||
/// <summary>
|
||||
/// Nome "assoluto" della posizione nell'area di memoria (anche diverso da indice)
|
||||
/// </summary>
|
||||
public string memAddr { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Valore minimo ammesso (ove usato, es simulazione)
|
||||
/// </summary>
|
||||
public int minVal { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// NOME parametro
|
||||
/// </summary>
|
||||
public string name { get; set; } = "none";
|
||||
|
||||
/// <summary>
|
||||
/// Size in byte
|
||||
/// </summary>
|
||||
public int size { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Tipo di dato
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public plcDataType tipoMem { get; set; } = plcDataType.Int;
|
||||
|
||||
/// <summary>
|
||||
/// Valore parametro (come stringa, decimali con ",", default VUOTO), poi LETTO da PLC (o appena scritto)
|
||||
/// </summary>
|
||||
public string value { get; set; } = "";
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Struttura conf tipo dati
|
||||
/// </summary>
|
||||
public class dataConfTSVC : dataConf
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Tipo di funzione da applicare al dato
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public VC_func func { get; set; } = VC_func.MAX;
|
||||
|
||||
/// <summary>
|
||||
/// Periodo campionamento
|
||||
/// </summary>
|
||||
public int period { get; set; } = 60;
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tracciato InputEvents in formato JSON valido
|
||||
/// Derivato da input realtime valore=3&dtEve=20181206180600000&dtCurr=20181206180600000&cnt=999
|
||||
/// </summary>
|
||||
public class evData
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Contatore incrementale x riordino invio (opzionale)
|
||||
/// </summary>
|
||||
public int cnt { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// DataOra corrente della trasmissione
|
||||
/// </summary>
|
||||
public DateTime dtCurr { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// DataOra evento
|
||||
/// </summary>
|
||||
public DateTime dtEve { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// Valore del dato di flusso registrato
|
||||
/// </summary>
|
||||
public string valore { get; set; } = "-";
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Array valori tipo evData inviati come JSon
|
||||
/// </summary>
|
||||
public class evJsonPayload
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
public List<evData> eventList { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tracciato FluxLog in formato JSON valido
|
||||
/// </summary>
|
||||
public class flogData : evData
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// nome del flusso
|
||||
/// </summary>
|
||||
public string flux { get; set; } = "ND";
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Array valori tipo flogData inviati come JSon
|
||||
/// </summary>
|
||||
public class flogJsonPayload
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
public List<flogData> fluxData { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Classe gestione ITEM di un OBJ (machine) generico (read/write)
|
||||
/// </summary>
|
||||
public class objItem
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Ultimo messaggio associato (conferma scrittura, errore, ...)
|
||||
/// </summary>
|
||||
public string lastMessage { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// DataOra ultima lettura
|
||||
/// </summary>
|
||||
public DateTime lastRead { get; set; } = DateTime.Now.AddHours(-1);
|
||||
|
||||
/// <summary>
|
||||
/// DataOra ultima richiesta scrittura
|
||||
/// </summary>
|
||||
public DateTime lastRequest { get; set; } = DateTime.Now.AddDays(-1);
|
||||
|
||||
/// <summary>
|
||||
/// NOME item
|
||||
/// </summary>
|
||||
public string name { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Indica il NUOVO valore richiesto x l'item
|
||||
/// </summary>
|
||||
public string reqValue { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// UID univoco
|
||||
/// </summary>
|
||||
public string uid { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Valore parametro (come stringa, decimali con ",", default VUOTO), sul CNC/PLC
|
||||
/// </summary>
|
||||
public string value { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Indica se sia abilitato in scrittura (WRITE)
|
||||
/// </summary>
|
||||
public bool writable { get; set; } = false;
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Struttura conf memorie PLC (inizialmente SIEMENS)
|
||||
/// </summary>
|
||||
public class plcMemMap
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Parametri ammessi per IOB x lettura
|
||||
/// = new Dictionary<string, dataConfTSVC>();
|
||||
/// </summary>
|
||||
public Dictionary<string, dataConfTSVC> mMapRead { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Parametri ammessi per IOB x scrittura
|
||||
/// = new Dictionary<string, dataConf>();
|
||||
/// </summary>
|
||||
public Dictionary<string, dataConf> mMapWrite { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
#endregion Public Classes
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,910 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using GWMS.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace GWMS.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(GWMSContext))]
|
||||
[Migration("20210802085127_RebootLog")]
|
||||
partial class RebootLog
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 64)
|
||||
.HasAnnotation("ProductVersion", "5.0.7");
|
||||
|
||||
modelBuilder.Entity("GWMS.Data.DatabaseModels.AnKeyValModel", b =>
|
||||
{
|
||||
b.Property<string>("KeyName")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)");
|
||||
|
||||
b.Property<string>("Descript")
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("varchar(250)")
|
||||
.HasComment("Descrizione dell'item");
|
||||
|
||||
b.Property<int>("ValFloat")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ValInt")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ValString")
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("varchar(250)");
|
||||
|
||||
b.HasKey("KeyName");
|
||||
|
||||
b.ToTable("AnKeyVal");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GWMS.Data.DatabaseModels.ConfigModel", b =>
|
||||
{
|
||||
b.Property<string>("KeyName")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("varchar(250)");
|
||||
|
||||
b.Property<string>("Val")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)");
|
||||
|
||||
b.Property<string>("ValStd")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)")
|
||||
.HasComment("Valore di default/riferimento per la variabile");
|
||||
|
||||
b.HasKey("KeyName");
|
||||
|
||||
b.ToTable("Config");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GWMS.Data.DatabaseModels.ItemModel", b =>
|
||||
{
|
||||
b.Property<int>("ItemId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ItemCode")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("varchar(100)");
|
||||
|
||||
b.Property<string>("ItemDesc")
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("varchar(250)");
|
||||
|
||||
b.Property<string>("ItemType")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)");
|
||||
|
||||
b.Property<string>("UM")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)");
|
||||
|
||||
b.HasKey("ItemId");
|
||||
|
||||
b.ToTable("Items");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GWMS.Data.DatabaseModels.ListValModel", b =>
|
||||
{
|
||||
b.Property<string>("TabName")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)")
|
||||
.HasColumnName("TabName");
|
||||
|
||||
b.Property<string>("FieldName")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)")
|
||||
.HasColumnName("FieldName");
|
||||
|
||||
b.Property<string>("Val")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)")
|
||||
.HasColumnName("Val");
|
||||
|
||||
b.Property<string>("Descript")
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("varchar(250)")
|
||||
.HasColumnName("Descript");
|
||||
|
||||
b.Property<int>("Ordinal")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("Ordinal");
|
||||
|
||||
b.HasKey("TabName", "FieldName", "Val");
|
||||
|
||||
b.ToTable("ListVal");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GWMS.Data.DatabaseModels.OrderModel", b =>
|
||||
{
|
||||
b.Property<int>("OrderId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtETA")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime>("DtExecEnd")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime>("DtExecStart")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime>("DtOrder")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<double>("ExecutionQty")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<string>("OrderCode")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("varchar(100)");
|
||||
|
||||
b.Property<string>("OrderDesc")
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("varchar(250)");
|
||||
|
||||
b.Property<double>("OrderQty")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<int>("PlantId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("SupplierId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("TransporterId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("OrderId");
|
||||
|
||||
b.HasIndex("PlantId");
|
||||
|
||||
b.HasIndex("SupplierId");
|
||||
|
||||
b.HasIndex("TransporterId");
|
||||
|
||||
b.ToTable("Order");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantDetailModel", b =>
|
||||
{
|
||||
b.Property<int>("PlantId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("LevelAct")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<double>("LevelMax")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<string>("PlantCode")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("varchar(100)");
|
||||
|
||||
b.Property<string>("PlantDesc")
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("varchar(250)");
|
||||
|
||||
b.Property<double>("PressAct")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<double>("PressBHAct")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<double>("PressBHMax")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<double>("PressBLAct")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<double>("PressBLMax")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<double>("PressMax")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.HasKey("PlantId");
|
||||
|
||||
b.ToTable("PlantDetail");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
PlantId = 1,
|
||||
LevelAct = 0.0,
|
||||
LevelMax = 28000.0,
|
||||
PlantCode = "PIZ03",
|
||||
PlantDesc = "Collecchio",
|
||||
PressAct = 0.0,
|
||||
PressBHAct = 0.0,
|
||||
PressBHMax = 270.0,
|
||||
PressBLAct = 0.0,
|
||||
PressBLMax = 270.0,
|
||||
PressMax = 19.0
|
||||
},
|
||||
new
|
||||
{
|
||||
PlantId = 2,
|
||||
LevelAct = 0.0,
|
||||
LevelMax = 28000.0,
|
||||
PlantCode = "PIZ04",
|
||||
PlantDesc = "Noceto",
|
||||
PressAct = 0.0,
|
||||
PressBHAct = 0.0,
|
||||
PressBHMax = 270.0,
|
||||
PressBLAct = 0.0,
|
||||
PressBLMax = 270.0,
|
||||
PressMax = 19.0
|
||||
},
|
||||
new
|
||||
{
|
||||
PlantId = 3,
|
||||
LevelAct = 0.0,
|
||||
LevelMax = 24000.0,
|
||||
PlantCode = "PIZ05",
|
||||
PlantDesc = "Baganzola",
|
||||
PressAct = 0.0,
|
||||
PressBHAct = 0.0,
|
||||
PressBHMax = 270.0,
|
||||
PressBLAct = 0.0,
|
||||
PressBLMax = 270.0,
|
||||
PressMax = 19.0
|
||||
},
|
||||
new
|
||||
{
|
||||
PlantId = 4,
|
||||
LevelAct = 0.0,
|
||||
LevelMax = 24000.0,
|
||||
PlantCode = "PIZ08",
|
||||
PlantDesc = "Pilastrello",
|
||||
PressAct = 0.0,
|
||||
PressBHAct = 0.0,
|
||||
PressBHMax = 270.0,
|
||||
PressBLAct = 0.0,
|
||||
PressBLMax = 270.0,
|
||||
PressMax = 19.0
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantLogModel", b =>
|
||||
{
|
||||
b.Property<int>("PlantDataId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtEvent")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("FluxType")
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("varchar(250)");
|
||||
|
||||
b.Property<int>("PlantId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("ValNumber")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<string>("ValString")
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("varchar(250)");
|
||||
|
||||
b.HasKey("PlantDataId");
|
||||
|
||||
b.HasIndex("PlantId");
|
||||
|
||||
b.ToTable("PlantLog");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantStatusModel", b =>
|
||||
{
|
||||
b.Property<int>("PlantId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("FluxType")
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("varchar(250)");
|
||||
|
||||
b.Property<DateTime>("DtEvent")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<double>("ValNumber")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<string>("ValString")
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("varchar(250)");
|
||||
|
||||
b.HasKey("PlantId", "FluxType");
|
||||
|
||||
b.ToTable("PlantStatus");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GWMS.Data.DatabaseModels.RebootLogModel", b =>
|
||||
{
|
||||
b.Property<int>("RecordId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtEvent")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Item")
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("varchar(250)");
|
||||
|
||||
b.Property<string>("Payload")
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("varchar(250)");
|
||||
|
||||
b.HasKey("RecordId");
|
||||
|
||||
b.ToTable("RebootLog");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GWMS.Data.DatabaseModels.SupplierModel", b =>
|
||||
{
|
||||
b.Property<int>("SupplierId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("SupplierCode")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("varchar(100)");
|
||||
|
||||
b.Property<string>("SupplierDesc")
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("varchar(250)");
|
||||
|
||||
b.HasKey("SupplierId");
|
||||
|
||||
b.ToTable("Supplier");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
SupplierId = 1,
|
||||
SupplierCode = "LIQUIGAS",
|
||||
SupplierDesc = "Liquigas"
|
||||
},
|
||||
new
|
||||
{
|
||||
SupplierId = 2,
|
||||
SupplierCode = "VULKANGAS",
|
||||
SupplierDesc = "Vulkangas"
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GWMS.Data.DatabaseModels.TransporterModel", b =>
|
||||
{
|
||||
b.Property<int>("TransporterId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("PositionLatitude")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<double>("PositionLongitude")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<DateTime>("PositionUpdated")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("TransporterCode")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("varchar(100)");
|
||||
|
||||
b.Property<string>("TransporterDesc")
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("varchar(250)");
|
||||
|
||||
b.HasKey("TransporterId");
|
||||
|
||||
b.ToTable("Transporter");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
TransporterId = 1,
|
||||
PositionLatitude = 0.0,
|
||||
PositionLongitude = 0.0,
|
||||
PositionUpdated = new DateTime(2021, 8, 2, 10, 51, 27, 549, DateTimeKind.Local).AddTicks(3264),
|
||||
TransporterCode = "LEVO",
|
||||
TransporterDesc = "Levorato"
|
||||
},
|
||||
new
|
||||
{
|
||||
TransporterId = 2,
|
||||
PositionLatitude = 0.0,
|
||||
PositionLongitude = 0.0,
|
||||
PositionUpdated = new DateTime(2021, 8, 2, 10, 51, 27, 549, DateTimeKind.Local).AddTicks(3842),
|
||||
TransporterCode = "TRAF",
|
||||
TransporterDesc = "Traffik"
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GWMS.Data.DatabaseModels.UserModel", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("AuthKey")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("varchar(100)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("varchar(250)");
|
||||
|
||||
b.Property<string>("Firstname")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("Lang")
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("varchar(10)");
|
||||
|
||||
b.Property<string>("Lastname")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)");
|
||||
|
||||
b.Property<int>("Livello")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MaskPlantId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MaskSupplierId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MaskTranspId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("SaltPasswd")
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("varchar(250)");
|
||||
|
||||
b.Property<string>("UserName")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)");
|
||||
|
||||
b.HasKey("UserId");
|
||||
|
||||
b.ToTable("Users");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
UserId = 1,
|
||||
AuthKey = "th1sIsTh3R1vrOfThNgt98",
|
||||
Email = "samuele@steamware.net",
|
||||
Firstname = "Samuele",
|
||||
IsActive = true,
|
||||
Lang = "IT",
|
||||
Lastname = "Locatelli",
|
||||
Livello = 1,
|
||||
MaskPlantId = 0,
|
||||
MaskSupplierId = 0,
|
||||
MaskTranspId = 0,
|
||||
SaltPasswd = "",
|
||||
UserName = "samuele.locatelli"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = 2,
|
||||
AuthKey = "th1sIsTh3R1vrOfThNgt91",
|
||||
Email = "giancarlo@steamware.net",
|
||||
Firstname = "Giancarlo",
|
||||
IsActive = true,
|
||||
Lang = "IT",
|
||||
Lastname = "Rottoli",
|
||||
Livello = 1,
|
||||
MaskPlantId = 0,
|
||||
MaskSupplierId = 0,
|
||||
MaskTranspId = 0,
|
||||
SaltPasswd = "",
|
||||
UserName = "giancarlo.rottoli"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = 3,
|
||||
AuthKey = "th1sIsTh3R1vrOfThNgt93",
|
||||
Email = "info@steamware.net",
|
||||
Firstname = "Steamware",
|
||||
IsActive = true,
|
||||
Lang = "IT",
|
||||
Lastname = "Admin",
|
||||
Livello = 1,
|
||||
MaskPlantId = 0,
|
||||
MaskSupplierId = 0,
|
||||
MaskTranspId = 0,
|
||||
SaltPasswd = "",
|
||||
UserName = "steamw.admin"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = 4,
|
||||
AuthKey = "th1sIsTh3R1vrOfThNgt97",
|
||||
Email = "a.pizzaferri@pizzaferripetroli.it",
|
||||
Firstname = "Angelo",
|
||||
IsActive = true,
|
||||
Lang = "IT",
|
||||
Lastname = "Pizzaferri",
|
||||
Livello = 2,
|
||||
MaskPlantId = 0,
|
||||
MaskSupplierId = 0,
|
||||
MaskTranspId = 0,
|
||||
SaltPasswd = "",
|
||||
UserName = "angelo.pizzaferri"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = 5,
|
||||
AuthKey = "th1sIsTh3R1vrOfThNgt99",
|
||||
Email = "andrei.valeanu@winnlab.it",
|
||||
Firstname = "Andrei",
|
||||
IsActive = true,
|
||||
Lang = "IT",
|
||||
Lastname = "Valeanu",
|
||||
Livello = 2,
|
||||
MaskPlantId = 0,
|
||||
MaskSupplierId = 0,
|
||||
MaskTranspId = 0,
|
||||
SaltPasswd = "",
|
||||
UserName = "andrei.valeanu"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = 6,
|
||||
AuthKey = "th1sIsTh3R1vrOfThNgt92",
|
||||
Email = "info@steamware.net",
|
||||
Firstname = "User",
|
||||
IsActive = true,
|
||||
Lang = "IT",
|
||||
Lastname = "LIQUIGAS",
|
||||
Livello = 4,
|
||||
MaskPlantId = 0,
|
||||
MaskSupplierId = 1,
|
||||
MaskTranspId = 0,
|
||||
SaltPasswd = "",
|
||||
UserName = "liquigas.user01"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = 7,
|
||||
AuthKey = "th1sIsTh3R1vrOfThNgt94",
|
||||
Email = "info@steamware.net",
|
||||
Firstname = "User",
|
||||
IsActive = true,
|
||||
Lang = "IT",
|
||||
Lastname = "VULKANGAS",
|
||||
Livello = 4,
|
||||
MaskPlantId = 0,
|
||||
MaskSupplierId = 2,
|
||||
MaskTranspId = 0,
|
||||
SaltPasswd = "",
|
||||
UserName = "vulkangas.user01"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = 8,
|
||||
AuthKey = "th1sIsTh3R1vrOfThNgt95",
|
||||
Email = "info@steamware.net",
|
||||
Firstname = "User",
|
||||
IsActive = true,
|
||||
Lang = "IT",
|
||||
Lastname = "LEVORATO",
|
||||
Livello = 4,
|
||||
MaskPlantId = 0,
|
||||
MaskSupplierId = 0,
|
||||
MaskTranspId = 1,
|
||||
SaltPasswd = "",
|
||||
UserName = "levorato.user01"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = 9,
|
||||
AuthKey = "th1sIsTh3R1vrOfThNgt96",
|
||||
Email = "info@steamware.net",
|
||||
Firstname = "User",
|
||||
IsActive = true,
|
||||
Lang = "IT",
|
||||
Lastname = "TRAFFIK",
|
||||
Livello = 4,
|
||||
MaskPlantId = 0,
|
||||
MaskSupplierId = 0,
|
||||
MaskTranspId = 2,
|
||||
SaltPasswd = "",
|
||||
UserName = "traffik.user01"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = 10,
|
||||
AuthKey = "th1sIsTh3R1vrOfThNgt96",
|
||||
Email = "info@steamware.net",
|
||||
Firstname = "Stazione",
|
||||
IsActive = true,
|
||||
Lang = "IT",
|
||||
Lastname = "Collecchio",
|
||||
Livello = 3,
|
||||
MaskPlantId = 1,
|
||||
MaskSupplierId = 0,
|
||||
MaskTranspId = 0,
|
||||
SaltPasswd = "",
|
||||
UserName = "piz03.user01"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = 11,
|
||||
AuthKey = "th1sIsTh3R1vrOfThNgt96",
|
||||
Email = "info@steamware.net",
|
||||
Firstname = "Stazione",
|
||||
IsActive = true,
|
||||
Lang = "IT",
|
||||
Lastname = "Noceto",
|
||||
Livello = 3,
|
||||
MaskPlantId = 2,
|
||||
MaskSupplierId = 0,
|
||||
MaskTranspId = 0,
|
||||
SaltPasswd = "",
|
||||
UserName = "piz04.user01"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = 12,
|
||||
AuthKey = "th1sIsTh3R1vrOfThNgt96",
|
||||
Email = "info@steamware.net",
|
||||
Firstname = "Stazione",
|
||||
IsActive = true,
|
||||
Lang = "IT",
|
||||
Lastname = "Baganzola",
|
||||
Livello = 3,
|
||||
MaskPlantId = 3,
|
||||
MaskSupplierId = 0,
|
||||
MaskTranspId = 0,
|
||||
SaltPasswd = "",
|
||||
UserName = "piz05.user01"
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = 13,
|
||||
AuthKey = "th1sIsTh3R1vrOfThNgt96",
|
||||
Email = "info@steamware.net",
|
||||
Firstname = "Stazione",
|
||||
IsActive = true,
|
||||
Lang = "IT",
|
||||
Lastname = "Pilastrello",
|
||||
Livello = 3,
|
||||
MaskPlantId = 4,
|
||||
MaskSupplierId = 0,
|
||||
MaskTranspId = 0,
|
||||
SaltPasswd = "",
|
||||
UserName = "piz08.user01"
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GWMS.Data.DatabaseModels.WeekPlanModel", b =>
|
||||
{
|
||||
b.Property<int>("WeekPlanId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("DayNum")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("DeliveryHour")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("varchar(250)");
|
||||
|
||||
b.Property<int>("PlantId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("SupplierId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("TransporterId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("WeekPlanId");
|
||||
|
||||
b.HasIndex("PlantId");
|
||||
|
||||
b.HasIndex("SupplierId");
|
||||
|
||||
b.HasIndex("TransporterId");
|
||||
|
||||
b.ToTable("WeekPlan");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
WeekPlanId = 1,
|
||||
DayNum = 1,
|
||||
DeliveryHour = 20,
|
||||
Note = "18K",
|
||||
PlantId = 2,
|
||||
SupplierId = 1,
|
||||
TransporterId = 1
|
||||
},
|
||||
new
|
||||
{
|
||||
WeekPlanId = 2,
|
||||
DayNum = 2,
|
||||
DeliveryHour = 20,
|
||||
Note = "18K",
|
||||
PlantId = 2,
|
||||
SupplierId = 1,
|
||||
TransporterId = 1
|
||||
},
|
||||
new
|
||||
{
|
||||
WeekPlanId = 3,
|
||||
DayNum = 3,
|
||||
DeliveryHour = 20,
|
||||
Note = "18K",
|
||||
PlantId = 2,
|
||||
SupplierId = 1,
|
||||
TransporterId = 2
|
||||
},
|
||||
new
|
||||
{
|
||||
WeekPlanId = 4,
|
||||
DayNum = 4,
|
||||
DeliveryHour = 15,
|
||||
Note = "9K",
|
||||
PlantId = 2,
|
||||
SupplierId = 1,
|
||||
TransporterId = 1
|
||||
},
|
||||
new
|
||||
{
|
||||
WeekPlanId = 5,
|
||||
DayNum = 4,
|
||||
DeliveryHour = 20,
|
||||
Note = "18K",
|
||||
PlantId = 2,
|
||||
SupplierId = 1,
|
||||
TransporterId = 1
|
||||
},
|
||||
new
|
||||
{
|
||||
WeekPlanId = 6,
|
||||
DayNum = 6,
|
||||
DeliveryHour = 20,
|
||||
Note = "18K",
|
||||
PlantId = 2,
|
||||
SupplierId = 1,
|
||||
TransporterId = 1
|
||||
},
|
||||
new
|
||||
{
|
||||
WeekPlanId = 7,
|
||||
DayNum = 2,
|
||||
DeliveryHour = 14,
|
||||
Note = "3K",
|
||||
PlantId = 3,
|
||||
SupplierId = 1,
|
||||
TransporterId = 1
|
||||
},
|
||||
new
|
||||
{
|
||||
WeekPlanId = 8,
|
||||
DayNum = 2,
|
||||
DeliveryHour = 15,
|
||||
Note = "15K",
|
||||
PlantId = 4,
|
||||
SupplierId = 1,
|
||||
TransporterId = 1
|
||||
},
|
||||
new
|
||||
{
|
||||
WeekPlanId = 9,
|
||||
DayNum = 2,
|
||||
DeliveryHour = 17,
|
||||
Note = "18K",
|
||||
PlantId = 1,
|
||||
SupplierId = 2,
|
||||
TransporterId = 2
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GWMS.Data.DatabaseModels.OrderModel", b =>
|
||||
{
|
||||
b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant")
|
||||
.WithMany()
|
||||
.HasForeignKey("PlantId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("GWMS.Data.DatabaseModels.SupplierModel", "Supplier")
|
||||
.WithMany()
|
||||
.HasForeignKey("SupplierId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("GWMS.Data.DatabaseModels.TransporterModel", "Transporter")
|
||||
.WithMany()
|
||||
.HasForeignKey("TransporterId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Plant");
|
||||
|
||||
b.Navigation("Supplier");
|
||||
|
||||
b.Navigation("Transporter");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantLogModel", b =>
|
||||
{
|
||||
b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant")
|
||||
.WithMany()
|
||||
.HasForeignKey("PlantId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Plant");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantStatusModel", b =>
|
||||
{
|
||||
b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant")
|
||||
.WithMany()
|
||||
.HasForeignKey("PlantId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Plant");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GWMS.Data.DatabaseModels.WeekPlanModel", b =>
|
||||
{
|
||||
b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant")
|
||||
.WithMany()
|
||||
.HasForeignKey("PlantId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("GWMS.Data.DatabaseModels.SupplierModel", "Supplier")
|
||||
.WithMany()
|
||||
.HasForeignKey("SupplierId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("GWMS.Data.DatabaseModels.TransporterModel", "Transporter")
|
||||
.WithMany()
|
||||
.HasForeignKey("TransporterId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Plant");
|
||||
|
||||
b.Navigation("Supplier");
|
||||
|
||||
b.Navigation("Transporter");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace GWMS.Data.Migrations
|
||||
{
|
||||
public partial class RebootLog : Migration
|
||||
{
|
||||
#region Protected Methods
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "RebootLog");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "Transporter",
|
||||
keyColumn: "TransporterId",
|
||||
keyValue: 1,
|
||||
column: "PositionUpdated",
|
||||
value: new DateTime(2021, 6, 25, 16, 15, 35, 940, DateTimeKind.Local).AddTicks(7402));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "Transporter",
|
||||
keyColumn: "TransporterId",
|
||||
keyValue: 2,
|
||||
column: "PositionUpdated",
|
||||
value: new DateTime(2021, 6, 25, 16, 15, 35, 940, DateTimeKind.Local).AddTicks(8022));
|
||||
}
|
||||
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "RebootLog",
|
||||
columns: table => new
|
||||
{
|
||||
RecordId = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
DtEvent = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
Item = table.Column<string>(type: "varchar(250)", maxLength: 250, nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Payload = table.Column<string>(type: "varchar(250)", maxLength: 250, nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_RebootLog", x => x.RecordId);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "Transporter",
|
||||
keyColumn: "TransporterId",
|
||||
keyValue: 1,
|
||||
column: "PositionUpdated",
|
||||
value: new DateTime(2021, 8, 2, 10, 51, 27, 549, DateTimeKind.Local).AddTicks(3264));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "Transporter",
|
||||
keyColumn: "TransporterId",
|
||||
keyValue: 2,
|
||||
column: "PositionUpdated",
|
||||
value: new DateTime(2021, 8, 2, 10, 51, 27, 549, DateTimeKind.Local).AddTicks(3842));
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -332,6 +332,28 @@ namespace GWMS.Data.Migrations
|
||||
b.ToTable("PlantStatus");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GWMS.Data.DatabaseModels.RebootLogModel", b =>
|
||||
{
|
||||
b.Property<int>("RecordId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtEvent")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Item")
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("varchar(250)");
|
||||
|
||||
b.Property<string>("Payload")
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("varchar(250)");
|
||||
|
||||
b.HasKey("RecordId");
|
||||
|
||||
b.ToTable("RebootLog");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GWMS.Data.DatabaseModels.SupplierModel", b =>
|
||||
{
|
||||
b.Property<int>("SupplierId")
|
||||
@@ -398,7 +420,7 @@ namespace GWMS.Data.Migrations
|
||||
TransporterId = 1,
|
||||
PositionLatitude = 0.0,
|
||||
PositionLongitude = 0.0,
|
||||
PositionUpdated = new DateTime(2021, 6, 25, 16, 15, 35, 940, DateTimeKind.Local).AddTicks(7402),
|
||||
PositionUpdated = new DateTime(2021, 8, 2, 10, 51, 27, 549, DateTimeKind.Local).AddTicks(3264),
|
||||
TransporterCode = "LEVO",
|
||||
TransporterDesc = "Levorato"
|
||||
},
|
||||
@@ -407,7 +429,7 @@ namespace GWMS.Data.Migrations
|
||||
TransporterId = 2,
|
||||
PositionLatitude = 0.0,
|
||||
PositionLongitude = 0.0,
|
||||
PositionUpdated = new DateTime(2021, 6, 25, 16, 15, 35, 940, DateTimeKind.Local).AddTicks(8022),
|
||||
PositionUpdated = new DateTime(2021, 8, 2, 10, 51, 27, 549, DateTimeKind.Local).AddTicks(3842),
|
||||
TransporterCode = "TRAF",
|
||||
TransporterDesc = "Traffik"
|
||||
});
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace GWMS.Data
|
||||
new PlantDetailModel { PlantId = 1, PlantCode = "PIZ03", PlantDesc = "Collecchio", LevelMax = 28000, PressMax = 19, PressBHMax = 270, PressBLMax = 270 },
|
||||
new PlantDetailModel { PlantId = 2, PlantCode = "PIZ04", PlantDesc = "Noceto", LevelMax = 28000, PressMax = 19, PressBHMax = 270, PressBLMax = 270 },
|
||||
new PlantDetailModel { PlantId = 3, PlantCode = "PIZ05", PlantDesc = "Baganzola", LevelMax = 24000, PressMax = 19, PressBHMax = 270, PressBLMax = 270 },
|
||||
new PlantDetailModel { PlantId = 4, PlantCode = "PIZ08", PlantDesc = "Pilastrello", LevelMax = 24000, PressMax = 19, PressBHMax = 270, PressBLMax = 270 }
|
||||
new PlantDetailModel { PlantId = 4, PlantCode = "PIZ08", PlantDesc = "Pilastrello", LevelMax = 25500, PressMax = 19, PressBHMax = 270, PressBLMax = 270 }
|
||||
);
|
||||
|
||||
// inizializzazione dei valori di default x Fornitori
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
DROP PROCEDURE IF EXISTS DecimateLog;
|
||||
|
||||
|
||||
DELIMITER $$
|
||||
|
||||
CREATE PROCEDURE DecimateLog(
|
||||
pStartDate DATETIME,
|
||||
pPlantId INT,
|
||||
pMinInt INT,
|
||||
pFluxType VARCHAR(250)
|
||||
)
|
||||
BEGIN
|
||||
|
||||
DECLARE pCounter INT DEFAULT 1;
|
||||
DECLARE pDt DATETIME DEFAULT pStartDate;
|
||||
DECLARE pMaxStep INT DEFAULT 1;
|
||||
|
||||
WHILE pDt <= DATE_ADD(NOW(), INTERVAL -pMinInt MINUTE) DO
|
||||
#SELECT pDt;
|
||||
CALL DeletePlantLogrecords(pDt, pPlantId, pMinInt, pFluxType);
|
||||
SET pCounter = pCounter + 1;
|
||||
SET pDt = DATE_ADD(pDt, INTERVAL pMinInt MINUTE);
|
||||
END WHILE;
|
||||
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
@@ -0,0 +1,42 @@
|
||||
|
||||
USE GWMS_PZZFRR;
|
||||
DROP PROCEDURE IF EXISTS DeletePlantLogrecords;
|
||||
|
||||
|
||||
DELIMITER $$
|
||||
|
||||
CREATE PROCEDURE DeletePlantLogrecords(
|
||||
IN pStartDate DATETIME,
|
||||
IN pPlantId INT,
|
||||
IN pMinInt INT,
|
||||
IN pFluxType VARCHAR(250)
|
||||
)
|
||||
BEGIN
|
||||
|
||||
# calcolo il primo record dalla data indicata
|
||||
DECLARE pDt DATETIME DEFAULT pStartDate;
|
||||
|
||||
SET pDt=
|
||||
(
|
||||
SELECT DtEvent
|
||||
FROM PlantLog
|
||||
WHERE PlantId = pPlantId
|
||||
AND FluxType = pFluxType
|
||||
AND DtEvent > pStartDate
|
||||
ORDER BY DtEvent
|
||||
LIMIT 1
|
||||
) + INTERVAL 10 SECOND;
|
||||
|
||||
#SELECT pDt;
|
||||
|
||||
# calcolo TUTTI i record successivi (da eliminare)
|
||||
DELETE
|
||||
FROM PlantLog
|
||||
WHERE PlantId = pPlantId
|
||||
AND FluxType = pFluxType
|
||||
AND DtEvent > pDt AND DtEvent < (pStartDate + INTERVAL pMinInt MINUTE)
|
||||
;
|
||||
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -76,7 +76,7 @@ namespace GWMS.UI.Controllers
|
||||
// verifico ci sia valore
|
||||
if (newItems != null)
|
||||
{
|
||||
fatto = _DataService.PlantLogInsert(newItems);
|
||||
fatto = _DataService.PlantLogInsert(newItems).Result;
|
||||
}
|
||||
if (fatto)
|
||||
{
|
||||
|
||||
@@ -14,6 +14,8 @@ using System.Diagnostics;
|
||||
using NLog;
|
||||
using GWMS.Data.DTO;
|
||||
using GWMS.Data.DatabaseModels;
|
||||
using static GWMS.Data.IobObjects;
|
||||
using System.Globalization;
|
||||
|
||||
namespace GWMS.UI.Data
|
||||
{
|
||||
@@ -88,20 +90,150 @@ namespace GWMS.UI.Data
|
||||
return new DistributedCacheEntryOptions().SetAbsoluteExpiration(DateTime.Now.AddSeconds(numSecAbsExp)).SetSlidingExpiration(TimeSpan.FromSeconds(numSecSliExp));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera PlantDTO e aggiorno valori attuali (se presente...)
|
||||
/// ATTENZIONE: i dati sono sempre ricevuti PER SINGOLO PlantId!!!
|
||||
/// </summary>
|
||||
/// <param name="newItems"></param>
|
||||
private async Task updateCurrDTO(List<PlantLogModel> newItems)
|
||||
{
|
||||
List<PlantDTO> dbResult = new List<PlantDTO>();
|
||||
int PlantId = newItems.FirstOrDefault().PlantId;
|
||||
string cacheKey = "DATA:PLANTS:ListDTO";
|
||||
string rawData;
|
||||
var redisDataList = await distributedCache.GetAsync(cacheKey);
|
||||
if (redisDataList != null)
|
||||
{
|
||||
rawData = Encoding.UTF8.GetString(redisDataList);
|
||||
dbResult = JsonConvert.DeserializeObject<List<PlantDTO>>(rawData);
|
||||
|
||||
// ora ciclo x ogni flusso/macchina l'ultimo record
|
||||
List<PlantLogModel> lastByFlux = newItems
|
||||
.OrderByDescending(x => x.DtEvent)
|
||||
.GroupBy(g => g.FluxType)
|
||||
.Select(s => s.First())
|
||||
.ToList();
|
||||
// aggiorno il DTO x i valori trovati...
|
||||
var currDto = dbResult.Where(x => x.PlantId == PlantId).FirstOrDefault();
|
||||
|
||||
// verifico SE c'è Level
|
||||
var lastLev = lastByFlux.Where(x => x.FluxType == "Level").FirstOrDefault();
|
||||
if (lastLev != null)
|
||||
{
|
||||
currDto.LevelAct = lastLev.ValNumber;
|
||||
}
|
||||
|
||||
// verifico SE c'è MainPress
|
||||
var lastMain = lastByFlux.Where(x => x.FluxType == "MainPress").FirstOrDefault();
|
||||
if (lastMain != null)
|
||||
{
|
||||
if (currDto.PressAct.ContainsKey("Main"))
|
||||
{
|
||||
currDto.PressAct["Main"] = lastMain.ValNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
currDto.PressAct.Add("Main", lastMain.ValNumber);
|
||||
}
|
||||
}
|
||||
|
||||
// verifico SE c'è PressBH
|
||||
var lastBH = lastByFlux.Where(x => x.FluxType == "PressBH").FirstOrDefault();
|
||||
if (lastBH != null)
|
||||
{
|
||||
if (currDto.PressAct.ContainsKey("BH"))
|
||||
{
|
||||
currDto.PressAct["BH"] = lastBH.ValNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
currDto.PressAct.Add("BH", lastBH.ValNumber);
|
||||
}
|
||||
}
|
||||
|
||||
// verifico SE c'è PressBL
|
||||
var lastBL = lastByFlux.Where(x => x.FluxType == "PressBL").FirstOrDefault();
|
||||
if (lastBL != null)
|
||||
{
|
||||
if (currDto.PressAct.ContainsKey("BL"))
|
||||
{
|
||||
currDto.PressAct["BL"] = lastBL.ValNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
currDto.PressAct.Add("BL", lastBL.ValNumber);
|
||||
}
|
||||
}
|
||||
|
||||
// salvo DTO!
|
||||
rawData = JsonConvert.SerializeObject(dbResult);
|
||||
redisDataList = Encoding.UTF8.GetBytes(rawData);
|
||||
await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(true));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Hash dati EXE TASK x la macchina specificata
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
protected static string exeTaskHash(string idxMacchina)
|
||||
{
|
||||
return mHash(string.Format("ExeTask:{0}", idxMacchina));
|
||||
}
|
||||
|
||||
protected string getCacheKey(string TableName, SelectOrderData CurrFilter)
|
||||
{
|
||||
string answ = $"{TableName}:P_{CurrFilter.PlantId:00}:S_{CurrFilter.SupplierId:00}:T_{CurrFilter.TransporterId:00}:D_{CurrFilter.DateStart:yyyyMMddHHmm}_{CurrFilter.DateEnd:yyyyMMddHHmm}";
|
||||
return answ;
|
||||
}
|
||||
|
||||
protected async Task<List<PlantLogModel>> PlantLogGetLastByFlux(int PlantId)
|
||||
{
|
||||
List<PlantLogModel> lastValues = new List<PlantLogModel>();
|
||||
// cerco in cache
|
||||
string cacheKey = $"DATA:PLANTS:LastFlux:{PlantId}";
|
||||
string rawData;
|
||||
var redisDataList = await distributedCache.GetAsync(cacheKey);
|
||||
if (redisDataList != null)
|
||||
{
|
||||
rawData = Encoding.UTF8.GetString(redisDataList);
|
||||
lastValues = JsonConvert.DeserializeObject<List<PlantLogModel>>(rawData);
|
||||
}
|
||||
// altrimenti DB e salvo...
|
||||
else
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
lastValues = dbController.PlantLogGetLastByFlux(PlantId);
|
||||
rawData = JsonConvert.SerializeObject(lastValues);
|
||||
redisDataList = Encoding.UTF8.GetBytes(rawData);
|
||||
await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(true));
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Info($"Effettuata lettura da DB + caching per PlantLogGetLastByFlux: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
return await Task.FromResult(lastValues);
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Hash Redis contenente i dati MP di una specifico TYPE (es StatusMacchina, StateMachineIngressi, ...)
|
||||
/// </summary>
|
||||
/// <param name="dataType"></param>
|
||||
/// <returns></returns>
|
||||
public static string mHash(string dataType)
|
||||
{
|
||||
return $"DATA:{dataType}";
|
||||
}
|
||||
|
||||
public async Task<List<GWMS.Data.DatabaseModels.ConfigModel>> ConfigGetAll()
|
||||
{
|
||||
//return Task.FromResult(dbController.ActionsGetAll());
|
||||
@@ -129,6 +261,26 @@ namespace GWMS.UI.Data
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
public PlantLogModel convertFluxToPL(int plantId, flogData origData)
|
||||
{
|
||||
// cerco di ottenere un val in cifre
|
||||
double valDbl = 0;
|
||||
NumberStyles style = NumberStyles.Number;
|
||||
CultureInfo culture = CultureInfo.CreateSpecificCulture("it-IT");
|
||||
double.TryParse(origData.valore.Replace(".", ","), style, culture, out valDbl);
|
||||
TimeSpan delta = origData.dtCurr.Subtract(origData.dtEve);
|
||||
PlantLogModel answ = new PlantLogModel()
|
||||
{
|
||||
FluxType = origData.flux,
|
||||
ValNumber = valDbl,
|
||||
ValString = origData.valore,
|
||||
PlantId = plantId,
|
||||
DtEvent = DateTime.Now.Subtract(delta)
|
||||
};
|
||||
|
||||
return answ;
|
||||
}
|
||||
|
||||
public async Task<bool> HasPlantLog()
|
||||
{
|
||||
return await Task.FromResult(dbController.HasPlantLog());
|
||||
@@ -161,6 +313,34 @@ namespace GWMS.UI.Data
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <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>> mTaskMacchina(string idxMacchina)
|
||||
{
|
||||
// hard coded dimensione vettore DatiMacchine
|
||||
Dictionary<string, string> answ = new Dictionary<string, string>();
|
||||
// ORA recupero da memoria redis...
|
||||
try
|
||||
{
|
||||
string cacheKey = exeTaskHash(idxMacchina);
|
||||
string rawData;
|
||||
var redisDataList = await distributedCache.GetAsync(cacheKey);
|
||||
if (redisDataList != null)
|
||||
{
|
||||
rawData = Encoding.UTF8.GetString(redisDataList);
|
||||
answ = JsonConvert.DeserializeObject<Dictionary<string, string>>(rawData);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Info($"Errore in recupero dati EXE TASK x Redis mTaskMacchina - idxMacchina {idxMacchina}{Environment.NewLine}{exc}");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
public async Task<List<OrderModel>> OrdersGetFilt(SelectOrderData CurrFilter)
|
||||
{
|
||||
List<OrderModel> dbResult = new List<OrderModel>();
|
||||
@@ -212,9 +392,51 @@ namespace GWMS.UI.Data
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
public bool PlantLogInsert(List<PlantLogModel> newItems)
|
||||
public async Task<bool> PlantLogInsert(List<PlantLogModel> newItems)
|
||||
{
|
||||
return dbController.PlantLogInsertNew(newItems);
|
||||
// init valori
|
||||
int IntervalMin = 60;
|
||||
int.TryParse(_configuration["IntervalMin"], out IntervalMin);
|
||||
List<PlantLogModel> item2insert = new List<PlantLogModel>();
|
||||
int PlantId = newItems.FirstOrDefault().PlantId;
|
||||
// aggiorno valori ACT x DTO
|
||||
await updateCurrDTO(newItems);
|
||||
|
||||
// recupero ultimi inseriti
|
||||
List<PlantLogModel> lastValues = await PlantLogGetLastByFlux(PlantId);
|
||||
// verifico i flussi presenti tra quelli ricevuti
|
||||
List<string> fluxList = newItems
|
||||
.GroupBy(g => g.FluxType)
|
||||
.Select(s => s.First().FluxType)
|
||||
.ToList();
|
||||
foreach (var item in fluxList)
|
||||
{
|
||||
// cerco se c'è valore...
|
||||
var lastInserted = lastValues.Where(x => x.FluxType == item).FirstOrDefault();
|
||||
DateTime dateLimit = DateTime.Today.AddDays(-1);
|
||||
if (lastInserted != null)
|
||||
{
|
||||
// per ogni flusso calcolo il valore minimo x inserimento (arrotondando a minInt)
|
||||
dateLimit = dbController.DateRoundEnd(lastInserted.DtEvent, IntervalMin);
|
||||
}
|
||||
|
||||
// cerco se ho record > valore minimo x ogni flusso ricevuto
|
||||
List<PlantLogModel> insCandidates = newItems.Where(x => x.FluxType == item && x.DtEvent >= dateLimit).ToList();
|
||||
|
||||
while (insCandidates.Count > 0)
|
||||
{
|
||||
var newRec = insCandidates.First();
|
||||
// il primo lo accodo da inserire
|
||||
item2insert.Add(newRec);
|
||||
// calcolo nuovo veto
|
||||
dateLimit = dbController.DateRoundEnd(newRec.DtEvent, IntervalMin);
|
||||
// ...e se ho record accodo
|
||||
insCandidates = newItems.Where(x => x.FluxType == item && x.DtEvent >= dateLimit).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
// faccio vero insert
|
||||
return await Task.FromResult(dbController.PlantLogInsertNew(item2insert));
|
||||
}
|
||||
|
||||
public async Task<List<PlantDTO>> PlantsGetAll()
|
||||
@@ -232,7 +454,9 @@ namespace GWMS.UI.Data
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbController.GetPlantsDTO();
|
||||
int maxRec = 100;
|
||||
int.TryParse(_configuration["MaxLogRecord"], out maxRec);
|
||||
dbResult = dbController.GetPlantsDTO(maxRec);
|
||||
rawData = JsonConvert.SerializeObject(dbResult);
|
||||
redisDataList = Encoding.UTF8.GetBytes(rawData);
|
||||
await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(true));
|
||||
@@ -243,6 +467,28 @@ namespace GWMS.UI.Data
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
public async Task<PlantDTO> PlantsGetByCode(string PlantCode)
|
||||
{
|
||||
PlantDTO answ = new PlantDTO();
|
||||
var ListRecords = await PlantsGetAll();
|
||||
var found = ListRecords.Where(x => x.PlantCode == PlantCode).FirstOrDefault();
|
||||
if (found != null)
|
||||
{
|
||||
answ = found;
|
||||
}
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
public void RebootLogInsert(RebootLogModel newItem)
|
||||
{
|
||||
try
|
||||
{
|
||||
dbController.RecordRebootLog(newItem);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
|
||||
public async Task<bool> RegenDB(int numDays, int stepMin = 30, int maxHourRate = 800)
|
||||
{
|
||||
return await Task.FromResult(dbController.RegenDB(1, numDays, stepMin, maxHourRate));
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<Version>1.0.2108.0515</Version>
|
||||
<UserSecretsId>95c9f021-52d1-4390-a670-5810b7b777b0</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,28 +1,38 @@
|
||||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:26659",
|
||||
"sslPort": 44339
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"GWMS.UI": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": "true",
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:5003;http://localhost:5002",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:26659",
|
||||
"sslPort": 44339
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"GWMS.UI": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": "true",
|
||||
"applicationUrl": "https://localhost:5003;http://localhost:5002"
|
||||
},
|
||||
"WSL 2": {
|
||||
"commandName": "WSL2",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "https://localhost:5003",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_URLS": "https://localhost:5003;http://localhost:5002",
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"distributionName": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -113,6 +113,9 @@ namespace GWMS.UI
|
||||
DbConfig.InitDb(dbServerAddr, nKey, sKey);
|
||||
// inizializzo il DB e creo (se necessario) l'utente
|
||||
DbConfig.CheckUser(nKey, sKey);
|
||||
// verifico se serve applicazione migrazioni
|
||||
//DbConfig.ExecMigrationMain();
|
||||
//DbConfig.ExecMigrationIdentity();
|
||||
|
||||
// altri parametri per check vari
|
||||
string connStringDB = DbConfig.CONNECTION_STRING;
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
"nKey": "PZZFRR",
|
||||
"sKey": "M3T@n0"
|
||||
},
|
||||
"IntervalMin": 60,
|
||||
"MaxLogRecord": 240,
|
||||
"ZCodeUrl": "https://qrcode.steamware.net/",
|
||||
"logo": "img/LogoPizzaferri.jpg"
|
||||
}
|
||||
@@ -20,7 +20,7 @@ Set-Content -Path $FileVers -Value $currRelNum
|
||||
# replace x manifest
|
||||
$manData = Get-Content $FileManIn
|
||||
$manData = $manData -replace "1.0.0.0", $currRelNum
|
||||
$manData = $manData -replace "{{DIRNAME}}", "MP-STATS"
|
||||
$manData = $manData -replace "{{DIRNAME}}", "GWMS"
|
||||
$manData = $manData -replace "{{BRANCHNAME}}", "stable/0"
|
||||
$manData = $manData -replace "{{PACKNAME}}", "GWMS.UI"
|
||||
Set-Content -Path $FileManOut -Value $manData
|
||||
|
||||
@@ -9,8 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GWMS.UI", "GWMS.UI\GWMS.UI.
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GWMS.User", "GWMS.User\GWMS.User.csproj", "{3112DC8B-4752-4D43-A9A7-41AC40A38DFD}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GWMS.API", "GWMS.API\GWMS.API.csproj", "{F455A3A5-89FD-49E3-B5B6-ED8B0DCEC444}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -29,10 +27,6 @@ Global
|
||||
{3112DC8B-4752-4D43-A9A7-41AC40A38DFD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3112DC8B-4752-4D43-A9A7-41AC40A38DFD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3112DC8B-4752-4D43-A9A7-41AC40A38DFD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F455A3A5-89FD-49E3-B5B6-ED8B0DCEC444}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F455A3A5-89FD-49E3-B5B6-ED8B0DCEC444}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F455A3A5-89FD-49E3-B5B6-ED8B0DCEC444}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F455A3A5-89FD-49E3-B5B6-ED8B0DCEC444}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<body>
|
||||
<i>Modulo statistiche MAPO</i>
|
||||
<i>GWMS - Gas Warehouse Management System</i>
|
||||
<h4>Versione: {{CURRENT-REL}}</h4>
|
||||
<br />
|
||||
Note di rilascio:
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
<b>Ultime modifiche:</b>
|
||||
@@ -11,6 +10,7 @@
|
||||
<li>
|
||||
<b>v.1.* →</b>
|
||||
<ul>
|
||||
<li>INtegrazione metodi MAPO IOB</li>
|
||||
<li>Prima release dotnet5</li>
|
||||
<li>Integrazione EFCore</li>
|
||||
</ul>
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<body>
|
||||
<i>Modulo statistiche MAPO</i>
|
||||
<h4>Versione: 1.0.2106.3010</h4>
|
||||
<br />
|
||||
Note di rilascio:
|
||||
<i>GWMS - Gas Warehouse Management System</i>
|
||||
<h4>Versione: 1.0.2108.0515</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
<b>Ultime modifiche:</b>
|
||||
@@ -11,6 +10,7 @@
|
||||
<li>
|
||||
<b>v.1.* →</b>
|
||||
<ul>
|
||||
<li>INtegrazione metodi MAPO IOB</li>
|
||||
<li>Prima release dotnet5</li>
|
||||
<li>Integrazione EFCore</li>
|
||||
</ul>
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.0.2106.3010
|
||||
1.0.2108.0515
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>1.0.2106.3010</version>
|
||||
<url>http://nexus.steamware.net/repository/SWS/MP-STATS/stable/0/GWMS.UI.zip</url>
|
||||
<changelog>http://nexus.steamware.net/repository/SWS/MP-STATS/stable/0/ChangeLog.html</changelog>
|
||||
<version>1.0.2108.0515</version>
|
||||
<url>http://nexus.steamware.net/repository/SWS/GWMS/stable/0/GWMS.UI.zip</url>
|
||||
<changelog>http://nexus.steamware.net/repository/SWS/GWMS/stable/0/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user