Avanzamento telemetria:
- altri metodi tracciati - modifica json x prod - aggiunta Async vari
This commit is contained in:
@@ -464,17 +464,17 @@ namespace GWMS.Data.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
public List<WeekPlanModel> GetWeekPlan()
|
||||
public async Task<List<WeekPlanModel>> GetWeekPlanAsync()
|
||||
{
|
||||
List<WeekPlanModel> dbResult = new List<WeekPlanModel>();
|
||||
using (GWMSContext localDbCtx = new GWMSContext(_configuration))
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetPlantSupplWeekPlan
|
||||
.Include(p => p.Plant)
|
||||
.Include(s => s.Supplier)
|
||||
.Include(t => t.Transporter)
|
||||
.ToList();
|
||||
dbResult = await localDbCtx
|
||||
.DbSetPlantSupplWeekPlan
|
||||
.Include(p => p.Plant)
|
||||
.Include(s => s.Supplier)
|
||||
.Include(t => t.Transporter)
|
||||
.ToListAsync();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
@@ -511,17 +511,17 @@ namespace GWMS.Data.Controllers
|
||||
try
|
||||
{
|
||||
#endif
|
||||
if (Item2Del != null)
|
||||
{
|
||||
var rec2del = await localDbCtx
|
||||
.DbSetOrders
|
||||
.Where(x => x.OrderId == Item2Del.OrderId)
|
||||
.FirstOrDefaultAsync();
|
||||
localDbCtx
|
||||
.DbSetOrders
|
||||
.Remove(rec2del);
|
||||
int numDone = await localDbCtx.SaveChangesAsync();
|
||||
done = numDone > 0;
|
||||
if (Item2Del != null)
|
||||
{
|
||||
var rec2del = await localDbCtx
|
||||
.DbSetOrders
|
||||
.Where(x => x.OrderId == Item2Del.OrderId)
|
||||
.FirstOrDefaultAsync();
|
||||
localDbCtx
|
||||
.DbSetOrders
|
||||
.Remove(rec2del);
|
||||
int numDone = await localDbCtx.SaveChangesAsync();
|
||||
done = numDone > 0;
|
||||
}
|
||||
#if false
|
||||
}
|
||||
@@ -530,7 +530,7 @@ namespace GWMS.Data.Controllers
|
||||
Log.Error($"Eccezione in OrderDeleteAsync:{Environment.NewLine}{exc}");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
@@ -548,18 +548,18 @@ namespace GWMS.Data.Controllers
|
||||
try
|
||||
{
|
||||
#endif
|
||||
if (orderId > 0)
|
||||
{
|
||||
var rec2del = await localDbCtx
|
||||
.DbSetOrders
|
||||
.Where(x => x.OrderId == orderId)
|
||||
.FirstOrDefaultAsync();
|
||||
localDbCtx
|
||||
.DbSetOrders
|
||||
.Remove(rec2del);
|
||||
int numDone = await localDbCtx.SaveChangesAsync();
|
||||
done = numDone > 0;
|
||||
}
|
||||
if (orderId > 0)
|
||||
{
|
||||
var rec2del = await localDbCtx
|
||||
.DbSetOrders
|
||||
.Where(x => x.OrderId == orderId)
|
||||
.FirstOrDefaultAsync();
|
||||
localDbCtx
|
||||
.DbSetOrders
|
||||
.Remove(rec2del);
|
||||
int numDone = await localDbCtx.SaveChangesAsync();
|
||||
done = numDone > 0;
|
||||
}
|
||||
#if false
|
||||
}
|
||||
catch (Exception exc)
|
||||
@@ -567,7 +567,7 @@ namespace GWMS.Data.Controllers
|
||||
Log.Error($"Eccezione in OrderDelete:{Environment.NewLine}{exc}");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
@@ -1121,52 +1121,60 @@ namespace GWMS.Data.Controllers
|
||||
/// </summary>
|
||||
/// <param name="updItem"></param>
|
||||
/// <returns></returns>
|
||||
public bool PlantUpdate(PlantDTO updItem)
|
||||
public async Task<bool> PlantUpdateAsync(PlantDTO updItem)
|
||||
{
|
||||
bool done = false;
|
||||
using (GWMSContext localDbCtx = new GWMSContext(_configuration))
|
||||
{
|
||||
#if false
|
||||
try
|
||||
{
|
||||
#endif
|
||||
PlantDetailModel currData = await localDbCtx
|
||||
.DbSetPlant
|
||||
.Where(x => x.PlantId == updItem.PlantId)
|
||||
.FirstOrDefaultAsync();
|
||||
if (currData != null)
|
||||
{
|
||||
PlantDetailModel currData = localDbCtx
|
||||
.DbSetPlant
|
||||
.Where(x => x.PlantId == updItem.PlantId)
|
||||
.FirstOrDefault();
|
||||
if (currData != null)
|
||||
{
|
||||
// aggiorno valori
|
||||
currData.LevelReorder = updItem.LevelReorder;
|
||||
currData.LevelMax = updItem.LevelMax;
|
||||
localDbCtx.Entry(currData).State = EntityState.Modified;
|
||||
localDbCtx.SaveChanges();
|
||||
}
|
||||
done = true;
|
||||
// aggiorno valori
|
||||
currData.LevelReorder = updItem.LevelReorder;
|
||||
currData.LevelMax = updItem.LevelMax;
|
||||
localDbCtx.Entry(currData).State = EntityState.Modified;
|
||||
int numDone = await localDbCtx.SaveChangesAsync();
|
||||
done = numDone > 0;
|
||||
}
|
||||
#if false
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in PlantUpdate:{Environment.NewLine}{exc}");
|
||||
}
|
||||
Log.Error($"Eccezione in PlantUpdateAsync:{Environment.NewLine}{exc}");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
public bool RecordRebootLog(RebootLogModel newItem)
|
||||
public async Task<bool> RecordRebootLogAsync(RebootLogModel newItem)
|
||||
{
|
||||
bool done = false;
|
||||
using (GWMSContext localDbCtx = new GWMSContext(_configuration))
|
||||
{
|
||||
#if false
|
||||
try
|
||||
{
|
||||
localDbCtx
|
||||
.DbRebootLog
|
||||
.Add(newItem);
|
||||
localDbCtx.SaveChanges();
|
||||
done = true;
|
||||
{
|
||||
#endif
|
||||
localDbCtx
|
||||
.DbRebootLog
|
||||
.Add(newItem);
|
||||
int numRec = await localDbCtx.SaveChangesAsync();
|
||||
done = numRec > 0;
|
||||
#if false
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante RecordRebootLog{Environment.NewLine}{exc}");
|
||||
}
|
||||
Log.Error($"Eccezione durante RecordRebootLogAsync{Environment.NewLine}{exc}");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="form-row text-light">
|
||||
<div class="col-5 pr-0 text-left">
|
||||
GWMS <span class="small">v.@version</span>
|
||||
<string>GWMS</string> <span class="small">v.@version</span><small> | Srv: @nodeId</small>
|
||||
</div>
|
||||
<div class="col-7 pl-0 text-right">
|
||||
<span class="small">@adesso</span>
|
||||
|
||||
@@ -49,6 +49,8 @@ namespace GWMS.UI.Components
|
||||
|
||||
protected DateTime adesso = DateTime.Now;
|
||||
|
||||
private string nodeId = Environment.MachineName;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Methods
|
||||
@@ -57,10 +59,20 @@ namespace GWMS.UI.Components
|
||||
{
|
||||
var rawVers = typeof(Program).Assembly.GetName().Version;
|
||||
version = rawVers != null ? rawVers : new Version("0.0.0.0");
|
||||
nodeId = Environment.MachineName;
|
||||
#if DEBUG
|
||||
// nome completo...
|
||||
#else
|
||||
//Se non fosse develop --> prende gli ultimi 2 caratteri(es. "01")
|
||||
if (nodeId.Length > 2)
|
||||
{
|
||||
nodeId = nodeId.Substring(nodeId.Length - 2);
|
||||
}
|
||||
#endif
|
||||
StartTimer();
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
|
||||
@@ -95,8 +95,8 @@ namespace GWMS.UI.Components
|
||||
|
||||
protected async Task ReloadAllData()
|
||||
{
|
||||
suppList = await DataService.SuppliersGetAll();
|
||||
transpList = await DataService.TransportersGetAll();
|
||||
suppList = await DataService.SuppliersGetAllAsync();
|
||||
transpList = await DataService.TransportersGetAllAsync();
|
||||
|
||||
// vedere anche https://www.mikesdotnetting.com/article/340/working-with-query-strings-in-blazor
|
||||
var uri = NavManager.ToAbsoluteUri(NavManager.Uri);
|
||||
|
||||
@@ -205,7 +205,7 @@ namespace GWMS.UI.Components
|
||||
|
||||
private async Task ReloadData()
|
||||
{
|
||||
plantsData = await DataService.PlantDtoGetAll();
|
||||
plantsData = await DataService.PlantDtoGetAllAsync();
|
||||
// recupero dato del plant corrente
|
||||
currPlantData = plantsData.Where(x => x.PlantId == PlantId).FirstOrDefault();
|
||||
// solo se ho valore QR selezionato
|
||||
|
||||
@@ -158,7 +158,7 @@
|
||||
|
||||
protected async Task ReloadAllData()
|
||||
{
|
||||
transpList = await DataService.TransportersGetAll();
|
||||
transpList = await DataService.TransportersGetAllAsync();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -111,7 +111,7 @@
|
||||
|
||||
protected async Task ReloadAllData()
|
||||
{
|
||||
transpList = await DataService.TransportersGetAll();
|
||||
transpList = await DataService.TransportersGetAllAsync();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -166,7 +166,7 @@ namespace GWMS.UI.Components
|
||||
|
||||
if (_currItem != null)
|
||||
{
|
||||
await DataService.updateMachineParameter(IdxMacchina, _currItem.uid, _currItem.reqValue);
|
||||
await DataService.UpdateMachineParameterAsync(IdxMacchina, _currItem.uid, _currItem.reqValue);
|
||||
await DataUpdated.InvokeAsync(0);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace GWMS.UI.Components
|
||||
if (value)
|
||||
{
|
||||
// test set parametri + invio...
|
||||
await DataService.ParamsSendCheck();
|
||||
await DataService.ParamsSendCheckAsync();
|
||||
paramSent = true;
|
||||
}
|
||||
await ReloadData();
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace GWMS.UI.Components
|
||||
{
|
||||
if (_currItem != null)
|
||||
{
|
||||
await DataService.PlantUpdate(_currItem);
|
||||
await DataService.PlantUpdateAsync(_currItem);
|
||||
await DataUpdated.InvokeAsync(0);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace GWMS.UI.Components
|
||||
DateStart = DateTime.Today.AddDays(-1),
|
||||
ShowClosed = false
|
||||
};
|
||||
PlantLevelDto = await DataService.PlantsAnalisysByFilt(plantLevFilt);
|
||||
PlantLevelDto = await DataService.PlantsAnalisysByFiltAsync(plantLevFilt);
|
||||
|
||||
// aggiunta delay o non riesce a disegnare
|
||||
int ChartWaitDelay = 150;
|
||||
|
||||
@@ -195,7 +195,7 @@
|
||||
{
|
||||
if (_currItem != null)
|
||||
{
|
||||
DataService.WeekPlanUpdate(_currItem);
|
||||
DataService.WeekPlanUpdateAsync(_currItem);
|
||||
await DataUpdated.InvokeAsync(1);
|
||||
}
|
||||
else
|
||||
@@ -211,7 +211,7 @@
|
||||
|
||||
if (_currItem != null)
|
||||
{
|
||||
DataService.WeekPlanDelete(_currItem);
|
||||
DataService.WeekPlanDeleteAsync(_currItem);
|
||||
await DataUpdated.InvokeAsync(1);
|
||||
}
|
||||
else
|
||||
@@ -232,9 +232,9 @@
|
||||
|
||||
protected async Task ReloadAllData()
|
||||
{
|
||||
PlantsList = await DataService.PlantsList();
|
||||
SuppliersList = await DataService.SuppliersGetAll();
|
||||
TransportersList = await DataService.TransportersGetAll();
|
||||
PlantsList = await DataService.PlantsListAsync();
|
||||
SuppliersList = await DataService.SuppliersGetAllAsync();
|
||||
TransportersList = await DataService.TransportersGetAllAsync();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -175,7 +175,7 @@ namespace GWMS.UI.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
var currPlant = await _DataService.PlantsGetByCode(id);
|
||||
var currPlant = await _DataService.PlantsGetByCodeAsync(id);
|
||||
answ = (currPlant != null && currPlant.PlantId > 0) ? "OK" : "NO";
|
||||
}
|
||||
return answ;
|
||||
@@ -292,7 +292,7 @@ namespace GWMS.UI.Controllers
|
||||
}
|
||||
|
||||
// recupero plant!
|
||||
var currPlant = await _DataService.PlantsGetByCode(id);
|
||||
var currPlant = await _DataService.PlantsGetByCodeAsync(id);
|
||||
if (currPlant != null && currPlant.PlantId > 0)
|
||||
{
|
||||
// converto in plantLogModel...
|
||||
@@ -308,7 +308,7 @@ namespace GWMS.UI.Controllers
|
||||
List<PlantLogModel> newData = new List<PlantLogModel>();
|
||||
newData.Add(newItem);
|
||||
// insert!
|
||||
fatto = await _DataService.PlantLogInsert(newData);
|
||||
fatto = await _DataService.PlantLogInsertAsync(newData);
|
||||
|
||||
// effettuo SEMPRE verifica per ricalcolo ordini...
|
||||
await _DataService.checkLevels();
|
||||
@@ -345,15 +345,15 @@ namespace GWMS.UI.Controllers
|
||||
if (rawData != null && !string.IsNullOrEmpty(id))
|
||||
{
|
||||
// recupero plant!
|
||||
var currPlant = await _DataService.PlantsGetByCode(id);
|
||||
var currPlant = await _DataService.PlantsGetByCodeAsync(id);
|
||||
if (currPlant != null && currPlant.PlantId > 0)
|
||||
{
|
||||
// conversione dati
|
||||
List<PlantLogModel> plData = rawData.fluxData.Select(jpl => _DataService.convertFluxToPL(currPlant.PlantId, jpl)).ToList();
|
||||
Log.Debug($"flogJson | {id} | Convertiti {plData.Count} record");
|
||||
// insert!
|
||||
fatto = await _DataService.PlantLogInsert(plData);
|
||||
Log.Debug($"flogJson | {id} | PlantLogInsert --> esito: {fatto}");
|
||||
fatto = await _DataService.PlantLogInsertAsync(plData);
|
||||
Log.Debug($"flogJson | {id} | PlantLogInsertAsync --> esito: {fatto}");
|
||||
|
||||
// effettuo SEMPRE verifica per ricalcolo ordini...
|
||||
await _DataService.checkLevels();
|
||||
@@ -378,7 +378,7 @@ namespace GWMS.UI.Controllers
|
||||
if (trovato.writable && string.IsNullOrEmpty(item.valore))
|
||||
{
|
||||
taskType currTask = (taskType)Enum.Parse(typeof(taskType), trovato.uid);
|
||||
await _DataService.addCheckTask4Machine(id, currTask, item.valore);
|
||||
await _DataService.AddCheckTask4MachineAsync(id, currTask, item.valore);
|
||||
}
|
||||
}
|
||||
// altrimenti AGGIUNGO (READ ONLY)...
|
||||
@@ -398,10 +398,10 @@ namespace GWMS.UI.Controllers
|
||||
fatto = true;
|
||||
}
|
||||
// faccio upsert innovations!
|
||||
await _DataService.upsertCurrObjItems(id, innovazioni);
|
||||
await _DataService.UpsertCurrObjItemsAsync(id, innovazioni);
|
||||
|
||||
// ultimo step: controllo invio quotidiano parametri gestiti (compreso validità parametri setup)
|
||||
await _DataService.ParamsSendCheck();
|
||||
await _DataService.ParamsSendCheckAsync();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
@@ -805,7 +805,7 @@ namespace GWMS.UI.Controllers
|
||||
bool fatto = Enum.TryParse(taskName, out tName);
|
||||
if (fatto)
|
||||
{
|
||||
await _DataService.remTask4Machine(id, tName);
|
||||
await _DataService.RemTask4MachineAsync(id, tName);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -852,7 +852,7 @@ namespace GWMS.UI.Controllers
|
||||
// se != null --> salvo!
|
||||
if (currMemMap != null)
|
||||
{
|
||||
await _DataService.saveMemMap(id, currMemMap);
|
||||
await _DataService.SaveMemMapAsync(id, currMemMap);
|
||||
answ = "OK";
|
||||
}
|
||||
}
|
||||
@@ -880,7 +880,7 @@ namespace GWMS.UI.Controllers
|
||||
else
|
||||
{
|
||||
// recupero plant...
|
||||
var currPlant = await _DataService.PlantsGetByCode(id);
|
||||
var currPlant = await _DataService.PlantsGetByCodeAsync(id);
|
||||
string alarmDecoded = "-";
|
||||
if (ActiveAlarms != null && ActiveAlarms.Count > 0)
|
||||
{
|
||||
@@ -907,7 +907,7 @@ namespace GWMS.UI.Controllers
|
||||
/// <param name="GWIP">IP del Gateway</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("sendReboot")]
|
||||
public string sendReboot(string idxMacchina, string mac)
|
||||
public async Task<string> sendReboot(string idxMacchina, string mac)
|
||||
{
|
||||
Log.Warn($"sendReboot | {idxMacchina} | {mac}");
|
||||
string answ = "";
|
||||
@@ -920,7 +920,7 @@ namespace GWMS.UI.Controllers
|
||||
Item = idxMacchina,
|
||||
Payload = mac
|
||||
};
|
||||
_DataService.RebootLogInsert(newItem);
|
||||
await _DataService.RebootLogInsertAsync(newItem);
|
||||
answ = "OK";
|
||||
}
|
||||
catch
|
||||
@@ -948,7 +948,7 @@ namespace GWMS.UI.Controllers
|
||||
// se != null --> salvo!
|
||||
if (currParams != null)
|
||||
{
|
||||
await _DataService.setCurrObjItems(id, currParams);
|
||||
await _DataService.SetCurrObjItemsAsync(id, currParams);
|
||||
answ = "OK";
|
||||
}
|
||||
}
|
||||
@@ -1023,7 +1023,7 @@ namespace GWMS.UI.Controllers
|
||||
if (innovazioni != null)
|
||||
{
|
||||
// salvo
|
||||
await _DataService.upsertCurrObjItems(id, innovazioni);
|
||||
await _DataService.UpsertCurrObjItemsAsync(id, innovazioni);
|
||||
answ = "OK";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace GWMS.UI.Controllers
|
||||
{
|
||||
Log.Debug("PlantData: Chiamata Get");
|
||||
// serializzo i dati di PlantDTO dell'impianto richiesto
|
||||
List<PlantDTO> ListRecords = await _DataService.PlantDtoGetAll();
|
||||
List<PlantDTO> ListRecords = await _DataService.PlantDtoGetAllAsync();
|
||||
return ListRecords;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace GWMS.UI.Controllers
|
||||
{
|
||||
Log.Debug($"PlantData: Chiamata Get | id: {id}");
|
||||
// serializzo i dati di PlantDTO dell'impianto richiesto
|
||||
var ListRecords = await _DataService.PlantDtoGetAll();
|
||||
var ListRecords = await _DataService.PlantDtoGetAllAsync();
|
||||
//seleziono plant...
|
||||
var SelRecords = ListRecords.Where(X => X.PlantId == id).FirstOrDefault();
|
||||
return SelRecords;
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace GWMS.UI.Controllers
|
||||
DateTime limite = DateTime.Today.AddHours(dayHour).AddMinutes(dayMin);
|
||||
|
||||
// serializzo i dati di PlantDTO dell'impianto richiesto
|
||||
var ListRecords = await _DataService.PlantLogGetFilt(0, limite, 100);
|
||||
var ListRecords = await _DataService.PlantLogGetFiltAsync(0, limite, 100);
|
||||
return ListRecords;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace GWMS.UI.Controllers
|
||||
DateTime limite = DateTime.Today.AddHours(dayHour).AddMinutes(dayMin);
|
||||
|
||||
// serializzo i dati di PlantDTO dell'impianto richiesto
|
||||
var ListRecords = await _DataService.PlantLogGetFilt(id, limite, 100);
|
||||
var ListRecords = await _DataService.PlantLogGetFiltAsync(id, limite, 100);
|
||||
return ListRecords;
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace GWMS.UI.Controllers
|
||||
// verifico ci sia valore
|
||||
if (newItems != null)
|
||||
{
|
||||
fatto = await _DataService.PlantLogInsert(newItems);
|
||||
fatto = await _DataService.PlantLogInsertAsync(newItems);
|
||||
}
|
||||
if (fatto)
|
||||
{
|
||||
|
||||
+330
-139
@@ -91,14 +91,14 @@ namespace GWMS.UI.Data
|
||||
/// <param name="taskKey"></param>
|
||||
/// <param name="taskVal"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> addCheckTask4Machine(string idxMacchina, taskType taskKey, string taskVal)
|
||||
public async Task<bool> AddCheckTask4MachineAsync(string idxMacchina, taskType taskKey, string taskVal)
|
||||
{
|
||||
bool answ = false;
|
||||
using var activity = ActivitySource.StartActivity("addCheckTask4Machine");
|
||||
using var activity = ActivitySource.StartActivity("AddCheckTask4MachineAsync");
|
||||
activity?.SetTag("iob.code", idxMacchina);
|
||||
activity?.SetTag("iob.task", $"{taskKey}");
|
||||
string currHash = exeTaskHash(idxMacchina);
|
||||
Log.Info($"addCheckTask4Machine idxMacchina: {idxMacchina} | taskKey: {taskKey} | taskVal: {taskVal}");
|
||||
Log.Info($"AddCheckTask4MachineAsync idxMacchina: {idxMacchina} | taskKey: {taskKey} | taskVal: {taskVal}");
|
||||
try
|
||||
{
|
||||
Dictionary<string, string> savedTask = await mSavedTaskMacchina(idxMacchina);
|
||||
@@ -122,7 +122,7 @@ namespace GWMS.UI.Data
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
string exMsg = $"Errore in addCheckTask4Machine | idxMacchina: {idxMacchina} | taskKey: {taskKey} | taskVal: {taskVal}";
|
||||
string exMsg = $"Eccezione in AddCheckTask4MachineAsync | idxMacchina: {idxMacchina} | taskKey: {taskKey} | taskVal: {taskVal}";
|
||||
Log.Error($"{exMsg}{Environment.NewLine}{exc}");
|
||||
// traccio errore
|
||||
activity?.SetStatus(ActivityStatusCode.Error, exc.Message);
|
||||
@@ -257,7 +257,7 @@ namespace GWMS.UI.Data
|
||||
string emailBody = "";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
List<PlantDTO> allPlants = await PlantDtoGetAll();
|
||||
List<PlantDTO> allPlants = await PlantDtoGetAllAsync();
|
||||
var currPlant = allPlants.Where(x => x.PlantId == newItem.PlantId).FirstOrDefault();
|
||||
|
||||
// inizio a comporre email
|
||||
@@ -278,11 +278,11 @@ namespace GWMS.UI.Data
|
||||
System.Security.Claims.Claim suppClaim = new System.Security.Claims.Claim("PlantId", $"{newItem.PlantId}");
|
||||
|
||||
// recupero elenco users associati al PLANT....
|
||||
var rawUserList = UserDataGetFilt("").Result;
|
||||
var rawUserList = UserDataGetFiltAsync("").Result;
|
||||
var plantUserList = rawUserList
|
||||
.Where(x => x.Roles.Contains("User"))
|
||||
.ToList();
|
||||
//var plantList = await PlantDtoGetAll();
|
||||
//var plantList = await PlantDtoGetAllAsync();
|
||||
var userListSupp = plantUserList
|
||||
.Where(x => x.Claims.Where(c => c.Type == "PlantId" && c.Value == $"{newItem.PlantId}").Count() > 0)
|
||||
.ToList();
|
||||
@@ -790,22 +790,22 @@ namespace GWMS.UI.Data
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<OrderModel> OrderGetById(int OrderId)
|
||||
public async Task<OrderModel> OrderGetByIdAsync(int OrderId)
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("OrderGetById");
|
||||
using var activity = ActivitySource.StartActivity("OrderGetByIdAsync");
|
||||
activity?.SetTag("order.ID", OrderId);
|
||||
string source = "DB";
|
||||
OrderModel result = new OrderModel();
|
||||
result = await dbController.GetOrderByIdAsync(OrderId);
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"OrderGetById | {source} | {activity?.Duration.TotalMilliseconds} ms");
|
||||
LogTrace($"OrderGetByIdAsync | {source} | {activity?.Duration.TotalMilliseconds} ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<List<OrderModel>> OrdersGetFilt(SelectOrderData CurrFilter)
|
||||
public async Task<List<OrderModel>> OrdersGetFiltAsync(SelectOrderData CurrFilter)
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("OrdersGetFilt");
|
||||
using var activity = ActivitySource.StartActivity("OrdersGetFiltAsync");
|
||||
activity?.SetTag("param.dtStart", CurrFilter.DateStart);
|
||||
activity?.SetTag("param.dtEnd", CurrFilter.DateEnd);
|
||||
activity?.SetTag("param.closed", CurrFilter.ShowClosed);
|
||||
@@ -816,7 +816,7 @@ namespace GWMS.UI.Data
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.SetTag("result.count", result.Count);
|
||||
activity?.Stop();
|
||||
LogTrace($"OrdersGetFilt | {source} | {activity?.Duration.TotalMilliseconds} ms");
|
||||
LogTrace($"OrdersGetFiltAsync | {source} | {activity?.Duration.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(result);
|
||||
}
|
||||
|
||||
@@ -825,9 +825,9 @@ namespace GWMS.UI.Data
|
||||
/// </summary>
|
||||
/// <param name="CurrFilter"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<OrderModel>> OrdersGetOpen(int PlantId)
|
||||
public async Task<List<OrderModel>> OrdersGetOpenAsync(int PlantId)
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("OrdersGetOpen");
|
||||
using var activity = ActivitySource.StartActivity("OrdersGetOpenAsync");
|
||||
activity?.SetTag("param.PlantId", PlantId);
|
||||
string source = "DB";
|
||||
List<OrderModel> result = new List<OrderModel>();
|
||||
@@ -835,7 +835,7 @@ namespace GWMS.UI.Data
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.SetTag("result.count", result.Count);
|
||||
activity?.Stop();
|
||||
LogTrace($"OrdersGetOpen | {source} | {activity?.Duration.TotalMilliseconds} ms");
|
||||
LogTrace($"OrdersGetOpenAsync | {source} | {activity?.Duration.TotalMilliseconds} ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1104,6 +1104,9 @@ namespace GWMS.UI.Data
|
||||
}));
|
||||
}
|
||||
}
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"ParamSetUpdateAsync | {source} | {activity?.Duration.TotalMilliseconds} ms");
|
||||
return done;
|
||||
}
|
||||
|
||||
@@ -1111,9 +1114,11 @@ namespace GWMS.UI.Data
|
||||
/// Effettua verifica parametri da inviare ed eventualmente invia
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ParamsSendCheck()
|
||||
public async Task<bool> ParamsSendCheckAsync()
|
||||
{
|
||||
bool answ = false;
|
||||
using var activity = ActivitySource.StartActivity("ParamsSendCheckAsync");
|
||||
string source = "REDIS";
|
||||
string cacheKey = mHash("ParamSend:List");
|
||||
// prima di tutto invalido cache dei parametri...
|
||||
await ExecFlushRedisPattern(cacheKey);
|
||||
@@ -1127,11 +1132,11 @@ namespace GWMS.UI.Data
|
||||
{
|
||||
foreach (var item in activeParams)
|
||||
{
|
||||
await ParamsSetCheck(item.PlantId, item.ParamUid);
|
||||
await ParamsSetCheckAsync(item.PlantId, item.ParamUid);
|
||||
// recupero valore...
|
||||
var newVal = await ParamSetCalcValAsync(item.PlantId, item.ParamUid);
|
||||
// registro richiesta
|
||||
bool fatto = await updateMachineParameter(item.PlantId, item.ParamUid, $"{newVal:N3}");
|
||||
bool fatto = await UpdateMachineParameterAsync(item.PlantId, item.ParamUid, $"{newVal:N3}");
|
||||
// registro nuovo veto
|
||||
if (fatto)
|
||||
{
|
||||
@@ -1148,6 +1153,9 @@ namespace GWMS.UI.Data
|
||||
|
||||
// alla fine di nuovo invalido cache dei parametri...
|
||||
await ExecFlushRedisPattern(cacheKey);
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"ParamsSendCheckAsync | {source} | {activity?.Duration.TotalMilliseconds} ms");
|
||||
return answ;
|
||||
}
|
||||
|
||||
@@ -1156,9 +1164,13 @@ namespace GWMS.UI.Data
|
||||
/// ed 1 passato x interpolare)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ParamsSetCheck(int PlantId, string ParamUid)
|
||||
public async Task<bool> ParamsSetCheckAsync(int PlantId, string ParamUid)
|
||||
{
|
||||
bool answ = false;
|
||||
using var activity = ActivitySource.StartActivity("ParamsSetCheckAsync");
|
||||
string source = "REDIS";
|
||||
activity?.SetTag("param.PlantId", PlantId);
|
||||
activity?.SetTag("param.ParamUid", ParamUid);
|
||||
// elenco parametri set...
|
||||
List<ParamSetModel> ListRecords = await ParamSetGetFiltAsync(PlantId, ParamUid);
|
||||
// per invecchiare DEVONO essere almeno 2
|
||||
@@ -1177,12 +1189,16 @@ namespace GWMS.UI.Data
|
||||
}
|
||||
answ = true;
|
||||
}
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"ParamsSetCheckAsync | {source} | {activity?.Duration.TotalMilliseconds} ms");
|
||||
return answ;
|
||||
}
|
||||
|
||||
public async Task<List<PlantDTO>> PlantDtoGetAll()
|
||||
public async Task<List<PlantDTO>> PlantDtoGetAllAsync()
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("PlantDtoGetAll");
|
||||
using var activity = ActivitySource.StartActivity("PlantDtoGetAllAsync");
|
||||
string source = "DB";
|
||||
List<PlantDTO> result = new List<PlantDTO>();
|
||||
string cacheVetoKey = mHash("PLANTS:VetoReadDto");
|
||||
string rawData;
|
||||
@@ -1202,7 +1218,7 @@ namespace GWMS.UI.Data
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Debug($"Veto attivo per PlantDtoGetAll: salto!");
|
||||
Log.Debug($"Veto attivo per PlantDtoGetAllAsync: salto!");
|
||||
// controllo se ci sia semaforo lettura
|
||||
rawData = await redisDb.StringGetAsync(cacheVetoKey);
|
||||
// attesa random 1...5 sec
|
||||
@@ -1219,7 +1235,6 @@ namespace GWMS.UI.Data
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
#endif
|
||||
string source = "DB";
|
||||
rawData = await redisDb.StringGetAsync(cacheKey);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
@@ -1243,29 +1258,34 @@ namespace GWMS.UI.Data
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.SetTag("result.count", result.Count);
|
||||
activity?.Stop();
|
||||
LogTrace($"PlantDtoGetAll | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
LogTrace($"PlantDtoGetAllAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<PlantDTO> PlantDtoGetByCode(string PlantCode)
|
||||
public async Task<PlantDTO> PlantDtoGetByCodeAsync(string PlantCode)
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("PlantDtoGetByCodeAsync");
|
||||
string source = "REDIS";
|
||||
activity?.SetTag("param.PlantCode", PlantCode);
|
||||
PlantDTO answ = new PlantDTO();
|
||||
var ListRecords = await PlantDtoGetAll();
|
||||
var ListRecords = await PlantDtoGetAllAsync();
|
||||
var found = ListRecords.Where(x => x.PlantCode == PlantCode).FirstOrDefault();
|
||||
if (found != null)
|
||||
{
|
||||
answ = found;
|
||||
}
|
||||
return await Task.FromResult(answ);
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"PlantDtoGetByCodeAsync | {source} | {activity?.Duration.TotalMilliseconds} ms");
|
||||
return answ;
|
||||
}
|
||||
|
||||
public async Task<List<PlantLogModel>> PlantLogGetFilt(int PlantId, DateTime DtMaxDate, int numRec)
|
||||
public async Task<List<PlantLogModel>> PlantLogGetFiltAsync(int PlantId, DateTime DtMaxDate, int numRec)
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("PlantLogGetFiltAsync");
|
||||
string source = "DB";
|
||||
List<PlantLogModel> dbResult = new List<PlantLogModel>();
|
||||
List<PlantLogModel> result = new List<PlantLogModel>();
|
||||
string cacheKey = mHash($"PLANTS:LOGS:{PlantId}:{DtMaxDate:yyyyMMddHHmm}:{numRec}");
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
string rawData = "";
|
||||
rawData = await redisDb.StringGetAsync(cacheKey);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
@@ -1274,26 +1294,30 @@ namespace GWMS.UI.Data
|
||||
var tempResult = JsonConvert.DeserializeObject<List<PlantLogModel>>(rawData);
|
||||
if (tempResult == null)
|
||||
{
|
||||
dbResult = new List<PlantLogModel>();
|
||||
result = new List<PlantLogModel>();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = tempResult;
|
||||
result = tempResult;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbController.GetPlantLog(PlantId, DtMaxDate, numRec);
|
||||
rawData = JsonConvert.SerializeObject(dbResult);
|
||||
result = dbController.GetPlantLog(PlantId, DtMaxDate, numRec);
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(cacheKey, rawData, LongCache);
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"PlantLogGetFilt | {source} | {sw.ElapsedMilliseconds} ms");
|
||||
return dbResult;
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.SetTag("result.count", result.Count);
|
||||
activity?.Stop();
|
||||
LogTrace($"PlantLogGetFiltAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<bool> PlantLogInsert(List<PlantLogModel> newItems)
|
||||
public async Task<bool> PlantLogInsertAsync(List<PlantLogModel> newItems)
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("PlantLogInsertAsync");
|
||||
string source = "DB+REDIS";
|
||||
bool fatto = false;
|
||||
// init valori
|
||||
int IntervalMin = 60;
|
||||
@@ -1348,77 +1372,92 @@ namespace GWMS.UI.Data
|
||||
// invalido i vari valori in cache
|
||||
await ExecFlushRedisPattern(mHash($"PLANTS:LastFlux:{PlantId}"));
|
||||
await ExecFlushRedisPattern(mHash("PLANTS:ListDTO"));
|
||||
Log.Debug($"PlantLogInsert | PlantId: {PlantId} | Completato insert {item2insert.Count} rec");
|
||||
Log.Debug($"PlantLogInsertAsync | PlantId: {PlantId} | Completato insert {item2insert.Count} rec");
|
||||
}
|
||||
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"PlantLogInsertAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
// restituisco
|
||||
return fatto;
|
||||
}
|
||||
|
||||
public async Task<List<PlantLevSumDTO>> PlantsAnalisysByFilt(SelectOrderData CurrFilter)
|
||||
public async Task<List<PlantLevSumDTO>> PlantsAnalisysByFiltAsync(SelectOrderData CurrFilter)
|
||||
{
|
||||
List<PlantLevSumDTO> dbResult = new List<PlantLevSumDTO>();
|
||||
using var activity = ActivitySource.StartActivity("PlantsAnalisysByFiltAsync");
|
||||
string source = "DB";
|
||||
activity?.SetTag("param.PlantId", CurrFilter.PlantId);
|
||||
activity?.SetTag("param.DateStart", CurrFilter.DateStart);
|
||||
activity?.SetTag("param.DateEnd", CurrFilter.DateEnd);
|
||||
activity?.SetTag("param.Closed", CurrFilter.ShowClosed);
|
||||
List<PlantLevSumDTO> result = new List<PlantLevSumDTO>();
|
||||
string cacheKey = mHash($"PLANTS:LevelSum:{CurrFilter.PlantId}:{CurrFilter.DateStart:yyMMdd}:{CurrFilter.DateEnd:yyMMdd}");
|
||||
string rawData;
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
string readSource = "DB";
|
||||
rawData = await redisDb.StringGetAsync(cacheKey);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
readSource = "REDIS";
|
||||
source = "REDIS";
|
||||
var tempResult = JsonConvert.DeserializeObject<List<PlantLevSumDTO>>(rawData);
|
||||
if (tempResult == null)
|
||||
{
|
||||
dbResult = new List<PlantLevSumDTO>();
|
||||
result = new List<PlantLevSumDTO>();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = tempResult;
|
||||
result = tempResult;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbController.GetPlantLevSumDto(CurrFilter.PlantId, CurrFilter.DateStart, CurrFilter.DateEnd);
|
||||
rawData = JsonConvert.SerializeObject(dbResult);
|
||||
result = dbController.GetPlantLevSumDto(CurrFilter.PlantId, CurrFilter.DateStart, CurrFilter.DateEnd);
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(cacheKey, rawData, UltraLongCache);
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"PlantsAnalisysByFilt | {readSource} | {sw.ElapsedMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.SetTag("result.count", result.Count);
|
||||
activity?.Stop();
|
||||
LogTrace($"PlantsAnalisysByFiltAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<bool> PlantsAnalisysReset(SelectOrderData CurrFilter)
|
||||
public async Task<bool> PlantsAnalisysResetAsync(SelectOrderData CurrFilter)
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("PlantsAnalisysResetAsync");
|
||||
string source = "REDIS";
|
||||
bool answ = false;
|
||||
string cacheKey = mHash($"PLANTS:LevelSum:{CurrFilter.PlantId}:{CurrFilter.DateStart:yyMMdd}:{CurrFilter.DateEnd:yyMMdd}");
|
||||
await ExecFlushRedisPattern(cacheKey);
|
||||
answ = true;
|
||||
return await Task.FromResult(answ);
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"PlantsAnalisysResetAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return answ;
|
||||
}
|
||||
|
||||
public async Task<PlantDetailModel> PlantsGetByCode(string PlantCode)
|
||||
public async Task<PlantDetailModel> PlantsGetByCodeAsync(string PlantCode)
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("PlantsGetByCodeAsync");
|
||||
activity?.SetTag("param.PlantCode", PlantCode);
|
||||
string source = "REDIS";
|
||||
PlantDetailModel answ = new PlantDetailModel();
|
||||
var ListRecords = await PlantsList();
|
||||
var ListRecords = await PlantsListAsync();
|
||||
var found = ListRecords.Where(x => x.PlantCode == PlantCode).FirstOrDefault();
|
||||
if (found != null)
|
||||
{
|
||||
answ = found;
|
||||
}
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"PlantsGetByCodeAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
public async Task<List<PlantDetailModel>> PlantsList()
|
||||
public async Task<List<PlantDetailModel>> PlantsListAsync()
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("PlantsList");
|
||||
string source = "DB";
|
||||
using var activity = ActivitySource.StartActivity("PlantsListAsync");
|
||||
string source = "REDIS";
|
||||
List<PlantDetailModel> result = new List<PlantDetailModel>();
|
||||
string cacheKey = mHash("PLANTS:ListModel");
|
||||
#if false
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
#endif
|
||||
string rawData;
|
||||
rawData = await redisDb.StringGetAsync(cacheKey);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
@@ -1440,40 +1479,69 @@ namespace GWMS.UI.Data
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(cacheKey, rawData, UltraLongCache);
|
||||
}
|
||||
#if false
|
||||
sw.Stop();
|
||||
Log.Debug($"PlantsList | {source} | {sw.ElapsedMilliseconds} ms");
|
||||
#endif
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.SetTag("result.count", result.Count);
|
||||
activity?.Stop();
|
||||
LogTrace($"PlantsList | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
LogTrace($"PlantsListAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return await Task.FromResult(result);
|
||||
}
|
||||
|
||||
public async Task<bool> PlantUpdate(PlantDTO currItem)
|
||||
public async Task<bool> PlantUpdateAsync(PlantDTO currItem)
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("PlantUpdateAsync");
|
||||
activity?.SetTag("param.PlantId", currItem.PlantId);
|
||||
activity?.SetTag("param.PlantCode", currItem.PlantCode);
|
||||
string source = "DB+REDIS";
|
||||
bool done = false;
|
||||
try
|
||||
{
|
||||
done = dbController.PlantUpdate(currItem);
|
||||
done = await dbController.PlantUpdateAsync(currItem);
|
||||
await FlushRedisCache();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in PlantUpdate:{Environment.NewLine}{exc}");
|
||||
string exMsg = $"Eccezione in PlantUpdateAsync | PlantId: {currItem.PlantId} | PlantCode: {currItem.PlantCode} | LevelAct: {currItem.LevelAct}";
|
||||
Log.Error($"{exMsg}{Environment.NewLine}{exc}");
|
||||
// traccio errore
|
||||
activity?.SetStatus(ActivityStatusCode.Error, exc.Message);
|
||||
activity?.AddEvent(new ActivityEvent("exception", tags: new ActivityTagsCollection {
|
||||
{ "exception.type", exc.GetType().Name },
|
||||
{ "exception.message", exc.Message },
|
||||
{ "exception.stacktrace", exc.StackTrace }
|
||||
}));
|
||||
}
|
||||
return await Task.FromResult(done);
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"PlantUpdateAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return done;
|
||||
}
|
||||
|
||||
public void RebootLogInsert(RebootLogModel newItem)
|
||||
public async Task<bool> RebootLogInsertAsync(RebootLogModel newItem)
|
||||
{
|
||||
bool done = false;
|
||||
using var activity = ActivitySource.StartActivity("RebootLogInsertAsync");
|
||||
string source = "DB";
|
||||
activity?.SetTag("param.Item", newItem.Item);
|
||||
try
|
||||
{
|
||||
dbController.RecordRebootLog(newItem);
|
||||
done= await dbController.RecordRebootLogAsync(newItem);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
catch (Exception exc)
|
||||
{
|
||||
string exMsg = $"Eccezione in RebootLogInsertAsync";
|
||||
Log.Error($"{exMsg}{Environment.NewLine}{exc}");
|
||||
// traccio errore
|
||||
activity?.SetStatus(ActivityStatusCode.Error, exc.Message);
|
||||
activity?.AddEvent(new ActivityEvent("exception", tags: new ActivityTagsCollection {
|
||||
{ "exception.type", exc.GetType().Name },
|
||||
{ "exception.message", exc.Message },
|
||||
{ "exception.stacktrace", exc.StackTrace }
|
||||
}));
|
||||
}
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"RebootLogInsertAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1482,9 +1550,13 @@ namespace GWMS.UI.Data
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="currValues"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> remObjItem(string idxMacchina, objItem item2rem)
|
||||
public async Task<bool> RemObjItemAsync(string idxMacchina, objItem item2rem)
|
||||
{
|
||||
bool answ = false;
|
||||
using var activity = ActivitySource.StartActivity("RemObjItemAsync");
|
||||
string source = "REDIS";
|
||||
activity?.SetTag("param.idxMacchina", idxMacchina);
|
||||
activity?.SetTag("param.obj", item2rem.name);
|
||||
if (item2rem != null)
|
||||
{
|
||||
string cacheKey = currParametersHash(idxMacchina);
|
||||
@@ -1506,6 +1578,9 @@ namespace GWMS.UI.Data
|
||||
await redisDb.StringSetAsync(cacheKey, rawData);
|
||||
}
|
||||
}
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"RemObjItemAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return answ;
|
||||
}
|
||||
|
||||
@@ -1515,9 +1590,13 @@ namespace GWMS.UI.Data
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="taskKey"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> remOptPar4Machine(string idxMacchina, string taskKey)
|
||||
public async Task<bool> RemOptPar4MachineAsync(string idxMacchina, string taskKey)
|
||||
{
|
||||
bool answ = false;
|
||||
using var activity = ActivitySource.StartActivity("RemOptPar4MachineAsync");
|
||||
string source = "REDIS";
|
||||
activity?.SetTag("param.idxMacchina", idxMacchina);
|
||||
activity?.SetTag("param.taskKey", taskKey);
|
||||
string currHash = optParHash(idxMacchina);
|
||||
try
|
||||
{
|
||||
@@ -1530,8 +1609,19 @@ namespace GWMS.UI.Data
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Errore in remOptPar4Machine | idxMacchina: {idxMacchina} | taskKey: {taskKey}{Environment.NewLine}{exc}");
|
||||
string exMsg = $"Eccezione in RemOptPar4MachineAsync | idxMacchina: {idxMacchina} | taskKey: {taskKey}";
|
||||
Log.Error($"{exMsg}{Environment.NewLine}{exc}");
|
||||
// traccio errore
|
||||
activity?.SetStatus(ActivityStatusCode.Error, exc.Message);
|
||||
activity?.AddEvent(new ActivityEvent("exception", tags: new ActivityTagsCollection {
|
||||
{ "exception.type", exc.GetType().Name },
|
||||
{ "exception.message", exc.Message },
|
||||
{ "exception.stacktrace", exc.StackTrace }
|
||||
}));
|
||||
}
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"RemOptPar4MachineAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return answ;
|
||||
}
|
||||
|
||||
@@ -1541,9 +1631,13 @@ namespace GWMS.UI.Data
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="taskKey"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> remTask4Machine(string idxMacchina, taskType taskKey)
|
||||
public async Task<bool> RemTask4MachineAsync(string idxMacchina, taskType taskKey)
|
||||
{
|
||||
bool answ = false;
|
||||
using var activity = ActivitySource.StartActivity("RemTask4MachineAsync");
|
||||
string source = "REDIS";
|
||||
activity?.SetTag("param.idxMacchina", idxMacchina);
|
||||
activity?.SetTag("param.taskKey", taskKey);
|
||||
string currHash = exeTaskHash(idxMacchina);
|
||||
try
|
||||
{
|
||||
@@ -1561,8 +1655,19 @@ namespace GWMS.UI.Data
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Errore in remTask4Machine | idxMacchina: {idxMacchina} | taskKey: {taskKey}{Environment.NewLine}{exc}");
|
||||
string exMsg = $"Eccezione in RemOptPar4MachineAsync | idxMacchina: {idxMacchina} | taskKey: {taskKey}";
|
||||
Log.Error($"{exMsg}{Environment.NewLine}{exc}");
|
||||
// traccio errore
|
||||
activity?.SetStatus(ActivityStatusCode.Error, exc.Message);
|
||||
activity?.AddEvent(new ActivityEvent("exception", tags: new ActivityTagsCollection {
|
||||
{ "exception.type", exc.GetType().Name },
|
||||
{ "exception.message", exc.Message },
|
||||
{ "exception.stacktrace", exc.StackTrace }
|
||||
}));
|
||||
}
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"RemTask4MachineAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return answ;
|
||||
}
|
||||
|
||||
@@ -1572,14 +1677,17 @@ namespace GWMS.UI.Data
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// salva la conf di memoria della amcchina in redis
|
||||
/// salva la conf di memoria della macchina in redis
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="currMap"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> saveMemMap(string idxMacchina, plcMemMap currMap)
|
||||
public async Task<bool> SaveMemMapAsync(string idxMacchina, plcMemMap currMap)
|
||||
{
|
||||
bool answ = false;
|
||||
using var activity = ActivitySource.StartActivity("SaveMemMapAsync");
|
||||
string source = "REDIS";
|
||||
activity?.SetTag("param.idxMacchina", idxMacchina);
|
||||
if (currMap != null)
|
||||
{
|
||||
string currHash = currMamMapHash(idxMacchina);
|
||||
@@ -1588,6 +1696,9 @@ namespace GWMS.UI.Data
|
||||
await redisDb.StringSetAsync(currHash, rawData);
|
||||
answ = true;
|
||||
}
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"SaveMemMapAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return answ;
|
||||
}
|
||||
|
||||
@@ -1597,9 +1708,13 @@ namespace GWMS.UI.Data
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="currValues"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> setCurrObjItems(string idxMacchina, List<objItem> currValues)
|
||||
public async Task<bool> SetCurrObjItemsAsync(string idxMacchina, List<objItem> currValues)
|
||||
{
|
||||
bool answ = false;
|
||||
using var activity = ActivitySource.StartActivity("SetCurrObjItemsAsync");
|
||||
string source = "REDIS";
|
||||
activity?.SetTag("param.idxMacchina", idxMacchina);
|
||||
activity?.SetTag("param.numRec", currValues.Count);
|
||||
taskType currTask = taskType.nihil;
|
||||
if (currValues != null)
|
||||
{
|
||||
@@ -1620,62 +1735,79 @@ namespace GWMS.UI.Data
|
||||
if (Enum.IsDefined(typeof(taskType), currTask))
|
||||
{
|
||||
currTask = (taskType)Enum.Parse(typeof(taskType), item.uid);
|
||||
await addCheckTask4Machine(idxMacchina, currTask, item.value);
|
||||
await AddCheckTask4MachineAsync(idxMacchina, currTask, item.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
answ = true;
|
||||
}
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"SetCurrObjItemsAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return answ;
|
||||
}
|
||||
|
||||
public async Task<List<SupplierModel>> SuppliersGetAll()
|
||||
public async Task<List<SupplierModel>> SuppliersGetAllAsync()
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("SuppliersGetAllAsync");
|
||||
string source = "DB";
|
||||
List<SupplierModel> dbResult = new List<SupplierModel>();
|
||||
List<SupplierModel> result = new List<SupplierModel>();
|
||||
string cacheKey = mHash("SUPPL:List");
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
string rawData;
|
||||
rawData = await redisDb.StringGetAsync(cacheKey);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
source = "REDIS";
|
||||
dbResult = JsonConvert.DeserializeObject<List<SupplierModel>>(rawData);
|
||||
result = JsonConvert.DeserializeObject<List<SupplierModel>>(rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbController.GetSuppliers();
|
||||
rawData = JsonConvert.SerializeObject(dbResult);
|
||||
result = dbController.GetSuppliers();
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(cacheKey, rawData, UltraLongCache);
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"SuppliersGetAll | {source} | {sw.ElapsedMilliseconds} ms");
|
||||
return dbResult;
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.SetTag("result.count", result.Count);
|
||||
activity?.Stop();
|
||||
LogTrace($"SuppliersGetAllAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<bool> TestSendEmail(string destEmail, string oggetto, string corpo)
|
||||
public async Task<bool> TestSendEmailAsync(string destEmail, string oggetto, string corpo)
|
||||
{
|
||||
bool answ = false;
|
||||
using var activity = ActivitySource.StartActivity("TestSendEmailAsync");
|
||||
string source = "SMTP";
|
||||
try
|
||||
{
|
||||
await _emailSender.SendEmailAsync(destEmail, oggetto, corpo);
|
||||
answ = true;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
catch (Exception exc)
|
||||
{
|
||||
string exMsg = $"Eccezione in TestSendEmailAsync | destEmail: {destEmail} | oggetto: {oggetto}";
|
||||
Log.Error($"{exMsg}{Environment.NewLine}{exc}");
|
||||
// traccio errore
|
||||
activity?.SetStatus(ActivityStatusCode.Error, exc.Message);
|
||||
activity?.AddEvent(new ActivityEvent("exception", tags: new ActivityTagsCollection {
|
||||
{ "exception.type", exc.GetType().Name },
|
||||
{ "exception.message", exc.Message },
|
||||
{ "exception.stacktrace", exc.StackTrace }
|
||||
}));
|
||||
}
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"TestSendEmailAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return answ;
|
||||
}
|
||||
|
||||
public async Task<List<TransporterModel>> TransportersGetAll()
|
||||
public async Task<List<TransporterModel>> TransportersGetAllAsync()
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("TransportersGetAllAsync");
|
||||
string source = "DB";
|
||||
List<TransporterModel> dbResult = new List<TransporterModel>();
|
||||
List<TransporterModel> result = new List<TransporterModel>();
|
||||
string cacheKey = mHash($"TRANSP:List");
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
string rawData;
|
||||
rawData = await redisDb.StringGetAsync(cacheKey);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
@@ -1684,22 +1816,24 @@ namespace GWMS.UI.Data
|
||||
var tempResult = JsonConvert.DeserializeObject<List<TransporterModel>>(rawData);
|
||||
if (tempResult == null)
|
||||
{
|
||||
dbResult = new List<TransporterModel>();
|
||||
result = new List<TransporterModel>();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = tempResult;
|
||||
result = tempResult;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbController.GetTransporters();
|
||||
rawData = JsonConvert.SerializeObject(dbResult);
|
||||
result = dbController.GetTransporters();
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(cacheKey, rawData, UltraLongCache);
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"TransportersGetAll | {source} | {sw.ElapsedMilliseconds} ms");
|
||||
return dbResult;
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.SetTag("result.count", result.Count);
|
||||
activity?.Stop();
|
||||
LogTrace($"TransportersGetAllAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1709,17 +1843,24 @@ namespace GWMS.UI.Data
|
||||
/// <param name="Original_uid">Parametro macchina come definito in file json</param>
|
||||
/// <param name="reqValue"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> updateMachineParameter(int PlantId, string Original_uid, string reqValue)
|
||||
public async Task<bool> UpdateMachineParameterAsync(int PlantId, string Original_uid, string reqValue)
|
||||
{
|
||||
bool fatto = false;
|
||||
var plantList = await PlantDtoGetAll();
|
||||
using var activity = ActivitySource.StartActivity("UpdateMachineParameterAsync");
|
||||
activity?.SetTag("param.PlantId", PlantId);
|
||||
activity?.SetTag("param.Original_uid", Original_uid);
|
||||
string source = "SRV";
|
||||
var plantList = await PlantDtoGetAllAsync();
|
||||
var currPlant = plantList
|
||||
.Where(x => x.PlantId == PlantId)
|
||||
.FirstOrDefault();
|
||||
if (currPlant != null)
|
||||
{
|
||||
fatto = await updateMachineParameter(currPlant.PlantCode, Original_uid, reqValue);
|
||||
fatto = await UpdateMachineParameterAsync(currPlant.PlantCode, Original_uid, reqValue);
|
||||
}
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"UpdateMachineParameterAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return fatto;
|
||||
}
|
||||
|
||||
@@ -1730,9 +1871,13 @@ namespace GWMS.UI.Data
|
||||
/// <param name="Original_uid">Parametro macchina come definito in file json</param>
|
||||
/// <param name="reqValue"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> updateMachineParameter(string idxMacchina, string Original_uid, string reqValue)
|
||||
public async Task<bool> UpdateMachineParameterAsync(string idxMacchina, string Original_uid, string reqValue)
|
||||
{
|
||||
bool answ = false;
|
||||
using var activity = ActivitySource.StartActivity("UpdateMachineParameterAsync");
|
||||
activity?.SetTag("param.idxMacchina", idxMacchina);
|
||||
activity?.SetTag("param.Original_uid", Original_uid);
|
||||
string source = "SRV";
|
||||
// recupero items...
|
||||
List<objItem> dcList = await getCurrObjItems(idxMacchina);
|
||||
List<objItem> list2Update = new List<objItem>();
|
||||
@@ -1752,7 +1897,7 @@ namespace GWMS.UI.Data
|
||||
trovato.reqValue = reqValue;
|
||||
trovato.lastRequest = DateTime.Now;
|
||||
list2Update.Add(trovato);
|
||||
await upsertCurrObjItems(idxMacchina, list2Update);
|
||||
await UpsertCurrObjItemsAsync(idxMacchina, list2Update);
|
||||
// accodo in Task2Exe la richiesta di processing
|
||||
await addTask4Machine(idxMacchina, taskType.setParameter, trovato.uid);
|
||||
|
||||
@@ -1765,6 +1910,9 @@ namespace GWMS.UI.Data
|
||||
|
||||
answ = true;
|
||||
}
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"UpdateMachineParameterAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return answ;
|
||||
}
|
||||
|
||||
@@ -1774,9 +1922,13 @@ namespace GWMS.UI.Data
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="innovations"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> upsertCurrObjItems(string idxMacchina, List<objItem> innovations)
|
||||
public async Task<bool> UpsertCurrObjItemsAsync(string idxMacchina, List<objItem> innovations)
|
||||
{
|
||||
bool answ = false;
|
||||
using var activity = ActivitySource.StartActivity("UpsertCurrObjItemsAsync");
|
||||
activity?.SetTag("param.idxMacchina", idxMacchina);
|
||||
activity?.SetTag("param.numInnov", innovations.Count);
|
||||
string source = "REDIS";
|
||||
if (innovations != null)
|
||||
{
|
||||
string currHash = currParametersHash(idxMacchina);
|
||||
@@ -1789,11 +1941,17 @@ namespace GWMS.UI.Data
|
||||
string rawData = JsonConvert.SerializeObject(innovations);
|
||||
await redisDb.StringSetAsync(currHash, rawData);
|
||||
}
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"UpsertCurrObjItemsAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return answ;
|
||||
}
|
||||
|
||||
public async Task<List<UserData>> UserDataGetFilt(string searchVal)
|
||||
public async Task<List<UserData>> UserDataGetFiltAsync(string searchVal)
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("UserDataGetFiltAsync");
|
||||
activity?.SetTag("param.searchVal", searchVal);
|
||||
string source = "USR";
|
||||
// Collezione utenti
|
||||
List<IdentityUser> RawList = new List<IdentityUser>();
|
||||
List<UserData> UsersList = new List<UserData>();
|
||||
@@ -1830,11 +1988,18 @@ namespace GWMS.UI.Data
|
||||
};
|
||||
UsersList.Add(newItem);
|
||||
}
|
||||
return await Task.FromResult(UsersList);
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"UserDataGetFiltAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return UsersList;
|
||||
}
|
||||
|
||||
public async void WeekPlanDelete(WeekPlanModel currItem)
|
||||
public async void WeekPlanDeleteAsync(WeekPlanModel currItem)
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("WeekPlanDeleteAsync");
|
||||
activity?.SetTag("param.PlantId", currItem.PlantId);
|
||||
activity?.SetTag("param.WeekPlanId", currItem.WeekPlanId);
|
||||
string source = "DB+REDIS";
|
||||
try
|
||||
{
|
||||
//dbController.ResetController();
|
||||
@@ -1842,26 +2007,40 @@ namespace GWMS.UI.Data
|
||||
string cacheKey = mHash($"WEEKPLAN:List");
|
||||
await ExecFlushRedisPattern(cacheKey);
|
||||
}
|
||||
catch
|
||||
catch (Exception exc)
|
||||
{
|
||||
string exMsg = $"Eccezione in WeekPlanDeleteAsync | PlantId: {currItem.PlantId} | WeekPlanId: {currItem.WeekPlanId}";
|
||||
Log.Error($"{exMsg}{Environment.NewLine}{exc}");
|
||||
// traccio errore
|
||||
activity?.SetStatus(ActivityStatusCode.Error, exc.Message);
|
||||
activity?.AddEvent(new ActivityEvent("exception", tags: new ActivityTagsCollection {
|
||||
{ "exception.type", exc.GetType().Name },
|
||||
{ "exception.message", exc.Message },
|
||||
{ "exception.stacktrace", exc.StackTrace }
|
||||
}));
|
||||
}
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"WeekPlanDeleteAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
}
|
||||
|
||||
public async Task<List<WeekPlanModel>> WeekPlanGet()
|
||||
public async Task<List<WeekPlanModel>> WeekPlanGetAsync()
|
||||
{
|
||||
List<WeekPlanModel> dbResult = new List<WeekPlanModel>();
|
||||
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbController.GetWeekPlan();
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Debug($"Effettuata lettura da DB per WeekPlanGet: {ts.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
using var activity = ActivitySource.StartActivity("WeekPlanGetAsync");
|
||||
string source = "DB";
|
||||
List<WeekPlanModel> result = new List<WeekPlanModel>();
|
||||
result = await dbController.GetWeekPlanAsync();
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.SetTag("result.count", result.Count);
|
||||
activity?.Stop();
|
||||
LogTrace($"WeekPlanGetAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
public async void WeekPlanUpdate(WeekPlanModel currItem)
|
||||
public async void WeekPlanUpdateAsync(WeekPlanModel currItem)
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("WeekPlanUpdateAsync");
|
||||
string source = "DB+REDIS";
|
||||
try
|
||||
{
|
||||
//dbController.ResetController();
|
||||
@@ -1869,9 +2048,21 @@ namespace GWMS.UI.Data
|
||||
string cacheKey = $"WEEKPLAN:List";
|
||||
await ExecFlushRedisPattern(cacheKey);
|
||||
}
|
||||
catch
|
||||
catch (Exception exc)
|
||||
{
|
||||
string exMsg = $"Eccezione in WeekPlanUpdateAsync | PlantId: {currItem.PlantId} | WeekPlanId: {currItem.WeekPlanId}";
|
||||
Log.Error($"{exMsg}{Environment.NewLine}{exc}");
|
||||
// traccio errore
|
||||
activity?.SetStatus(ActivityStatusCode.Error, exc.Message);
|
||||
activity?.AddEvent(new ActivityEvent("exception", tags: new ActivityTagsCollection {
|
||||
{ "exception.type", exc.GetType().Name },
|
||||
{ "exception.message", exc.Message },
|
||||
{ "exception.stacktrace", exc.StackTrace }
|
||||
}));
|
||||
}
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"WeekPlanUpdateAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
@@ -1909,12 +2100,12 @@ namespace GWMS.UI.Data
|
||||
int transporterId = 1;
|
||||
double qtyOrd = 0;
|
||||
// faccio ciclo x tutti gli impianti
|
||||
List<PlantDTO> currPlantData = await PlantDtoGetAll();
|
||||
List<WeekPlanModel> fullWeekPlan = WeekPlanGet().Result;
|
||||
List<PlantDTO> currPlantData = await PlantDtoGetAllAsync();
|
||||
List<WeekPlanModel> fullWeekPlan = WeekPlanGetAsync().Result;
|
||||
foreach (var item in currPlantData)
|
||||
{
|
||||
// recupero ordini x il plant
|
||||
var listOrderOpen = await OrdersGetOpen(item.PlantId);
|
||||
var listOrderOpen = await OrdersGetOpenAsync(item.PlantId);
|
||||
|
||||
// verifico NON ci siano duplicati,
|
||||
var list2del = listOrderOpen
|
||||
@@ -1964,7 +2155,7 @@ namespace GWMS.UI.Data
|
||||
dbController.OrderInsert(NewOrders);
|
||||
|
||||
// recupero elenco users associati al FORNITORE....
|
||||
var rawUserList = UserDataGetFilt("").Result;
|
||||
var rawUserList = UserDataGetFiltAsync("").Result;
|
||||
var supplList = rawUserList
|
||||
.Where(x => x.Roles.Contains("ExtUser"))
|
||||
.ToList();
|
||||
@@ -1975,7 +2166,7 @@ namespace GWMS.UI.Data
|
||||
// recupero NUOVI ordini x plant...
|
||||
foreach (var plant in currPlantData)
|
||||
{
|
||||
var newOrderOpen = await OrdersGetOpen(plant.PlantId);
|
||||
var newOrderOpen = await OrdersGetOpenAsync(plant.PlantId);
|
||||
string emailDest = "";
|
||||
string emailSubj = "";
|
||||
string emailBody = "";
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Version>1.0.2603.0315</Version>
|
||||
<Version>1.0.2603.0318</Version>
|
||||
<UserSecretsId>95c9f021-52d1-4390-a670-5810b7b777b0</UserSecretsId>
|
||||
<EnableNETAnalyzers>true</EnableNETAnalyzers>
|
||||
<RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
|
||||
|
||||
@@ -229,11 +229,11 @@ namespace GWMS.UI.Pages
|
||||
// se ho un plantId valido --> altrimenti non abilitato
|
||||
if (ClaimPlantId == 0)
|
||||
{
|
||||
PlantsList = await DataService.PlantDtoGetAll();
|
||||
PlantsList = await DataService.PlantDtoGetAllAsync();
|
||||
}
|
||||
else if (ClaimPlantId > 0)
|
||||
{
|
||||
var rawData = await DataService.PlantDtoGetAll();
|
||||
var rawData = await DataService.PlantDtoGetAllAsync();
|
||||
PlantsList = rawData.Where(x => x.PlantId == ClaimPlantId).ToList();
|
||||
SelPlantId = ClaimPlantId;
|
||||
}
|
||||
|
||||
@@ -279,11 +279,11 @@ namespace GWMS.UI.Pages
|
||||
// se ho un plantId valido --> altrimenti non abilitato
|
||||
if (ClaimPlantId == 0)
|
||||
{
|
||||
PlantsList = await DataService.PlantsList();
|
||||
PlantsList = await DataService.PlantsListAsync();
|
||||
}
|
||||
else if (ClaimPlantId > 0)
|
||||
{
|
||||
var rawData = await DataService.PlantsList();
|
||||
var rawData = await DataService.PlantsListAsync();
|
||||
PlantsList = rawData.Where(x => x.PlantId == ClaimPlantId).ToList();
|
||||
SelPlantId = ClaimPlantId;
|
||||
}
|
||||
|
||||
@@ -179,11 +179,11 @@ namespace GWMS.UI.Pages
|
||||
// se ho un plantId valido --> altrimenti non abilitato
|
||||
if (ClaimPlantId == 0)
|
||||
{
|
||||
PlantsList = await DataService.PlantsList();
|
||||
PlantsList = await DataService.PlantsListAsync();
|
||||
}
|
||||
else if (ClaimPlantId > 0)
|
||||
{
|
||||
var rawData = await DataService.PlantsList();
|
||||
var rawData = await DataService.PlantsListAsync();
|
||||
PlantsList = rawData.Where(x => x.PlantId == ClaimPlantId).ToList();
|
||||
SelPlantId = ClaimPlantId;
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ namespace GWMS.UI.Pages
|
||||
private async Task ReloadData()
|
||||
{
|
||||
isLoading = true;
|
||||
SearchRecords = await DataService.OrdersGetFilt(AppMService.Order_Filter);
|
||||
SearchRecords = await DataService.OrdersGetFiltAsync(AppMService.Order_Filter);
|
||||
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
||||
isLoading = false;
|
||||
}
|
||||
@@ -334,17 +334,17 @@ namespace GWMS.UI.Pages
|
||||
protected async Task ReloadAllData()
|
||||
{
|
||||
isLoading = true;
|
||||
SuppliersList = await DataService.SuppliersGetAll();
|
||||
SuppliersList = await DataService.SuppliersGetAllAsync();
|
||||
PlantsList = null;
|
||||
await GetClaimsData();
|
||||
// se ho un plantId valido --> altrimenti non abilitato
|
||||
if (ClaimPlantId == 0)
|
||||
{
|
||||
PlantsList = await DataService.PlantsList();
|
||||
PlantsList = await DataService.PlantsListAsync();
|
||||
}
|
||||
else if (ClaimPlantId > 0)
|
||||
{
|
||||
var rawData = await DataService.PlantsList();
|
||||
var rawData = await DataService.PlantsListAsync();
|
||||
PlantsList = rawData.Where(x => x.PlantId == ClaimPlantId).ToList();
|
||||
SelPlantId = ClaimPlantId;
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ namespace GWMS.UI.Pages
|
||||
ListRecords = null;
|
||||
try
|
||||
{
|
||||
SearchRecords = await DataService.PlantsAnalisysByFilt(AppMService.Order_Filter);
|
||||
SearchRecords = await DataService.PlantsAnalisysByFiltAsync(AppMService.Order_Filter);
|
||||
SearchRecords = SearchRecords.Where(x => x.HasRefill || !_ShowOnlyRefill).ToList();
|
||||
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
||||
}
|
||||
@@ -321,7 +321,7 @@ namespace GWMS.UI.Pages
|
||||
// rileggo dal DB il record corrente...
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
currRecord = await DataService.OrderGetById(selRecord.OrdersIds.FirstOrDefault());
|
||||
currRecord = await DataService.OrderGetByIdAsync(selRecord.OrdersIds.FirstOrDefault());
|
||||
});
|
||||
pUpd.Wait();
|
||||
}
|
||||
@@ -348,17 +348,17 @@ namespace GWMS.UI.Pages
|
||||
protected async Task ReloadAllData()
|
||||
{
|
||||
isLoading = true;
|
||||
SuppliersList = await DataService.SuppliersGetAll();
|
||||
SuppliersList = await DataService.SuppliersGetAllAsync();
|
||||
PlantsList = null;
|
||||
await GetClaimsData();
|
||||
// se ho un plantId valido --> altrimenti non abilitato
|
||||
if (ClaimPlantId == 0)
|
||||
{
|
||||
PlantsList = await DataService.PlantDtoGetAll();
|
||||
PlantsList = await DataService.PlantDtoGetAllAsync();
|
||||
}
|
||||
else if (ClaimPlantId > 0)
|
||||
{
|
||||
var rawData = await DataService.PlantDtoGetAll();
|
||||
var rawData = await DataService.PlantDtoGetAllAsync();
|
||||
PlantsList = rawData.Where(x => x.PlantId == ClaimPlantId).ToList();
|
||||
SelPlantId = ClaimPlantId;
|
||||
}
|
||||
@@ -383,7 +383,7 @@ namespace GWMS.UI.Pages
|
||||
SearchRecords = null;
|
||||
ListRecords = null;
|
||||
AppMService.Order_Filter = SelectOrderData.Init(5, 10);
|
||||
await DataService.PlantsAnalisysReset(AppMService.Order_Filter);
|
||||
await DataService.PlantsAnalisysResetAsync(AppMService.Order_Filter);
|
||||
await ReloadAllData();
|
||||
}
|
||||
|
||||
@@ -396,7 +396,7 @@ namespace GWMS.UI.Pages
|
||||
protected async Task UpdateData()
|
||||
{
|
||||
currRecord = null;
|
||||
await DataService.PlantsAnalisysReset(AppMService.Order_Filter);
|
||||
await DataService.PlantsAnalisysResetAsync(AppMService.Order_Filter);
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
|
||||
@@ -256,11 +256,11 @@ namespace GWMS.UI.Pages
|
||||
// se ho un plantId valido --> altrimenti non abilitato
|
||||
if (ClaimPlantId == 0)
|
||||
{
|
||||
PlantsList = await DataService.PlantsList();
|
||||
PlantsList = await DataService.PlantsListAsync();
|
||||
}
|
||||
else if (ClaimPlantId > 0)
|
||||
{
|
||||
var rawData = await DataService.PlantsList();
|
||||
var rawData = await DataService.PlantsListAsync();
|
||||
PlantsList = rawData.Where(x => x.PlantId == ClaimPlantId).ToList();
|
||||
SelPlantId = ClaimPlantId;
|
||||
}
|
||||
@@ -279,7 +279,7 @@ namespace GWMS.UI.Pages
|
||||
|
||||
if (selRecord != null)
|
||||
{
|
||||
await DataService.remObjItem(SelPlantCode, selRecord);
|
||||
await DataService.RemObjItemAsync(SelPlantCode, selRecord);
|
||||
}
|
||||
await ReloadAllData();
|
||||
}
|
||||
@@ -299,7 +299,7 @@ namespace GWMS.UI.Pages
|
||||
protected async Task UpdateData()
|
||||
{
|
||||
currRecord = null;
|
||||
await DataService.PlantsAnalisysReset(AppMService.Order_Filter);
|
||||
await DataService.PlantsAnalisysResetAsync(AppMService.Order_Filter);
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace GWMS.UI.Pages
|
||||
protected void Edit(PlantDTO selRecord)
|
||||
{
|
||||
// rileggo dal DB il record corrente...
|
||||
var pUpd = Task.Run(async () => currRecord = await DataService.PlantDtoGetByCode(selRecord.PlantCode));
|
||||
var pUpd = Task.Run(async () => currRecord = await DataService.PlantDtoGetByCodeAsync(selRecord.PlantCode));
|
||||
pUpd.Wait();
|
||||
}
|
||||
|
||||
@@ -152,11 +152,11 @@ namespace GWMS.UI.Pages
|
||||
// se ho un plantId valido --> altrimenti non abilitato
|
||||
if (ClaimPlantId == 0)
|
||||
{
|
||||
ListRecords = await DataService.PlantDtoGetAll();
|
||||
ListRecords = await DataService.PlantDtoGetAllAsync();
|
||||
}
|
||||
else if (ClaimPlantId > 0)
|
||||
{
|
||||
var rawData = await DataService.PlantDtoGetAll();
|
||||
var rawData = await DataService.PlantDtoGetAllAsync();
|
||||
ListRecords = rawData.Where(x => x.PlantId == ClaimPlantId).ToList();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -110,11 +110,11 @@ namespace GWMS.UI.Pages
|
||||
// se ho un plantId valido --> altrimenti non abilitato
|
||||
if (ClaimPlantId == 0)
|
||||
{
|
||||
ListRecords = await DataService.PlantDtoGetAll();
|
||||
ListRecords = await DataService.PlantDtoGetAllAsync();
|
||||
}
|
||||
else if (ClaimPlantId > 0)
|
||||
{
|
||||
var rawData = await DataService.PlantDtoGetAll();
|
||||
var rawData = await DataService.PlantDtoGetAllAsync();
|
||||
ListRecords = rawData.Where(x => x.PlantId == ClaimPlantId).ToList();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -173,18 +173,18 @@ namespace GWMS.UI.Pages
|
||||
protected async Task ReloadAllData()
|
||||
{
|
||||
isLoading = true;
|
||||
PlantsList = await DataService.PlantsList();
|
||||
PlantsList = await DataService.PlantsListAsync();
|
||||
SelSupplierId = 0;
|
||||
SuppliersList = null;
|
||||
await GetClaimsData();
|
||||
// se ho un plantId valido --> altrimenti non abilitato
|
||||
if (ClaimSupplierId == 0)
|
||||
{
|
||||
SuppliersList = await DataService.SuppliersGetAll();
|
||||
SuppliersList = await DataService.SuppliersGetAllAsync();
|
||||
}
|
||||
else if (ClaimSupplierId > 0)
|
||||
{
|
||||
var rawData = await DataService.SuppliersGetAll();
|
||||
var rawData = await DataService.SuppliersGetAllAsync();
|
||||
SuppliersList = rawData.Where(x => x.SupplierId == ClaimSupplierId).ToList();
|
||||
SelSupplierId = ClaimSupplierId;
|
||||
}
|
||||
@@ -379,7 +379,7 @@ namespace GWMS.UI.Pages
|
||||
private async Task ReloadData()
|
||||
{
|
||||
isLoading = true;
|
||||
SearchRecords = await DataService.OrdersGetFilt(AppMService.Order_Filter);
|
||||
SearchRecords = await DataService.OrdersGetFiltAsync(AppMService.Order_Filter);
|
||||
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace GWMS.UI.Pages
|
||||
|
||||
protected async Task SendEmail()
|
||||
{
|
||||
await DataService.TestSendEmail(emailDest, emailOggetto, emailCorpo);
|
||||
await DataService.TestSendEmailAsync(emailDest, emailOggetto, emailCorpo);
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
@@ -171,18 +171,18 @@ namespace GWMS.UI.Pages
|
||||
protected async Task ReloadAllData()
|
||||
{
|
||||
isLoading = true;
|
||||
PlantsList = await DataService.PlantsList();
|
||||
PlantsList = await DataService.PlantsListAsync();
|
||||
SelTranspId = 0;
|
||||
TransportersList = null;
|
||||
await GetClaimsData();
|
||||
// se ho un plantId valido --> altrimenti non abilitato
|
||||
if (ClaimTransporterId == 0)
|
||||
{
|
||||
TransportersList = await DataService.TransportersGetAll();
|
||||
TransportersList = await DataService.TransportersGetAllAsync();
|
||||
}
|
||||
else if (ClaimTransporterId > 0)
|
||||
{
|
||||
var rawData = await DataService.TransportersGetAll();
|
||||
var rawData = await DataService.TransportersGetAllAsync();
|
||||
TransportersList = rawData.Where(x => x.TransporterId == ClaimTransporterId).ToList();
|
||||
SelTranspId = ClaimTransporterId;
|
||||
}
|
||||
@@ -419,7 +419,7 @@ namespace GWMS.UI.Pages
|
||||
private async Task ReloadData()
|
||||
{
|
||||
isLoading = true;
|
||||
SearchRecords = await DataService.OrdersGetFilt(AppMService.Order_Filter);
|
||||
SearchRecords = await DataService.OrdersGetFiltAsync(AppMService.Order_Filter);
|
||||
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace GWMS.UI.Pages
|
||||
// clear any error messages
|
||||
strError = "";
|
||||
|
||||
UsersAll = await DataService.UserDataGetFilt(searchVal);
|
||||
UsersAll = await DataService.UserDataGetFiltAsync(searchVal);
|
||||
|
||||
// filtro visualizzazione x tipo SE richeisto
|
||||
if (FiltUserRole != "0")
|
||||
@@ -524,7 +524,7 @@ namespace GWMS.UI.Pages
|
||||
{
|
||||
case "PlantId":
|
||||
// elenco plant --> to dictionary!
|
||||
var plantList = await DataService.PlantsList();
|
||||
var plantList = await DataService.PlantsListAsync();
|
||||
if (plantList != null)
|
||||
{
|
||||
ClaimValList = plantList
|
||||
@@ -534,7 +534,7 @@ namespace GWMS.UI.Pages
|
||||
|
||||
case "SupplierId":
|
||||
// elenco plant --> to dictionary!
|
||||
var suppList = await DataService.SuppliersGetAll();
|
||||
var suppList = await DataService.SuppliersGetAllAsync();
|
||||
if (suppList != null)
|
||||
{
|
||||
ClaimValList = suppList
|
||||
@@ -544,7 +544,7 @@ namespace GWMS.UI.Pages
|
||||
|
||||
case "TransporterId":
|
||||
// elenco plant --> to dictionary!
|
||||
var transpList = await DataService.TransportersGetAll();
|
||||
var transpList = await DataService.TransportersGetAllAsync();
|
||||
if (transpList != null)
|
||||
{
|
||||
ClaimValList = transpList
|
||||
@@ -563,15 +563,15 @@ namespace GWMS.UI.Pages
|
||||
// effettuo refresh valori cache plants/suppliers/transp
|
||||
if (plantList == null)
|
||||
{
|
||||
plantList = await DataService.PlantsList();
|
||||
plantList = await DataService.PlantsListAsync();
|
||||
}
|
||||
if (suppList == null)
|
||||
{
|
||||
suppList = await DataService.SuppliersGetAll();
|
||||
suppList = await DataService.SuppliersGetAllAsync();
|
||||
}
|
||||
if (transpList == null)
|
||||
{
|
||||
transpList = await DataService.TransportersGetAll();
|
||||
transpList = await DataService.TransportersGetAllAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -206,7 +206,7 @@ namespace GWMS.UI.Pages
|
||||
private async Task ReloadData()
|
||||
{
|
||||
isLoading = true;
|
||||
ListRecords = await DataService.WeekPlanGet();
|
||||
ListRecords = await DataService.WeekPlanGetAsync();
|
||||
// calcolo min/max...
|
||||
checkHourRange();
|
||||
isLoading = false;
|
||||
@@ -252,9 +252,9 @@ namespace GWMS.UI.Pages
|
||||
|
||||
protected async Task ReloadAllData()
|
||||
{
|
||||
PlantsList = await DataService.PlantsList();
|
||||
SuppliersList = await DataService.SuppliersGetAll();
|
||||
TransportersList = await DataService.TransportersGetAll();
|
||||
PlantsList = await DataService.PlantsListAsync();
|
||||
SuppliersList = await DataService.SuppliersGetAllAsync();
|
||||
TransportersList = await DataService.TransportersGetAllAsync();
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
},
|
||||
"Otel": {
|
||||
"EnableTracing": true,
|
||||
"Endpoint": "",
|
||||
"Endpoint": "http://localhost:4317",
|
||||
"Dsn": ""
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>GWMS - Gas Warehouse Management System</i>
|
||||
<h4>Versione: 1.0.2603.0315</h4>
|
||||
<h4>Versione: 1.0.2603.0318</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.0.2603.0315
|
||||
1.0.2603.0318
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>1.0.2603.0315</version>
|
||||
<version>1.0.2603.0318</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>
|
||||
|
||||
Reference in New Issue
Block a user