Miglioramenti travi e sesting
This commit is contained in:
@@ -210,6 +210,10 @@
|
||||
Friend Const MGR_PRT_DES As String = "DES"
|
||||
Friend Const MGR_PRT_STARTCUT As String = "STARTCUT"
|
||||
Friend Const MGR_PRT_MATERIAL As String = "MATERIAL"
|
||||
Friend Const MGR_PRT_ROT As String = "ROT"
|
||||
Friend Const MGR_PRT_FLIP As String = "FLIP"
|
||||
Friend Const MGR_PRT_POSX As String = "POSX"
|
||||
Friend Const MGR_PRT_POSY As String = "POSY"
|
||||
|
||||
Friend Const MGR_FTR_GRP As String = "GRP"
|
||||
Friend Const MGR_FTR_PRC As String = "PRC"
|
||||
|
||||
@@ -81,6 +81,8 @@ Public Class MyMachGroupPanelM
|
||||
ElseIf UsedMachine.nType = MachineType.WALL Then
|
||||
TempList.Add(WallMachGroupM.CreateWallMachGroup(nId, sName, sMachine))
|
||||
End If
|
||||
' rimuovo info
|
||||
EgtSetInfo(nId, "UPDATEUI", "")
|
||||
End If
|
||||
nId = EgtGetNextMachGroup(nId)
|
||||
End While
|
||||
|
||||
+24
-20
@@ -62,26 +62,30 @@ Public Class WallM
|
||||
End If
|
||||
NewWallM.SetInverted(nTemp)
|
||||
' leggo PosX, PosY, Rot e Flip
|
||||
Dim sInfo As String = ""
|
||||
Dim Index = 1
|
||||
Dim sSplitInfo() As String
|
||||
Dim bFound As Boolean = False
|
||||
While EgtGetInfo(NewWallM.m_ParentMachGroup.Id, MGR_RPT_PART & Index, sInfo)
|
||||
If Not String.IsNullOrWhiteSpace(sInfo) Then
|
||||
sSplitInfo = sInfo.Split(","c)
|
||||
If sSplitInfo(0) = nPartId Then
|
||||
bFound = True
|
||||
Exit While
|
||||
End If
|
||||
End If
|
||||
Index += 1
|
||||
End While
|
||||
If bFound Then
|
||||
StringToDouble(sSplitInfo(1), NewWallM.m_dPOSX)
|
||||
StringToDouble(sSplitInfo(2), NewWallM.m_dPOSY)
|
||||
StringToDouble(sSplitInfo(3), NewWallM.m_dROT)
|
||||
StringToDouble(sSplitInfo(4), NewWallM.m_bFLIP)
|
||||
End If
|
||||
EgtGetInfo(nPartId, MGR_PRT_POSX, NewWallM.m_dPOSX)
|
||||
EgtGetInfo(nPartId, MGR_PRT_POSY, NewWallM.m_dPOSY)
|
||||
EgtGetInfo(nPartId, MGR_PRT_ROT, NewWallM.m_dROT)
|
||||
EgtGetInfo(nPartId, MGR_PRT_FLIP, NewWallM.m_bFLIP)
|
||||
'Dim sInfo As String = ""
|
||||
'Dim Index = 1
|
||||
'Dim sSplitInfo() As String
|
||||
'Dim bFound As Boolean = False
|
||||
'While EgtGetInfo(NewWallM.m_ParentMachGroup.Id, MGR_RPT_PART & Index, sInfo)
|
||||
' If Not String.IsNullOrWhiteSpace(sInfo) Then
|
||||
' sSplitInfo = sInfo.Split(","c)
|
||||
' If sSplitInfo(0) = nPartId Then
|
||||
' bFound = True
|
||||
' Exit While
|
||||
' End If
|
||||
' End If
|
||||
' Index += 1
|
||||
'End While
|
||||
'If bFound Then
|
||||
' StringToDouble(sSplitInfo(1), NewWallM.m_dPOSX)
|
||||
' StringToDouble(sSplitInfo(2), NewWallM.m_dPOSY)
|
||||
' StringToDouble(sSplitInfo(3), NewWallM.m_dROT)
|
||||
' StringToDouble(sSplitInfo(4), NewWallM.m_bFLIP)
|
||||
'End If
|
||||
' leggo feature
|
||||
NewWallM.m_FeatureMList = LoadBTLFeatures(nPartId)
|
||||
Return NewWallM
|
||||
|
||||
@@ -6,484 +6,485 @@ using EgtBEAMWALL.DataLayer.DatabaseModels;
|
||||
|
||||
namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
{
|
||||
public class ProjController : IDisposable
|
||||
{
|
||||
#region Private Fields
|
||||
public class ProjController : IDisposable
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private DatabaseContext dbCtx;
|
||||
private DatabaseContext dbCtx;
|
||||
|
||||
#endregion Private Fields
|
||||
#endregion Private Fields
|
||||
|
||||
#region Public Constructors
|
||||
#region Public Constructors
|
||||
|
||||
public ProjController()
|
||||
{
|
||||
// Initialize database context
|
||||
dbCtx = new DatabaseContext(Constants.CONNECTION_STRING);
|
||||
}
|
||||
public ProjController()
|
||||
{
|
||||
// Initialize database context
|
||||
dbCtx = new DatabaseContext(Constants.CONNECTION_STRING);
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Protected Methods
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Helper conversione modelli
|
||||
/// </summary>
|
||||
/// <param name="currProj"></param>
|
||||
/// <returns></returns>
|
||||
protected Core.ProjFileM coreConv(ProjModel currProj)
|
||||
{
|
||||
Core.ProjFileM answ = Core.ProjFileM.CreateProjFileM(currProj.ProjId, ProdIdByProdDbId(currProj.ProdDbId), currProj.DtCreated, currProj.DtExported, currProj.ListName, currProj.BTLFileName, currProj.IsNew, currProj.Locked);
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Helper conversione modelli
|
||||
/// </summary>
|
||||
/// <param name="currProj"></param>
|
||||
/// <returns></returns>
|
||||
protected Core.ProjFileM coreConv(ProjModel currProj)
|
||||
{
|
||||
Core.ProjFileM answ = Core.ProjFileM.CreateProjFileM(currProj.ProjId, ProdIdByProdDbId(currProj.ProdDbId), currProj.DtCreated, currProj.DtExported, currProj.ListName, currProj.BTLFileName, currProj.IsNew, currProj.Locked);
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get LAST paginated data from DB (DESC ordered)
|
||||
/// </summary>
|
||||
/// <param name="numRecord"></param>
|
||||
/// <returns></returns>
|
||||
protected List<ProjModel> GetLastDbModelDesc(int numRecord)
|
||||
{
|
||||
// se numRecord = 0 --> passo tutti
|
||||
if (numRecord == 0)
|
||||
{
|
||||
numRecord = dbCtx.ProjList.Count();
|
||||
}
|
||||
// retrieve
|
||||
return dbCtx
|
||||
.ProjList
|
||||
.OrderByDescending(x => x.ProjId)
|
||||
.Take(numRecord)
|
||||
.ToList();
|
||||
}
|
||||
/// <summary>
|
||||
/// Get LAST paginated data from DB (DESC ordered)
|
||||
/// </summary>
|
||||
/// <param name="numRecord"></param>
|
||||
/// <returns></returns>
|
||||
protected List<ProjModel> GetLastDbModelDesc(int numRecord)
|
||||
{
|
||||
// se numRecord = 0 --> passo tutti
|
||||
if (numRecord == 0)
|
||||
{
|
||||
numRecord = dbCtx.ProjList.Count();
|
||||
}
|
||||
// retrieve
|
||||
return dbCtx
|
||||
.ProjList
|
||||
.OrderByDescending(x => x.ProjId)
|
||||
.Take(numRecord)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get ProdId by ProdDbId, 0 se non trovato
|
||||
/// </summary>
|
||||
/// <param name="ProdDbId"></param>
|
||||
/// <returns></returns>
|
||||
protected int ProdIdByProdDbId(int? ProdDbId)
|
||||
{
|
||||
int answ = 0;
|
||||
/// <summary>
|
||||
/// Get ProdId by ProdDbId, 0 se non trovato
|
||||
/// </summary>
|
||||
/// <param name="ProdDbId"></param>
|
||||
/// <returns></returns>
|
||||
protected int ProdIdByProdDbId(int? ProdDbId)
|
||||
{
|
||||
int answ = 0;
|
||||
|
||||
if (ProdDbId != null)
|
||||
{
|
||||
var prodRecord = dbCtx
|
||||
.ProdList
|
||||
.Where(x => x.ProdDbId == ProdDbId)
|
||||
.SingleOrDefault();
|
||||
|
||||
if (prodRecord != null)
|
||||
{
|
||||
answ = prodRecord.ProdId;
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public bool DeleteProj(int ProjId)
|
||||
{
|
||||
bool done = false;
|
||||
|
||||
var currProj = FindByProjId(ProjId);
|
||||
|
||||
// sel delle BTLParts da proj
|
||||
var parts2del = dbCtx
|
||||
.BTLPartList
|
||||
.Where(x => x.ProjDbId == currProj.ProjDbId);
|
||||
|
||||
try
|
||||
{
|
||||
// remove from database
|
||||
dbCtx.BTLPartList.RemoveRange(parts2del);
|
||||
dbCtx.ProjList.Remove(currProj);
|
||||
// Commit changes
|
||||
dbCtx.SaveChanges();
|
||||
done = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Console.WriteLine($"EXCEPTION on DeleteProj: {exc}");
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database context
|
||||
dbCtx.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get record by ProjDbId
|
||||
/// </summary>
|
||||
/// <param name="ProjDbId"></param>
|
||||
/// <returns></returns>
|
||||
public ProjModel FindByProjDbId(int ProjDbId)
|
||||
{
|
||||
ProjModel answ = dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProjDbId == ProjDbId)
|
||||
.SingleOrDefault();
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get record by ProjId
|
||||
/// </summary>
|
||||
/// <param name="ProjId"></param>
|
||||
/// <returns></returns>
|
||||
public ProjModel FindByProjId(int ProjId)
|
||||
{
|
||||
var answ = dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProjId == ProjId)
|
||||
.SingleOrDefault();
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get record by ProjId converted
|
||||
/// </summary>
|
||||
/// <param name="ProjId"></param>
|
||||
/// <returns></returns>
|
||||
public Core.ProjFileM FindByProjIdConv(int ProjId)
|
||||
{
|
||||
return coreConv(FindByProjId(ProjId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get filtered data by ProdId (ASC ordered)
|
||||
/// </summary>
|
||||
/// <param name="ProdDbId"></param>
|
||||
/// <returns></returns>
|
||||
public List<ProjModel> GetByProdAsc(int ProdId)
|
||||
{
|
||||
List<ProjModel> answ = new List<ProjModel>();
|
||||
int ProdDbId = 0;
|
||||
try
|
||||
{
|
||||
var currProd = dbCtx
|
||||
.ProdList
|
||||
.Where(x => x.ProdId == ProdId)
|
||||
.FirstOrDefault();
|
||||
if (currProd != null)
|
||||
{
|
||||
ProdDbId = currProd.ProdDbId;
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Console.WriteLine($"EXCEPTION on GetByProdAsc: {exc}");
|
||||
}
|
||||
// retrieve
|
||||
answ = dbCtx
|
||||
.ProjList
|
||||
if (ProdDbId != null)
|
||||
{
|
||||
var prodRecord = dbCtx
|
||||
.ProdList
|
||||
.Where(x => x.ProdDbId == ProdDbId)
|
||||
.OrderBy(x => x.ProdDbId)
|
||||
.ToList();
|
||||
return answ;
|
||||
}
|
||||
.SingleOrDefault();
|
||||
|
||||
/// <summary>
|
||||
/// Get filtered data by ProdId (DESC ordered)
|
||||
/// </summary>
|
||||
/// <param name="ProdDbId"></param>
|
||||
/// <returns></returns>
|
||||
public List<Core.ProjFileM> GetByProdDesc(int ProdId)
|
||||
{
|
||||
List<Core.ProjFileM> answ = new List<Core.ProjFileM>();
|
||||
int ProdDbId = 0;
|
||||
try
|
||||
if (prodRecord != null)
|
||||
{
|
||||
var currProd = dbCtx
|
||||
.ProdList
|
||||
.Where(x => x.ProdId == ProdId)
|
||||
.FirstOrDefault();
|
||||
if (currProd != null)
|
||||
{
|
||||
ProdDbId = currProd.ProdDbId;
|
||||
}
|
||||
answ = prodRecord.ProdId;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Console.WriteLine($"EXCEPTION on GetByProdAsc: {exc}");
|
||||
}
|
||||
// retrieve
|
||||
var dbRes = dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProdDbId == ProdDbId)
|
||||
.OrderByDescending(x => x.ProdDbId)
|
||||
.ToList();
|
||||
// conversione
|
||||
answ = dbRes.Select(x => coreConv(x)).ToList();
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco progetti
|
||||
/// </summary>
|
||||
/// <param name="numRecord"></param>
|
||||
/// <returns></returns>
|
||||
public List<Core.ProjFileM> GetLastDesc(int numRecord)
|
||||
{
|
||||
List<Core.ProjFileM> answ = new List<Core.ProjFileM>();
|
||||
#endregion Protected Methods
|
||||
|
||||
// se numRecord = 0 --> passo tutti
|
||||
if (numRecord == 0)
|
||||
{
|
||||
numRecord = dbCtx.ProjList.Count();
|
||||
}
|
||||
// retrieve
|
||||
var dbRes = dbCtx
|
||||
.ProjList
|
||||
.OrderByDescending(x => x.ProjId)
|
||||
.Take(numRecord)
|
||||
.ToList();
|
||||
// conversione
|
||||
answ = dbRes.Select(x => coreConv(x)).ToList();
|
||||
return answ;
|
||||
}
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Fornisce nuovo indice VUOTO da usare (allocando sul DB)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int GetNextIndex()
|
||||
{
|
||||
int nextId = 0;
|
||||
public bool DeleteProj(int ProjId)
|
||||
{
|
||||
bool done = false;
|
||||
|
||||
// cerco se ne ho ALMENO 1....
|
||||
var numRec = dbCtx.ProjList.Count();
|
||||
if (numRec == 0)
|
||||
{
|
||||
nextId = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// retrieve ultimo...
|
||||
var maxRecord = dbCtx
|
||||
.ProjList
|
||||
.OrderByDescending(x => x.ProjId)
|
||||
.Take(1)
|
||||
.FirstOrDefault();
|
||||
// incremento
|
||||
nextId = maxRecord.ProjId + 1;
|
||||
}
|
||||
var currProj = FindByProjId(ProjId);
|
||||
|
||||
// creo nuovo...
|
||||
var newRec = dbCtx
|
||||
.ProjList
|
||||
.Add(new ProjModel() { ProjId = nextId, BTLFileName = "", IsNew = true, Locked = true, DtCreated = DateTime.Now });
|
||||
// sel delle BTLParts da proj
|
||||
var parts2del = dbCtx
|
||||
.BTLPartList
|
||||
.Where(x => x.ProjDbId == currProj.ProjDbId);
|
||||
|
||||
try
|
||||
{
|
||||
// remove from database
|
||||
dbCtx.BTLPartList.RemoveRange(parts2del);
|
||||
dbCtx.ProjList.Remove(currProj);
|
||||
// Commit changes
|
||||
dbCtx.SaveChanges();
|
||||
done = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Console.WriteLine($"EXCEPTION on DeleteProj: {exc}");
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
return nextId;
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database context
|
||||
dbCtx.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Manage Lock by ProjId (proj & prod)
|
||||
/// </summary>
|
||||
/// <param name="ProjId">ProjID</param>
|
||||
/// <param name="Locked">Stato Lock da impostare</param>
|
||||
/// <returns></returns>
|
||||
public Core.ProjFileM LockByProjId(int ProjId, bool Locked)
|
||||
{
|
||||
var currProj = dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProjId == ProjId)
|
||||
.SingleOrDefault();
|
||||
// aggiorno stato del proj
|
||||
currProj.Locked = Locked;
|
||||
dbCtx.Entry(currProj).State = System.Data.Entity.EntityState.Modified;
|
||||
/// <summary>
|
||||
/// Get record by ProjDbId
|
||||
/// </summary>
|
||||
/// <param name="ProjDbId"></param>
|
||||
/// <returns></returns>
|
||||
public ProjModel FindByProjDbId(int ProjDbId)
|
||||
{
|
||||
ProjModel answ = dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProjDbId == ProjDbId)
|
||||
.SingleOrDefault();
|
||||
return answ;
|
||||
}
|
||||
|
||||
// seleziono il prod e lo blocco...
|
||||
/// <summary>
|
||||
/// Get record by ProjId
|
||||
/// </summary>
|
||||
/// <param name="ProjId"></param>
|
||||
/// <returns></returns>
|
||||
public ProjModel FindByProjId(int ProjId)
|
||||
{
|
||||
var answ = dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProjId == ProjId)
|
||||
.SingleOrDefault();
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get record by ProjId converted
|
||||
/// </summary>
|
||||
/// <param name="ProjId"></param>
|
||||
/// <returns></returns>
|
||||
public Core.ProjFileM FindByProjIdConv(int ProjId)
|
||||
{
|
||||
return coreConv(FindByProjId(ProjId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get filtered data by ProdId (ASC ordered)
|
||||
/// </summary>
|
||||
/// <param name="ProdDbId"></param>
|
||||
/// <returns></returns>
|
||||
public List<ProjModel> GetByProdAsc(int ProdId)
|
||||
{
|
||||
List<ProjModel> answ = new List<ProjModel>();
|
||||
int ProdDbId = 0;
|
||||
try
|
||||
{
|
||||
var currProd = dbCtx
|
||||
.ProdList
|
||||
.Where(x => x.ProdDbId == currProj.ProdDbId)
|
||||
.SingleOrDefault();
|
||||
|
||||
.Where(x => x.ProdId == ProdId)
|
||||
.FirstOrDefault();
|
||||
if (currProd != null)
|
||||
{
|
||||
// blocco prod corrente
|
||||
currProd.Locked = Locked;
|
||||
ProdDbId = currProd.ProdDbId;
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Console.WriteLine($"EXCEPTION on GetByProdAsc: {exc}");
|
||||
}
|
||||
// retrieve
|
||||
answ = dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProdDbId == ProdDbId)
|
||||
.OrderBy(x => x.ProdDbId)
|
||||
.ToList();
|
||||
return answ;
|
||||
}
|
||||
|
||||
// ora blocco altri proj del prod...
|
||||
var currProjs = dbCtx
|
||||
/// <summary>
|
||||
/// Get filtered data by ProdId (DESC ordered)
|
||||
/// </summary>
|
||||
/// <param name="ProdDbId"></param>
|
||||
/// <returns></returns>
|
||||
public List<Core.ProjFileM> GetByProdDesc(int ProdId)
|
||||
{
|
||||
List<Core.ProjFileM> answ = new List<Core.ProjFileM>();
|
||||
int ProdDbId = 0;
|
||||
try
|
||||
{
|
||||
var currProd = dbCtx
|
||||
.ProdList
|
||||
.Where(x => x.ProdId == ProdId)
|
||||
.FirstOrDefault();
|
||||
if (currProd != null)
|
||||
{
|
||||
ProdDbId = currProd.ProdDbId;
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Console.WriteLine($"EXCEPTION on GetByProdAsc: {exc}");
|
||||
}
|
||||
// retrieve
|
||||
var dbRes = dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProdDbId == ProdDbId)
|
||||
.OrderByDescending(x => x.ProdDbId)
|
||||
.ToList();
|
||||
// conversione
|
||||
answ = dbRes.Select(x => coreConv(x)).ToList();
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco progetti
|
||||
/// </summary>
|
||||
/// <param name="numRecord"></param>
|
||||
/// <returns></returns>
|
||||
public List<Core.ProjFileM> GetLastDesc(int numRecord)
|
||||
{
|
||||
List<Core.ProjFileM> answ = new List<Core.ProjFileM>();
|
||||
|
||||
// se numRecord = 0 --> passo tutti
|
||||
if (numRecord == 0)
|
||||
{
|
||||
numRecord = dbCtx.ProjList.Count();
|
||||
}
|
||||
// retrieve
|
||||
var dbRes = dbCtx
|
||||
.ProjList
|
||||
.OrderByDescending(x => x.ProjId)
|
||||
.Take(numRecord)
|
||||
.ToList();
|
||||
// conversione
|
||||
answ = dbRes.Select(x => coreConv(x)).ToList();
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fornisce nuovo indice VUOTO da usare (allocando sul DB)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int GetNextIndex()
|
||||
{
|
||||
int nextId = 0;
|
||||
|
||||
// cerco se ne ho ALMENO 1....
|
||||
var numRec = dbCtx.ProjList.Count();
|
||||
if (numRec == 0)
|
||||
{
|
||||
nextId = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// retrieve ultimo...
|
||||
var maxRecord = dbCtx
|
||||
.ProjList
|
||||
.OrderByDescending(x => x.ProjId)
|
||||
.Take(1)
|
||||
.FirstOrDefault();
|
||||
// incremento
|
||||
nextId = maxRecord.ProjId + 1;
|
||||
}
|
||||
|
||||
// creo nuovo...
|
||||
var newRec = dbCtx
|
||||
.ProjList
|
||||
.Add(new ProjModel() { ProjId = nextId, BTLFileName = "", IsNew = true, Locked = true, DtCreated = DateTime.Now });
|
||||
|
||||
// Commit changes
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
return nextId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Manage Lock by ProjId (proj & prod)
|
||||
/// </summary>
|
||||
/// <param name="ProjId">ProjID</param>
|
||||
/// <param name="Locked">Stato Lock da impostare</param>
|
||||
/// <returns></returns>
|
||||
public Core.ProjFileM LockByProjId(int ProjId, bool Locked)
|
||||
{
|
||||
var currProj = dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProjId == ProjId)
|
||||
.SingleOrDefault();
|
||||
// aggiorno stato del proj
|
||||
currProj.Locked = Locked;
|
||||
dbCtx.Entry(currProj).State = System.Data.Entity.EntityState.Modified;
|
||||
|
||||
// seleziono il prod e lo blocco...
|
||||
var currProd = dbCtx
|
||||
.ProdList
|
||||
.Where(x => x.ProdDbId == currProj.ProdDbId)
|
||||
.SingleOrDefault();
|
||||
|
||||
if (currProd != null)
|
||||
{
|
||||
// blocco prod corrente
|
||||
currProd.Locked = Locked;
|
||||
dbCtx.Entry(currProd).State = System.Data.Entity.EntityState.Modified;
|
||||
|
||||
// ora blocco altri proj del prod...
|
||||
var currProjs = dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProdDbId == currProd.ProdDbId && x.ProjId != ProjId)
|
||||
.ToList();
|
||||
|
||||
//currProjs.ForEach(x => x.Locked = Locked);
|
||||
foreach (var item in currProjs)
|
||||
{
|
||||
item.Locked = Locked;
|
||||
dbCtx.Entry(item).State = System.Data.Entity.EntityState.Modified;
|
||||
}
|
||||
}
|
||||
// salvataggio
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
return coreConv(currProj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reimposta come NEW
|
||||
/// </summary>
|
||||
/// <param name="ProjId">ProjID</param>
|
||||
/// <param name="Locked">Stato Lock da impostare</param>
|
||||
/// <returns></returns>
|
||||
public Core.ProjFileM ResetNew(int ProjId)
|
||||
{
|
||||
var currProj = dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProjId == ProjId)
|
||||
.SingleOrDefault();
|
||||
|
||||
// aggiorno stato
|
||||
currProj.IsNew = false;
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
return coreConv(currProj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update single PROJ
|
||||
/// </summary>
|
||||
/// <param name="updItem"></param>
|
||||
/// <returns></returns>
|
||||
public bool Update(ProjModel updItem)
|
||||
{
|
||||
bool done = false;
|
||||
var item2update = dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProjDbId == updItem.ProjDbId)
|
||||
.SingleOrDefault();
|
||||
try
|
||||
//currProjs.ForEach(x => x.Locked = Locked);
|
||||
foreach (var item in currProjs)
|
||||
{
|
||||
// update, vers 1...
|
||||
dbCtx.Entry(item2update).CurrentValues.SetValues(updItem);
|
||||
|
||||
//// update, vers 2
|
||||
//dbCtx.PartList.Remove(item2del);
|
||||
//dbCtx.PartList.Add(updItem);
|
||||
|
||||
// Commit changes
|
||||
dbCtx.SaveChanges();
|
||||
done = true;
|
||||
item.Locked = Locked;
|
||||
dbCtx.Entry(item).State = System.Data.Entity.EntityState.Modified;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return done;
|
||||
}
|
||||
}
|
||||
// salvataggio
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
/// <summary>
|
||||
/// Update record su DB x elenco BTLParts
|
||||
/// </summary>
|
||||
/// <param name="ProjId"></param>
|
||||
/// <param name="newBTLFileName"></param>
|
||||
/// <returns></returns>
|
||||
public ProjModel UpdateBtlParts(int ProjId, List<Core.BTLPartM> BtlPartList)
|
||||
{
|
||||
// record del proj corrente
|
||||
var currData = FindByProjId(ProjId);
|
||||
return coreConv(currProj);
|
||||
}
|
||||
|
||||
// 2021.05.03 modifica update: esistenti le MODIFICO, nuove aggiungo, inesistenti elimino in cascata con Part
|
||||
/// <summary>
|
||||
/// Reimposta come NEW
|
||||
/// </summary>
|
||||
/// <param name="ProjId">ProjID</param>
|
||||
/// <param name="Locked">Stato Lock da impostare</param>
|
||||
/// <returns></returns>
|
||||
public Core.ProjFileM ResetNew(int ProjId)
|
||||
{
|
||||
var currProj = dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProjId == ProjId)
|
||||
.SingleOrDefault();
|
||||
|
||||
// sel delle BTLParts del proj
|
||||
List<BTLPartModel> oldBtlParts = dbCtx
|
||||
.BTLPartList
|
||||
.Where(x => x.ProjDbId == currData.ProjDbId)
|
||||
.ToList();
|
||||
// aggiorno stato
|
||||
currProj.IsNew = false;
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
// converto le BtlParts da core --> DB
|
||||
List<BTLPartModel> newBtlParts = BtlPartList.Select(x => BTLPartController.ConvertFromCore(x, currData.ProjDbId)).ToList();
|
||||
return coreConv(currProj);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// elementi BtlPartId NON + presenti da eliminare
|
||||
List<int> bpi2rem = oldBtlParts.Select(x => x.PartId).Except(newBtlParts.Select(y => y.PartId)).ToList();
|
||||
List<int> bpi2add = newBtlParts.Select(x => x.PartId).Except(oldBtlParts.Select(y => y.PartId)).ToList();
|
||||
List<int> bpiExis = newBtlParts.Select(x => x.PartId).Intersect(oldBtlParts.Select(y => y.PartId)).ToList();
|
||||
/// <summary>
|
||||
/// Update single PROJ
|
||||
/// </summary>
|
||||
/// <param name="updItem"></param>
|
||||
/// <returns></returns>
|
||||
public bool Update(ProjModel updItem)
|
||||
{
|
||||
bool done = false;
|
||||
var item2update = dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProjDbId == updItem.ProjDbId)
|
||||
.SingleOrDefault();
|
||||
try
|
||||
{
|
||||
// update, vers 1...
|
||||
dbCtx.Entry(item2update).CurrentValues.SetValues(updItem);
|
||||
|
||||
// aggiorno existing...
|
||||
foreach (var currPartId in bpiExis)
|
||||
{
|
||||
// recupero item da aggiornare...
|
||||
var oldItem = oldBtlParts.Where(x => x.PartId == currPartId).FirstOrDefault();
|
||||
// dati nuovo item
|
||||
var newItem = newBtlParts.Where(x => x.PartId == currPartId).FirstOrDefault();
|
||||
if (newItem != null && oldItem != null)
|
||||
{
|
||||
oldItem.CALC_State = newItem.CALC_State;
|
||||
oldItem.CNT = newItem.CNT;
|
||||
oldItem.DO = newItem.DO;
|
||||
oldItem.H = newItem.H;
|
||||
oldItem.L = newItem.L;
|
||||
oldItem.W = newItem.W;
|
||||
oldItem.Material = newItem.Material;
|
||||
oldItem.NAM = newItem.NAM;
|
||||
oldItem.PDN = newItem.PDN;
|
||||
}
|
||||
}
|
||||
|
||||
// aggiungo le nuove part
|
||||
foreach (var newPartId in bpi2add)
|
||||
{
|
||||
var newItem = newBtlParts.Where(x => x.PartId == newPartId).FirstOrDefault();
|
||||
dbCtx.BTLPartList.Add(newItem);
|
||||
}
|
||||
|
||||
// elimino dal DB i non + esistenti
|
||||
foreach (var oldPartId in bpi2rem)
|
||||
{
|
||||
// elimino parts nei MachGroup
|
||||
var oldIstPartList = dbCtx.PartList.Where(x => x.BTLPart.PartId == oldPartId).ToList();
|
||||
dbCtx.PartList.RemoveRange(oldIstPartList);
|
||||
// elimino BtlParts
|
||||
var oldItem = oldBtlParts.Where(x => x.PartId == oldPartId).FirstOrDefault();
|
||||
dbCtx.BTLPartList.Remove(oldItem);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
// aggiorno valore isNew a false
|
||||
currData.IsNew = false;
|
||||
//// update, vers 2
|
||||
//dbCtx.PartList.Remove(item2del);
|
||||
//dbCtx.PartList.Add(updItem);
|
||||
|
||||
// Commit changes
|
||||
dbCtx.SaveChanges();
|
||||
done = true;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return done;
|
||||
}
|
||||
|
||||
return currData;
|
||||
}
|
||||
/// <summary>
|
||||
/// Update record su DB x elenco BTLParts
|
||||
/// </summary>
|
||||
/// <param name="ProjId"></param>
|
||||
/// <param name="newBTLFileName"></param>
|
||||
/// <returns></returns>
|
||||
public ProjModel UpdateBtlParts(int ProjId, List<Core.BTLPartM> BtlPartList)
|
||||
{
|
||||
// record del proj corrente
|
||||
var currData = FindByProjId(ProjId);
|
||||
|
||||
/// <summary>
|
||||
/// Update record su DB x nomeBTL, ListName, ExportDate
|
||||
/// </summary>
|
||||
/// <param name="ProjId"></param>
|
||||
/// <param name="BTLFileName"></param>
|
||||
/// <param name="ListName"></param>
|
||||
/// <param name="DtExported"></param>
|
||||
/// <returns></returns>
|
||||
public Core.ProjFileM UpdateInfo(int ProjId, string BTLFileName, string ListName, DateTime DtExported)
|
||||
{
|
||||
var currData = FindByProjId(ProjId);
|
||||
// aggiorno valore BTL
|
||||
currData.BTLFileName = BTLFileName;
|
||||
currData.DtExported = DtExported;
|
||||
currData.ListName = ListName;
|
||||
// 2021.05.03 modifica update: esistenti le MODIFICO, nuove aggiungo, inesistenti elimino in cascata con Part
|
||||
|
||||
// Commit changes
|
||||
dbCtx.SaveChanges();
|
||||
// sel delle BTLParts del proj
|
||||
List<BTLPartModel> oldBtlParts = dbCtx
|
||||
.BTLPartList
|
||||
.Where(x => x.ProjDbId == currData.ProjDbId)
|
||||
.ToList();
|
||||
|
||||
return coreConv(currData);
|
||||
}
|
||||
// converto le BtlParts da core --> DB
|
||||
List<BTLPartModel> newBtlParts = BtlPartList.Select(x => BTLPartController.ConvertFromCore(x, currData.ProjDbId)).ToList();
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
try
|
||||
{
|
||||
// elementi BtlPartId NON + presenti da eliminare
|
||||
List<int> bpi2rem = oldBtlParts.Select(x => x.PartId).Except(newBtlParts.Select(y => y.PartId)).ToList();
|
||||
List<int> bpi2add = newBtlParts.Select(x => x.PartId).Except(oldBtlParts.Select(y => y.PartId)).ToList();
|
||||
List<int> bpiExis = newBtlParts.Select(x => x.PartId).Intersect(oldBtlParts.Select(y => y.PartId)).ToList();
|
||||
|
||||
// aggiorno existing...
|
||||
foreach (var currPartId in bpiExis)
|
||||
{
|
||||
// recupero item da aggiornare...
|
||||
var oldItem = oldBtlParts.Where(x => x.PartId == currPartId).FirstOrDefault();
|
||||
// dati nuovo item
|
||||
var newItem = newBtlParts.Where(x => x.PartId == currPartId).FirstOrDefault();
|
||||
if (newItem != null && oldItem != null)
|
||||
{
|
||||
oldItem.CALC_State = newItem.CALC_State;
|
||||
oldItem.CNT = newItem.CNT;
|
||||
oldItem.DO = newItem.DO;
|
||||
oldItem.H = newItem.H;
|
||||
oldItem.L = newItem.L;
|
||||
oldItem.W = newItem.W;
|
||||
oldItem.Material = newItem.Material;
|
||||
oldItem.NAM = newItem.NAM;
|
||||
oldItem.PDN = newItem.PDN;
|
||||
}
|
||||
}
|
||||
|
||||
// aggiungo le nuove part
|
||||
foreach (var newPartId in bpi2add)
|
||||
{
|
||||
var newItem = newBtlParts.Where(x => x.PartId == newPartId).FirstOrDefault();
|
||||
dbCtx.BTLPartList.Add(newItem);
|
||||
}
|
||||
|
||||
// elimino dal DB i non + esistenti
|
||||
foreach (var oldPartId in bpi2rem)
|
||||
{
|
||||
// elimino parts nei MachGroup
|
||||
var oldIstPartList = dbCtx.PartList.Where(x => x.BTLPart.PartId == oldPartId).ToList();
|
||||
dbCtx.PartList.RemoveRange(oldIstPartList);
|
||||
// elimino BtlParts
|
||||
var oldItem = oldBtlParts.Where(x => x.PartId == oldPartId).FirstOrDefault();
|
||||
dbCtx.BTLPartList.Remove(oldItem);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
// aggiorno valore isNew a false
|
||||
currData.IsNew = false;
|
||||
|
||||
// Commit changes
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
return currData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update record su DB x nomeBTL, ListName, ExportDate
|
||||
/// </summary>
|
||||
/// <param name="ProjId"></param>
|
||||
/// <param name="BTLFileName"></param>
|
||||
/// <param name="ListName"></param>
|
||||
/// <param name="DtExported"></param>
|
||||
/// <returns></returns>
|
||||
public Core.ProjFileM UpdateInfo(int ProjId, string BTLFileName, string ListName, DateTime DtExported)
|
||||
{
|
||||
var currData = FindByProjId(ProjId);
|
||||
// aggiorno valore BTL
|
||||
currData.BTLFileName = BTLFileName;
|
||||
currData.DtExported = DtExported;
|
||||
currData.ListName = ListName;
|
||||
|
||||
// Commit changes
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
return coreConv(currData);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -134,7 +134,7 @@
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<!--Pos - Posizione-->
|
||||
<DataGridTextColumn Binding="{Binding sPOSX}"
|
||||
<DataGridTextColumn Binding="{Binding sPOSX, UpdateSourceTrigger=PropertyChanged}"
|
||||
Width="65"
|
||||
IsReadOnly="False">
|
||||
<DataGridTextColumn.Header>
|
||||
@@ -142,7 +142,7 @@
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<!--Pos - Posizione-->
|
||||
<DataGridTextColumn Binding="{Binding sPOSY}"
|
||||
<DataGridTextColumn Binding="{Binding sPOSY, UpdateSourceTrigger=PropertyChanged}"
|
||||
Width="65"
|
||||
IsReadOnly="False">
|
||||
<DataGridTextColumn.Header>
|
||||
|
||||
@@ -207,6 +207,8 @@
|
||||
Friend Const MGR_PRT_MATERIAL As String = "MATERIAL"
|
||||
Friend Const MGR_PRT_ROT As String = "ROT"
|
||||
Friend Const MGR_PRT_FLIP As String = "FLIP"
|
||||
Friend Const MGR_PRT_POSX As String = "POSX"
|
||||
Friend Const MGR_PRT_POSY As String = "POSY"
|
||||
|
||||
Friend Const MGR_FTR_GRP As String = "GRP"
|
||||
Friend Const MGR_FTR_PRC As String = "PRC"
|
||||
@@ -254,6 +256,7 @@
|
||||
Friend Const WRH_CURRENT As String = "Current"
|
||||
Friend Const WRH_STARTOFFSET As String = "StartOffset"
|
||||
Friend Const WRH_OFFSET As String = "Offset"
|
||||
Friend Const WRH_QUANTITY As String = "Quantity"
|
||||
Friend Const WRH_L As String = "L"
|
||||
Friend Const WRH_KERF As String = "Kerf"
|
||||
Friend Const WRH_S As String = "S"
|
||||
|
||||
@@ -80,6 +80,7 @@ Module ConstIni
|
||||
|
||||
Public Const S_IMPORT As String = "Import"
|
||||
Public Const K_BTLFLAG As String = "BtlFlag"
|
||||
Public Const K_WALLBTLFLAG As String = "WallBtlFlag"
|
||||
|
||||
Public Const S_MACH As String = "Mach"
|
||||
Public Const K_MACHINESDIR As String = "MachinesDir"
|
||||
|
||||
@@ -113,11 +113,14 @@ Public Class LeftPanelVM
|
||||
BeamMachGroup.m_BeamMachGroupM.RefreshGroupData()
|
||||
' aggiorno dati ultilizzo barra
|
||||
BeamMachGroup.UpdateUsage()
|
||||
EgtSetView(VT.ISO_SW, False)
|
||||
ElseIf Map.refMachinePanelVM.SelectedMachine.nType = MachineType.WALL Then
|
||||
' scrivo dati in gruppo di lavorazione
|
||||
Dim dPosX = 10
|
||||
Dim dPosY = 10
|
||||
EgtSetInfo(nCurrMachGroup, MGR_RPT_PANELLEN, AddRawPartWndVM.VariableList(0).dValue)
|
||||
EgtSetInfo(nCurrMachGroup, MGR_RPT_PANELWIDTH, AddRawPartWndVM.VariableList(1).dValue)
|
||||
EgtSetInfo(nCurrMachGroup, MGR_RPT_PART & 1, nPartDuploId & "," & 10 & "," & 10 & "," & 0 & "," & 0)
|
||||
EgtSetInfo(nCurrMachGroup, MGR_RPT_PART & 1, nPartDuploId & "," & dPosX & "," & dPosY & "," & 0 & "," & 0)
|
||||
Dim WallMachGroup As WallMachGroupVM = DirectCast(Map.refMachGroupPanelVM.MachGroupVMList(Map.refMachGroupPanelVM.MachGroupVMList.Count - 1), WallMachGroupVM)
|
||||
' eseguo script creazione grezzo
|
||||
If Not ExecWall(sLogPath, Map.refMachinePanelVM.SelectedMachine.Name, CalcIntegration.CmdType.RAWPART, False) Then
|
||||
@@ -128,13 +131,18 @@ Public Class LeftPanelVM
|
||||
End If
|
||||
Return
|
||||
End If
|
||||
'aggiorno lista pezzi
|
||||
' scrivo dati pezzo
|
||||
EgtSetInfo(nPartDuploId, MGR_PRT_POSX, dPosX)
|
||||
EgtSetInfo(nPartDuploId, MGR_PRT_POSY, dPosY)
|
||||
EgtSetInfo(nPartDuploId, MGR_PRT_ROT, 0)
|
||||
EgtSetInfo(nPartDuploId, MGR_PRT_FLIP, False)
|
||||
' aggiorno lista pezzi
|
||||
WallMachGroup.m_WallMachGroupM.RefreshPartList()
|
||||
WallMachGroup.m_WallMachGroupM.RefreshGroupData()
|
||||
' aggiorno dati ultilizzo barra
|
||||
WallMachGroup.UpdateUsage()
|
||||
EgtSetView(VT.TOP, False)
|
||||
End If
|
||||
EgtSetView(VT.ISO_SW, False)
|
||||
EgtZoom(ZM.ALL)
|
||||
End Sub
|
||||
|
||||
@@ -208,6 +216,7 @@ Public Class LeftPanelVM
|
||||
End If
|
||||
' aggiorno dati ultilizzo barra
|
||||
BeamMachGroup.UpdateUsage()
|
||||
EgtSetView(VT.ISO_SW, False)
|
||||
ElseIf Map.refMachinePanelVM.SelectedMachine.nType = MachineType.WALL Then
|
||||
Dim WallMachGroup As WallMachGroupVM = DirectCast(SelMachGroup, WallMachGroupVM)
|
||||
' verifico spessore
|
||||
@@ -221,8 +230,8 @@ Public Class LeftPanelVM
|
||||
End If
|
||||
' aggiorno dati ultilizzo barra
|
||||
WallMachGroup.UpdateUsage()
|
||||
EgtSetView(VT.TOP, False)
|
||||
End If
|
||||
EgtSetView(VT.ISO_SW, False)
|
||||
EgtZoom(ZM.ALL)
|
||||
End Sub
|
||||
|
||||
@@ -328,15 +337,23 @@ Public Class LeftPanelVM
|
||||
dPosY = 10
|
||||
End If
|
||||
End If
|
||||
' scrivo dati in gruppo di lavorazione
|
||||
EgtSetInfo(WallMachGroup.Id, MGR_RPT_PART & WallMachGroup.PartVMList.Count + 1, nPartDuploId & "," & dPosX & "," & dPosY & "," & 0 & "," & 0)
|
||||
' eseguo script creazione grezzo
|
||||
Dim nRawId As Integer = EgtGetFirstRawPart()
|
||||
While nRawId <> GDB_ID.NULL
|
||||
EgtRemoveRawPart(nRawId)
|
||||
nRawId = EgtGetFirstRawPart()
|
||||
End While
|
||||
If Not ExecWall(Map.refMainWindowVM.MainWindowM.sTempDir, Map.refMachinePanelVM.SelectedMachine.Name, CalcIntegration.CmdType.RAWPART, False) Then Return False
|
||||
If EgtAddPartToRawPart(nPartDuploId, New Point3d(dPosX, dPosY, 0), WallMachGroup.m_WallMachGroupM.nRawPartId) Then
|
||||
EgtSetInfo(nPartDuploId, MGR_PRT_POSX, dPosX)
|
||||
EgtSetInfo(nPartDuploId, MGR_PRT_POSY, dPosY)
|
||||
EgtSetInfo(nPartDuploId, MGR_PRT_ROT, 0)
|
||||
EgtSetInfo(nPartDuploId, MGR_PRT_FLIP, False)
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
'' scrivo dati in gruppo di lavorazione
|
||||
'EgtSetInfo(WallMachGroup.Id, MGR_RPT_PART & WallMachGroup.PartVMList.Count + 1, nPartDuploId & "," & dPosX & "," & dPosY & "," & 0 & "," & 0)
|
||||
'' eseguo script creazione grezzo
|
||||
'Dim nRawId As Integer = EgtGetFirstRawPart()
|
||||
'While nRawId <> GDB_ID.NULL
|
||||
' EgtRemoveRawPart(nRawId)
|
||||
' nRawId = EgtGetFirstRawPart()
|
||||
'End While
|
||||
'If Not ExecWall(Map.refMainWindowVM.MainWindowM.sTempDir, Map.refMachinePanelVM.SelectedMachine.Name, CalcIntegration.CmdType.RAWPART, False) Then Return False
|
||||
'aggiorno lista pezzi
|
||||
WallMachGroup.m_WallMachGroupM.RefreshPartList()
|
||||
' seleziono pezzo aggiunto
|
||||
|
||||
@@ -75,8 +75,6 @@ Public Class MyMachGroupPanelVM
|
||||
End Function
|
||||
|
||||
Public Function RefreshMachGroupList() As Boolean
|
||||
' Svuoto precedente lista di MachGroup
|
||||
MachGroupVMList.Clear()
|
||||
' carico lista dei gruppi di lavorazione
|
||||
For Each MachGroup As MyMachGroupM In MyMachGroupPanelM.UpdateFromNestingMyMachGroups(Map.refMachinePanelVM.MachineList.ToList())
|
||||
m_MachGroupPanelM.AddMachGroup(MachGroup)
|
||||
@@ -183,7 +181,18 @@ Public Class MyMachGroupPanelVM
|
||||
Public Overrides Function OnPostSetCurrMachGroup() As Boolean
|
||||
' Imposto vista solo tavola
|
||||
EgtSetMachineLook(MCH_LOOK.TAB)
|
||||
EgtSetView(VT.ISO_SW, False)
|
||||
Dim View As VT
|
||||
For Each Mach As MyMachine In Map.refMachinePanelVM.MachineList
|
||||
If Mach.Name = SelectedMachGroup.Machine Then
|
||||
If Mach.nType = Core.ConstBeam.MachineType.BEAM Then
|
||||
View = VT.ISO_SW
|
||||
Else
|
||||
View = VT.TOP
|
||||
End If
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
EgtSetView(View, False)
|
||||
EgtZoom(ZM.ALL)
|
||||
Return True
|
||||
End Function
|
||||
|
||||
@@ -22,7 +22,9 @@ Public Class WallVM
|
||||
If StringToLen(value, dValue) Then
|
||||
Dim dOldValue As Double = m_WallM.dPOSX
|
||||
m_WallM.dPOSX = dValue
|
||||
If Not EgtMovePartInRawPart(nPartId, New Vector3d(dValue - dOldValue, 0, 0)) Then
|
||||
If EgtMovePartInRawPart(nPartId, New Vector3d(dValue - dOldValue, 0, 0)) Then
|
||||
EgtSetInfo(nPartId, MGR_PRT_POSX, dValue)
|
||||
Else
|
||||
' rispristino vecchio valore
|
||||
m_WallM.dPOSX = dOldValue
|
||||
End If
|
||||
@@ -42,7 +44,9 @@ Public Class WallVM
|
||||
If StringToLen(value, dValue) Then
|
||||
Dim dOldValue As Double = m_WallM.dPOSY
|
||||
m_WallM.dPOSY = dValue
|
||||
If Not EgtMovePartInRawPart(nPartId, New Vector3d(0, dValue - dOldValue, 0)) Then
|
||||
If EgtMovePartInRawPart(nPartId, New Vector3d(0, dValue - dOldValue, 0)) Then
|
||||
EgtSetInfo(nPartId, MGR_PRT_POSY, dValue)
|
||||
Else
|
||||
' rispristino vecchio valore
|
||||
m_WallM.dPOSY = dOldValue
|
||||
End If
|
||||
@@ -75,6 +79,7 @@ Public Class WallVM
|
||||
EgtGetBBoxGlob(nPartId, GDB_BB.STANDARD, b3Part)
|
||||
If EgtRotate(nPartId, b3Part.Center, Vector3d.X_AX, 180) Then
|
||||
m_WallM.bFLIP = value
|
||||
EgtSetInfo(nPartId, MGR_PRT_FLIP, value)
|
||||
Else
|
||||
NotifyPropertyChanged(NameOf(bFLIP))
|
||||
End If
|
||||
@@ -125,8 +130,6 @@ Public Class WallVM
|
||||
ParentMachGroupVM.SelPart = ParentMachGroupVM.PartVMList(Index - 1)
|
||||
End If
|
||||
ParentMachGroupVM.PartVMList.Remove(Me)
|
||||
Dim WallParentMachGroup As WallMachGroupVM = DirectCast(ParentMachGroupVM, WallMachGroupVM)
|
||||
If Not IsNothing(WallParentMachGroup) Then WallParentMachGroup.ReDrawWallMachgroup()
|
||||
' aggiorno contatore pezzi usati in Prod
|
||||
If Not IsNothing(BTLPart) Then BTLPart.RefreshPartInProd()
|
||||
EgtDraw()
|
||||
|
||||
@@ -126,6 +126,7 @@ Public Class MainMenuVM
|
||||
' apro progetto proj
|
||||
If Not IsNothing(Map.refProjManagerVM.CurrProj) Then
|
||||
Map.refProjManagerVM.OpenProject(Map.refProjManagerVM.CurrProj)
|
||||
DbControllers.m_ProjController.LockByProjId(Map.refProjManagerVM.CurrProj.nProjId, True)
|
||||
End If
|
||||
Map.refMainWindowVM.NotifyPropertyChanged("nSelTabPage")
|
||||
Return True
|
||||
@@ -142,10 +143,6 @@ Public Class MainMenuVM
|
||||
Map.refProjectVM.SetProdManager_Visibility(True)
|
||||
' verifico se progetto modificato, e chiedo se salvare
|
||||
If bVerifyModification Then ProjFileVM.VerifyProjectModification(Map.refProjManagerVM.CurrProj, ProjectType.PROJ)
|
||||
' sblocco progetto
|
||||
If Not IsNothing(Map.refProjManagerVM.CurrProj) Then
|
||||
DbControllers.m_ProjController.LockByProjId(Map.refProjManagerVM.CurrProj.nProjId, False)
|
||||
End If
|
||||
Return True
|
||||
End Function
|
||||
|
||||
@@ -165,6 +162,7 @@ Public Class MainMenuVM
|
||||
If File.Exists(Map.refProdManagerVM.CurrProd.sProdPath) Then
|
||||
' apro progetto
|
||||
Map.refSceneHostVM.MainController.OpenProject(Map.refProdManagerVM.CurrProd.sProdPath, False)
|
||||
DbControllers.m_ProdController.LockByProdId(Map.refProdManagerVM.CurrProd.nProdId, True)
|
||||
' seleziono prima barra
|
||||
Map.refProjectVM.MachGroupPanelVM.SelFirstMachGroup()
|
||||
Else
|
||||
@@ -190,10 +188,6 @@ Public Class MainMenuVM
|
||||
' verifico se progetto modificato, e chiedo se salvare
|
||||
If bVerifyModification Then ProdFileVM.VerifyProjectModification(Map.refProdManagerVM.CurrProd)
|
||||
EgtResetCurrMachGroup()
|
||||
' sblocco progetto
|
||||
If Not IsNothing(Map.refProdManagerVM.CurrProd) Then
|
||||
DbControllers.m_ProdController.LockByProdId(Map.refProdManagerVM.CurrProd.nProdId, False)
|
||||
End If
|
||||
Return True
|
||||
End Function
|
||||
|
||||
|
||||
@@ -63,13 +63,13 @@ Public Class MainWindowVM
|
||||
Select Case Map.refMainMenuVM.SelPage
|
||||
Case Pages.VIEW
|
||||
If Map.refProjManagerVM.CurrProj.bIsNew Then
|
||||
m_Title = "New"
|
||||
m_Title = "New - " & Map.refProjManagerVM.CurrProj.nProjId.ToString("0000")
|
||||
Else
|
||||
m_Title = Map.refProjManagerVM.CurrProj.nProjId.ToString("0000") & " - " & Map.refProjManagerVM.CurrProj.sBTLFileName
|
||||
End If
|
||||
Case Pages.MACHINING
|
||||
If Map.refProdManagerVM.CurrProd.bIsNew Then
|
||||
m_Title = "New"
|
||||
m_Title = "New" & Map.refProdManagerVM.CurrProd.nProdId.ToString("0000")
|
||||
Else
|
||||
m_Title = Map.refProdManagerVM.CurrProd.nProdId.ToString("0000")
|
||||
End If
|
||||
|
||||
@@ -102,17 +102,20 @@ Public Class OptimizePanelVM
|
||||
Dim dKerf As Double = 0
|
||||
Select Case WhType
|
||||
Case WarehouseType.BASIC
|
||||
Dim nQuantity As Integer = 0
|
||||
sWarehouseIniPath = Map.refMainWindowVM.MainWindowM.sWarehouseDir & "\" & WH_BASIC_INI_FILE_NAME
|
||||
If Map.refMachinePanelVM.SelectedMachine.nType = MachineType.BEAM Then
|
||||
' leggo lunghezza barra
|
||||
Dim nCurrentL As Integer = EgtUILib.GenInterface.GetPrivateProfileInt(WRH_BEAM, WRH_CURRENT & WRH_S, 1, sWarehouseIniPath)
|
||||
dRawL = EgtUILib.GenInterface.GetPrivateProfileInt(WRH_BEAM, WRH_L & nCurrentL, 0, sWarehouseIniPath)
|
||||
' leggo start offset ed offset
|
||||
' leggo start offset, offset e quantity
|
||||
dStartOffset = EgtUILib.GenInterface.GetPrivateProfileDouble(WRH_BEAM, WRH_STARTOFFSET, 0, sWarehouseIniPath)
|
||||
dOffset = EgtUILib.GenInterface.GetPrivateProfileDouble(WRH_BEAM, WRH_OFFSET, 0, sWarehouseIniPath)
|
||||
Integer.TryParse(EgtUILib.GenInterface.GetPrivateProfileDouble(WRH_BEAM, WRH_QUANTITY, 0, sWarehouseIniPath), nQuantity)
|
||||
' riporto la stessa lunghezza in tutte le sezioni
|
||||
For Each Section In SectionList
|
||||
Section.dL = dRawL
|
||||
Section.nQuantity = nQuantity
|
||||
Next
|
||||
ElseIf Map.refMachinePanelVM.SelectedMachine.nType = MachineType.WALL Then
|
||||
Dim nCurrentS As Integer = EgtUILib.GenInterface.GetPrivateProfileInt(WRH_WALL, WRH_CURRENT & WRH_S, nCurrentS, sWarehouseIniPath)
|
||||
@@ -121,28 +124,37 @@ Public Class OptimizePanelVM
|
||||
EgtUILib.GenInterface.GetPrivateProfileString(WRH_WALL, WRH_S & nCurrentS, "", sPanelDim, sWarehouseIniPath)
|
||||
If Not String.IsNullOrWhiteSpace(sPanelDim) Then sPanelDims = sPanelDim.Split(","c)
|
||||
If Not sPanelDims.Count = 2 OrElse Not StringToDouble(sPanelDims(0), dRawL) OrElse Not StringToDouble(sPanelDims(1), dRawW) Then Return
|
||||
' leggo start offset, offset e quantity
|
||||
dOffset = EgtUILib.GenInterface.GetPrivateProfileDouble(WRH_WALL, WRH_OFFSET, 0, sWarehouseIniPath)
|
||||
dKerf = EgtUILib.GenInterface.GetPrivateProfileDouble(WRH_WALL, WRH_KERF, 0, sWarehouseIniPath)
|
||||
Integer.TryParse(EgtUILib.GenInterface.GetPrivateProfileDouble(WRH_WALL, WRH_QUANTITY, 0, sWarehouseIniPath), nQuantity)
|
||||
' riporto le stesse dimensioni in tutte le sezioni
|
||||
For Each Section In SectionList
|
||||
Section.dL = dRawL
|
||||
Section.dW = dRawW
|
||||
Section.nQuantity = nQuantity
|
||||
Next
|
||||
End If
|
||||
Case WarehouseType.MEDIUM
|
||||
Dim sCurrL As String
|
||||
Dim nIndex As Integer = 1
|
||||
sWarehouseIniPath = Map.refMainWindowVM.MainWindowM.sWarehouseDir & "\" & WH_MEDIUM_INI_FILE_NAME
|
||||
' aggiungo le sezioni con diverse lunghezze in base al warehouse
|
||||
If Map.refMachinePanelVM.SelectedMachine.nType = MachineType.BEAM Then
|
||||
' leggo lunghezza barra
|
||||
Dim nCurrentL As Integer = EgtUILib.GenInterface.GetPrivateProfileInt(WRH_BEAM, WRH_CURRENT & WRH_S, 1, sWarehouseIniPath)
|
||||
dRawL = EgtUILib.GenInterface.GetPrivateProfileInt(WRH_BEAM, WRH_L & nCurrentL, 0, sWarehouseIniPath)
|
||||
' leggo start offset ed offset
|
||||
dStartOffset = EgtUILib.GenInterface.GetPrivateProfileDouble(WRH_BEAM, WRH_STARTOFFSET, 0, sWarehouseIniPath)
|
||||
dOffset = EgtUILib.GenInterface.GetPrivateProfileDouble(WRH_BEAM, WRH_OFFSET, 0, sWarehouseIniPath)
|
||||
' riporto la stessa lunghezza in tutte le sezioni
|
||||
For Each Section In SectionList
|
||||
Section.dL = dRawL
|
||||
Next
|
||||
' leggo lunghezza barra e quantity
|
||||
While EgtUILib.GenInterface.GetPrivateProfileString(WRH_BEAM, WRH_CURRENT & nIndex, "", sCurrL, sWarehouseIniPath) > 0
|
||||
Dim sLValues() As String = sCurrL.Split(","c)
|
||||
For Each Section In SectionList
|
||||
If Section.SectXMat.dW = sLValues(0) AndAlso Section.SectXMat.dH = sLValues(1) AndAlso Section.SectXMat.MaterialForSameSection_List(0) = sLValues(2) Then
|
||||
StringToDouble(sLValues(3), Section.dL)
|
||||
Integer.TryParse(sLValues(4), Section.nQuantity)
|
||||
End If
|
||||
Next
|
||||
nIndex += 1
|
||||
End While
|
||||
ElseIf Map.refMachinePanelVM.SelectedMachine.nType = MachineType.WALL Then
|
||||
Dim nCurrentS As Integer = EgtUILib.GenInterface.GetPrivateProfileInt(WRH_WALL, WRH_CURRENT & WRH_S, nCurrentS, sWarehouseIniPath)
|
||||
Dim sPanelDim As String = ""
|
||||
@@ -152,11 +164,18 @@ Public Class OptimizePanelVM
|
||||
If Not sPanelDims.Count = 2 OrElse Not StringToDouble(sPanelDims(0), dRawL) OrElse Not StringToDouble(sPanelDims(1), dRawW) Then Return
|
||||
dOffset = EgtUILib.GenInterface.GetPrivateProfileDouble(WRH_WALL, WRH_OFFSET, 0, sWarehouseIniPath)
|
||||
dKerf = EgtUILib.GenInterface.GetPrivateProfileDouble(WRH_WALL, WRH_KERF, 0, sWarehouseIniPath)
|
||||
' riporto le stesse dimensioni in tutte le sezioni
|
||||
For Each Section In SectionList
|
||||
Section.dL = dRawL
|
||||
Section.dW = dRawW
|
||||
Next
|
||||
' leggo lunghezza barra e quantity
|
||||
While EgtUILib.GenInterface.GetPrivateProfileString(WRH_WALL, WRH_CURRENT & nIndex, "", sCurrL, sWarehouseIniPath) > 0
|
||||
Dim sLValues() As String = sCurrL.Split(","c)
|
||||
For Each Section In SectionList
|
||||
If Section.SectXMat.dH = sLValues(0) AndAlso Section.SectXMat.MaterialForSameSection_List(0) = sLValues(1) Then
|
||||
StringToDouble(sLValues(2), Section.dW)
|
||||
StringToDouble(sLValues(3), Section.dL)
|
||||
Integer.TryParse(sLValues(4), Section.nQuantity)
|
||||
End If
|
||||
Next
|
||||
nIndex += 1
|
||||
End While
|
||||
End If
|
||||
End Select
|
||||
' attivo loading progress
|
||||
@@ -164,10 +183,10 @@ Public Class OptimizePanelVM
|
||||
For Each Section In SectionList
|
||||
'Dim SectionPartList As New List(Of BTLPartM)(Map.refProjectVM.BTLStructureVM.BTLPartVMList.Where(Function(x) x.Section = Section.SectXMat).ToList())
|
||||
Dim SectionPartList As List(Of BTLPartM) = (From x In Map.refProjectVM.BTLStructureVM.BTLPartVMList
|
||||
Where x.Section = Section.SectXMat
|
||||
Where x.Section = Section.SectXMat AndAlso x.bDO
|
||||
Select x.BTLPartM).ToList()
|
||||
' passo a lua lista id pezzi da nestare
|
||||
ExecNesting(sLogPath, CurrentMachine.sMachineName, SectionPartList, Section.dL, Section.dW, dStartOffset, dOffset, dKerf)
|
||||
ExecNesting(sLogPath, CurrentMachine.sMachineName, SectionPartList, Section.dL, Section.dW, dStartOffset, dOffset, dKerf, Section.nQuantity)
|
||||
Next
|
||||
' update liste grezzi e pezzi della grafica
|
||||
Map.refProjectVM.MachGroupPanelVM.RefreshMachGroupList()
|
||||
|
||||
@@ -134,26 +134,15 @@ Public Class ProdManagerVM
|
||||
If File.Exists(sFilePath) Then
|
||||
If Map.refSceneHostVM.MainController.OpenProject(sFilePath, False) Then
|
||||
m_CurrProd = TempCurrProd
|
||||
Map.refMainWindowVM.UpdateTitle()
|
||||
'If Map.refMachGroupPanelVM.InitMachGroupList() Then
|
||||
' m_CurrProd = TempCurrProd
|
||||
' Map.refMainWindowVM.SetTitle(CurrProd.nProdId.ToString("0000") & " - EgtBEAMWALL")
|
||||
'Else
|
||||
'MessageBox.Show("Impossibile aprire gruppi di lavorazione del file!!")
|
||||
'Map.refSceneHostVM.MainController.NewProject()
|
||||
'Map.refMainWindowVM.SetTitle("New - EgtBEAMWALL")
|
||||
'End If
|
||||
Else
|
||||
MessageBox.Show("Impossibile aprire il file!!")
|
||||
Map.refSceneHostVM.MainController.NewProject()
|
||||
Map.refMainWindowVM.SetTitle("New - EgtBEAMWALL")
|
||||
DbControllers.m_ProdController.LockByProdId(m_CurrProd.nProdId, True)
|
||||
End If
|
||||
Else
|
||||
MessageBox.Show("File non trovato!!")
|
||||
Map.refSceneHostVM.MainController.NewProject()
|
||||
Map.refMainWindowVM.SetTitle("New - EgtBEAMWALL")
|
||||
End If
|
||||
|
||||
' aggiorno titolo
|
||||
Map.refMainWindowVM.UpdateTitle()
|
||||
End Sub
|
||||
|
||||
#End Region ' OpenCommand
|
||||
|
||||
@@ -194,9 +194,6 @@ Public Class ProjManagerVM
|
||||
End Function
|
||||
|
||||
Public Function SetCurrProj(nProjId As Integer) As Boolean
|
||||
If Not IsNothing(m_CurrProj) Then
|
||||
DbControllers.m_ProjController.LockByProjId(m_CurrProj.nProjId, False)
|
||||
End If
|
||||
Dim Currproj As ProjFileM = DbControllers.m_ProjController.FindByProjIdConv(nProjId)
|
||||
If IsNothing(Currproj) Then Return False
|
||||
m_CurrProj = New ProjFileVM(Currproj)
|
||||
@@ -292,7 +289,6 @@ Public Class ProjManagerVM
|
||||
If Map.refSceneHostVM.MainController.OpenProject(sFilePath, False) Then
|
||||
m_CurrProj = TempCurrProj
|
||||
DbControllers.m_ProjController.LockByProjId(m_CurrProj.nProjId, True)
|
||||
Map.refMainWindowVM.UpdateTitle()
|
||||
End If
|
||||
' aggiorno titolo
|
||||
Map.refMainWindowVM.UpdateTitle()
|
||||
|
||||
@@ -207,6 +207,7 @@ Public Class ProdFileVM
|
||||
Return False
|
||||
End If
|
||||
End If
|
||||
DbControllers.m_ProdController.LockByProdId(CurrProject.nProdId, False)
|
||||
Return True
|
||||
End Function
|
||||
|
||||
|
||||
@@ -230,6 +230,7 @@ Public Class ProjFileVM
|
||||
Return False
|
||||
End If
|
||||
End If
|
||||
DbControllers.m_ProjController.LockByProjId(CurrProject.nProjId, False)
|
||||
Return True
|
||||
End Function
|
||||
|
||||
|
||||
@@ -272,7 +272,13 @@ Public Class MySceneHostVM
|
||||
|
||||
Private Sub OnImportingProject(sender As Object, nType As Integer, ByRef nFlag As Integer)
|
||||
If nType = FT.BTL Or nType = FT.BTLX Then
|
||||
nFlag = GetMainPrivateProfileInt(S_IMPORT, K_BTLFLAG, EIB_FL.TS3_POS + EIB_FL.SORT + EIB_FL.USEUATTR)
|
||||
Dim sBTLFlag As String
|
||||
If Map.refMachinePanelVM.SelectedMachine.nType = Core.ConstBeam.MachineType.BEAM Then
|
||||
sBTLFlag = K_BTLFLAG
|
||||
Else
|
||||
sBTLFlag = K_WALLBTLFLAG
|
||||
End If
|
||||
nFlag = GetMainPrivateProfileInt(S_IMPORT, sBTLFlag, EIB_FL.TS3_POS + EIB_FL.SORT + EIB_FL.USEUATTR)
|
||||
Else
|
||||
MessageBox.Show(Application.Current.MainWindow, EgtMsg(10005), EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' File type unknown - Error
|
||||
End If
|
||||
|
||||
@@ -70,7 +70,7 @@ Module LuaExec
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Friend Function ExecNesting(sFile As String, sMachine As String, PartList As List(Of BTLPartM), dLength As Double, dWidth As Double, dStartOffset As Double, dOffset As Double, dKerf As Double) As Boolean
|
||||
Friend Function ExecNesting(sFile As String, sMachine As String, PartList As List(Of BTLPartM), dLength As Double, dWidth As Double, dStartOffset As Double, dOffset As Double, dKerf As Double, nQty As Integer) As Boolean
|
||||
EgtOutLog("-- Start ExecNest --")
|
||||
' Recupero lo script da eseguire
|
||||
Dim sExecPath As String = ""
|
||||
@@ -96,6 +96,7 @@ Module LuaExec
|
||||
EgtLuaSetGlobNumVar("NEST.STARTOFFSET", dStartOffset)
|
||||
EgtLuaSetGlobNumVar("NEST.OFFSET", dOffset)
|
||||
EgtLuaSetGlobNumVar("NEST.KERF", dKerf)
|
||||
EgtLuaSetGlobNumVar("NEST.QTY", nQty)
|
||||
EgtLuaCreateGlobTable("PART")
|
||||
For PartIndex = 0 To PartList.Count - 1
|
||||
EgtLuaSetGlobIntVar("PART." & PartList(PartIndex).nPartId.ToString(), PartList(PartIndex).m_nCNT + PartList(PartIndex).m_nADDED - PartList(PartIndex).nINPROD)
|
||||
|
||||
Reference in New Issue
Block a user