From d4024058b44aba1d99c89d02e46a8b8f748ee836 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 17 Jan 2024 19:52:21 +0100 Subject: [PATCH 1/8] Update demo VB --- TestWinFormVB/Form1.Designer.vb | 14 +++++- TestWinFormVB/Form1.vb | 70 +++++++++++++++++++++++++++--- TestWinFormVB/TestWinFormVB.vbproj | 2 +- TestWinFormVB/packages.config | 2 +- 4 files changed, 80 insertions(+), 8 deletions(-) diff --git a/TestWinFormVB/Form1.Designer.vb b/TestWinFormVB/Form1.Designer.vb index c872beb..1aa10ea 100644 --- a/TestWinFormVB/Form1.Designer.vb +++ b/TestWinFormVB/Form1.Designer.vb @@ -26,6 +26,7 @@ Partial Class Form1 Me.lblServTest = New System.Windows.Forms.Label() Me.Button2 = New System.Windows.Forms.Button() Me.txtOut = New System.Windows.Forms.TextBox() + Me.Button3 = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'Button1 @@ -62,14 +63,24 @@ Partial Class Form1 Me.txtOut.Location = New System.Drawing.Point(103, 53) Me.txtOut.Multiline = True Me.txtOut.Name = "txtOut" - Me.txtOut.Size = New System.Drawing.Size(685, 184) + Me.txtOut.Size = New System.Drawing.Size(685, 392) Me.txtOut.TabIndex = 3 ' + 'Button3 + ' + Me.Button3.Location = New System.Drawing.Point(12, 97) + Me.Button3.Name = "Button3" + Me.Button3.Size = New System.Drawing.Size(75, 23) + Me.Button3.TabIndex = 4 + Me.Button3.Text = "Get Invent." + Me.Button3.UseVisualStyleBackColor = True + ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(800, 450) + Me.Controls.Add(Me.Button3) Me.Controls.Add(Me.txtOut) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.lblServTest) @@ -85,4 +96,5 @@ Partial Class Form1 Friend WithEvents lblServTest As Label Friend WithEvents Button2 As Button Friend WithEvents txtOut As TextBox + Friend WithEvents Button3 As Button End Class diff --git a/TestWinFormVB/Form1.vb b/TestWinFormVB/Form1.vb index d63ade4..f28d002 100644 --- a/TestWinFormVB/Form1.vb +++ b/TestWinFormVB/Form1.vb @@ -3,13 +3,29 @@ Imports Microsoft.SqlServer Public Class Form1 + + +#If DEBUG Then + + ' token di auth Private restToken As String = "91f4fec6-7e9c-4130-9df2-702d729ccdd3" + ' Indirizzo server (DEBUG) + Private servAddr As String = "localhost:7207" + +#Else + + ' token di auth + Private restToken As String = "22fa4426-6670-41ad-ac2b-d7b5c3dfe849" + ' Indirizzo server (DEBUG) + Private servAddr As String = "magman.egalware.com" + +#End If Private commLib As DataSyncro Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click ' esegue test comunicazione server (ping, alive) - commLib = New DataSyncro(restToken) + commLib = New DataSyncro(servAddr, restToken) Dim servOk As Boolean servOk = commLib.CheckRemote() Dim esito As String = "" @@ -24,7 +40,7 @@ Public Class Form1 Private Async Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click ' recupera e mostra dati elenco materiali - commLib = New DataSyncro(restToken) + commLib = New DataSyncro(servAddr, restToken) Dim result As String = "" @@ -32,13 +48,57 @@ Public Class Form1 If matList IsNot Nothing Then For Each item In matList - result += $"Mat Code: {item.MatExtCode}{Environment.NewLine}" - result += $"Mat Code: {item.MatExtCode}{Environment.NewLine}" + result += $"Mat ID: {item.MatID}{Environment.NewLine}" result += $"Mat Code: {item.MatExtCode}{Environment.NewLine}" result += $"Dtmx Code: {item.MatDtmx}{Environment.NewLine}" result += $"descript: {item.MatDesc}{Environment.NewLine}" result += $"Dimensions W x T x L: {item.WMm:N3} x {item.TMm:N3} x {item.LMm:N3}{Environment.NewLine}" - 'result += $"Items count: {item.ItemList.Count}" + If item.ItemNav IsNot Nothing Then + 'result += $"Items count: {item.ItemList.Count}" + result += $"{Environment.NewLine}" + End If + Next + End If + + txtOut.Text = result + + End Sub + + Private Async Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click + ' recupera e mostra dati elenco materiali + commLib = New DataSyncro(servAddr, restToken) + + Dim result As String = "" + Dim sepShort As String = "----" + + Dim matList = Await commLib.GetInventario(0) + + If matList IsNot Nothing Then + + For Each item In matList + result += $"Mat ID: {item.MatID}{Environment.NewLine}" + result += $"Mat Code: {item.MatExtCode}{Environment.NewLine}" + result += $"Dtmx Code: {item.MatDtmx}{Environment.NewLine}" + result += $"descript: {item.MatDesc}{Environment.NewLine}" + result += $"Dimensions W x T x L: {item.WMm:N3} x {item.TMm:N3} x {item.LMm:N3}{Environment.NewLine}" + If item.ItemNav IsNot Nothing Then + result += $"Items count: {item.ItemNav.Count}" + + If item.ItemNav.Count > 0 Then + result += "Inventario:" + + For Each itemInv In item.ItemNav + result += $"{sepShort}{Environment.NewLine}" + result += $"ID: {itemInv.ItemID}{Environment.NewLine}" + result += $"Location: {itemInv.Location}{Environment.NewLine}" + result += $"Descript: {itemInv.Note}{Environment.NewLine}" + result += $"Giacenza: {itemInv.QtyAvail}{Environment.NewLine}" + result += $"Dimensions W x T x L: {itemInv.WMm:N3} x {itemInv.TMm:N3} x {itemInv.LMm:N3}{Environment.NewLine}" + result += $"Dtmx Code: {itemInv.ItemDtmx}{Environment.NewLine}" + Next + End If + End If + result += $"{Environment.NewLine}" Next End If diff --git a/TestWinFormVB/TestWinFormVB.vbproj b/TestWinFormVB/TestWinFormVB.vbproj index 8e1fca0..152fead 100644 --- a/TestWinFormVB/TestWinFormVB.vbproj +++ b/TestWinFormVB/TestWinFormVB.vbproj @@ -49,7 +49,7 @@ - ..\packages\EgwProxy.MagMan.0.9.2401-beta.1718\lib\EgwProxy.MagMan.dll + ..\packages\EgwProxy.MagMan.0.9.2401-beta.1719\lib\EgwProxy.MagMan.dll ..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll diff --git a/TestWinFormVB/packages.config b/TestWinFormVB/packages.config index bded6e6..7d159d3 100644 --- a/TestWinFormVB/packages.config +++ b/TestWinFormVB/packages.config @@ -1,6 +1,6 @@  - + From b2c4d76d787863659ee1224875adc5d663b946ff Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 18 Jan 2024 08:59:20 +0100 Subject: [PATCH 2/8] Inizio aggiunta nuove classi x gestione richieste da Proj --- MagMan.Core/Enums.cs | 32 ++++- .../DbModels/LogMachineModel.cs | 121 +++++++++++++++++ MagMan.Data.Tenant/DbModels/ProjModel.cs | 122 ++++++++++++++++++ .../DbModels/RequestDetailModel.cs | 41 ++++++ .../DbModels/RequestPlanModel.cs | 33 +++++ MagMan.Data.Tenant/MagManContext.cs | 3 + MagMan.UI/Controllers/ProjectsController.cs | 59 +++++++++ MagMan.UI/MagMan.UI.csproj | 2 +- Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 11 files changed, 413 insertions(+), 6 deletions(-) create mode 100644 MagMan.Data.Tenant/DbModels/LogMachineModel.cs create mode 100644 MagMan.Data.Tenant/DbModels/ProjModel.cs create mode 100644 MagMan.Data.Tenant/DbModels/RequestDetailModel.cs create mode 100644 MagMan.Data.Tenant/DbModels/RequestPlanModel.cs create mode 100644 MagMan.UI/Controllers/ProjectsController.cs diff --git a/MagMan.Core/Enums.cs b/MagMan.Core/Enums.cs index 573e11e..6b76686 100644 --- a/MagMan.Core/Enums.cs +++ b/MagMan.Core/Enums.cs @@ -1,7 +1,18 @@ -namespace MagMan.Core +using StackExchange.Redis; + +namespace MagMan.Core { public class Enums { + #region Public Enums + + public enum BWType + { + NULL = 0, + BEAM = 1, + WALL = 2 + } + public enum ItemState { None, @@ -10,5 +21,22 @@ Request, } + + public enum RequestStatus + { + None = 0, + Estimated, + Confirmed, + Reserved + } + + public enum ResultTypes + { + NULL = 0, + EXECUTED = 1, + RESULT = 2 + } + + #endregion Public Enums } -} +} \ No newline at end of file diff --git a/MagMan.Data.Tenant/DbModels/LogMachineModel.cs b/MagMan.Data.Tenant/DbModels/LogMachineModel.cs new file mode 100644 index 0000000..15e65fc --- /dev/null +++ b/MagMan.Data.Tenant/DbModels/LogMachineModel.cs @@ -0,0 +1,121 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using static MagMan.Core.Enums; + +namespace MagMan.Data.Tenant.DbModels +{ + // + // This is here so CodeMaid doesn't reorganize this document + // + /// + /// Tabella dei LOG Macchina (per macchina) + /// + [Table("LogMachine")] + [Index(nameof(MachineID))] + [Index(nameof(KeyNum))] + public class LogMachineModel + { + [Key, Column("DbId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int LogDbId { get; set; } + + /// + /// Id macchina (diMagMan) + /// + public int MachineID { get; set; } = 0; + + /// + /// Key di riferimento per il progetto + /// + public int KeyNum { get; set; } = 0; + +#if false + /// + /// Codice Allarme + /// + [Column("AlarmCode")] + public string AlarmCode { get; set; } = ""; + + /// + /// Data Evento + /// + [Column("AlarmDtEvent")] + public DateTime AlarmDatetime { get; set; } = DateTime.Now; + + /// + /// Messaggio Allarme + /// + [Column("AlarmMessage")] + public string AlarmMessage { get; set; } = ""; + + /// + /// Alarm Operation + /// + [Column("AlarmOperation")] + public int AlarmOperation { get; set; } = 0; + + /// + /// Alarm Type + /// + [Column("AlarmType")] + public int AlarmType { get; set; } = 0; + + /// + /// Esaecuzione comando corretta + /// + [Column("CommExecuted")] + public bool CommandExecutedCorrectly { get; set; } = false; + + /// + /// Stato da enum Core + /// + [Column("CommandState")] + public Core.ConstMachComm.CommandStates CommandState { get; set; } = Core.ConstMachComm.CommandStates.NULL; + + /// + /// Tipo Comando da enum Core + /// + [Column("CommandType")] + public Core.ConstMachComm.LogCommandTypes CommandType { get; set; } = Core.ConstMachComm.LogCommandTypes.NULL; + + /// + /// Descrizione + /// + [Column("Description")] + public string Description { get; set; } = ""; + + + + /// + /// New OP State + /// + [Column("NewOpState")] + public int NewOpState { get; set; } = 0; +#endif + + /// + /// Stato da enum Core + /// + [Column("ResultType")] + public ResultTypes ResultType { get; set; } = ResultTypes.NULL; + + /// + /// Indirizzo VAR + /// + [Column("VarAddress")] + public string VarAddress { get; set; } = ""; + + /// + /// Valore VAR + /// + [Column("VarValue")] + public string VarValue { get; set; } = ""; + + + } +} diff --git a/MagMan.Data.Tenant/DbModels/ProjModel.cs b/MagMan.Data.Tenant/DbModels/ProjModel.cs new file mode 100644 index 0000000..fb3044e --- /dev/null +++ b/MagMan.Data.Tenant/DbModels/ProjModel.cs @@ -0,0 +1,122 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static MagMan.Core.Enums; + +namespace MagMan.Data.Tenant.DbModels +{ + // + // This is here so CodeMaid doesn't reorganize this document + // + /// + /// Tabella dei PROJ caricati da EgtBeamWall + /// + [Table("ProjList")] + [Index(nameof(MachineID))] + [Index(nameof(KeyNum))] + [Index(nameof(DtCreated))] + [Index(nameof(DtStartProd))] + [Index(nameof(DtLastAction))] + [Index(nameof(ProjId))] + [Index(nameof(IsActive))] + [Index(nameof(IsArchived))] + public class ProjModel + { + #region Public Properties + + /// + /// Chiave univoca su DB + /// + [Key, Column("ProjDbId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int ProjDbId { get; set; } + + /// + /// ID da modello ext + /// + [Column("Id")] + public int ProjId { get; set; } + + /// + /// Nome file BTL originale + /// + public string BTLFileName { get; set; } = ""; + + /// + /// Tipologia del progetto (Travi, Pareti, ...) + /// + public BWType PType { get; set; } = BWType.NULL; + + /// + /// Id macchina (diMagMan) + /// + public int MachineID { get; set; } = 0; + + /// + /// Key di riferimento per il progetto + /// + public int KeyNum { get; set; } = 0; + + /// + /// Macchina (Costruttore/Modello) + /// + public string Machine { get; set; } = ""; + + /// + /// Descrizione progetto (copiata da BTLFileName inizialmente) + /// + public string ProjDescription { get; set; } = ""; + + /// + /// Data Creazione progetto + /// + public DateTime DtCreated { get; set; } = DateTime.Now; + + /// + /// Data di schedulazione (prevista) + /// + public DateTime DtSchedule { get; set; } = DateTime.Today.AddMonths(3); + + /// + /// Data Inizio Produzione + /// + public DateTime DtStartProd { get; set; } = DateTime.MinValue; + + /// + /// Data ora ultima operazione registrata + /// + public DateTime DtLastAction { get; set; } = DateTime.MinValue; + + /// + /// ListName del BTL + /// + public string ListName { get; set; } = ""; + + /// + /// Tempo lavorazione previsto (stima) + /// + public double ProcTimeEst { get; set; } = 0; + + /// + /// Tempo lavorazione reale (parziale o totale se chiuso/completato/archiviato) + /// + public double ProcTimeReal { get; set; } = 0; + + /// + /// Record attivo (se false == cancellazione logica) + /// + public bool IsActive { get; set; } = true; + + /// + /// Stato Archiviato = NON visualizzabile normalmente, già prodotto/chiuso + /// + public bool IsArchived { get; set; } = false; + + #endregion Public Properties + } +} diff --git a/MagMan.Data.Tenant/DbModels/RequestDetailModel.cs b/MagMan.Data.Tenant/DbModels/RequestDetailModel.cs new file mode 100644 index 0000000..fadaf41 --- /dev/null +++ b/MagMan.Data.Tenant/DbModels/RequestDetailModel.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static MagMan.Core.Enums; + +namespace MagMan.Data.Tenant.DbModels +{ + // + // This is here so CodeMaid doesn't reorganize this document + // + /// + /// Tabella esplosione richieste come items + /// + [Table("RequestDetail")] + public class RequestDetailModel + { + /// + /// Riferimento Richiesta + /// + public int RequestId { get; set; } = 0; + + /// + /// Riferimento Item specifico + /// + public int ItemID { get; set; } = 0; + + /// + /// Quantità necessaria + /// + public int QtyReq { get; set; } = 0; + + /// + /// Stato richeista + /// + public RequestStatus ReqState { get; set; } = RequestStatus.None; + } +} diff --git a/MagMan.Data.Tenant/DbModels/RequestPlanModel.cs b/MagMan.Data.Tenant/DbModels/RequestPlanModel.cs new file mode 100644 index 0000000..0e83b05 --- /dev/null +++ b/MagMan.Data.Tenant/DbModels/RequestPlanModel.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MagMan.Data.Tenant.DbModels +{ + // + // This is here so CodeMaid doesn't reorganize this document + // + /// + /// Tabella dei Piano Richieste associate a Proj + /// + [Table("RequestPlan")] + public class RequestPlanModel + { + [Key, Column("RequestId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int RequestId { get; set; } + + /// + /// Progetto di riferimento + /// + public int ProjDbId { get; set; } + + /// + /// Data richiesta + /// + public DateTime DtRequest{ get; set; } + } +} diff --git a/MagMan.Data.Tenant/MagManContext.cs b/MagMan.Data.Tenant/MagManContext.cs index d4ed53c..528ab42 100644 --- a/MagMan.Data.Tenant/MagManContext.cs +++ b/MagMan.Data.Tenant/MagManContext.cs @@ -117,6 +117,9 @@ namespace MagMan.Data.Tenant .HasComment("Valore di default/riferimento per la variabile"); }); + modelBuilder.Entity() + .HasKey(c => new { c.RequestId, c.ItemID}); + #if false modelBuilder.Entity().HasKey(c => new { c.TabName, c.FieldName, c.Val }); diff --git a/MagMan.UI/Controllers/ProjectsController.cs b/MagMan.UI/Controllers/ProjectsController.cs new file mode 100644 index 0000000..1ef0461 --- /dev/null +++ b/MagMan.UI/Controllers/ProjectsController.cs @@ -0,0 +1,59 @@ +using MagMan.Data.Admin.DbModels; +using MagMan.Data.Admin.Services; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using NLog; + +namespace MagMan.UI.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class ProjectsController : ControllerBase + { + /// + /// Classe per logging + /// + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + private MTAdminService _DataService { get; set; } = null!; + public ProjectsController(MTAdminService DataService) + { + _DataService = DataService; + Log.Info("Avviata classe ProjectsController"); + } + + /// + /// Controllo status Alive + /// GET: api/Machines/alive + /// + /// + [HttpGet("alive")] + public string alive() + { + //Log.Debug("Chiamata alive"); + return $"OK"; + } + + // GET api/Machines/5 + [HttpGet] + public async Task> Get() + { + // se non ho chaive --> vuoto! + List ListRecords = new List(); + await Task.Delay(100); + return ListRecords; + } + + /// + /// Elenco Macchine dato RestToken + /// + /// Rest Token cliente + /// + // GET api/Machines/2cba60c7-7be4-40b1-aa0d-52e7c71fc1a7 + [HttpGet("{id}")] + public async Task> Get(string id, int KeyNum) + { + var ListRecords = await _DataService.MachineGetByToken(id); + return ListRecords; + } + } +} diff --git a/MagMan.UI/MagMan.UI.csproj b/MagMan.UI/MagMan.UI.csproj index ba0d30e..7f9f33c 100644 --- a/MagMan.UI/MagMan.UI.csproj +++ b/MagMan.UI/MagMan.UI.csproj @@ -2,7 +2,7 @@ net6.0 - 1.0.2401.1716 + 1.0.2401.1808 enable enable true diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 3f26b06..577a186 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ MagMan - Wood Warehouse Management System -

Versione: 1.0.2401.1716

+

Versione: 1.0.2401.1808


Note di rilascio: