Merge branch 'feature/NugetSdk' into develop
This commit is contained in:
@@ -41,6 +41,6 @@ namespace EgwProxy.MagMan.DTO
|
||||
/// <summary>
|
||||
/// Elenco item e giancenze
|
||||
/// </summary>
|
||||
public List<ItemDTO> ItemNav { get; set; } = new List<ItemDTO>();
|
||||
public List<ItemDTO> ItemList { get; set; } = new List<ItemDTO>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Net.NetworkInformation;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using RestSharp.Serializers.NewtonsoftJson;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
@@ -82,7 +83,7 @@ namespace EgwProxy.MagMan
|
||||
/// <summary>
|
||||
/// Elenco Materiali dato RestToken
|
||||
/// </summary>
|
||||
public async Task<List<MaterialDTO>> GetMaterials()
|
||||
public async Task<List<MaterialDTO>> MaterialsGet()
|
||||
{
|
||||
List<MaterialDTO> answ = new List<MaterialDTO>();
|
||||
// cerco online
|
||||
@@ -91,21 +92,42 @@ namespace EgwProxy.MagMan
|
||||
var request = new RestRequest($"Materials/{MKeyEnc}", Method.Get);
|
||||
var response = await client.GetAsync(request);
|
||||
// controllo risposta
|
||||
if (response.StatusCode == System.Net.HttpStatusCode.OK)
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
// salvo in redis contenuto serializzato
|
||||
// contenuto serializzato
|
||||
string rawData = $"{response.Content}";
|
||||
answ = JsonConvert.DeserializeObject<List<MaterialDTO>>(rawData);
|
||||
}
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
/// <summary>
|
||||
/// Invia un elenco (anche parziale) di Materiali, il server farà il merge
|
||||
/// </summary>
|
||||
public async Task<bool> MaterialsSend(List<MaterialDTO> List2Merge)
|
||||
{
|
||||
bool answ = false;
|
||||
// cerco online
|
||||
var client = new RestClient(apiUrl);
|
||||
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
|
||||
var jsonBody = JsonConvert.SerializeObject(List2Merge);
|
||||
var request = new RestRequest($"Materials/upsert/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
|
||||
var response = await client.PostAsync(request);
|
||||
// controllo risposta
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
// contenuto serializzato
|
||||
string rawData = $"{response.Content}";
|
||||
answ = rawData == "OK";
|
||||
}
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inventario per materiale
|
||||
/// </summary>
|
||||
/// <param name="MatID">Se 0 = tutto</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<MaterialDTO>> GetInventario(int MatID)
|
||||
public async Task<List<MaterialDTO>> InventoryGet(int MatID)
|
||||
{
|
||||
List<MaterialDTO> answ = new List<MaterialDTO>();
|
||||
// cerco online
|
||||
@@ -114,14 +136,35 @@ namespace EgwProxy.MagMan
|
||||
var request = new RestRequest($"Inventory/{MKeyEnc}?MatId={MatID}", Method.Get);
|
||||
var response = await client.GetAsync(request);
|
||||
// controllo risposta
|
||||
if (response.StatusCode == System.Net.HttpStatusCode.OK)
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
// salvo in redis contenuto serializzato
|
||||
// contenuto serializzato
|
||||
string rawData = $"{response.Content}";
|
||||
answ = JsonConvert.DeserializeObject<List<MaterialDTO>>(rawData);
|
||||
}
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
/// <summary>
|
||||
/// Invia un elenco di RawItems associati ad un singolo materiale, il server farà il merge
|
||||
/// </summary>
|
||||
public async Task<bool> InventorySend(MaterialDTO Mat2Merge)
|
||||
{
|
||||
bool answ = false;
|
||||
// cerco online
|
||||
var client = new RestClient(apiUrl);
|
||||
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
|
||||
var jsonBody = JsonConvert.SerializeObject(Mat2Merge.ItemList);
|
||||
var request = new RestRequest($"Inventory/upsert/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
|
||||
var response = await client.PostAsync(request);
|
||||
// controllo risposta
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
// contenuto serializzato
|
||||
string rawData = $"{response.Content}";
|
||||
answ = rawData == "OK";
|
||||
}
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RestSharp, Version=110.2.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\RestSharp.110.2.0\lib\net471\RestSharp.dll</HintPath>
|
||||
@@ -58,8 +58,8 @@
|
||||
<Reference Include="System.Text.Encodings.Web, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Text.Encodings.Web.7.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Text.Json, Version=7.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Text.Json.7.0.2\lib\net462\System.Text.Json.dll</HintPath>
|
||||
<Reference Include="System.Text.Json, Version=7.0.0.3, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Text.Json.7.0.3\lib\net462\System.Text.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
|
||||
@@ -6,6 +6,14 @@
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="RestSharp" publicKeyToken="598062e77f915f75" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-110.2.1.0" newVersion="110.2.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.3" newVersion="7.0.0.3" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
@@ -1,14 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Bcl.AsyncInterfaces" version="7.0.0" targetFramework="net472" />
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
|
||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
|
||||
<package id="RestSharp" version="110.2.0" targetFramework="net472" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
|
||||
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
|
||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net472" />
|
||||
<package id="System.Text.Encodings.Web" version="7.0.0" targetFramework="net472" />
|
||||
<package id="System.Text.Json" version="7.0.2" targetFramework="net472" />
|
||||
<package id="System.Text.Json" version="7.0.3" targetFramework="net472" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
|
||||
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
|
||||
</packages>
|
||||
@@ -12,7 +12,12 @@ namespace MagMan.Core.DTO
|
||||
/// <summary>
|
||||
/// Ext ref for Material
|
||||
/// </summary>
|
||||
public int MatID { get; set; } = 0;
|
||||
public int MatId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Key del RawItem di riferimento (se zero da verificare con quote)
|
||||
/// </summary>
|
||||
public int RawItemId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Check if is a Remnant
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace MagMan.Core.DTO
|
||||
public class MaterialDTO
|
||||
{
|
||||
/// <summary>
|
||||
/// Primary Key AUTO, 0 se proviente da EgtBeamWall
|
||||
/// Primary Key Materiale, 0 se proviente da EgtBeamWall
|
||||
/// </summary>
|
||||
public int MatId { get; set; } = 0;
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static MagMan.Core.Enums;
|
||||
|
||||
namespace MagMan.Core.DTO
|
||||
{
|
||||
public class ProjectDTO
|
||||
{
|
||||
/// <summary>
|
||||
/// Id macchina (MagMan)
|
||||
/// </summary>
|
||||
public int MachineID { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Key di riferimento per il progetto
|
||||
/// </summary>
|
||||
public int KeyNum { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// ID del DB EgtBW, univoco con KeyNum
|
||||
/// </summary>
|
||||
public int ProjExtDbId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// ID esterno (da EgtBW)
|
||||
/// </summary>
|
||||
public int ProjExtId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Nome file BTL originale
|
||||
/// </summary>
|
||||
public string BTLFileName { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Tipologia del progetto (Travi, Pareti, ...)
|
||||
/// </summary>
|
||||
public BWType PType { get; set; } = BWType.NULL;
|
||||
|
||||
/// <summary>
|
||||
/// Macchina (Costruttore/Modello)
|
||||
/// </summary>
|
||||
public string Machine { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Descrizione progetto (copiata da BTLFileName inizialmente)
|
||||
/// </summary>
|
||||
public string ProjDescription { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Data Creazione progetto
|
||||
/// </summary>
|
||||
public DateTime DtCreated { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// Data di schedulazione (prevista)
|
||||
/// </summary>
|
||||
public DateTime DtSchedule { get; set; } = DateTime.Today.AddMonths(3);
|
||||
|
||||
/// <summary>
|
||||
/// Data Inizio Produzione
|
||||
/// </summary>
|
||||
public DateTime DtStartProd { get; set; } = DateTime.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// Data ora ultima operazione registrata
|
||||
/// </summary>
|
||||
public DateTime DtLastAction { get; set; } = DateTime.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// ListName del BTL
|
||||
/// </summary>
|
||||
public string ListName { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Tempo lavorazione previsto (stima) in minuti
|
||||
/// </summary>
|
||||
public double ProcTimeEst { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Tempo lavorazione reale in minuti (parziale o totale se chiuso/completato/archiviato)
|
||||
/// </summary>
|
||||
public double ProcTimeReal { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Record attivo (se false == cancellazione logica)
|
||||
/// </summary>
|
||||
public bool IsActive { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Stato Archiviato = NON visualizzabile normalmente, già prodotto/chiuso
|
||||
/// </summary>
|
||||
public bool IsArchived { get; set; } = false;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Core.DTO
|
||||
{
|
||||
public class ResourceDTO
|
||||
{
|
||||
/// <summary>
|
||||
/// Ext ref for Material
|
||||
/// </summary>
|
||||
public int RawItemId { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// Qty, se > 0 rappresenta un IMPEGNO di qualsiasi tipo, se < 0 è un CONSUMO
|
||||
/// </summary>
|
||||
public int Qty { get; set; } = 0;
|
||||
|
||||
}
|
||||
}
|
||||
+19
-2
@@ -22,11 +22,27 @@ namespace MagMan.Core
|
||||
Request,
|
||||
}
|
||||
|
||||
public enum RequestStatus
|
||||
public enum ProjResState
|
||||
{
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// Registrazione consumo effettivo (update giacenza su tab RawItemList)
|
||||
/// </summary>
|
||||
Consumed = -1,
|
||||
/// <summary>
|
||||
/// Non definito
|
||||
/// </summary>
|
||||
ND = 0,
|
||||
/// <summary>
|
||||
/// Consumo stimato da nesting (solo simulazione)
|
||||
/// </summary>
|
||||
Estimated,
|
||||
/// <summary>
|
||||
/// Consumo confermato (da ordinare)
|
||||
/// </summary>
|
||||
Confirmed,
|
||||
/// <summary>
|
||||
/// Riservato (utile x calcolo quantità da ordinare)
|
||||
/// </summary>
|
||||
Reserved
|
||||
}
|
||||
|
||||
@@ -37,6 +53,7 @@ namespace MagMan.Core
|
||||
RESULT = 2
|
||||
}
|
||||
|
||||
|
||||
#endregion Public Enums
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.4.0" />
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0" />
|
||||
<PackageReference Include="Blazored.SessionStorage" Version="2.4.0" />
|
||||
<PackageReference Include="MailKit" Version="4.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MagMan.Core.DTO;
|
||||
using static MagMan.Core.Enums;
|
||||
|
||||
namespace MagMan.Core
|
||||
{
|
||||
@@ -23,5 +24,21 @@ namespace MagMan.Core
|
||||
/// </summary>
|
||||
public List<ItemDTO>? ItemList { get; set; }
|
||||
}
|
||||
|
||||
public class Resources
|
||||
{
|
||||
/// <summary>
|
||||
/// ID progetto univoco esterno (da associare a KEY)
|
||||
/// </summary>
|
||||
public int ProjDbId { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// Tipo di registrazione dato inviata (previsione consumo, consumo effettivo...)
|
||||
/// </summary>
|
||||
public ProjResState ReqState { get; set; } = ProjResState.ND;
|
||||
/// <summary>
|
||||
/// Elenco Risorse x invio POST
|
||||
/// </summary>
|
||||
public List<ResourceDTO>? ResourceList { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,6 +131,23 @@ namespace MagMan.Core.Services
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cliente selezionato (da browser data cache)
|
||||
/// </summary>
|
||||
public async Task<int> ClientIdGet()
|
||||
{
|
||||
var answ = await localStore.GetItemAsync<int>("ClientID");
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Imposta Cliente selezionato (browser data cache)
|
||||
/// </summary>
|
||||
public async Task ClientIdSet(int machSel)
|
||||
{
|
||||
await localStore.SetItemAsync("ClientID", machSel);
|
||||
}
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.4.0" />
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0" />
|
||||
<PackageReference Include="Blazored.SessionStorage" Version="2.4.0" />
|
||||
<PackageReference Include="MailKit" Version="4.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.25" />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MagMan.Data.Tenant.DbModels;
|
||||
using MagMan.Data.Tenant.Services;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using NLog;
|
||||
@@ -117,6 +118,43 @@ namespace MagMan.Data.Tenant.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary> Aggiunge/Modifica un item in magazzino </summary> <param
|
||||
/// name="connString">Stringa connessione (variabile x cliente)</param> <param
|
||||
/// name="rec2upd">Record da aggiornare</param> <param name="deltaQty">quantità da
|
||||
/// aggiornare (se <0 è consumo)</param> <returns></returns>
|
||||
public bool ItemModQty(string connString, RawItemModel rec2upd, int deltaQty)
|
||||
{
|
||||
bool done = false;
|
||||
using (MagManContext dbCtx = new MagManContext(connString))
|
||||
{
|
||||
try
|
||||
{
|
||||
/*
|
||||
* Verifica se esistesse: deve essere valido TUTTO
|
||||
* - stesso materiale
|
||||
* - stesse dimensioni
|
||||
* */
|
||||
var currData = dbCtx
|
||||
.DbSetItems
|
||||
.Where(x => (x.RawItemId == rec2upd.RawItemId) ||
|
||||
(x.MatId == rec2upd.MatId && (x.WMm == rec2upd.WMm && x.HMm == rec2upd.HMm && x.LMm == rec2upd.LMm)))
|
||||
.FirstOrDefault();
|
||||
if (currData != null)
|
||||
{
|
||||
currData.QtyAvail += deltaQty;
|
||||
dbCtx.Entry(currData).State = EntityState.Modified;
|
||||
}
|
||||
dbCtx.SaveChanges();
|
||||
done = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in ItemModQty{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiunge/Modifica un item in magazzino
|
||||
/// </summary>
|
||||
@@ -238,12 +276,11 @@ namespace MagMan.Data.Tenant.Controllers
|
||||
}
|
||||
return dbResult;
|
||||
} /// <summary>
|
||||
/// Elenco Materiali gestiti a magazzino
|
||||
/// </summary>
|
||||
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
|
||||
/// <param name="matID">Materiale richiesto, 0 = tutti</param>
|
||||
/// <param name="withChild">Se true allora include record child (Items)</param>
|
||||
/// <returns></returns>
|
||||
|
||||
/// Elenco Materiali gestiti a magazzino </summary> <param name="connString">Stringa
|
||||
/// connessione (variabile x cliente)</param> <param name="numKey">Materiale richiesto, 0
|
||||
/// = tutti</param> <param name="withChild">Se true allora include record child
|
||||
/// (Items)</param> <returns></returns>
|
||||
public List<MaterialModel> MaterialGetFilt(string connString, int matID, bool withChild)
|
||||
{
|
||||
List<MaterialModel> dbResult = new List<MaterialModel>();
|
||||
@@ -290,8 +327,8 @@ namespace MagMan.Data.Tenant.Controllers
|
||||
try
|
||||
{
|
||||
/*
|
||||
* Ricerca equal: corrisponde se
|
||||
* - MatID identico
|
||||
* Ricerca equal: corrisponde se
|
||||
* - MatId identico
|
||||
* - se Uguali + NonNulli [MatCode oppure MatDescript] + uguali [W/H/L]...
|
||||
*/
|
||||
var currData = dbCtx
|
||||
@@ -327,6 +364,165 @@ namespace MagMan.Data.Tenant.Controllers
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elimina record Project
|
||||
/// </summary>
|
||||
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
|
||||
/// <param name="rec2del">Item da eliminare</param>
|
||||
/// <returns></returns>
|
||||
public bool ProjectDelete(string connString, ProjModel rec2del)
|
||||
{
|
||||
bool done = false;
|
||||
using (MagManContext dbCtx = new MagManContext(connString))
|
||||
{
|
||||
try
|
||||
{
|
||||
var currData = dbCtx
|
||||
.DbSetProjects
|
||||
.Where(x => x.ProjDbId == rec2del.ProjDbId)
|
||||
.FirstOrDefault();
|
||||
if (currData != null)
|
||||
{
|
||||
dbCtx
|
||||
.DbSetProjects
|
||||
.Remove(currData);
|
||||
dbCtx.SaveChanges();
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in ProjectDelete{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Projects (all)
|
||||
/// </summary>
|
||||
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
|
||||
/// <returns></returns>
|
||||
public List<ProjModel> ProjectGetAll(string connString)
|
||||
{
|
||||
List<ProjModel> dbResult = new List<ProjModel>();
|
||||
using (MagManContext dbCtx = new MagManContext(connString))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetProjects
|
||||
.OrderBy(x => x.DtCreated)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Items gestiti a magazzino dato Materiale
|
||||
/// </summary>
|
||||
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
|
||||
/// <param name="numKey">ID del materiale x cui filtrare, 0 = tutti</param>
|
||||
/// <returns></returns>
|
||||
public List<ProjModel> ProjectGetByNumKey(string connString, int numKey)
|
||||
{
|
||||
List<ProjModel> dbResult = new List<ProjModel>();
|
||||
using (MagManContext dbCtx = new MagManContext(connString))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetProjects
|
||||
.Where(x => numKey == 0 || x.KeyNum == numKey)
|
||||
.OrderBy(x => x.DtCreated)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Items gestiti a magazzino dato Materiale
|
||||
/// </summary>
|
||||
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
|
||||
/// <param name="numKey">ID master key, 0 = tutti</param>
|
||||
/// <param name="numKey">periodo x filtraggio</param>
|
||||
/// <returns></returns>
|
||||
public List<ProjModel> ProjectGetFilt(string connString, int numKey, SelectData period)
|
||||
{
|
||||
List<ProjModel> dbResult = new List<ProjModel>();
|
||||
using (MagManContext dbCtx = new MagManContext(connString))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetProjects
|
||||
.Where(x => (numKey == 0 || x.KeyNum == numKey) &&
|
||||
((x.DtCreated >= period.DateStart && x.DtCreated <= period.DateEnd)
|
||||
|| (x.DtSchedule >= period.DateStart && x.DtSchedule <= period.DateEnd)
|
||||
|| (x.DtLastAction >= period.DateStart && x.DtLastAction <= period.DateEnd)
|
||||
))
|
||||
.OrderBy(x => x.DtCreated)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiunge/Modifica un record Project
|
||||
/// </summary>
|
||||
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
|
||||
/// <param name="rec2upd">Record da aggiungere/aggiornare</param>
|
||||
/// <returns></returns>
|
||||
public bool ProjectUpdate(string connString, ProjModel rec2upd)
|
||||
{
|
||||
bool done = false;
|
||||
using (MagManContext dbCtx = new MagManContext(connString))
|
||||
{
|
||||
try
|
||||
{
|
||||
/*
|
||||
* Ricerca:
|
||||
* - DbId corrisponde
|
||||
* - Key + Id remoti corrispondono
|
||||
* */
|
||||
var currData = dbCtx
|
||||
.DbSetProjects
|
||||
.Where(x => (x.ProjDbId == rec2upd.ProjDbId) ||
|
||||
(x.ProjExtDbId == rec2upd.ProjExtDbId && x.KeyNum == rec2upd.KeyNum) ||
|
||||
(x.ProjExtId == rec2upd.ProjExtId && x.KeyNum == rec2upd.KeyNum))
|
||||
.FirstOrDefault();
|
||||
if (currData != null)
|
||||
{
|
||||
currData.MachineID = rec2upd.MachineID;
|
||||
currData.KeyNum = rec2upd.KeyNum;
|
||||
currData.ProjExtDbId = rec2upd.ProjExtDbId;
|
||||
currData.ProjExtId = rec2upd.ProjExtId;
|
||||
currData.BTLFileName = rec2upd.BTLFileName;
|
||||
currData.PType = rec2upd.PType;
|
||||
currData.Machine = rec2upd.Machine;
|
||||
currData.ProjDescription = rec2upd.ProjDescription;
|
||||
currData.DtCreated = rec2upd.DtCreated;
|
||||
currData.DtLastAction = rec2upd.DtLastAction;
|
||||
currData.DtSchedule = rec2upd.DtSchedule;
|
||||
currData.DtStartProd = rec2upd.DtStartProd;
|
||||
currData.ListName = rec2upd.ListName;
|
||||
currData.ProcTimeEst = rec2upd.ProcTimeEst;
|
||||
currData.ProcTimeReal = rec2upd.ProcTimeReal;
|
||||
currData.IsActive = rec2upd.IsActive;
|
||||
currData.IsArchived = rec2upd.IsArchived;
|
||||
dbCtx.Entry(currData).State = EntityState.Modified;
|
||||
}
|
||||
else
|
||||
{
|
||||
dbCtx
|
||||
.DbSetProjects
|
||||
.Add(rec2upd);
|
||||
}
|
||||
dbCtx.SaveChanges();
|
||||
done = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in ItemUpdate{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
@@ -93,18 +93,21 @@ namespace MagMan.Data.Tenant.DbModels
|
||||
[NotMapped]
|
||||
public bool IsBeam
|
||||
{
|
||||
get => LMm == 0;
|
||||
get => (LMm == 0 && (HMm > 0 && WMm > 0));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifica che sia Wall, quando W/H == 0
|
||||
/// Verifica che sia Wall, quando W/L == 0
|
||||
/// </summary>
|
||||
[NotMapped]
|
||||
public bool IsWall
|
||||
{
|
||||
get => (HMm == 0 && WMm==0);
|
||||
get => (HMm > 0 && (LMm == 0 && WMm == 0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Navigazione ad oggetti child
|
||||
/// </summary>
|
||||
public virtual ICollection<RawItemModel>? RawItemList { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,7 @@ namespace MagMan.Data.Tenant.DbModels
|
||||
[Table("ProjList")]
|
||||
[Index(nameof(MachineID))]
|
||||
[Index(nameof(KeyNum))]
|
||||
[Index(nameof(DtCreated))]
|
||||
[Index(nameof(DtStartProd))]
|
||||
[Index(nameof(DtLastAction))]
|
||||
[Index(nameof(ProjId))]
|
||||
[Index(nameof(ProjExtDbId))]
|
||||
[Index(nameof(IsActive))]
|
||||
[Index(nameof(IsArchived))]
|
||||
public class ProjModel
|
||||
@@ -33,14 +30,28 @@ namespace MagMan.Data.Tenant.DbModels
|
||||
/// <summary>
|
||||
/// Chiave univoca su DB
|
||||
/// </summary>
|
||||
[Key, Column("ProjDbId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int ProjDbId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ID da modello ext
|
||||
/// Id macchina (MagMan)
|
||||
/// </summary>
|
||||
[Column("Id")]
|
||||
public int ProjId { get; set; }
|
||||
public int MachineID { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Key di riferimento per il progetto
|
||||
/// </summary>
|
||||
public int KeyNum { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// ID del DB EgtBW, univoco con KeyNum
|
||||
/// </summary>
|
||||
public int ProjExtDbId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// ID esterno (da EgtBW)
|
||||
/// </summary>
|
||||
public int ProjExtId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Nome file BTL originale
|
||||
@@ -52,16 +63,6 @@ namespace MagMan.Data.Tenant.DbModels
|
||||
/// </summary>
|
||||
public BWType PType { get; set; } = BWType.NULL;
|
||||
|
||||
/// <summary>
|
||||
/// Id macchina (diMagMan)
|
||||
/// </summary>
|
||||
public int MachineID { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Key di riferimento per il progetto
|
||||
/// </summary>
|
||||
public int KeyNum { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Macchina (Costruttore/Modello)
|
||||
/// </summary>
|
||||
|
||||
@@ -5,6 +5,7 @@ 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
|
||||
{
|
||||
@@ -17,9 +18,17 @@ namespace MagMan.Data.Tenant.DbModels
|
||||
[Table("RequestPlan")]
|
||||
public class RequestPlanModel
|
||||
{
|
||||
[Key, Column("RequestId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
/// <summary>
|
||||
/// Init classe
|
||||
/// </summary>
|
||||
public RequestPlanModel()
|
||||
{
|
||||
ResourcesList = new HashSet<ResourceModel>();
|
||||
}
|
||||
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int RequestId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Progetto di riferimento
|
||||
/// </summary>
|
||||
@@ -28,12 +37,21 @@ namespace MagMan.Data.Tenant.DbModels
|
||||
/// <summary>
|
||||
/// Data richiesta
|
||||
/// </summary>
|
||||
public DateTime DtRequest{ get; set; }
|
||||
|
||||
public DateTime DtRequest { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Record attivo (se false == NON è il piano scelto)
|
||||
/// Tipo richiesta
|
||||
/// </summary>
|
||||
public ProjResState ReqState { get; set; } = ProjResState.ND;
|
||||
|
||||
/// <summary>
|
||||
/// Record attivo (se false == NON è il piano scelto per i casi "previsionali" = ReqState >0 )
|
||||
/// </summary>
|
||||
public bool IsActive { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Navigazione ad oggetti child
|
||||
/// </summary>
|
||||
public virtual ICollection<ResourceModel>? ResourcesList { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
+14
-10
@@ -13,29 +13,33 @@ namespace MagMan.Data.Tenant.DbModels
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
/// <summary>
|
||||
/// Tabella esplosione richieste come items
|
||||
/// Tabella esplosione risorse (richiesta + items)
|
||||
/// </summary>
|
||||
[Table("RequestDetail")]
|
||||
public class RequestDetailModel
|
||||
[Table("ResourceList")]
|
||||
public class ResourceModel
|
||||
{
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int ResourceId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Riferimento Richiesta
|
||||
/// Riferimento richiesta parent
|
||||
/// </summary>
|
||||
public int RequestId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Riferimento Item specifico
|
||||
/// Riferimento RawItem specifico
|
||||
/// </summary>
|
||||
public int ItemID { get; set; } = 0;
|
||||
public int RawItemId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Quantità necessaria
|
||||
/// Qty, se > 0 rappresenta un IMPEGNO di qualsiasi tipo, se < 0 è un CONSUMO
|
||||
/// </summary>
|
||||
public int QtyReq { get; set; } = 0;
|
||||
public int Qty { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Stato richeista
|
||||
/// Navigation property to RequestPlan
|
||||
/// </summary>
|
||||
public RequestStatus ReqState { get; set; } = RequestStatus.None;
|
||||
[ForeignKey("RequestId")]
|
||||
public virtual RequestPlanModel RequestNav { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.4.0" />
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0" />
|
||||
<PackageReference Include="Blazored.SessionStorage" Version="2.4.0" />
|
||||
<PackageReference Include="MailKit" Version="4.2.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.25" />
|
||||
|
||||
@@ -43,8 +43,9 @@ namespace MagMan.Data.Tenant
|
||||
public virtual DbSet<MaterialModel> DbSetMaterials { get; set; } = null!;
|
||||
public virtual DbSet<RawItemModel> DbSetRawItem { get; set; } = null!;
|
||||
public virtual DbSet<AliasModel> DbSetAlias { get; set; } = null!;
|
||||
public virtual DbSet<ProjModel> DbSetProjects { get; set; } = null!;
|
||||
public virtual DbSet<RequestPlanModel> DbSetReqPlan { get; set; } = null!;
|
||||
public virtual DbSet<RequestDetailModel> DbSetReqDet{ get; set; } = null!;
|
||||
public virtual DbSet<ResourceModel> DbSetResources { get; set; } = null!;
|
||||
|
||||
|
||||
#if false
|
||||
@@ -90,9 +91,6 @@ namespace MagMan.Data.Tenant
|
||||
.HasComment("Valore di default/riferimento per la variabile");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<RequestDetailModel>()
|
||||
.HasKey(c => new { c.RequestId, c.ItemID });
|
||||
|
||||
modelBuilder.Entity<AliasModel>()
|
||||
.HasKey(c => new { c.Family, c.ValueOriginal});
|
||||
|
||||
|
||||
+119
-22
@@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
namespace MagMan.Data.Tenant.Migrations
|
||||
{
|
||||
[DbContext(typeof(MagManContext))]
|
||||
[Migration("20240118161646_InitDb")]
|
||||
[Migration("20240122174314_InitDb")]
|
||||
partial class InitDb
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@@ -97,6 +97,82 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
b.ToTable("MaterialsList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ProjModel", b =>
|
||||
{
|
||||
b.Property<int>("ProjDbId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("BTLFileName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<DateTime>("DtCreated")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime>("DtLastAction")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime>("DtSchedule")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime>("DtStartProd")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("IsArchived")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<int>("KeyNum")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ListName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Machine")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("MachineID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PType")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("ProcTimeEst")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<double>("ProcTimeReal")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<string>("ProjDescription")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("ProjExtDbId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ProjExtId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ProjDbId");
|
||||
|
||||
b.HasIndex("IsActive");
|
||||
|
||||
b.HasIndex("IsArchived");
|
||||
|
||||
b.HasIndex("KeyNum");
|
||||
|
||||
b.HasIndex("MachineID");
|
||||
|
||||
b.HasIndex("ProjExtDbId");
|
||||
|
||||
b.ToTable("ProjList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RawItemModel", b =>
|
||||
{
|
||||
b.Property<int>("RawItemId")
|
||||
@@ -139,31 +215,11 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
b.ToTable("RawItemList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RequestDetailModel", b =>
|
||||
{
|
||||
b.Property<int>("RequestId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ItemID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("QtyReq")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ReqState")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("RequestId", "ItemID");
|
||||
|
||||
b.ToTable("RequestDetail");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RequestPlanModel", b =>
|
||||
{
|
||||
b.Property<int>("RequestId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("RequestId");
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtRequest")
|
||||
.HasColumnType("datetime(6)");
|
||||
@@ -174,11 +230,36 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
b.Property<int>("ProjDbId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ReqState")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("RequestId");
|
||||
|
||||
b.ToTable("RequestPlan");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ResourceModel", b =>
|
||||
{
|
||||
b.Property<int>("ResourceId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Qty")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("RawItemId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("RequestId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ResourceId");
|
||||
|
||||
b.HasIndex("RequestId");
|
||||
|
||||
b.ToTable("ResourceList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RawItemModel", b =>
|
||||
{
|
||||
b.HasOne("MagMan.Data.Tenant.DbModels.MaterialModel", "MaterialNav")
|
||||
@@ -190,10 +271,26 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
b.Navigation("MaterialNav");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ResourceModel", b =>
|
||||
{
|
||||
b.HasOne("MagMan.Data.Tenant.DbModels.RequestPlanModel", "RequestNav")
|
||||
.WithMany("ResourcesList")
|
||||
.HasForeignKey("RequestId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("RequestNav");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MaterialModel", b =>
|
||||
{
|
||||
b.Navigation("RawItemList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RequestPlanModel", b =>
|
||||
{
|
||||
b.Navigation("ResourcesList");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
+85
-10
@@ -70,17 +70,36 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "RequestDetail",
|
||||
name: "ProjList",
|
||||
columns: table => new
|
||||
{
|
||||
RequestId = table.Column<int>(type: "int", nullable: false),
|
||||
ItemID = table.Column<int>(type: "int", nullable: false),
|
||||
QtyReq = table.Column<int>(type: "int", nullable: false),
|
||||
ReqState = table.Column<int>(type: "int", nullable: false)
|
||||
ProjDbId = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
MachineID = table.Column<int>(type: "int", nullable: false),
|
||||
KeyNum = table.Column<int>(type: "int", nullable: false),
|
||||
ProjExtDbId = table.Column<int>(type: "int", nullable: false),
|
||||
ProjExtId = table.Column<int>(type: "int", nullable: false),
|
||||
BTLFileName = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
PType = table.Column<int>(type: "int", nullable: false),
|
||||
Machine = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ProjDescription = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
DtCreated = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
DtSchedule = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
DtStartProd = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
DtLastAction = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
ListName = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ProcTimeEst = table.Column<double>(type: "double", nullable: false),
|
||||
ProcTimeReal = table.Column<double>(type: "double", nullable: false),
|
||||
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
IsArchived = table.Column<bool>(type: "tinyint(1)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_RequestDetail", x => new { x.RequestId, x.ItemID });
|
||||
table.PrimaryKey("PK_ProjList", x => x.ProjDbId);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
@@ -92,6 +111,7 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
ProjDbId = table.Column<int>(type: "int", nullable: false),
|
||||
DtRequest = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
ReqState = table.Column<int>(type: "int", nullable: false),
|
||||
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
@@ -130,10 +150,62 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ResourceList",
|
||||
columns: table => new
|
||||
{
|
||||
ResourceId = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
RequestId = table.Column<int>(type: "int", nullable: false),
|
||||
RawItemId = table.Column<int>(type: "int", nullable: false),
|
||||
Qty = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ResourceList", x => x.ResourceId);
|
||||
table.ForeignKey(
|
||||
name: "FK_ResourceList_RequestPlan_RequestId",
|
||||
column: x => x.RequestId,
|
||||
principalTable: "RequestPlan",
|
||||
principalColumn: "RequestId",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProjList_IsActive",
|
||||
table: "ProjList",
|
||||
column: "IsActive");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProjList_IsArchived",
|
||||
table: "ProjList",
|
||||
column: "IsArchived");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProjList_KeyNum",
|
||||
table: "ProjList",
|
||||
column: "KeyNum");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProjList_MachineID",
|
||||
table: "ProjList",
|
||||
column: "MachineID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProjList_ProjExtDbId",
|
||||
table: "ProjList",
|
||||
column: "ProjExtDbId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RawItemList_MatId",
|
||||
table: "RawItemList",
|
||||
column: "MatId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ResourceList_RequestId",
|
||||
table: "ResourceList",
|
||||
column: "RequestId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
@@ -144,17 +216,20 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
migrationBuilder.DropTable(
|
||||
name: "Config");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ProjList");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "RawItemList");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "RequestDetail");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "RequestPlan");
|
||||
name: "ResourceList");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "MaterialsList");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "RequestPlan");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -95,6 +95,82 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
b.ToTable("MaterialsList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ProjModel", b =>
|
||||
{
|
||||
b.Property<int>("ProjDbId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("BTLFileName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<DateTime>("DtCreated")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime>("DtLastAction")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime>("DtSchedule")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime>("DtStartProd")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("IsArchived")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<int>("KeyNum")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ListName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Machine")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("MachineID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PType")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("ProcTimeEst")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<double>("ProcTimeReal")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<string>("ProjDescription")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("ProjExtDbId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ProjExtId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ProjDbId");
|
||||
|
||||
b.HasIndex("IsActive");
|
||||
|
||||
b.HasIndex("IsArchived");
|
||||
|
||||
b.HasIndex("KeyNum");
|
||||
|
||||
b.HasIndex("MachineID");
|
||||
|
||||
b.HasIndex("ProjExtDbId");
|
||||
|
||||
b.ToTable("ProjList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RawItemModel", b =>
|
||||
{
|
||||
b.Property<int>("RawItemId")
|
||||
@@ -137,31 +213,11 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
b.ToTable("RawItemList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RequestDetailModel", b =>
|
||||
{
|
||||
b.Property<int>("RequestId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ItemID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("QtyReq")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ReqState")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("RequestId", "ItemID");
|
||||
|
||||
b.ToTable("RequestDetail");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RequestPlanModel", b =>
|
||||
{
|
||||
b.Property<int>("RequestId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("RequestId");
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DtRequest")
|
||||
.HasColumnType("datetime(6)");
|
||||
@@ -172,11 +228,36 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
b.Property<int>("ProjDbId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ReqState")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("RequestId");
|
||||
|
||||
b.ToTable("RequestPlan");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ResourceModel", b =>
|
||||
{
|
||||
b.Property<int>("ResourceId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Qty")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("RawItemId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("RequestId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ResourceId");
|
||||
|
||||
b.HasIndex("RequestId");
|
||||
|
||||
b.ToTable("ResourceList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RawItemModel", b =>
|
||||
{
|
||||
b.HasOne("MagMan.Data.Tenant.DbModels.MaterialModel", "MaterialNav")
|
||||
@@ -188,10 +269,26 @@ namespace MagMan.Data.Tenant.Migrations
|
||||
b.Navigation("MaterialNav");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ResourceModel", b =>
|
||||
{
|
||||
b.HasOne("MagMan.Data.Tenant.DbModels.RequestPlanModel", "RequestNav")
|
||||
.WithMany("ResourcesList")
|
||||
.HasForeignKey("RequestId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("RequestNav");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MaterialModel", b =>
|
||||
{
|
||||
b.Navigation("RawItemList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RequestPlanModel", b =>
|
||||
{
|
||||
b.Navigation("ResourcesList");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,481 +0,0 @@
|
||||
using Blazored.LocalStorage;
|
||||
using Blazored.SessionStorage;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using NLog;
|
||||
using NLog.Fluent;
|
||||
using StackExchange.Redis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection.Metadata;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.Tenant.Services
|
||||
{
|
||||
public class MessageService
|
||||
{
|
||||
#region Public Events
|
||||
|
||||
public event Action EA_FilterUpdated = null!;
|
||||
|
||||
public event Action EA_HideSearch = null!;
|
||||
|
||||
public event Action EA_PageUpdated = null!;
|
||||
|
||||
public event Action EA_SearchUpdated = null!;
|
||||
|
||||
public event Action EA_ShowSearch = null!;
|
||||
|
||||
#endregion Public Events
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public SelectData DetailFilter
|
||||
{
|
||||
get => _detailFilter;
|
||||
set
|
||||
{
|
||||
if (_detailFilter != value)
|
||||
{
|
||||
_detailFilter = value;
|
||||
|
||||
if (EA_FilterUpdated != null)
|
||||
{
|
||||
EA_FilterUpdated?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SelectOrderData Order_Filter { get; set; } = SelectOrderData.Init(5, 30);
|
||||
|
||||
public string PageIcon
|
||||
{
|
||||
get => _pageIcon;
|
||||
set
|
||||
{
|
||||
if (_pageIcon != value)
|
||||
{
|
||||
_pageIcon = value;
|
||||
ReportPageUpd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string PageName
|
||||
{
|
||||
get => _pageName;
|
||||
set
|
||||
{
|
||||
if (_pageName != value)
|
||||
{
|
||||
_pageName = value;
|
||||
ReportPageUpd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string SearchVal
|
||||
{
|
||||
get => _searchVal;
|
||||
set
|
||||
{
|
||||
if (_searchVal != value)
|
||||
{
|
||||
_searchVal = value;
|
||||
|
||||
if (EA_SearchUpdated != null)
|
||||
{
|
||||
EA_SearchUpdated?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string SelOrderCode { get; set; } = "";
|
||||
public string SelPlantId { get; set; } = "0";
|
||||
|
||||
public bool ShowSearch
|
||||
{
|
||||
get => _showSearch;
|
||||
set
|
||||
{
|
||||
if (_showSearch != value)
|
||||
{
|
||||
_showSearch = value;
|
||||
if (_showSearch)
|
||||
{
|
||||
if (EA_ShowSearch != null)
|
||||
{
|
||||
EA_ShowSearch?.Invoke();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (EA_HideSearch != null)
|
||||
{
|
||||
EA_HideSearch?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
public MessageService(IConfiguration configuration, ILocalStorageService genLocalStorage, ISessionStorageService sessStore)
|
||||
{
|
||||
_configuration = configuration;
|
||||
// gestione sessioni in browser
|
||||
localStore = genLocalStorage;
|
||||
sessionStore = sessStore;
|
||||
// setup compoenti REDIS
|
||||
redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis"));
|
||||
redisDb = redisConn.GetDatabase();
|
||||
}
|
||||
protected static IConfiguration _configuration = null!;
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Svuota localstorage (clear)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> StoreLocalClear()
|
||||
{
|
||||
bool answ = false;
|
||||
try
|
||||
{
|
||||
await localStore.ClearAsync();
|
||||
answ = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"Eccezione in StoreLocalClear{Environment.NewLine}{ex}");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce il valore richiesto da localstorage
|
||||
/// </summary>
|
||||
/// <param name="sKey">Chiave</param>
|
||||
/// <returns></returns>
|
||||
public async Task<string> StoreLocalGet(string sKey)
|
||||
{
|
||||
string answ = "";
|
||||
var result = await localStore.GetItemAsync<string>(sKey);
|
||||
if (result != null)
|
||||
{
|
||||
answ = result;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scrive il valore nel localstorage
|
||||
/// </summary>
|
||||
/// <param name="sKey">Chiave</param>
|
||||
/// <param name="sVal">Valore associato</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> StoreLocalSet(string sKey, string sVal)
|
||||
{
|
||||
bool answ = false;
|
||||
try
|
||||
{
|
||||
await localStore.SetItemAsStringAsync(sKey, sVal);
|
||||
answ = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"Eccezione in StoreLocalSet{Environment.NewLine}{ex}");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Svuota sessionstorage (clear)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> StoreSessClear()
|
||||
{
|
||||
bool answ = false;
|
||||
try
|
||||
{
|
||||
await sessionStore.ClearAsync();
|
||||
answ = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"Eccezione in StoreLocalClear{Environment.NewLine}{ex}");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce il valore richiesto da sessionstorage
|
||||
/// </summary>
|
||||
/// <param name="sKey">Chiave</param>
|
||||
/// <returns></returns>
|
||||
public async Task<string> StoreSessGet(string sKey)
|
||||
{
|
||||
string answ = "";
|
||||
var result = await sessionStore.GetItemAsync<string>(sKey);
|
||||
if (result != null)
|
||||
{
|
||||
answ = result;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scrive il valore nel sessionstorage (tab)
|
||||
/// </summary>
|
||||
/// <param name="sKey">Chiave</param>
|
||||
/// <param name="sVal">Valore associato</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> StoreSessSet(string sKey, string sVal)
|
||||
{
|
||||
bool answ = false;
|
||||
try
|
||||
{
|
||||
await sessionStore.SetItemAsStringAsync(sKey, sVal);
|
||||
answ = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"Eccezione in StoreSessSet{Environment.NewLine}{ex}");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected ILocalStorageService localStore { get; set; } = null!;
|
||||
protected ISessionStorageService sessionStore { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private SelectData _detailFilter = SelectData.Init(5, 15);
|
||||
private string _pageIcon = "";
|
||||
private string _pageName = "";
|
||||
private string _searchVal = "";
|
||||
private bool _showSearch = false;
|
||||
private Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void ReportPageUpd()
|
||||
{
|
||||
if (EA_PageUpdated != null)
|
||||
{
|
||||
EA_PageUpdated?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
private void ReportSearch()
|
||||
{
|
||||
if (EA_SearchUpdated != null)
|
||||
{
|
||||
EA_SearchUpdated?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Recupero HashSet redis come Dictionary
|
||||
/// </summary>
|
||||
/// <param name="currKey"></param>
|
||||
/// <param name="dict"></param>
|
||||
private Dictionary<string, string> RedisHashDictGet(RedisKey currKey)
|
||||
{
|
||||
Dictionary<string, string> answ = new Dictionary<string, string>();
|
||||
try
|
||||
{
|
||||
answ = redisDb
|
||||
.HashGetAll(currKey)
|
||||
.ToDictionary(x => $"{x.Name}", x => $"{x.Value}");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Info($"Errore RedisHashDictGet | currKey: {currKey}{Environment.NewLine}{exc}");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Oggetto per connessione a REDIS
|
||||
/// </summary>
|
||||
protected ConnectionMultiplexer redisConn = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto DB redis da impiegare x chiamate R/W
|
||||
/// </summary>
|
||||
protected IDatabase redisDb = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Salvataggio Dictionary come HashSet Redis
|
||||
/// </summary>
|
||||
/// <param name="currKey"></param>
|
||||
/// <param name="dict"></param>
|
||||
private bool RedisHashDictSet(RedisKey currKey, Dictionary<string, string> dict)
|
||||
{
|
||||
bool fatto = false;
|
||||
try
|
||||
{
|
||||
HashEntry[] data2ins = new HashEntry[dict.Count];
|
||||
int i = 0;
|
||||
foreach (KeyValuePair<string, string> kvp in dict)
|
||||
{
|
||||
data2ins[i] = new HashEntry(kvp.Key, kvp.Value);
|
||||
i++;
|
||||
}
|
||||
// salvo!
|
||||
redisDb.HashSet(currKey, data2ins);
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in RedisHashDictSet | currKey: {currKey}{Environment.NewLine}{exc}");
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
/// <summary>
|
||||
/// Salvataggio Dictionary come HashSet Redis
|
||||
/// </summary>
|
||||
/// <param name="currKey"></param>
|
||||
/// <param name="dict"></param>
|
||||
/// <param name="ttl"></param>
|
||||
private bool RedisHashDictSet(RedisKey currKey, Dictionary<string, string> dict, TimeSpan ttl)
|
||||
{
|
||||
bool fatto = false;
|
||||
try
|
||||
{
|
||||
HashEntry[] data2ins = new HashEntry[dict.Count];
|
||||
int i = 0;
|
||||
foreach (KeyValuePair<string, string> kvp in dict)
|
||||
{
|
||||
data2ins[i] = new HashEntry(kvp.Key, kvp.Value);
|
||||
i++;
|
||||
}
|
||||
// salvo!
|
||||
redisDb.HashSet(currKey, data2ins);
|
||||
redisDb.KeyExpire(currKey, ttl);
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in RedisHashDictSet(+TTL) | currKey: {currKey} | ttl: {ttl}{Environment.NewLine}{exc}");
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
/// <summary>
|
||||
/// Effettua upsert in HasList redis
|
||||
/// </summary>
|
||||
/// <param name="currKey">Chiave redis della Hashlist</param>
|
||||
/// <param name="chiave">Chiave nella HashList</param>
|
||||
/// <param name="valore">Valore da salvare</param>
|
||||
/// <returns>Num record nella HashList</returns>
|
||||
protected async Task<long> RedisHashUpsert(RedisKey currKey, string chiave, string valore)
|
||||
{
|
||||
long numReq = 0;
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
await redisDb.HashSetAsync(currKey, chiave, valore);
|
||||
numReq = await redisDb.HashLengthAsync(currKey);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"RedisHashUpsert | {currKey} | in: {ts.TotalMilliseconds} ms");
|
||||
return numReq;
|
||||
}
|
||||
/// <summary>
|
||||
/// Get single hash record
|
||||
/// </summary>
|
||||
/// <param name="currKey">Redis Key for Hashlist</param>
|
||||
/// <param name="chiave">Requested key on list</param>
|
||||
/// <returns>Value as Int</returns>
|
||||
public async Task<int> RedisHashGetInt(RedisKey currKey, string chiave)
|
||||
{
|
||||
int result = 0;
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
var hasVal = await redisDb.HashExistsAsync(currKey, chiave);
|
||||
if (hasVal)
|
||||
{
|
||||
var rawRes = await redisDb.HashGetAsync(currKey, chiave);
|
||||
if (rawRes.HasValue)
|
||||
{
|
||||
int.TryParse($"{rawRes}", out result);
|
||||
}
|
||||
}
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"RedisHashGetInt | {currKey} | in: {ts.TotalMilliseconds} ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get single hash record
|
||||
/// </summary>
|
||||
/// <param name="currKey">Redis Key for Hashlist</param>
|
||||
/// <param name="chiave">Requested key on list</param>
|
||||
/// <returns>Value as string</returns>
|
||||
public async Task<string> RedisHashGetString(RedisKey currKey, string chiave)
|
||||
{
|
||||
string result = "";
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
var hasVal = await redisDb.HashExistsAsync(currKey, chiave);
|
||||
if (hasVal)
|
||||
{
|
||||
var rawRes = await redisDb.HashGetAsync(currKey, chiave);
|
||||
if (rawRes.HasValue)
|
||||
{
|
||||
result = $"{rawRes}";
|
||||
}
|
||||
}
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"RedisHashGetString | {currKey} | in: {ts.TotalMilliseconds} ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove for single hash record
|
||||
/// </summary>
|
||||
/// <param name="currKey">Chiave redis della Hashlist</param>
|
||||
/// <param name="chiave">Chiave nella HashList</param>
|
||||
/// <returns>Esito rimozione</returns>
|
||||
public async Task<bool> RedisHashRemove(RedisKey currKey, string chiave)
|
||||
{
|
||||
bool fatto = false;
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
fatto = await redisDb.HashDeleteAsync(currKey, chiave);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"RedisHashRemove | {currKey} | in: {ts.TotalMilliseconds} ms");
|
||||
return fatto;
|
||||
}
|
||||
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Dizionario totale preferenze utente
|
||||
/// </summary>
|
||||
public Dictionary<string, string> UsersPrefDict
|
||||
{
|
||||
get => RedisHashDictGet((RedisKey)$"{redisBaseKey}:{MatrOpr}");
|
||||
set => RedisHashDictSet((RedisKey)$"{redisBaseKey}:{MatrOpr}", value);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -82,20 +82,22 @@ namespace MagMan.Data.Tenant.Services
|
||||
/// <summary>
|
||||
/// Converte il DTO in ItemModel
|
||||
/// </summary>
|
||||
/// <param name="origItem"></param>
|
||||
/// <param name="origItem">DTO di partenza</param>
|
||||
/// <param name="isActive">Parametro active da impostare</param>
|
||||
/// <returns></returns>
|
||||
public RawItemModel ItemFromDto(ItemDTO origItem)
|
||||
public RawItemModel ItemFromDto(ItemDTO origItem, bool isActive)
|
||||
{
|
||||
RawItemModel answ = new RawItemModel()
|
||||
{
|
||||
MatId = origItem.MatID,
|
||||
MatId = origItem.MatId,
|
||||
Note = origItem.Note,
|
||||
LMm = origItem.LMm,
|
||||
WMm = origItem.WMm,
|
||||
HMm = origItem.HMm,
|
||||
IsRemn = origItem.IsRemn,
|
||||
Location = origItem.Location,
|
||||
QtyAvail = origItem.QtyAvail
|
||||
QtyAvail = origItem.QtyAvail,
|
||||
IsActive = isActive
|
||||
};
|
||||
|
||||
return answ;
|
||||
@@ -164,7 +166,7 @@ namespace MagMan.Data.Tenant.Services
|
||||
List<RawItemModel>? dbResult = new List<RawItemModel>();
|
||||
try
|
||||
{
|
||||
string currKey = $"{Const.rKeyConfig}:{nKey}:{matID}:ItemList";
|
||||
string currKey = $"{Const.rKeyConfig}:{nKey}:ItemList:{matID}";
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
string? rawData = await redisDb.StringGetAsync(currKey);
|
||||
@@ -202,11 +204,33 @@ namespace MagMan.Data.Tenant.Services
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary> Update record Item + refresh cache </summary> <param name="nKey">Key di
|
||||
/// riferimento</param> <param name="currItem">Item interesato</param> <param
|
||||
/// name="deltaQty">quantità da aggiornare (se <0 è consumo)</param> <returns></returns>
|
||||
public async Task<bool> ItemModQty(int nKey, RawItemModel currItem, int deltaQty)
|
||||
{
|
||||
bool fatto = false;
|
||||
string cString = ConnString(nKey);
|
||||
try
|
||||
{
|
||||
fatto = dbController.ItemModQty(cString, currItem, deltaQty);
|
||||
if (fatto)
|
||||
{
|
||||
await FlushRedisCache();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error during ItemModQty:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update record Item + refresh cache
|
||||
/// </summary>
|
||||
/// <param name="nKey">Key di riferimento</param>
|
||||
/// <param name="currItem"></param>
|
||||
/// <param name="currItem">Item interesato</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ItemUpdate(int nKey, RawItemModel currItem)
|
||||
{
|
||||
@@ -329,6 +353,7 @@ namespace MagMan.Data.Tenant.Services
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lista Materiali gestiti a magazzino
|
||||
/// </summary>
|
||||
@@ -413,6 +438,188 @@ namespace MagMan.Data.Tenant.Services
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elimina record Project + refresh cache
|
||||
/// </summary>
|
||||
/// <param name="nKey">Key di riferimento</param>
|
||||
/// <param name="rec2del">Item da eliminare</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ProjectDelete(int nKey, ProjModel rec2del)
|
||||
{
|
||||
bool fatto = false;
|
||||
string cString = ConnString(nKey);
|
||||
try
|
||||
{
|
||||
fatto = dbController.ProjectDelete(cString, rec2del);
|
||||
if (fatto)
|
||||
{
|
||||
await FlushRedisCache();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error during ProjectDelete:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converte il DTO in ItemModel
|
||||
/// </summary>
|
||||
/// <param name="origItem">DTO di partenza</param>
|
||||
/// <returns></returns>
|
||||
public ProjModel ProjectFromDto(ProjectDTO origItem)
|
||||
{
|
||||
ProjModel answ = new ProjModel()
|
||||
{
|
||||
MachineID = origItem.MachineID,
|
||||
KeyNum = origItem.KeyNum,
|
||||
ProjExtDbId = origItem.ProjExtDbId,
|
||||
ProjExtId = origItem.ProjExtId,
|
||||
BTLFileName = origItem.BTLFileName,
|
||||
PType = origItem.PType,
|
||||
Machine = origItem.Machine,
|
||||
ProjDescription = origItem.ProjDescription,
|
||||
DtCreated = origItem.DtCreated,
|
||||
DtLastAction = origItem.DtLastAction,
|
||||
DtSchedule = origItem.DtSchedule,
|
||||
DtStartProd = origItem.DtStartProd,
|
||||
ListName = origItem.ListName,
|
||||
ProcTimeEst = origItem.ProcTimeEst,
|
||||
ProcTimeReal = origItem.ProcTimeReal,
|
||||
IsActive = origItem.IsActive,
|
||||
IsArchived = origItem.IsArchived
|
||||
};
|
||||
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lista Projects gestiti a magazzino
|
||||
/// </summary>
|
||||
/// <param name="nKey">Key di riferimento</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ProjModel>> ProjectGetAll(int nKey)
|
||||
{
|
||||
string source = "DB";
|
||||
string cString = ConnString(nKey);
|
||||
List<ProjModel>? dbResult = new List<ProjModel>();
|
||||
try
|
||||
{
|
||||
string currKey = $"{Const.rKeyConfig}:ProjList:{nKey}";
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
string? rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
source = "REDIS";
|
||||
var tempResult = JsonConvert.DeserializeObject<List<ProjModel>>(rawData);
|
||||
if (tempResult == null)
|
||||
{
|
||||
dbResult = new List<ProjModel>();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = tempResult;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbController.ProjectGetAll(cString);
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
}
|
||||
if (dbResult == null)
|
||||
{
|
||||
dbResult = new List<ProjModel>();
|
||||
}
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Debug($"ProjectGetAll | {source} in: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error during ProjectGetAll:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lista Items gestiti a magazzino x materiale
|
||||
/// </summary>
|
||||
/// <param name="nKey">Key di riferimento</param>
|
||||
/// <param name="numKey">ID del materiale x cui filtrare, 0 = tutti</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ProjModel>> ProjectGetByNumKey(int nKey, int numKey)
|
||||
{
|
||||
string source = "DB";
|
||||
string cString = ConnString(nKey);
|
||||
List<ProjModel>? dbResult = new List<ProjModel>();
|
||||
try
|
||||
{
|
||||
string currKey = $"{Const.rKeyConfig}:{nKey}:ProjList:{numKey}";
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
string? rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
source = "REDIS";
|
||||
var tempResult = JsonConvert.DeserializeObject<List<ProjModel>>(rawData);
|
||||
if (tempResult == null)
|
||||
{
|
||||
dbResult = new List<ProjModel>();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = tempResult;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbController.ProjectGetByNumKey(cString, numKey);
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
}
|
||||
if (dbResult == null)
|
||||
{
|
||||
dbResult = new List<ProjModel>();
|
||||
}
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Debug($"ProjectGetByNumKey | {source} in: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error during ProjectGetByNumKey:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update record Item + refresh cache
|
||||
/// </summary>
|
||||
/// <param name="nKey">Key di riferimento</param>
|
||||
/// <param name="currItem">Item interesato</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ProjectUpdate(int nKey, ProjModel currItem)
|
||||
{
|
||||
bool fatto = false;
|
||||
string cString = ConnString(nKey);
|
||||
try
|
||||
{
|
||||
fatto = dbController.ProjectUpdate(cString, currItem);
|
||||
if (fatto)
|
||||
{
|
||||
await FlushRedisCache();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Error during ProjectUpdate:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
@@ -459,40 +666,5 @@ namespace MagMan.Data.Tenant.Services
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Dizionario dei token 2 connectionStrings
|
||||
/// </summary>
|
||||
private Dictionary<string, string> TokenList { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// Recupera ConnectionString dal dizionario dei token noti o cercando sul DB
|
||||
/// </summary>
|
||||
/// <param name="RestToken"></param>
|
||||
/// <returns></returns>
|
||||
public string ConnStringByToken(string RestToken)
|
||||
{
|
||||
string answ = "";
|
||||
if (TokenList.ContainsKey(RestToken))
|
||||
{
|
||||
answ = TokenList[RestToken];
|
||||
}
|
||||
else
|
||||
{
|
||||
// cerco nel DB
|
||||
var custList = dbController.CustomerGetAll();
|
||||
var custRow = custList.FirstOrDefault(x => x.RestToken == RestToken);
|
||||
// se trovato salvo
|
||||
if (custRow != null)
|
||||
{
|
||||
answ = DbConfig.CustomerConnString(DbServerAddr, nKey);
|
||||
TokenList.Add(RestToken, answ);
|
||||
Log.Info($"TokenList: added {RestToken} --> {answ}");
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<div class="input-group">
|
||||
<label class="input-group-text">Cliente</label>
|
||||
<select class="form-select" @bind="@CustomerID">
|
||||
<option value="0">--- Selezionare Cliente ---</option>
|
||||
@if (CustomersList != null)
|
||||
{
|
||||
@foreach (var item in CustomersList)
|
||||
{
|
||||
<option value="@item.CustomerID">@item.Name [@item.CustomerID]</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
using MagMan.Core.Services;
|
||||
using MagMan.Data.Admin.DbModels;
|
||||
using MagMan.Data.Admin.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace MagMan.UI.Components
|
||||
{
|
||||
public partial class CmpSelCliente
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<int> E_CustSelected { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected MessageService AppMService { get; set; } = null!;
|
||||
|
||||
protected int CustomerID
|
||||
{
|
||||
get => customerID;
|
||||
set
|
||||
{
|
||||
if (customerID != value)
|
||||
{
|
||||
customerID = value;
|
||||
E_CustSelected.InvokeAsync(value);
|
||||
InvokeAsync(() => AppMService.ClientIdSet(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Inject]
|
||||
protected MTAdminService MTService { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
CustomerID = await AppMService.ClientIdGet();
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected async Task ReloadData()
|
||||
{
|
||||
CustomersList = await MTService.CustomerGetAll();
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private int customerID = 0;
|
||||
|
||||
private List<CustomerModel>? CustomersList = null;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
@if (CurrRecord != null)
|
||||
{
|
||||
<div class="row g-1">
|
||||
<div class="col-md-8">
|
||||
<div class="input-group">
|
||||
<div class="form-floating">
|
||||
<input type="text" class="form-control" @bind="@CurrRecord.QtyAvail">
|
||||
<label class="small">Giacenza</label>
|
||||
</div>
|
||||
<div class="form-floating">
|
||||
<input type="text" class="form-control" @bind="@CurrRecord.Note">
|
||||
<label class="small">Note</label>
|
||||
</div>
|
||||
<div class="form-floating">
|
||||
<input type="text" class="form-control" @bind="@CurrRecord.Location">
|
||||
<label class="small">Posizone</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="d-flex">
|
||||
<div class="input-group">
|
||||
@if (CurrRecord.MaterialNav.IsWall)
|
||||
{
|
||||
<div class="form-floating">
|
||||
<NumInput CssClass="form-control" DisplFormat="0.00" @bind-Value="@CurrRecord.WMm"></NumInput>
|
||||
<label class="small">W (mm)</label>
|
||||
</div>
|
||||
}
|
||||
@* <div class="form-floating">
|
||||
<NumInput CssClass="form-control" DisplFormat="0.00" Value="@CurrRecord.HMm"></NumInput>
|
||||
<label class="small">H (mm)</label>
|
||||
</div> *@
|
||||
<div class="form-floating">
|
||||
<NumInput CssClass="form-control" DisplFormat="0.00" @bind-Value="@CurrRecord.LMm"></NumInput>
|
||||
<label class="small">L (mm)</label>
|
||||
</div>
|
||||
<button class="btn btn-success w-10" @onclick="() => DoSave()"><i class="fa-solid fa-floppy-disk"></i> Save</button>
|
||||
@* <button class="btn btn-warning w-10" @onclick="() => DoCancel()"><i class="fa-solid fa-ban"></i> Cancel</button> *@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using MagMan.Data.Tenant.DbModels;
|
||||
using MagMan.Data.Tenant.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace MagMan.UI.Components
|
||||
{
|
||||
public partial class ItemEdit
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
[Parameter]
|
||||
public RawItemModel? CurrRecord { get; set; } = null;
|
||||
|
||||
[Parameter]
|
||||
public int KeyNum { get; set; } = 0;
|
||||
[Parameter]
|
||||
public EventCallback<bool> EC_update { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected TenantService TService { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected async Task DoSave()
|
||||
{
|
||||
bool fatto = false;
|
||||
await Task.Delay(1);
|
||||
if (CurrRecord != null)
|
||||
{
|
||||
fatto = await TService.ItemUpdate(KeyNum, CurrRecord);
|
||||
}
|
||||
if (fatto)
|
||||
{
|
||||
await EC_update.InvokeAsync(true);
|
||||
}
|
||||
}
|
||||
protected async Task DoCancel()
|
||||
{
|
||||
await EC_update.InvokeAsync(true);
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,117 @@
|
||||
<h3>ItemMan</h3>
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="d-flex justify-content-between">
|
||||
<div class="px-2">
|
||||
<h3>Articoli</h3>
|
||||
</div>
|
||||
<div class="px-2">
|
||||
<div class="d-flex">
|
||||
<div class="px-2">
|
||||
@if (CurrItem == null)
|
||||
{
|
||||
<button class="btn btn-success" @onclick="()=>CreateNew()"><i class="fa-solid fa-square-plus"></i> Add New</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button class="btn btn-warning" @onclick="()=> DoEdit(null)"><i class="fa-solid fa-ban"></i> Cancel</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@if (CurrItem != null)
|
||||
{
|
||||
<hr />
|
||||
<ItemEdit CurrRecord="CurrItem" EC_update="ForceReload"></ItemEdit>
|
||||
}
|
||||
</div>
|
||||
<div class="card-body p-1">
|
||||
@if (ListRecords == null || isLoading)
|
||||
{
|
||||
<EgwCoreLib.Razor.LoadingData></EgwCoreLib.Razor.LoadingData>
|
||||
}
|
||||
else if (totalCount == 0)
|
||||
{
|
||||
<div class="alert alert-info">Nessun record trovato</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table table-striped table-sm text-start">
|
||||
<thead>
|
||||
<tr class="">
|
||||
<th>
|
||||
<button class="btn btn-primary btn-sm" @onclick="() => DoEdit(null)"><i class="fa-solid fa-rotate"></i></button>
|
||||
</th>
|
||||
<th class="text-end">Qty <Sorter ParamName="Qty" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
|
||||
<th>ID <Sorter ParamName="RawItemId" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
|
||||
<th>Note <Sorter ParamName="Note" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
|
||||
<th>Posizione <Sorter ParamName="Location" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
|
||||
@if (MaterialSel.IsWall)
|
||||
{
|
||||
<th class="text-end">W (mm) <Sorter ParamName="W" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
|
||||
}
|
||||
@* <th class="text-end">H (mm) <Sorter ParamName="H" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th> *@
|
||||
<th class="text-end">L (mm) <Sorter ParamName="L" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
|
||||
@* <th class="text-end"></th> *@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in ListRecords)
|
||||
{
|
||||
<tr class="align-middle @CheckSel(item)">
|
||||
<td>
|
||||
@* <button class="btn btn-info btn-sm" @onclick="() => DoSelect(item)"><i class="fa-solid fa-search"></i></button> *@
|
||||
<button class="btn btn-primary btn-sm" @onclick="() => DoEdit(item)"><i class="fa-solid fa-edit"></i></button>
|
||||
</td>
|
||||
<td class="text-end fs-5">
|
||||
<b>@item.QtyAvail</b>
|
||||
</td>
|
||||
<td>
|
||||
@if (item.IsActive)
|
||||
{
|
||||
<span class="border border-primary rounded px-1">
|
||||
<i class="fa-regular fa-thumbs-up"></i>
|
||||
</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="border border-info rounded px-1">
|
||||
<i class="fa-regular fa-thumbs-down"></i>
|
||||
</span>
|
||||
}
|
||||
@item.RawItemId
|
||||
</td>
|
||||
<td>
|
||||
@item.Note
|
||||
</td>
|
||||
<td>
|
||||
@item.Location
|
||||
</td>
|
||||
@if (MaterialSel.IsWall)
|
||||
{
|
||||
<td class="text-end">
|
||||
@($"{item.WMm:N2}")
|
||||
</td>
|
||||
}
|
||||
@* <td class="text-end">
|
||||
@($"{item.HMm:N2}")
|
||||
</td> *@
|
||||
<td class="text-end">
|
||||
@($"{item.LMm:N2}")
|
||||
</td>
|
||||
@* <td class="text-end">
|
||||
<button class="btn btn-sm btn-danger" @onclick="() => DeleteRecord(item)"><i class="fa-solid fa-trash-can"></i></button>
|
||||
</td> *@
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<EgwCoreLib.Razor.DataPager PageSize="@numRecord" currPage="@currPage" numRecordChanged="SetNumRec" numPageChanged="SetPage" totalCount="@totalCount" showLoading="@isLoading"></EgwCoreLib.Razor.DataPager>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,346 @@
|
||||
using EgwCoreLib.Razor;
|
||||
using MagMan.Core.Services;
|
||||
using MagMan.Data.Tenant.DbModels;
|
||||
using MagMan.Data.Tenant.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
|
||||
namespace MagMan.UI.Components
|
||||
{
|
||||
public partial class ItemMan
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
[Parameter]
|
||||
public int CustomerId { get; set; } = 0;
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<int> E_RawItemSel { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public int KeyNum { get; set; } = 0;
|
||||
|
||||
[Parameter]
|
||||
public MaterialModel MaterialSel { get; set; } = null!;
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected MessageService AppMService { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected IConfiguration Configuration { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected IJSRuntime JSRuntime { get; set; } = null!;
|
||||
|
||||
protected int totalCount { get; set; } = 0;
|
||||
|
||||
[Inject]
|
||||
protected TenantService TService { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected string CheckSel(RawItemModel curItem)
|
||||
{
|
||||
string answ = "";
|
||||
if (CurrItem != null)
|
||||
{
|
||||
answ = curItem.RawItemId == CurrItem.RawItemId ? "table-info" : "";
|
||||
}
|
||||
else
|
||||
{
|
||||
answ = curItem.RawItemId == RawItemId ? "table-info" : "";
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
|
||||
protected async Task CreateNew()
|
||||
{
|
||||
CurrItem = new RawItemModel()
|
||||
{
|
||||
MatId = MaterialSel.MatId,
|
||||
Location = "nd",
|
||||
Note = "...",
|
||||
QtyAvail = 0,
|
||||
IsActive = true,
|
||||
IsRemn = false,
|
||||
HMm = MaterialSel.HMm,
|
||||
LMm = MaterialSel.LMm,
|
||||
WMm = MaterialSel.WMm
|
||||
};
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
protected async Task DeleteRecord(RawItemModel selItem)
|
||||
{
|
||||
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler eliminare il record?"))
|
||||
return;
|
||||
await TService.ItemDelete(KeyNum, selItem);
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected void DoEdit(RawItemModel? selItem)
|
||||
{
|
||||
CurrItem = selItem;
|
||||
if (selItem == null)
|
||||
{
|
||||
DoSelect(null);
|
||||
}
|
||||
}
|
||||
|
||||
protected void DoSelect(RawItemModel? selItem)
|
||||
{
|
||||
if (selItem != null)
|
||||
{
|
||||
RawItemId = selItem.MatId;
|
||||
}
|
||||
else
|
||||
{
|
||||
RawItemId = 0;
|
||||
}
|
||||
E_RawItemSel.InvokeAsync(RawItemId);
|
||||
}
|
||||
|
||||
protected async Task ForceReload(bool force)
|
||||
{
|
||||
CurrItem = null;
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
currSearch = "";
|
||||
AppMService.EA_SearchUpdated += AppMService_EA_SearchUpdated;
|
||||
}
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
CurrItem = null;
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected void SetNumRec(int newNum)
|
||||
{
|
||||
numRecord = newNum;
|
||||
currPage = 1;
|
||||
InvokeAsync(ReloadData);
|
||||
}
|
||||
|
||||
protected void SetPage(int newNum)
|
||||
{
|
||||
currPage = newNum;
|
||||
InvokeAsync(ReloadData);
|
||||
}
|
||||
|
||||
protected async Task SortRequested(Sorter.SortCallBack e)
|
||||
{
|
||||
sortField = e.ParamName;
|
||||
sortAsc = e.IsAscending;
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private RawItemModel? CurrItem = null;
|
||||
private string currSearch = "";
|
||||
private int filtType = 0;
|
||||
private List<RawItemModel>? ListRecords = null;
|
||||
private int RawItemId = 0;
|
||||
private List<RawItemModel>? SearchRecords = null;
|
||||
|
||||
private bool sortAsc = true;
|
||||
|
||||
private string sortField = "";
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private int currPage { get; set; } = 1;
|
||||
|
||||
private int FiltType
|
||||
{
|
||||
get => filtType;
|
||||
set
|
||||
{
|
||||
if (filtType != value)
|
||||
{
|
||||
filtType = value;
|
||||
InvokeAsync(ReloadData);
|
||||
InvokeAsync(StateHasChanged);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool isLoading { get; set; } = false;
|
||||
|
||||
private int numRecord { get; set; } = 10;
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private async void AppMService_EA_SearchUpdated()
|
||||
{
|
||||
currSearch = AppMService.SearchVal;
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
private async Task ReloadData()
|
||||
{
|
||||
isLoading = true;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
ListRecords = null;
|
||||
SearchRecords = await TService.ItemGetByMat(KeyNum, MaterialSel.MatId);
|
||||
// verifico filtro per ricerca
|
||||
if (!string.IsNullOrEmpty(currSearch))
|
||||
{
|
||||
SearchRecords = SearchRecords.Where(x => x.Note.Contains(currSearch, StringComparison.InvariantCultureIgnoreCase)).ToList();
|
||||
}
|
||||
totalCount = SearchRecords.Count;
|
||||
SortTable();
|
||||
isLoading = false;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private void SortTable()
|
||||
{
|
||||
if (SearchRecords != null)
|
||||
{
|
||||
// se ho ordinamento riordino...
|
||||
if (!string.IsNullOrEmpty(sortField))
|
||||
{
|
||||
switch (sortField)
|
||||
{
|
||||
case "RawItemId":
|
||||
if (sortAsc)
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderBy(x => x.RawItemId).ThenBy(x => x.Note).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderByDescending(x => x.RawItemId).ThenByDescending(x => x.Note).ToList();
|
||||
}
|
||||
break;
|
||||
|
||||
case "Location":
|
||||
if (sortAsc)
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderBy(x => x.Location).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderByDescending(x => x.Location).ToList();
|
||||
}
|
||||
break;
|
||||
|
||||
case "QtyAvail":
|
||||
if (sortAsc)
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderBy(x => x.QtyAvail).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderByDescending(x => x.QtyAvail).ToList();
|
||||
}
|
||||
break;
|
||||
|
||||
case "Note":
|
||||
if (sortAsc)
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderBy(x => x.Note).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderByDescending(x => x.Note).ToList();
|
||||
}
|
||||
break;
|
||||
|
||||
case "IsActive":
|
||||
if (sortAsc)
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderBy(x => x.IsActive).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderByDescending(x => x.IsActive).ToList();
|
||||
}
|
||||
break;
|
||||
|
||||
case "IsRemn":
|
||||
if (sortAsc)
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderBy(x => x.IsRemn).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderByDescending(x => x.IsRemn).ToList();
|
||||
}
|
||||
break;
|
||||
|
||||
case "W":
|
||||
if (sortAsc)
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderBy(x => x.WMm).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderByDescending(x => x.WMm).ToList();
|
||||
}
|
||||
break;
|
||||
|
||||
case "H":
|
||||
if (sortAsc)
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderBy(x => x.HMm).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderByDescending(x => x.HMm).ToList();
|
||||
}
|
||||
break;
|
||||
|
||||
case "L":
|
||||
if (sortAsc)
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderBy(x => x.LMm).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderByDescending(x => x.LMm).ToList();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// filtro x display
|
||||
ListRecords = SearchRecords
|
||||
.Skip(numRecord * (currPage - 1))
|
||||
.Take(numRecord)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
ListRecords = new List<RawItemModel>();
|
||||
}
|
||||
}
|
||||
|
||||
private string textCss(bool isActive)
|
||||
{
|
||||
return isActive ? "text-dark" : "text-secondary text-decoration-line-through";
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
<div class="input-group">
|
||||
<div class="form-floating w-25">
|
||||
<input type="text" class="form-control" @bind="@CurrRecord.MatCode">
|
||||
<label class="small">Codicee</label>
|
||||
<label class="small">Codice</label>
|
||||
</div>
|
||||
<div class="form-floating w-75">
|
||||
<input type="text" class="form-control" @bind="@CurrRecord.MatDesc">
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
}
|
||||
</div>
|
||||
<div class="card-body p-1">
|
||||
@if (ListRecords == null)
|
||||
@if (ListRecords == null || isLoading)
|
||||
{
|
||||
<EgwCoreLib.Razor.LoadingData></EgwCoreLib.Razor.LoadingData>
|
||||
}
|
||||
@@ -55,9 +55,9 @@
|
||||
<th>ID <Sorter ParamName="MatId" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
|
||||
<th>Mat.Code <Sorter ParamName="MatCode" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
|
||||
<th>Descr. <Sorter ParamName="MatDesc" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
|
||||
<th>W (mm) <Sorter ParamName="W" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
|
||||
<th>H (mm) <Sorter ParamName="H" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
|
||||
<th>L (mm) <Sorter ParamName="L" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
|
||||
<th class="text-end">W (mm) <Sorter ParamName="W" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
|
||||
<th class="text-end">H (mm) <Sorter ParamName="H" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
|
||||
@* <th class="text-end">L (mm) <Sorter ParamName="L" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th> *@
|
||||
@* <th class="text-end"></th> *@
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -66,10 +66,23 @@
|
||||
{
|
||||
<tr class="align-middle @CheckSel(item)">
|
||||
<td>
|
||||
<button class="btn btn-info btn-sm" @onclick="() => DoSelect(item)"><i class="fa-solid fa-search"></i></button>
|
||||
<button class="btn btn-primary btn-sm" @onclick="() => DoEdit(item)"><i class="fa-solid fa-edit"></i></button>
|
||||
</td>
|
||||
<td>
|
||||
@item.MatId
|
||||
@if (item.IsBeam)
|
||||
{
|
||||
<span class="border border-primary rounded px-1">
|
||||
<i class="fa-solid fa-lines-leaning"></i>
|
||||
</span>
|
||||
}
|
||||
else if (@item.IsWall)
|
||||
{
|
||||
<span class="border border-info rounded px-1">
|
||||
<i class="fa-solid fa-draw-polygon"></i>
|
||||
</span>
|
||||
}
|
||||
@item.MatId
|
||||
</td>
|
||||
<td>
|
||||
@item.MatCode
|
||||
@@ -77,15 +90,22 @@
|
||||
<td>
|
||||
@item.MatDesc
|
||||
</td>
|
||||
<td>
|
||||
@($"{item.WMm:N2}")
|
||||
<td class="text-end">
|
||||
@if (item.IsBeam)
|
||||
{
|
||||
@($"{item.WMm:N2}")
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>-</span>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
<td class="text-end">
|
||||
@($"{item.HMm:N2}")
|
||||
</td>
|
||||
<td>
|
||||
@($"{item.LMm:N2}")
|
||||
</td>
|
||||
@* <td class="text-end">
|
||||
@($"{item.LMm:N2}")
|
||||
</td> *@
|
||||
@* <td class="text-end">
|
||||
<button class="btn btn-sm btn-danger" @onclick="() => DeleteRecord(item)"><i class="fa-solid fa-trash-can"></i></button>
|
||||
</td> *@
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this
|
||||
// file to you under the MIT license.
|
||||
using EgwCoreLib.Razor;
|
||||
using MagMan.Core.Services;
|
||||
using MagMan.Data.Admin.DbModels;
|
||||
using MagMan.Data.Admin.Services;
|
||||
using MagMan.Data.Tenant.DbModels;
|
||||
@@ -18,6 +19,9 @@ namespace MagMan.UI.Components
|
||||
[Parameter]
|
||||
public int CustomerId { get; set; } = 0;
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<MaterialModel?> E_MaterialSel { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public int KeyNum { get; set; } = 0;
|
||||
|
||||
@@ -25,17 +29,20 @@ namespace MagMan.UI.Components
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected MessageService AppMService { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected IConfiguration Configuration { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected IJSRuntime JSRuntime { get; set; } = null!;
|
||||
|
||||
protected int totalCount { get; set; } = 0;
|
||||
|
||||
[Inject]
|
||||
protected TenantService TService { get; set; } = null!;
|
||||
|
||||
protected int totalCount { get; set; } = 0;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
@@ -45,7 +52,11 @@ namespace MagMan.UI.Components
|
||||
string answ = "";
|
||||
if (CurrItem != null)
|
||||
{
|
||||
answ = curItem.MatId == CurrItem.MatId? "table-info" : "";
|
||||
answ = curItem.MatId == CurrItem.MatId ? "table-info" : "";
|
||||
}
|
||||
else
|
||||
{
|
||||
answ = curItem.MatId == MaterialId ? "table-info" : "";
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
@@ -71,6 +82,22 @@ namespace MagMan.UI.Components
|
||||
protected void DoEdit(MaterialModel? selItem)
|
||||
{
|
||||
CurrItem = selItem;
|
||||
if (selItem == null)
|
||||
{
|
||||
DoSelect(null);
|
||||
}
|
||||
}
|
||||
protected void DoSelect(MaterialModel? selItem)
|
||||
{
|
||||
if (selItem != null)
|
||||
{
|
||||
MaterialId = selItem.MatId;
|
||||
}
|
||||
else
|
||||
{
|
||||
MaterialId = 0;
|
||||
}
|
||||
E_MaterialSel.InvokeAsync(selItem);
|
||||
}
|
||||
|
||||
protected async Task ForceReload(bool force)
|
||||
@@ -79,6 +106,12 @@ namespace MagMan.UI.Components
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
currSearch = "";
|
||||
AppMService.EA_SearchUpdated += AppMService_EA_SearchUpdated;
|
||||
}
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
await ReloadData();
|
||||
@@ -88,11 +121,14 @@ namespace MagMan.UI.Components
|
||||
{
|
||||
numRecord = newNum;
|
||||
currPage = 1;
|
||||
InvokeAsync(ReloadData);
|
||||
}
|
||||
|
||||
protected void SetPage(int newNum)
|
||||
{
|
||||
currPage = newNum;
|
||||
DoSelect(null);
|
||||
InvokeAsync(ReloadData);
|
||||
}
|
||||
|
||||
protected async Task SortRequested(Sorter.SortCallBack e)
|
||||
@@ -104,11 +140,13 @@ namespace MagMan.UI.Components
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private MaterialModel? CurrItem = null;
|
||||
private int MaterialId = 0;
|
||||
|
||||
private string currSearch = "";
|
||||
private int filtType = 0;
|
||||
private List<MaterialModel>? ListRecords = null;
|
||||
|
||||
private List<MaterialModel>? SearchRecords = null;
|
||||
@@ -123,30 +161,6 @@ namespace MagMan.UI.Components
|
||||
|
||||
private int currPage { get; set; } = 1;
|
||||
|
||||
private bool isLoading { get; set; } = false;
|
||||
|
||||
private int numRecord { get; set; } = 10;
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private async Task ReloadData()
|
||||
{
|
||||
isLoading = true;
|
||||
ListRecords = null;
|
||||
SearchRecords = await TService.MaterialGetAll(KeyNum, false);
|
||||
// verifico se filtrare x beam/wall
|
||||
if (FiltType> 0)
|
||||
{
|
||||
SearchRecords = SearchRecords.Where(x => (x.IsBeam && FiltType == 1) || (x.IsWall && FiltType == 2)).ToList();
|
||||
}
|
||||
totalCount = SearchRecords.Count;
|
||||
SortTable();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
private int filtType = 0;
|
||||
private int FiltType
|
||||
{
|
||||
get => filtType;
|
||||
@@ -155,12 +169,48 @@ namespace MagMan.UI.Components
|
||||
if (filtType != value)
|
||||
{
|
||||
filtType = value;
|
||||
var pUpd = Task.Run(async () => await ReloadData());
|
||||
pUpd.Wait();
|
||||
InvokeAsync(ReloadData);
|
||||
InvokeAsync(StateHasChanged);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool isLoading { get; set; } = false;
|
||||
|
||||
private int numRecord { get; set; } = 10;
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private async void AppMService_EA_SearchUpdated()
|
||||
{
|
||||
currSearch = AppMService.SearchVal;
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
private async Task ReloadData()
|
||||
{
|
||||
isLoading = true;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
ListRecords = null;
|
||||
SearchRecords = await TService.MaterialGetAll(KeyNum, false);
|
||||
// verifico se filtrare x beam/wall
|
||||
if (FiltType > 0)
|
||||
{
|
||||
SearchRecords = SearchRecords.Where(x => (x.IsBeam && FiltType == 1) || (x.IsWall && FiltType == 2)).ToList();
|
||||
}
|
||||
// verifico filtro per ricerca
|
||||
if (!string.IsNullOrEmpty(currSearch))
|
||||
{
|
||||
SearchRecords = SearchRecords.Where(x => x.MatCode.Contains(currSearch, StringComparison.InvariantCultureIgnoreCase) || x.MatDesc.Contains(currSearch, StringComparison.InvariantCultureIgnoreCase)).ToList();
|
||||
}
|
||||
totalCount = SearchRecords.Count;
|
||||
SortTable();
|
||||
isLoading = false;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private void SortTable()
|
||||
{
|
||||
if (SearchRecords != null)
|
||||
@@ -170,7 +220,7 @@ namespace MagMan.UI.Components
|
||||
{
|
||||
switch (sortField)
|
||||
{
|
||||
case "MatId":
|
||||
case "RawItemId":
|
||||
if (sortAsc)
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderBy(x => x.MatId).ThenBy(x => x.MatCode).ToList();
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
<div class="input-group input-group-sm">
|
||||
<input @bind-value="searchVal" @bind-value:event="oninput" type="text" class="form-control" title="Campo Ricerca" placeholder="Ricerca [ALT-R]" accesskey="R" />
|
||||
<div class="input-group-append">
|
||||
<button @onclick="reset" class="btn btn-success input-group-text">reset</button>
|
||||
</div>
|
||||
<button @onclick="reset" class="btn btn-success input-group-text">reset</button>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using MagMan.Core;
|
||||
using k8s.Models;
|
||||
using MagMan.Core;
|
||||
using MagMan.Core.DTO;
|
||||
using MagMan.Core.Services;
|
||||
using MagMan.Data.Admin.DbModels;
|
||||
using MagMan.Data.Admin.Services;
|
||||
@@ -20,12 +22,12 @@ namespace MagMan.UI.Controllers
|
||||
/// Classe per logging
|
||||
/// </summary>
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private MTAdminService MTAdminService { get; set; } = null!;
|
||||
private MTAdminService MTAdmService { get; set; } = null!;
|
||||
private static JsonSerializerSettings? JSSettings;
|
||||
private TenantService TService { get; set; } = null!;
|
||||
public InventoryController(MTAdminService MTDataService, TenantService TDataService)
|
||||
{
|
||||
MTAdminService = MTDataService;
|
||||
MTAdmService = MTDataService;
|
||||
TService = TDataService;
|
||||
// json serializer... FIX errore loop circolare https://www.ryadel.com/en/jsonserializationexception-self-referencing-loop-detected-error-fix-entity-framework-asp-net-core/
|
||||
JSSettings = new JsonSerializerSettings()
|
||||
@@ -68,7 +70,7 @@ namespace MagMan.UI.Controllers
|
||||
public async Task<List<MaterialModel>> Get(string id, int MatId)
|
||||
{
|
||||
// in primis recupero codice chiave da token...
|
||||
int nKey = await MTAdminService.MainKeyByToken(id);
|
||||
int nKey = await MTAdmService.MainKeyByToken(id);
|
||||
// ora recupero direttametne i materiali
|
||||
var ListRecords = await TService.MaterialGetFilt(nKey, MatId, true);
|
||||
return ListRecords;
|
||||
@@ -89,11 +91,11 @@ namespace MagMan.UI.Controllers
|
||||
if (!string.IsNullOrEmpty(id) && rawList != null && rawList.ItemList != null)
|
||||
{
|
||||
// in primis recupero codice chiave da token...
|
||||
int nKey = await MTAdminService.MainKeyByToken(id);
|
||||
int nKey = await MTAdmService.MainKeyByToken(id);
|
||||
if (nKey > 0)
|
||||
{
|
||||
// creo oggetti materiale da lista ricevuta
|
||||
List<RawItemModel> matList = rawList.ItemList.Select(jpl => TService.ItemFromDto(jpl)).ToList();
|
||||
List<RawItemModel> matList = rawList.ItemList.Select(jpl => TService.ItemFromDto(jpl, true)).ToList();
|
||||
|
||||
foreach (var item in matList)
|
||||
{
|
||||
@@ -108,10 +110,14 @@ namespace MagMan.UI.Controllers
|
||||
fatto = false;
|
||||
}
|
||||
}
|
||||
// resetto cache redis
|
||||
await MTAdmService.FlushRedisCache();
|
||||
}
|
||||
}
|
||||
answ = fatto ? "OK" : "NO";
|
||||
return answ;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,12 +19,12 @@ namespace MagMan.UI.Controllers
|
||||
/// Classe per logging
|
||||
/// </summary>
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private MTAdminService MTAdminService { get; set; } = null!;
|
||||
private MTAdminService MTAdmService { get; set; } = null!;
|
||||
private static JsonSerializerSettings? JSSettings;
|
||||
private TenantService TService { get; set; } = null!;
|
||||
public MaterialsController(MTAdminService MTDataService, TenantService TDataService)
|
||||
{
|
||||
MTAdminService = MTDataService;
|
||||
MTAdmService = MTDataService;
|
||||
TService = TDataService;
|
||||
// json serializer... FIX errore loop circolare https://www.ryadel.com/en/jsonserializationexception-self-referencing-loop-detected-error-fix-entity-framework-asp-net-core/
|
||||
JSSettings = new JsonSerializerSettings()
|
||||
@@ -66,7 +66,7 @@ namespace MagMan.UI.Controllers
|
||||
public async Task<List<MaterialModel>> Get(string id)
|
||||
{
|
||||
// in primis recupero codice chiave da token...
|
||||
int nKey = await MTAdminService.MainKeyByToken(id);
|
||||
int nKey = await MTAdmService.MainKeyByToken(id);
|
||||
// ora recupero direttametne i materiali
|
||||
var ListRecords = await TService.MaterialGetAll(nKey, false);
|
||||
return ListRecords;
|
||||
@@ -87,7 +87,7 @@ namespace MagMan.UI.Controllers
|
||||
if (!string.IsNullOrEmpty(id) && rawList != null && rawList.MatList != null)
|
||||
{
|
||||
// in primis recupero codice chiave da token...
|
||||
int nKey = await MTAdminService.MainKeyByToken(id);
|
||||
int nKey = await MTAdmService.MainKeyByToken(id);
|
||||
if (nKey > 0)
|
||||
{
|
||||
// creo oggetti materiale da lista ricevuta
|
||||
@@ -106,6 +106,8 @@ namespace MagMan.UI.Controllers
|
||||
fatto = false;
|
||||
}
|
||||
}
|
||||
// resetto cache redis
|
||||
await MTAdmService.FlushRedisCache();
|
||||
}
|
||||
}
|
||||
answ = fatto ? "OK" : "NO";
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
using MagMan.Data.Admin.DbModels;
|
||||
using k8s.Models;
|
||||
using MagMan.Core;
|
||||
using MagMan.Core.DTO;
|
||||
using MagMan.Data.Admin.DbModels;
|
||||
using MagMan.Data.Admin.Services;
|
||||
using MagMan.Data.Tenant.DbModels;
|
||||
using MagMan.Data.Tenant.Services;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace MagMan.UI.Controllers
|
||||
{
|
||||
@@ -14,10 +21,18 @@ namespace MagMan.UI.Controllers
|
||||
/// Classe per logging
|
||||
/// </summary>
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private MTAdminService _DataService { get; set; } = null!;
|
||||
public ProjectsController(MTAdminService DataService)
|
||||
private MTAdminService MTAdmService { get; set; } = null!;
|
||||
private static JsonSerializerSettings? JSSettings;
|
||||
private TenantService TService { get; set; } = null!;
|
||||
public ProjectsController(MTAdminService MTDataService, TenantService TDataService)
|
||||
{
|
||||
_DataService = DataService;
|
||||
MTAdmService = MTDataService;
|
||||
TService = TDataService;
|
||||
// json serializer... FIX errore loop circolare https://www.ryadel.com/en/jsonserializationexception-self-referencing-loop-detected-error-fix-entity-framework-asp-net-core/
|
||||
JSSettings = new JsonSerializerSettings()
|
||||
{
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
|
||||
};
|
||||
Log.Info("Avviata classe ProjectsController");
|
||||
}
|
||||
|
||||
@@ -52,8 +67,47 @@ namespace MagMan.UI.Controllers
|
||||
[HttpGet("{id}")]
|
||||
public async Task<List<MachineModel>> Get(string id, int KeyNum)
|
||||
{
|
||||
var ListRecords = await _DataService.MachineGetByToken(id);
|
||||
var ListRecords = await MTAdmService.MachineGetByToken(id);
|
||||
return ListRecords;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processa una chiamata POST per l'invio di un oggetto di aggiornamento progetto
|
||||
/// PUT: api/Inventory/upsert/00000000-0000-0000-0000-000000000000
|
||||
/// </summary>
|
||||
/// <param name="id">token comunicazione</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("upsert/{id}")]
|
||||
public async Task<string> upsert(string id, [FromBody] ProjectDTO projectData)
|
||||
{
|
||||
string answ = "ND";
|
||||
bool fatto = false;
|
||||
// verifico ci sia valore
|
||||
if (!string.IsNullOrEmpty(id) && projectData != null)
|
||||
{
|
||||
// in primis recupero codice chiave da token...
|
||||
int nKey = await MTAdmService.MainKeyByToken(id);
|
||||
if (nKey > 0)
|
||||
{
|
||||
// converto ProjDto --> DB
|
||||
var currRec = TService.ProjectFromDto(projectData);
|
||||
try
|
||||
{
|
||||
await TService.ProjectUpdate(nKey, currRec);
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"ProjectsController.upsert | Errore in fase salvataggio ProjectDTO{Environment.NewLine}{exc}");
|
||||
fatto = false;
|
||||
}
|
||||
// resetto cache redis
|
||||
await MTAdmService.FlushRedisCache();
|
||||
|
||||
}
|
||||
}
|
||||
answ = fatto ? "OK" : "NO";
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
using k8s.Models;
|
||||
using MagMan.Core;
|
||||
using MagMan.Core.DTO;
|
||||
using MagMan.Data.Admin.DbModels;
|
||||
using MagMan.Data.Admin.Services;
|
||||
using MagMan.Data.Tenant.DbModels;
|
||||
using MagMan.Data.Tenant.Services;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
|
||||
namespace MagMan.UI.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class ResourcesController : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe per logging
|
||||
/// </summary>
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private MTAdminService MTAdmService { get; set; } = null!;
|
||||
private static JsonSerializerSettings? JSSettings;
|
||||
private TenantService TService { get; set; } = null!;
|
||||
public ResourcesController(MTAdminService MTDataService, TenantService TDataService)
|
||||
{
|
||||
MTAdmService = MTDataService;
|
||||
TService = TDataService;
|
||||
// json serializer... FIX errore loop circolare https://www.ryadel.com/en/jsonserializationexception-self-referencing-loop-detected-error-fix-entity-framework-asp-net-core/
|
||||
JSSettings = new JsonSerializerSettings()
|
||||
{
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
|
||||
};
|
||||
Log.Info("Avviata classe ResourcesController");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Controllo status Alive
|
||||
/// GET: api/Machines/alive
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("alive")]
|
||||
public string alive()
|
||||
{
|
||||
//Log.Debug("Chiamata alive");
|
||||
return $"OK";
|
||||
}
|
||||
|
||||
// GET api/Machines/5
|
||||
[HttpGet]
|
||||
public async Task<List<MachineModel>> Get()
|
||||
{
|
||||
// se non ho chaive --> vuoto!
|
||||
List<MachineModel> ListRecords = new List<MachineModel>();
|
||||
await Task.Delay(100);
|
||||
return ListRecords;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Macchine dato RestToken
|
||||
/// </summary>
|
||||
/// <param name="id">Rest Token cliente</param>
|
||||
/// <returns></returns>
|
||||
// GET api/Machines/2cba60c7-7be4-40b1-aa0d-52e7c71fc1a7
|
||||
[HttpGet("{id}")]
|
||||
public async Task<List<MachineModel>> Get(string id, int KeyNum)
|
||||
{
|
||||
var ListRecords = await MTAdmService.MachineGetByToken(id);
|
||||
return ListRecords;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processa una chiamata POST per l'invio di un oggetto di aggiornamento risorse progetto (RestPayload.Resources)
|
||||
/// PUT: api/Inventory/upsert/00000000-0000-0000-0000-000000000000
|
||||
/// </summary>
|
||||
/// <param name="id">token comunicazione</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("upsert/{id}")]
|
||||
public async Task<string> upsert(string id, [FromBody] RestPayload.Resources projectData)
|
||||
{
|
||||
string answ = "ND";
|
||||
bool fatto = false;
|
||||
// verifico ci sia valore
|
||||
if (!string.IsNullOrEmpty(id) && projectData != null)
|
||||
{
|
||||
// in primis recupero codice chiave da token...
|
||||
int nKey = await MTAdmService.MainKeyByToken(id);
|
||||
if (nKey > 0)
|
||||
{
|
||||
#if false
|
||||
// creo oggetti materiale da lista ricevuta
|
||||
List<RawItemModel> matList = item2Consume.ItemList.Select(jpl => TService.ItemFromDto(jpl, true)).ToList();
|
||||
|
||||
foreach (var item in matList)
|
||||
{
|
||||
try
|
||||
{
|
||||
await TService.ItemUpdate(nKey, item);
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"InventoryController.upsert | Errore in fase salvataggio ItemDto{Environment.NewLine}{exc}");
|
||||
fatto = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// resetto cache redis
|
||||
await MTAdmService.FlushRedisCache();
|
||||
}
|
||||
}
|
||||
answ = fatto ? "OK" : "NO";
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Version>1.0.2401.1911</Version>
|
||||
<Version>1.0.2401.2220</Version>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<EnableNETAnalyzers>true</EnableNETAnalyzers>
|
||||
@@ -36,7 +36,7 @@
|
||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="6.0.5" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.UI.InMemory.Storage" Version="6.0.5" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="6.0.3" />
|
||||
<PackageReference Include="EgwCoreLib.Razor" Version="1.4.2401.1911" />
|
||||
<PackageReference Include="EgwCoreLib.Razor" Version="1.4.2401.2209" />
|
||||
<PackageReference Include="EgwCoreLib.Utils" Version="1.4.2401.1911" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.25" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="6.0.25" />
|
||||
|
||||
@@ -22,19 +22,7 @@
|
||||
<div class="px-0">
|
||||
@if (currMode != CtMode.Company)
|
||||
{
|
||||
<div class="input-group">
|
||||
<label class="input-group-text" for="inputGroupSelect01">Cliente</label>
|
||||
<select class="form-select" @bind="@CustomerID">
|
||||
<option value="0">--- Selezionare Cliente ---</option>
|
||||
@if (CustomersList != null)
|
||||
{
|
||||
@foreach (var item in CustomersList)
|
||||
{
|
||||
<option value="@item.CustomerID">@item.Name [@item.CustomerID]</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<CmpSelCliente E_CustSelected="SaveCust"></CmpSelCliente>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -31,12 +31,16 @@ namespace MagMan.UI.Pages
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
AppMService.ShowSearch = false;
|
||||
AppMService.PageName = "Admin Area";
|
||||
AppMService.PageIcon = "fa-solid fa-house pr-2";
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected void SaveCust(int newCustId)
|
||||
{
|
||||
CustomerID = newCustId;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
@@ -44,14 +48,12 @@ namespace MagMan.UI.Pages
|
||||
#region Private Fields
|
||||
|
||||
private CtMode currMode = CtMode.Company;
|
||||
private int CustomerID = 0;
|
||||
private List<CustomerModel>? CustomersList = null;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private bool isLoading { get; set; } = false;
|
||||
private int CustomerID { get; set; } = 0;
|
||||
|
||||
[Inject]
|
||||
private NavigationManager NavMan { get; set; } = null!;
|
||||
@@ -66,13 +68,6 @@ namespace MagMan.UI.Pages
|
||||
return answ;
|
||||
}
|
||||
|
||||
private async Task ReloadData()
|
||||
{
|
||||
isLoading = true;
|
||||
CustomersList = await MTService.CustomerGetAll();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
private void SetMode(CtMode newMode)
|
||||
{
|
||||
currMode = newMode;
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
<div class="col-6 col-md-4">
|
||||
<AuthorizeView Roles="SuperAdmin, Admin, User">
|
||||
<Authorized>
|
||||
<NavLink type="button" class="btn btn-block btn-primary text-light p-3 m-2 w-100" title="Stato Impianti" href="PlantStatus">
|
||||
<NavLink type="button" class="btn btn-block btn-primary text-light p-3 m-2 w-100" title="Stato Impianti" href="MachineStatus">
|
||||
<i class="fa-solid fa-screwdriver-wrench fa-2x mb-2" aria-hidden="true"></i>
|
||||
<h4>Dati Macchine</h4>
|
||||
</NavLink>
|
||||
@@ -65,7 +65,7 @@
|
||||
<div class="col-6 col-md-4">
|
||||
<AuthorizeView Roles="SuperAdmin, Admin, User">
|
||||
<Authorized>
|
||||
<NavLink type="button" class="btn btn-block btn-primary text-light p-3 m-2 w-100" title="Scheda Stazione" href="GasStation">
|
||||
<NavLink type="button" class="btn btn-block btn-primary text-light p-3 m-2 w-100" title="Scheda Stazione" href="WareHouse">
|
||||
<i class="fa-solid fa-warehouse fa-2x mb-2" aria-hidden="true"></i>
|
||||
<h4>Magazzino</h4>
|
||||
</NavLink>
|
||||
|
||||
@@ -4,29 +4,9 @@
|
||||
|
||||
<div class="d-flex justify-content-between">
|
||||
<div class="px-0">
|
||||
<ul class="nav nav-tabs">
|
||||
@foreach (var item in Enum.GetValues(typeof(CtMode)))
|
||||
{
|
||||
<li class="nav-item">
|
||||
<button class="nav-link @IsActive((CtMode)item)" @onclick="()=> SetMode((CtMode)item)">@((CtMode)item)</button>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="px-0">
|
||||
<div class="input-group">
|
||||
<label class="input-group-text">Cliente</label>
|
||||
<select class="form-select" @bind="@CustomerID">
|
||||
<option value="0">--- Selezionare Cliente ---</option>
|
||||
@if (CustomersList != null)
|
||||
{
|
||||
@foreach (var item in CustomersList)
|
||||
{
|
||||
<option value="@item.CustomerID">@item.Name [@item.CustomerID]</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<CmpSelCliente E_CustSelected="SaveCust"></CmpSelCliente>
|
||||
</div>
|
||||
</div>
|
||||
@if (CustomerID == 0)
|
||||
@@ -40,12 +20,15 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
@if (currMode == CtMode.Materials)
|
||||
{
|
||||
<MaterialMan CustomerId="@CustomerID" KeyNum="@nKey"></MaterialMan>
|
||||
}
|
||||
else if (currMode == CtMode.Items)
|
||||
{
|
||||
<ItemMan></ItemMan>
|
||||
}
|
||||
<div class="row">
|
||||
<div class="@mainCss">
|
||||
<MaterialMan CustomerId="@CustomerID" KeyNum="@nKey" E_MaterialSel="SaveMat"></MaterialMan>
|
||||
</div>
|
||||
@if (MaterialSel != null)
|
||||
{
|
||||
<div class="col-6">
|
||||
<ItemMan CustomerId="@CustomerID" KeyNum="@nKey" MaterialSel="@MaterialSel"></ItemMan>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
@@ -1,72 +1,83 @@
|
||||
using MagMan.Core.Services;
|
||||
using MagMan.Data.Admin.DbModels;
|
||||
using MagMan.Data.Admin.Services;
|
||||
using MagMan.Data.Tenant.DbModels;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using YamlDotNet.Core.Tokens;
|
||||
|
||||
namespace MagMan.UI.Pages
|
||||
{
|
||||
public partial class WareHouse
|
||||
{
|
||||
#region Protected Fields
|
||||
|
||||
protected int nKey = 0;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected MessageService AppMService { get; set; } = null!;
|
||||
|
||||
protected int CustomerID { get; set; } = 0;
|
||||
|
||||
protected string mainCss
|
||||
{
|
||||
get => MaterialSel == null ? "col-12" : "col-6 small";
|
||||
}
|
||||
|
||||
[Inject]
|
||||
protected MTAdminService MTService { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
AppMService.ShowSearch = false;
|
||||
AppMService.ShowSearch = true;
|
||||
AppMService.PageName = "Warehouse Area";
|
||||
AppMService.PageIcon = "fa-solid fa-warehouse pr-2";
|
||||
// rileggo dati
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected async Task SaveCust(int newCustId)
|
||||
{
|
||||
CustomerID = newCustId;
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected void SaveMat(MaterialModel? newMat)
|
||||
{
|
||||
MaterialSel = newMat;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private int KeyNum = 0;
|
||||
private MaterialModel? MaterialSel = null;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private bool isLoading { get; set; } = false;
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private async Task ReloadData()
|
||||
{
|
||||
isLoading = true;
|
||||
CustomersList = await MTService.CustomerGetAll();
|
||||
nKey = await MTService.MainKeyByCustomer(CustomerID);
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
protected int nKey = 0;
|
||||
|
||||
private bool isLoading { get; set; } = false;
|
||||
private CtMode currMode = CtMode.Materials;
|
||||
protected int CustomerID
|
||||
{
|
||||
get => customerID;
|
||||
set
|
||||
{
|
||||
if (customerID != value)
|
||||
{
|
||||
customerID = value;
|
||||
// update keys
|
||||
var pUpd = Task.Run(async () => await ReloadData());
|
||||
pUpd.Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
private int customerID = 0;
|
||||
private int KeyNum = 0;
|
||||
private List<CustomerModel>? CustomersList = null;
|
||||
|
||||
protected enum CtMode
|
||||
{
|
||||
Materials,
|
||||
Items,
|
||||
//Deposit,
|
||||
//Pickup
|
||||
}
|
||||
|
||||
private string IsActive(CtMode modeReq)
|
||||
{
|
||||
string answ = currMode == modeReq ? "active" : "";
|
||||
return answ;
|
||||
}
|
||||
|
||||
private void SetMode(CtMode newMode)
|
||||
{
|
||||
currMode = newMode;
|
||||
}
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,11 @@
|
||||
<i class="fa-solid fa-screwdriver-wrench pe-2"></i> Dati Macchine
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-2">
|
||||
<NavLink class="nav-link py-0 px-2 mb-0" href="ProjectsStatus">
|
||||
<i class="fa-solid fa-chart-gantt pe-2"></i> Progetti
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-2">
|
||||
<NavLink class="nav-link py-0 px-2 mb-0" href="WareHouse">
|
||||
<i class="fa-solid fa-warehouse pe-2"></i> Magazzino
|
||||
|
||||
@@ -4,13 +4,13 @@ Gestione magazzino per applicazioni BeamWall, integrato con EgtBeamWall.
|
||||
|
||||
## Prerequisiti e versioni
|
||||
|
||||
Un prerequisito è il disaccoppiamento tra EgtB&W ed il componente MagMan: abbiamo che il sw EgtB&W è basato su **netFramework 4.7.2** mentre l'applciazione, che deve girare su windows e linux e quindi **dotNet Core 6.0** LTS o successivi, non può essere direttamente connessa tramite dll
|
||||
Un prerequisito è il disaccoppiamento tra EgtB&W ed il componente MagMan: abbiamo che il sw EgtB&W è basato su **netFramework 4.7.2** mentre l'applicazione, che deve girare su windows e linux e quindi **dotNet Core 6.0** LTS o successivi, non può essere direttamente connessa tramite dll
|
||||
|
||||
In particoalre il problema c'è a livello delle librerie di accesso EntityFramework.
|
||||
|
||||
Per superare il problema il disaccoppiamento sarà svolto tramite chaimate **REST** che il client (applicazione EgtB&W) farà al server.
|
||||
|
||||
Inoltre la distribuzione della funzionalità, per essere semplificata,a vverra tramite apposito pacchetto nuget ospitato sul repository nexus aziendale.
|
||||
Inoltre la distribuzione della funzionalità, per essere semplificata, avverrà tramite apposito pacchetto nuget ospitato sul repository nexus aziendale.
|
||||
|
||||
## Descrizione
|
||||
|
||||
@@ -23,6 +23,7 @@ Il sofware è previsto in modalità **multi-tenant**, dove verrà generato un DB
|
||||
Di base il sistema deve prevedere il riconoscimento degli utenti e/o dei software EgalWare licenziati e reindirizzare l'impiego delle funzionalità avanzate verso il DB dedicato al cliente.
|
||||
|
||||
<div style="page-break-after: always; visibility: hidden"></div>
|
||||
|
||||
## Architettura
|
||||
|
||||
Il progetto è pensato in architettura **multi-tenant** per la versione **online**, ovvero un unico indirizzo web (tramite load balancers x reverse proxy) che fornisce l'applicazione a tutti i clienti.
|
||||
|
||||
BIN
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>MagMan - Wood Warehouse Management System</i>
|
||||
<h4>Versione: 1.0.2401.1911</h4>
|
||||
<h4>Versione: 1.0.2401.2220</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.0.2401.1911
|
||||
1.0.2401.2220
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>1.0.2401.1911</version>
|
||||
<version>1.0.2401.2220</version>
|
||||
<url>http://nexus.steamware.net/repository/SWS/MagMan/stable/0/MagMan.UI.zip</url>
|
||||
<changelog>http://nexus.steamware.net/repository/SWS/MagMan/stable/0/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
@@ -1,6 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="RestSharp" publicKeyToken="598062e77f915f75" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-110.2.1.0" newVersion="110.2.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.3" newVersion="7.0.0.3" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
@@ -44,7 +44,7 @@ namespace DemoApp
|
||||
Console.WriteLine("Premere un tasto per lettura archivio materiali");
|
||||
answ = Console.ReadLine();
|
||||
// leggo materiali
|
||||
var matList = await commLib.GetMaterials();
|
||||
var matList = await commLib.MaterialsGet();
|
||||
if (matList != null)
|
||||
{
|
||||
foreach (var item in matList)
|
||||
@@ -65,7 +65,7 @@ namespace DemoApp
|
||||
}
|
||||
answ = Console.ReadLine();
|
||||
// leggo inventario
|
||||
var inventList = await commLib.GetInventario(0);
|
||||
var inventList = await commLib.InventarioGet(0);
|
||||
if (inventList != null)
|
||||
{
|
||||
foreach (var itemMat in inventList)
|
||||
|
||||
Reference in New Issue
Block a user