Compare commits

...

15 Commits

Author SHA1 Message Date
Samuele Locatelli 52c1fa654e Correzione naming e nuova dll sync 2024-08-05 14:39:23 +02:00
Samuele Locatelli 43ebd3db5b Modifica controller rawitems
- sync stato cancellato
- fix upsert a fine modifica magazzino che riporta a zero cloudID
2024-08-05 14:06:05 +02:00
Samuele Locatelli 3aab1d8d8c Aggiunta cancellazione logica x rawItemsID 2024-08-05 14:05:33 +02:00
Samuele Locatelli 96e78e1c72 Update in aggiornamento rawItem: trova duplicato e da errore 2024-08-02 10:45:17 +02:00
Samuele Locatelli 7cc1eb1561 Fix update materiali: descrizione aggioranta SOLO SE !=null 2024-07-29 13:46:33 +02:00
Samuele Locatelli 29c0ea3537 trasformata funzione private - public x sync stato archiviato 2024-07-18 18:29:06 +02:00
Samuele Locatelli 76d7ef8c25 forzato nei modelli minDate a 1900-01-01 + fix migration 2024-07-17 19:29:50 +02:00
Samuele Locatelli 130b71aaf7 Fix limite sync a 1 anno 2024-07-17 11:20:28 +02:00
Samuele Locatelli 33c55dfc62 Aggiunta migrazione x modifica gestione DtLastMod su tab Prod 2024-07-17 09:05:44 +02:00
Samuele Locatelli 080a9cfbf2 Aggiunta metodi gestione sync archiviato 2024-07-17 09:03:13 +02:00
Samuele Locatelli 8f1b068850 Merge remote-tracking branch 'origin/feature/NewWarehouseTest' into DataLayer 2024-07-11 11:50:41 +02:00
Samuele Locatelli f1624982c6 Fix ricezione QtyTot decimale 2024-07-11 11:50:36 +02:00
Emmanuele Sassi 4449a73137 - aggiunta sincronizzazione progetti magazzino dopo archiviazione
- commentata sincronizzazione log macchina
- corretto invio dimensioni RawPart a magazzino
2024-07-09 15:22:51 +02:00
Samuele Locatelli a7e5206f45 Fix possibile errore commit locale come Lovato il 04.07.2024 alle 8.00 2024-07-04 16:57:26 +02:00
Samuele Locatelli dbeef11a90 Merge remote-tracking branch 'origin/feature/NewWarehouseTest' into DataLayer 2024-07-03 07:30:56 +02:00
24 changed files with 730 additions and 81 deletions
@@ -6,6 +6,7 @@ using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
namespace EgtBEAMWALL.DataLayer.Controllers
@@ -24,9 +25,11 @@ namespace EgtBEAMWALL.DataLayer.Controllers
/// <param name="authToken">Token di autorizzazione</param>
public MagmanController(string ServerAddress, string AuthToken)
{
commLib = new DataSyncro(ServerAddress, AuthToken);
// forzo a 30 sec...
int timeout = 30000;
commLib = new DataSyncro(ServerAddress, AuthToken, timeout);
bool servOk = commLib.CheckRemote();
Log.Info($"Avviato MagmanController | server: {ServerAddress} | timeout: standard (500ms)| CheckRemote OK: {servOk}");
Log.Info($"Avviato MagmanController | server: {ServerAddress} | timeout: {timeout}ms | CheckRemote OK: {servOk}");
}
/// <summary>
@@ -371,8 +374,24 @@ namespace EgtBEAMWALL.DataLayer.Controllers
}
// eseguo il sync!
List<MaterialDTO> list2send = matListDb.Select(x => MaterialsController.ConvToDto(x)).ToList();
// preparo pacchetto invio...
bool okMat = commLib.MaterialsSend(list2send);
// preparo pacchetto invio... 10 alla volta...
bool okMat = false;
#if false
int numRec = list2send.Count;
if (numRec > 10)
{
for (int i = 0; i < numRec / 10; i++)
{
var currList = list2send.Skip(10 * i).Take(10).ToList();
okMat = commLib.MaterialsSend(currList);
}
}
else
{
okMat = commLib.MaterialsSend(list2send);
}
#endif
okMat = commLib.MaterialsSend(list2send);
// se inviato, scarico x merge locale
if (!okMat)
{
@@ -873,11 +892,85 @@ namespace EgtBEAMWALL.DataLayer.Controllers
// loggo completato
Log.Info($"ProjAllSyncro | Eseguita sincronizzazione di {numSent}/{recList.Count} record");
}
/*------------------------------------------------
* 2024.07.10 ora faccio giro differente:
* - calcolo data limite da MagmanSync x tipo ProjAllSyncro, ultimo rec --> data limite
* - recupero progetti modificati dopo data limite (DtLastMod)
* - invio TUTTI i record modificati dopo data limite
* - recupero tutti i record remoti modificati dopo la stessa data limite
* - merge locale (x archiviato)
*------------------------------------------------ */
}
}
return answ;
}
/// <summary> Effettua sync stato archiviato progetti locali <--> cloud </summary> <returns></returns>
public SyncResult ProjArchSync()
{
SyncResult answ = SyncResult.ERR_ND;
// per prima cosa calcolo limite sync come ultimo record registrato
DateTime dtLastSync = DateTime.MinValue;
DateTime adesso = DateTime.Now;
string syncType = "ProjArchSync";
using (MagmanSyncController msContr = new MagmanSyncController())
{
var lastRec = msContr.GetLastBySync(syncType);
dtLastSync = lastRec.DtReq;
// ora uso controller x gestione progetti
using (ProdController prodContr = new ProdController())
{
// recupero elenco prod da inviare...
var list2send = prodContr.GetModAfter(dtLastSync);
// converto x inviare
bool servOk = commLib.CheckRemote();
if (!servOk)
{
answ = SyncResult.ERR_ServerKo;
}
else
{
try
{
// converto gli oggetti
Dictionary<int, bool> proj2send = list2send.ToDictionary(x => x.ProjCloudId, x => x.IsArchived);
// effettuo invio...
bool resOk = commLib.ProjectArchSend(proj2send);
if (!resOk)
{
answ = SyncResult.ERR_CloudResNotSent;
}
else
{
// ora chiedo da online elenco proj modificati x sync locale...
Dictionary<int, bool> cloudUpdated = commLib.ProjectArchGet(dtLastSync);
if (cloudUpdated != null)
{
prodContr.UpdateListArchived(cloudUpdated);
}
// registro nuovo sync fatto ora...
MagmanSyncModel newRec = new MagmanSyncModel()
{
CloudId = 0,
SyncType = syncType,
DtReq = adesso,
Payload = ""
};
int syncId = msContr.Insert(newRec);
answ = SyncResult.ALL_OK;
}
}
catch
{
answ = SyncResult.ERR_ServerKo;
}
}
}
}
// restituisco
return answ;
}
/// <summary>
/// Esegue invio info avanzamento di un SINGOLO PROD dato il suo Id + info avanzamento
/// </summary>
@@ -114,6 +114,37 @@ namespace EgtBEAMWALL.DataLayer.Controllers
return dbResult;
}
/// <summary>
/// Recupero ultimo record di sync dato tipo
/// </summary>
/// <param name="SyncType">TIpo di sync richiesto, tipicamente ProjArchSync x fix stato archived</param>
/// <returns></returns>
public MagmanSyncModel GetLastBySync(string SyncType)
{
// record default a 1 anno fa...
DateTime dtLim = DateTime.Today.AddYears(-1);
MagmanSyncModel dbResult = new MagmanSyncModel()
{
CloudId = 0,
SyncType = SyncType,
DtReq = dtLim,
Payload = ""
};
using (DatabaseContext localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING))
{
var rawRes = localDbCtx
.SyncList
.Where(x => (!string.IsNullOrEmpty(SyncType) && x.SyncType == SyncType))
.OrderByDescending(x => x.DtReq)
.FirstOrDefault();
if (rawRes != null)
{
dbResult = rawRes;
}
}
return dbResult;
}
/// <summary>
/// Lista record NON inviati filtrati x tipo e num max
/// </summary>
@@ -88,9 +88,9 @@ namespace EgtBEAMWALL.DataLayer.Controllers
{
MatId = coreRec.nId,
MatCode = coreRec.sWarehouseMaterial,
HMm = (decimal)Math.Round(coreRec.dH,2),
LMm = (decimal)Math.Round(coreRec.dL,2),
WMm = (decimal)Math.Round(coreRec.dW,2),
HMm = (decimal)Math.Round(coreRec.dH, 2),
LMm = (decimal)Math.Round(coreRec.dL, 2),
WMm = (decimal)Math.Round(coreRec.dW, 2),
};
}
return answ;
@@ -231,7 +231,8 @@ namespace EgtBEAMWALL.DataLayer.Controllers
.Where(x => (updItem.MatId > 0 && x.MatId == updItem.MatId)
|| (updItem.MatCloudId > 0 && x.MatCloudId == updItem.MatCloudId)
|| (x.MatCode == updItem.MatCode && x.WMm == updItem.WMm && x.HMm == updItem.HMm && x.LMm == updItem.LMm))
.SingleOrDefault();
.OrderBy(x => x.MatId)
.FirstOrDefault();
if (item2update != null)
{
@@ -415,7 +416,11 @@ namespace EgtBEAMWALL.DataLayer.Controllers
//// update, vers 1...
//localDbCtx.Entry(item2update).CurrentValues.SetValues(updItem);
item2update.MatCloudId = updItem.MatCloudId;
item2update.MatDesc = updItem.MatDesc;
// aggiorno SE presente...
if (!string.IsNullOrEmpty(updItem.MatDesc))
{
item2update.MatDesc = updItem.MatDesc;
}
localDbCtx.Entry(item2update).State = System.Data.Entity.EntityState.Modified;
// Commit changes
localDbCtx.SaveChanges();
@@ -454,7 +459,11 @@ namespace EgtBEAMWALL.DataLayer.Controllers
//// update, vers 1...
//localDbCtx.Entry(item2update).CurrentValues.SetValues(updItem);
item2update.MatCloudId = updItem.MatCloudId;
item2update.MatDesc = updItem.MatDesc;
// aggiorno SE presente...
if (!string.IsNullOrEmpty(updItem.MatDesc))
{
item2update.MatDesc = updItem.MatDesc;
}
localDbCtx.Entry(item2update).State = System.Data.Entity.EntityState.Modified;
// Commit changes
localDbCtx.SaveChanges();
@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Linq.Expressions;
using static EgtBEAMWALL.Core.ConstBeam;
namespace EgtBEAMWALL.DataLayer.Controllers
@@ -22,6 +23,42 @@ namespace EgtBEAMWALL.DataLayer.Controllers
#region Public Methods
/// <summary>
/// Helper conversione a ProjectDTO
/// </summary>
/// <param name="currRec">record in formato ProdModel</param>
/// <returns></returns>
public static ProjectDTO ConvToDto(ProdModel currRec)
{
// ho valori mancanti che saranno calcolati dal cloud e valori messi a zero di default
ProjectDTO answ = new ProjectDTO()
{
ProjCloudId = currRec.ProjCloudId,
ProjLocalId = currRec.ProdDbId,
ProjExtId = currRec.ProdId,
// è calcolato sul cloud, da token --> machine ID
MachineCloudId = 0,
// è calcolato sul cloud, da token --> KeyNum
KeyNum = 0,
// disponibile solo su PROJ
BTLFileName = "",
PType = (EgwProxy.MagMan.BWType)currRec.PType,
Machine = currRec.Machine,
ProjDescription = currRec.Description,
DtCreated = currRec.DtCreated,
DtLastAction = DateTime.MinValue,
DtSchedule = DateTime.MinValue,
DtStartProd = DateTime.MinValue,
// disponibile solo su PROJ
ListName = "",
ProcTimeEst = 0,
ProcTimeReal = 0,
IsActive = currRec.IsActive,
IsArchived = currRec.IsArchived
};
return answ;
}
/// <summary>
/// Aggiunta di un PROJ ad un PROD
/// </summary>
@@ -59,41 +96,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers
return done;
}
/// <summary>
/// Helper conversione a ProjectDTO
/// </summary>
/// <param name="currRec">record in formato ProdModel</param>
/// <returns></returns>
public static ProjectDTO ConvToDto(ProdModel currRec)
{
// ho valori mancanti che saranno calcolati dal cloud e valori messi a zero di default
ProjectDTO answ = new ProjectDTO()
{
ProjCloudId = currRec.ProjCloudId,
ProjLocalId = currRec.ProdDbId,
ProjExtId = currRec.ProdId,
// è calcolato sul cloud, da token --> machine ID
MachineCloudId = 0,
// è calcolato sul cloud, da token --> KeyNum
KeyNum = 0,
// disponibile solo su PROJ
BTLFileName = "",
PType = (EgwProxy.MagMan.BWType)currRec.PType,
Machine = currRec.Machine,
ProjDescription = currRec.Description,
DtCreated = currRec.DtCreated,
DtLastAction = DateTime.MinValue,
DtSchedule = DateTime.MinValue,
DtStartProd = DateTime.MinValue,
// disponibile solo su PROJ
ListName = "",
ProcTimeEst = 0,
ProcTimeReal = 0,
IsActive = currRec.IsActive,
IsArchived = currRec.IsArchived
};
return answ;
}
/// <summary>
/// Helper conversione modelli verso Core.ProdItem
/// </summary>
@@ -124,7 +126,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers
public Core.ProdFileM ConvToCoreFile(ProdModel currProd)
{
Core.ProdFileM answ = Core.ProdFileM.CreateProdFileM(currProd.ProdId, ProjIdByProd(currProd.ProdId), currProd.DtCreated, currProd.Description, currProd.PType, currProd.Machine, currProd.LockedBy, currProd.LockDate, currProd.IsActive, currProd.IsProduced, currProd.IsArchived, currProd.ProjCloudId);
//Core.ProdFileM answ = Core.ProdFileM.CreateProdFileM(currProd.ProdId, ProjIdByProd(currProd.ProdId), currProd.DtCreated, currProd.Description, currProd.PType, currProd.Machine, currProd.LockedBy, currProd.LockDate, currProd.IsActive, currProd.IsProduced, currProd.IsArchived, currProd.ProjListNav.Select(j => Core.ProjFileM.CreateProjFileM(j.ProdId, currProd.ProdId, j.DtCreated, j.DtExported, j.ListName, j.BTLFileName, j.ProjDescription, j.IsNew, j.Locked, j.PType, j.Machine, j.IsActive, j.IsActive)).ToList());
return answ;
}
@@ -166,6 +167,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
}
// segno eliminazione logica al prod
currProd.IsActive = false;
currProd.DtLastMod = DateTime.Now;
// Commit changes
localDbCtx.SaveChanges();
done = true;
@@ -533,6 +535,24 @@ namespace EgtBEAMWALL.DataLayer.Controllers
return result;
}
/// <summary>
/// Recupero i dati modificati dopo la data richiesta x sincr su cloud
/// </summary>
/// <param name="DtLimit"></param>
/// <returns></returns>
public List<ProdModel> GetModAfter(DateTime DtLimit)
{
using (DatabaseContext localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING))
{
// retrieve
return localDbCtx
.ProdList
.Where(x => x.DtLastMod >= DtLimit)
.OrderBy(x => x.ProdDbId)
.ToList();
}
}
/// <summary>
/// Fornisce nuovo indice VUOTO da usare (allocando sul DB)
/// </summary>
@@ -587,7 +607,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
}
/// <summary>
/// Recupero i dati NON sincronizzati in ordine crescente fino al num max indicato
/// Recupero i dati NON sincronizzati
/// </summary>
/// <param name="dtStart"></param>
/// <param name="dtEnd"></param>
@@ -625,7 +645,11 @@ namespace EgtBEAMWALL.DataLayer.Controllers
return numAssigned > 0;
}
/// <summary> Return Lock by ProdId (proj & prod) </summary> <param name="ProdId"></param> <returns></returns>
/// <summary>
/// Return Lock by ProdId (proj & prod)
/// </summary>
/// <param name="ProdId"></param>
/// <returns></returns>
public bool IsLockByProdId(int ProdId)
{
bool bIsLock = false;
@@ -655,9 +679,13 @@ namespace EgtBEAMWALL.DataLayer.Controllers
return bIsLock;
}
/// <summary> Manage Lock by ProdId (proj & prod) </summary> <param name="ProdId"></param>
/// <param name="Locked">Stato Lock da impostare</param> <param name="UserKey">User ID / Key
/// number</param> <returns></returns>
/// <summary>
/// Manage Lock by ProdId (proj & prod)
/// </summary>
/// <param name="ProdId"></param>
/// <param name="Locked">Stato Lock da impostare</param>
/// <param name="UserKey">User ID / Key number</param>
/// <returns></returns>
public ProdModel LockByProdId(int ProdId, bool Locked, string UserKey = "USER01")
{
ProdModel currProd;
@@ -674,7 +702,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
currProd.Locked = Locked;
currProd.LockDate = DateTime.Now;
currProd.LockedBy = Locked ? UserKey : "";
localDbCtx.Entry(currProd).State = System.Data.Entity.EntityState.Modified;
localDbCtx.Entry(currProd).State = EntityState.Modified;
var currProj = localDbCtx
.ProjList
@@ -687,7 +715,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
item.Locked = Locked;
item.LockDate = DateTime.Now;
item.LockedBy = Locked ? UserKey : "";
localDbCtx.Entry(item).State = System.Data.Entity.EntityState.Modified;
localDbCtx.Entry(item).State = EntityState.Modified;
}
}
@@ -750,6 +778,36 @@ namespace EgtBEAMWALL.DataLayer.Controllers
return done;
}
/// <summary>
/// Esegue syncro sul DB dell'elenco dei record
/// </summary>
/// <param name="cloudStatus">Dizionario valori cloudId / isArchived</param>
/// <returns></returns>
public bool UpdateListArchived(Dictionary<int, bool> cloudStatus)
{
bool fatto = false;
int numDone = 0;
int num2do = cloudStatus.Count;
try
{
DateTime adesso = DateTime.Now;
// ciclo tutti i record e segno update...
foreach (var item in cloudStatus)
{
// chiamo metodo singolo
numDone += UpdateArchivedByCloudId(item.Key, item.Value) ? 1 : 0;
}
fatto = numDone == num2do;
}
catch (Exception exc)
{
string errMessage = $"EXCEPTION on Prod.UpdateListArchived: {Environment.NewLine}{exc}";
Console.WriteLine(errMessage);
Log.Error(errMessage);
}
return fatto;
}
/// <summary>
/// Update record su DB x campo IsArchived
/// </summary>
@@ -778,6 +836,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
{
// aggiorno valore descrizione
currData.IsArchived = IsArchived;
currData.DtLastMod = DateTime.Now;
// update dei proj relativi
foreach (var item in proj2update)
@@ -1231,7 +1290,64 @@ namespace EgtBEAMWALL.DataLayer.Controllers
{
var ProjCtr = new ProjController();
return ProjCtr.GetByProdAsc(ProdId).Select(y => y.nProjId).ToList();
//return DbManager.obj.ProjCtr.GetByProdAsc(ProdId).Select(y => y.nProjId).ToList();
}
/// <summary>
/// Update record su DB x campo IsArchived dato CloudId
/// </summary>
/// <param name="ProjCloudId"></param>
/// <param name="IsArchived"></param>
/// <returns></returns>
protected bool UpdateArchivedByCloudId(int ProjCloudId, bool IsArchived)
{
bool fatto = false;
DateTime adesso = DateTime.Now;
// cerco specifico Prod
ProdModel currData = new ProdModel();
using (DatabaseContext localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING))
{
currData = localDbCtx
.ProdList
.Where(x => x.ProjCloudId == ProjCloudId)
.SingleOrDefault();
if (currData != null)
{
// sel dei proj da aggiornare...
var proj2update = localDbCtx
.ProjList
.Where(x => x.ProdDbId == currData.ProdDbId)
.ToList();
try
{
// aggiorno valore descrizione
currData.IsArchived = IsArchived;
currData.DtLastMod = adesso;
// update dei proj relativi
foreach (var item in proj2update)
{
item.IsArchived = IsArchived;
}
// Commit changes
localDbCtx.SaveChanges();
fatto = true;
}
catch (Exception exc)
{
string errMessage = $"EXCEPTION on Prod.UpdateArchivedByCloudId:{Environment.NewLine}{exc}";
Console.WriteLine(errMessage);
Log.Error(errMessage);
}
}
else
{
string errMessage = $"ERROR on Prod.UpdateArchivedByCloudId: req item was not found | ProjCloudId {ProjCloudId} | IsArchived {IsArchived}";
Console.WriteLine(errMessage);
Log.Error(errMessage);
}
}
return fatto;
}
#endregion Protected Methods
@@ -50,6 +50,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
RawItemCloudId = currRec.RawItemCloudId,
RawItemLocalId = currRec.RawItemId,
IsRemn = currRec.IsRemn,
IsDeleted = currRec.IsDeleted,
QtyAvail = currRec.QtyAvail,
HMm = currRec.HMm,
LMm = currRec.LMm,
@@ -76,7 +77,9 @@ namespace EgtBEAMWALL.DataLayer.Controllers
LMm = currRec.LMm,
WMm = currRec.WMm,
MatId = currRec.MatLocalId,
IsDeleted = currRec.IsDeleted,
IsRemn = currRec.IsRemn,
// attivo = selezionato x nesting
IsActive = isActive,
UseQty = true,
Note = currRec.Note
@@ -102,7 +105,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
WMm = currRec.WMm,
MatId = matLocalId,
IsRemn = currRec.IsRemn,
IsActive = currRec.IsActive,
IsDeleted = currRec.IsDeleted,
UseQty = true,
Note = currRec.Note
};
@@ -123,9 +126,9 @@ namespace EgtBEAMWALL.DataLayer.Controllers
{
RawItemId = coreRec.nId,
MatId = coreRec.Material.nId,
HMm = (decimal)Math.Round(coreRec.Material.dH,2),
LMm = (decimal)Math.Round(coreRec.dL,2),
WMm = coreRec.dW > 0 ? (decimal)Math.Round(coreRec.dW,2) : (decimal)Math.Round(coreRec.Material.dW,2),
HMm = (decimal)Math.Round(coreRec.Material.dH, 2),
LMm = (decimal)Math.Round(coreRec.dL, 2),
WMm = coreRec.dW > 0 ? (decimal)Math.Round(coreRec.dW, 2) : (decimal)Math.Round(coreRec.Material.dW, 2),
IsActive = coreRec.bActive,
UseQty = coreRec.bUseQuantity,
QtyAvail = coreRec.nQuantity
@@ -178,13 +181,27 @@ namespace EgtBEAMWALL.DataLayer.Controllers
{
var items2del = localDbCtx
.RawItemList
.Where(x => x.RawItemId == RawItemId);
.Where(x => x.RawItemId == RawItemId)
.FirstOrDefault();
try
{
// Add to database
localDbCtx.RawItemList.RemoveRange(items2del);
// Commit changes
localDbCtx.SaveChanges();
// verifico SE esista
if (items2del != null)
{
// verifico seabbia un cloud id (fa canc logica)...
if (items2del.RawItemCloudId > 0)
{
items2del.IsDeleted = true;
localDbCtx.Entry(items2del).State = EntityState.Modified;
}
else
{
// ...o meno: fa eliminazione vera
localDbCtx.RawItemList.Remove(items2del);
}
// Commit changes
localDbCtx.SaveChanges();
}
done = true;
}
catch (Exception exc)
@@ -278,17 +295,20 @@ namespace EgtBEAMWALL.DataLayer.Controllers
.RawItemList
.Where(x => (updItem.RawItemId > 0 && x.RawItemId == updItem.RawItemId)
|| (x.MatId == updItem.MatId && x.WMm == updItem.WMm && x.HMm == updItem.HMm && x.LMm == updItem.LMm))
.SingleOrDefault();
.FirstOrDefault();
if (item2update != null)
{
//// update, vers 1...
//localDbCtx.Entry(item2update).CurrentValues.SetValues(updItem);\
item2update.RawItemCloudId = updItem.RawItemCloudId;
// se ho un valore > 0 x CloudId sennò NON modifica
if (updItem.RawItemCloudId > 0)
{
item2update.RawItemCloudId = updItem.RawItemCloudId;
}
item2update.HMm = updItem.HMm;
item2update.LMm = updItem.LMm;
item2update.WMm = updItem.WMm;
item2update.IsActive = updItem.IsActive;
item2update.IsDeleted = updItem.IsDeleted;
item2update.IsRemn = updItem.IsRemn;
if (changeUseQty)
{
@@ -297,7 +317,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
if (changeQtyAvail)
{
item2update.QtyAvail = updItem.QtyAvail;
item2update.LastSync = DateTime.Now;
item2update.LastSync = DateTime.Now;
}
localDbCtx.Entry(item2update).State = EntityState.Modified;
}
@@ -83,7 +83,7 @@ namespace EgtBEAMWALL.DataLayer.DatabaseModels
/// DataOra ultima operazione di Lock (o di rimozione di lock), quando aperto da un dispositivo in rete
/// </summary>
[Column("LockDate")]
public DateTime LockDate { get; set; } = DateTime.MinValue;
public DateTime LockDate { get; set; } = new DateTime(1900, 01, 01);
/// <summary>
/// Record attivo (se false == cancellazione logica)
@@ -106,6 +106,13 @@ namespace EgtBEAMWALL.DataLayer.DatabaseModels
[Column("IsArchived")]
public bool IsArchived { get; set; } = false;
/// <summary>
/// Data Creazione
/// </summary>
[Index]
[Column("DtLastMod")]
public DateTime DtLastMod { get; set; } = new DateTime(1900, 01, 01);
/// <summary>
/// Collezione oggetti Proj associati (almeno 1 by design)
/// </summary>
@@ -92,7 +92,7 @@ namespace EgtBEAMWALL.DataLayer.DatabaseModels
/// dispositivo in rete
/// </summary>
[Column("LockDate")]
public DateTime LockDate { get; set; } = DateTime.MinValue;
public DateTime LockDate { get; set; } = new DateTime(1900, 01, 01);
/// <summary>
/// Record attivo (se false == cancellazione logica)
@@ -37,7 +37,7 @@ namespace EgtBEAMWALL.DataLayer.DatabaseModels
public int QtyAvail { get; set; } = 0;
/// <summary>
/// Active/ = can be used
/// Active = can be used
/// </summary>
public bool IsActive { get; set; } = false;
@@ -46,6 +46,11 @@ namespace EgtBEAMWALL.DataLayer.DatabaseModels
/// </summary>
public bool IsRemn { get; set; } = false;
/// <summary>
/// Deleted = from cloud, not to use
/// </summary>
public bool IsDeleted { get; set; } = false;
/// <summary>
/// Item's Lenght
/// </summary>
@@ -47,7 +47,7 @@
<HintPath>..\ExtLibs\EgtWPFLib5.dll</HintPath>
</Reference>
<Reference Include="EgwProxy.MagMan, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\EgwProxy.MagMan.1.0.2406.2911\lib\EgwProxy.MagMan.dll</HintPath>
<HintPath>..\packages\EgwProxy.MagMan.1.0.2408.514\lib\EgwProxy.MagMan.dll</HintPath>
</Reference>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll</HintPath>
@@ -273,6 +273,14 @@
<Compile Include="Migrations\202406070826284_AddStoredProc01.Designer.cs">
<DependentUpon>202406070826284_AddStoredProc01.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\202407170704518_AddProdDtLastMod.cs" />
<Compile Include="Migrations\202407170704518_AddProdDtLastMod.Designer.cs">
<DependentUpon>202407170704518_AddProdDtLastMod.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\202408051054365_AddRawItemLogicalDelete.cs" />
<Compile Include="Migrations\202408051054365_AddRawItemLogicalDelete.Designer.cs">
<DependentUpon>202408051054365_AddRawItemLogicalDelete.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\Configuration.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils.cs" />
@@ -357,6 +365,12 @@
<EmbeddedResource Include="Migrations\202406070826284_AddStoredProc01.resx">
<DependentUpon>202406070826284_AddStoredProc01.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Migrations\202407170704518_AddProdDtLastMod.resx">
<DependentUpon>202407170704518_AddProdDtLastMod.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Migrations\202408051054365_AddRawItemLogicalDelete.resx">
<DependentUpon>202408051054365_AddRawItemLogicalDelete.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Content Include="SqlScripts\Stored\stp_LogMachineFixPid.sql">
@@ -0,0 +1,29 @@
// <auto-generated />
namespace EgtBEAMWALL.DataLayer.Migrations
{
using System.CodeDom.Compiler;
using System.Data.Entity.Migrations;
using System.Data.Entity.Migrations.Infrastructure;
using System.Resources;
[GeneratedCode("EntityFramework.Migrations", "6.4.4")]
public sealed partial class AddProdDtLastMod : IMigrationMetadata
{
private readonly ResourceManager Resources = new ResourceManager(typeof(AddProdDtLastMod));
string IMigrationMetadata.Id
{
get { return "202407170704518_AddProdDtLastMod"; }
}
string IMigrationMetadata.Source
{
get { return null; }
}
string IMigrationMetadata.Target
{
get { return Resources.GetString("Target"); }
}
}
}
@@ -0,0 +1,20 @@
namespace EgtBEAMWALL.DataLayer.Migrations
{
using System;
using System.Data.Entity.Migrations;
public partial class AddProdDtLastMod : DbMigration
{
public override void Up()
{
AddColumn("dbo.ProdList", "DtLastMod", c => c.DateTime(nullable: false, precision: 0, defaultValueSql: "DATE('1900-01-01')"));
CreateIndex("dbo.ProdList", "DtLastMod");
}
public override void Down()
{
DropIndex("dbo.ProdList", new[] { "DtLastMod" });
DropColumn("dbo.ProdList", "DtLastMod");
}
}
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,29 @@
// <auto-generated />
namespace EgtBEAMWALL.DataLayer.Migrations
{
using System.CodeDom.Compiler;
using System.Data.Entity.Migrations;
using System.Data.Entity.Migrations.Infrastructure;
using System.Resources;
[GeneratedCode("EntityFramework.Migrations", "6.4.4")]
public sealed partial class AddRawItemLogicalDelete : IMigrationMetadata
{
private readonly ResourceManager Resources = new ResourceManager(typeof(AddRawItemLogicalDelete));
string IMigrationMetadata.Id
{
get { return "202408051054365_AddRawItemLogicalDelete"; }
}
string IMigrationMetadata.Source
{
get { return null; }
}
string IMigrationMetadata.Target
{
get { return Resources.GetString("Target"); }
}
}
}
@@ -0,0 +1,18 @@
namespace EgtBEAMWALL.DataLayer.Migrations
{
using System;
using System.Data.Entity.Migrations;
public partial class AddRawItemLogicalDelete : DbMigration
{
public override void Up()
{
AddColumn("dbo.RawItemList", "IsDeleted", c => c.Boolean(nullable: false, defaultValue: false, defaultValueSql: "0"));
}
public override void Down()
{
DropColumn("dbo.RawItemList", "IsDeleted");
}
}
}
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -2,7 +2,7 @@
<packages>
<package id="BouncyCastle.Cryptography" version="2.4.0" targetFramework="net472" />
<package id="DotNetZip" version="1.16.0" targetFramework="net472" />
<package id="EgwProxy.MagMan" version="1.0.2406.2911" targetFramework="net472" />
<package id="EgwProxy.MagMan" version="1.0.2408.514" targetFramework="net472" />
<package id="EntityFramework" version="6.4.4" targetFramework="net452" />
<package id="Google.Protobuf" version="3.27.0" targetFramework="net472" />
<package id="K4os.Compression.LZ4" version="1.3.8" targetFramework="net472" />
@@ -161,7 +161,7 @@
<HintPath>..\ExtLibs\EgtWPFLib5.dll</HintPath>
</Reference>
<Reference Include="EgwProxy.MagMan, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\EgwProxy.MagMan.1.0.2406.2617\lib\EgwProxy.MagMan.dll</HintPath>
<HintPath>..\packages\EgwProxy.MagMan.1.0.2407.1708\lib\EgwProxy.MagMan.dll</HintPath>
</Reference>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll</HintPath>
@@ -158,7 +158,7 @@ Public Class MainWindowVM
' sincronizzo tutti i progetti
DbControllers.m_MagmanController.ProjAllSyncro()
' sincronizzo log macchina
DbControllers.m_MagmanController.CloudLogMaccSyncro(100, 5000, True)
'DbControllers.m_MagmanController.CloudLogMaccSyncro(100, 5000, True)
End If
End Sub
@@ -255,7 +255,7 @@ Public Class MainWindowVM
' loggo chiusura programma
DbControllers.m_LogMachineController.Create(LogEvent.CreateSoftwareOnOffLog(False, DbControllers.m_SupervisorId))
' sincronizzo
DbControllers.m_MagmanController.CloudLogMaccSyncro(100, 5000, True)
' DbControllers.m_MagmanController.CloudLogMaccSyncro(100, 5000, True)
End If
' Termino il Model
MainWindowM.Close()
+1 -1
View File
@@ -3,7 +3,7 @@
<package id="BouncyCastle.Cryptography" version="2.4.0" targetFramework="net472" />
<package id="Csv" version="1.0.31" targetFramework="net472" />
<package id="DotNetZip" version="1.16.0" targetFramework="net472" />
<package id="EgwProxy.MagMan" version="1.0.2406.2617" targetFramework="net472" />
<package id="EgwProxy.MagMan" version="1.0.2407.1708" targetFramework="net472" />
<package id="EntityFramework" version="6.4.4" targetFramework="net452" />
<package id="FluentFTP" version="19.2.2" targetFramework="net472" />
<package id="Google.Protobuf" version="3.27.0" targetFramework="net472" />
+1 -1
View File
@@ -67,7 +67,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="RestSharp" publicKeyToken="598062e77f915f75" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-111.2.0.0" newVersion="111.2.0.0" />
<bindingRedirect oldVersion="0.0.0.0-111.1.0.0" newVersion="111.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="ZstdSharp" publicKeyToken="8d151af33a4ad5cf" culture="neutral" />
@@ -169,7 +169,7 @@
<HintPath>..\ExtLibs\EgtWPFLib5.dll</HintPath>
</Reference>
<Reference Include="EgwProxy.MagMan, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\EgwProxy.MagMan.1.0.2406.2617\lib\EgwProxy.MagMan.dll</HintPath>
<HintPath>..\packages\EgwProxy.MagMan.1.0.2407.1708\lib\EgwProxy.MagMan.dll</HintPath>
</Reference>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll</HintPath>
@@ -318,7 +318,12 @@ Public Class MyMachGroupPanelVM
Part.MaterialM.SetWarehouseMaterial(RawPart.Material.sWarehouseMaterial)
Next
Else
Dim nRawPartId As Integer = DbControllers.m_RawItemsController.Upsert(New RawPartM(Material, MachGroup.dW, MachGroup.dL, 0, False))
Dim nRawPartId As Integer = 0
If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM Then
nRawPartId = DbControllers.m_RawItemsController.Upsert(New RawPartM(Material, 0, MachGroup.dL, 0, False))
ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL Then
nRawPartId = DbControllers.m_RawItemsController.Upsert(New RawPartM(Material, MachGroup.dW, MachGroup.dL, 0, False))
End If
If nRawPartId > 0 Then
SearchRawPart = DbControllers.m_RawItemsController.GetFilt(Material.nId)
If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM Then
@@ -140,6 +140,7 @@ Public Class NewOpenProjectFileDialogVM
If Not IsNothing(SelProject.ProdFileVM) Then
' archivio il progetto
DbControllers.m_ProdController.UpdateArchived(SelProject.ProdFileVM.nProdId, Not SelProject.bIsArchived)
DbControllers.m_MagmanController.ProjSyncro(SelProject.ProdFileVM.nProdId)
NotifyPropertyChanged(NameOf(Archive_Msg))
End If
' aggiorno lista progetti
+1 -1
View File
@@ -2,7 +2,7 @@
<packages>
<package id="BouncyCastle.Cryptography" version="2.4.0" targetFramework="net472" />
<package id="DotNetZip" version="1.16.0" targetFramework="net472" />
<package id="EgwProxy.MagMan" version="1.0.2406.2617" targetFramework="net472" />
<package id="EgwProxy.MagMan" version="1.0.2407.1708" targetFramework="net472" />
<package id="EntityFramework" version="6.4.4" targetFramework="net452" />
<package id="Google.Protobuf" version="3.27.0" targetFramework="net472" />
<package id="K4os.Compression.LZ4" version="1.3.8" targetFramework="net472" />