Update sync x proj (all)
This commit is contained in:
@@ -243,7 +243,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero i dati in ordine crescente fino al num max indicato
|
||||
/// Recupero i dati NON sincronizzati in ordine crescente fino al num max indicato
|
||||
/// </summary>
|
||||
/// <param name="dtStart"></param>
|
||||
/// <param name="dtEnd"></param>
|
||||
|
||||
@@ -69,6 +69,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
RES_CheckChanged,
|
||||
RES_CheckEqual,
|
||||
RES_CheckND,
|
||||
ERR_AllProjSyncUncomplete,
|
||||
ERR_LogMaccSyncUncomplete
|
||||
}
|
||||
|
||||
@@ -774,6 +775,58 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue sync dei dati PROJ su cloud (se NON sincronizzati):
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public SyncResult ProjAllSyncro()
|
||||
{
|
||||
SyncResult answ = SyncResult.ERR_ND;
|
||||
// verifico server ok
|
||||
bool servOk = commLib.CheckRemote();
|
||||
if (!servOk)
|
||||
{
|
||||
answ = SyncResult.ERR_ServerKo;
|
||||
}
|
||||
else
|
||||
{
|
||||
int numSent = 0;
|
||||
using (ProdController lmDbContr = new ProdController())
|
||||
{
|
||||
bool syncEnabled = true;
|
||||
// elenco record da inviare...
|
||||
List<ProdModel> recList = lmDbContr.GetUnsentAsc();
|
||||
// controllo ci sia qulcosa da inviare...
|
||||
if (recList.Count > 0)
|
||||
{
|
||||
foreach (var item in recList)
|
||||
{
|
||||
if (syncEnabled)
|
||||
{
|
||||
answ = ProjSyncro(item.ProdId);
|
||||
if (answ != SyncResult.ALL_OK)
|
||||
{
|
||||
// disabilito altri sync
|
||||
syncEnabled = false;
|
||||
// loggo
|
||||
Log.Error($"ProjAllSyncro | Errore in sincornizzazione progetto: prodId: {item.ProdId} | prodDbId: {item.ProdDbId} record");
|
||||
// salvo errore
|
||||
answ = SyncResult.ERR_AllProjSyncUncomplete;
|
||||
}
|
||||
else
|
||||
{
|
||||
numSent++;
|
||||
}
|
||||
}
|
||||
}
|
||||
// loggo completato
|
||||
Log.Info($"ProjAllSyncro | Eseguita sincronizzazione di {numSent}/{recList.Count} record");
|
||||
}
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue sync di un SINGOLO PROD (cloud proj):
|
||||
/// - legge il progetto locale + upload x sync (verso cloud)
|
||||
|
||||
@@ -586,6 +586,25 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
return nextId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero i dati NON sincronizzati in ordine crescente fino al num max indicato
|
||||
/// </summary>
|
||||
/// <param name="dtStart"></param>
|
||||
/// <param name="dtEnd"></param>
|
||||
/// <returns></returns>
|
||||
public List<ProdModel> GetUnsentAsc()
|
||||
{
|
||||
using (DatabaseContext localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING))
|
||||
{
|
||||
// retrieve
|
||||
return localDbCtx
|
||||
.ProdList
|
||||
.Where(x => x.ProjCloudId == 0)
|
||||
.OrderBy(x => x.ProdDbId)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifica prod assegnato a supervisor: ...se c'e' anche un solo machgroup del prod
|
||||
/// assegnato ad un supervisor o in stato 0 (dovrebbe essere la stessa cosa?)
|
||||
@@ -812,7 +831,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
// salvo record PROD
|
||||
localDbCtx.SaveChanges();
|
||||
|
||||
// cerco se ci siano prod colelgati ed aggiorno pure loro...
|
||||
// cerco se ci siano projects collegati ed aggiorno pure loro...
|
||||
var projList = localDbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProdDbId == currData.ProdDbId)
|
||||
|
||||
Reference in New Issue
Block a user