80 Commits

Author SHA1 Message Date
Samuele Locatelli ef54b8762b Merge tag 'FixMatItemEmptyDescr' into develop
Fix descrizioni vuote x progetti
2024-03-01 08:13:01 +01:00
Samuele Locatelli 954543feb4 Merge branch 'release/FixMatItemEmptyDescr' 2024-03-01 08:12:51 +01:00
Samuele Locatelli 495811fa26 Update controller RawItem + fix display proj 2024-03-01 08:12:20 +01:00
Samuele Locatelli c72756f25b Update metodi x calcolo descr materiale se mancante 2024-02-29 19:54:01 +01:00
Samuele Locatelli f0867272ec Fix gestione update risorse 2024-02-29 18:54:10 +01:00
Samuele Locatelli 7848d7802b Update gestione ResourceTrack:
- update controller POST
- update lib SDK x syncro
2024-02-29 12:51:25 +01:00
Samuele Locatelli 95af7cc9b5 Update syncro x restituzione val INT 2024-02-29 11:28:55 +01:00
Samuele Locatelli b6d7b1e7b9 Merge tag 'Nuget_AddProjGetSingle' into develop
Aggiunta gestione nuget progetti x get single
2024-02-29 10:32:06 +01:00
Samuele Locatelli d59dea5c51 Merge branch 'release/Nuget_AddProjGetSingle' 2024-02-29 10:31:53 +01:00
Samuele Locatelli 4eae0fa7ac Update SDK x nuget gestione syncro con single Proj get 2024-02-29 10:30:39 +01:00
Samuele Locatelli 3bd0806942 Aggiunta metodo x download singolo Proj da CloudId 2024-02-29 10:22:09 +01:00
Samuele Locatelli 0f255e444b Merge tag 'UpgradeProjUpsert' into develop
Update x gestione Proj aggiornata in upsert e permettere nuovo SDK x
sync
2024-02-29 08:49:03 +01:00
Samuele Locatelli 62b14754cd Merge branch 'release/UpgradeProjUpsert' 2024-02-29 08:48:29 +01:00
Samuele Locatelli bd7a82d50f update metodi gestione Progetti:
- ritorno ID creato/aggiornato
- check funzioni insert/update
- REST refresh x testing
2024-02-29 08:47:58 +01:00
Samuele Locatelli 944ae6126c Merge tag 'AddAliasMan01' into develop
Gestione alias materiali online
2024-02-22 16:24:37 +01:00
Samuele Locatelli c276563d2f Merge branch 'release/AddAliasMan01' 2024-02-22 16:23:56 +01:00
Samuele Locatelli 3979d378b2 update index page 2024-02-22 16:23:36 +01:00
Samuele Locatelli 8959cb0751 Update gestione Alias 2024-02-22 16:20:51 +01:00
Samuele Locatelli 438ade3a10 Update SDK methos AliasSendAsync name 2024-02-20 19:13:10 +01:00
Samuele Locatelli 13b904f61a Merge tag 'AddAliasSync' into develop
Completato update anche dell'SDK
2024-02-20 18:39:32 +01:00
Samuele Locatelli fcd7788a84 Merge branch 'release/AddAliasSync' 2024-02-20 18:39:21 +01:00
Samuele Locatelli 14e4b75b69 Update proxy con SDK 2024-02-20 18:39:10 +01:00
Samuele Locatelli a39a037aee Update x metodi gestione sync Alias 2024-02-20 18:19:09 +01:00
Samuele Locatelli c5f7a7d78e Merge tag 'AddForceReloadPage02' into develop
Fix reload page x blazor js
2024-02-19 19:57:00 +01:00
Samuele Locatelli b5fcf6cd4d Merge branch 'release/AddForceReloadPage02' 2024-02-19 19:56:51 +01:00
Samuele Locatelli bef5fdc203 Fix layout x reload blazor js 2024-02-19 19:56:36 +01:00
Samuele Locatelli f899ea5380 Merge tag 'AddForceReloadPage01' into develop
Update gestione force reload pagina per evitare reload waiting
2024-02-19 09:26:43 +01:00
Samuele Locatelli 87b5f37b5a Merge branch 'release/AddForceReloadPage01' 2024-02-19 09:26:28 +01:00
Samuele Locatelli 56de33cfc6 Fix force reload page 2024-02-19 09:24:34 +01:00
Samuele Locatelli 4aca1a465a Merge tag 'FixEditMaterials01' into develop
Fix editing materiali
2024-02-17 10:59:22 +01:00
Samuele Locatelli d5d28524bd Merge branch 'release/FixEditMaterials01' 2024-02-17 10:59:08 +01:00
Samuele Locatelli c67c37cd2c Fix catena selezione materiali 2024-02-17 10:58:31 +01:00
Samuele Locatelli 529179e581 Merge tag 'FixEditMaterialsOnCancel01' into develop
Fix gestone edit materiali su cancel
2024-02-16 18:50:23 +01:00
Samuele Locatelli 7635da616d Merge branch 'release/FixEditMaterialsOnCancel01' 2024-02-16 18:50:08 +01:00
Samuele Locatelli 7d9999b336 Update gestione exit edit Materiali 2024-02-16 18:49:18 +01:00
Samuele Locatelli 8918110dec Update gestione cancel edit materiali 2024-02-16 18:17:18 +01:00
Samuele Locatelli 287a9929b6 Merge tag 'InventoryFixUpdQtyOnlyCloud' into develop
Update gestione qty non aggiornata da EgtBW in sync
2024-02-14 15:09:50 +01:00
Samuele Locatelli dc0cb5fc69 Merge branch 'release/InventoryFixUpdQtyOnlyCloud' 2024-02-14 15:07:06 +01:00
Samuele Locatelli 147bd0dc9e Gestione opzionale set qty RawItem 2024-02-14 15:06:31 +01:00
Samuele Locatelli 75186f4628 Merge tag 'FixReloadSelCustomer' into develop
Fix refresh ceh eprde customer
2024-02-09 14:44:54 +01:00
Samuele Locatelli d9731433d1 Merge branch 'release/FixReloadSelCustomer' 2024-02-09 14:44:44 +01:00
Samuele Locatelli 1f75a0a39e Fix invio x merge itemRaw 2024-02-09 14:44:08 +01:00
Samuele Locatelli 9b32b9ae95 Merge tag 'fixAddDeleteRawItem' into develop
Aggiornamento insert/delete rawItem
2024-02-08 13:02:19 +01:00
Samuele Locatelli a58458b0e6 Merge branch 'release/fixAddDeleteRawItem' 2024-02-08 13:01:47 +01:00
Samuele Locatelli b466b3e8e5 Fix calcolo solo su attivi 2024-02-08 13:01:14 +01:00
Samuele Locatelli 86664908cb Fix display su cambio attivi (RawItem) 2024-02-08 12:43:51 +01:00
Samuele Locatelli f43acfd3ac Fix ItemRaw add 2024-02-08 11:24:34 +01:00
Samuele Locatelli 9bb42101ea Fix editing materiali 2024-02-08 10:23:06 +01:00
Samuele Locatelli 13dae1c425 Merge tag 'AddDeleteMatForAdmin' into develop
Aggiunta eliminazione materiali x admin
2024-02-08 09:09:13 +01:00
Samuele Locatelli 150916acbd Merge branch 'release/AddDeleteMatForAdmin' 2024-02-08 09:09:03 +01:00
Samuele Locatelli 08832c26f2 Update x gestione eliminazione record su MagMan 2024-02-08 09:08:42 +01:00
Samuele Locatelli f614d3df7f Merge branch 'SDK' into develop 2024-02-06 19:43:40 +01:00
Samuele Locatelli 786e850380 Update log invio in caso di problemi response 2024-02-06 19:43:31 +01:00
Samuele Locatelli ceadec4ae6 Merge branch 'develop' into SDK 2024-02-06 16:11:47 +01:00
Samuele Locatelli eb02173f67 Fix check bool fatto da statuscode 2024-02-06 16:11:42 +01:00
Samuele Locatelli 47bf84c5be Merge branch 'SDK' into develop 2024-02-06 15:54:54 +01:00
Samuele Locatelli acccb38a25 Update: ping con timeout pure lui 2024-02-06 15:54:46 +01:00
Samuele Locatelli abf8d30ecd Merge branch 'develop' into SDK 2024-02-06 15:48:32 +01:00
Samuele Locatelli ff066ddf1a Aggiunta override x timeout 2024-02-06 15:48:25 +01:00
Samuele Locatelli e51870a87b Merge tag 'SdkAddSyncroSyncAsync' into develop
Aggiunta metodi sync/async in SDK
2024-02-06 14:27:58 +01:00
Samuele Locatelli e1c3de8199 Merge branch 'release/SdkAddSyncroSyncAsync' 2024-02-06 14:27:48 +01:00
Samuele Locatelli 9a7e273fd5 Merge branch 'develop' into SDK 2024-02-06 14:27:13 +01:00
Samuele Locatelli 7d7bbf46c5 Update pacchetti DataSyncro x metodi Sync/Async 2024-02-06 14:27:06 +01:00
Samuele Locatelli 71ea0405d8 Merge tag 'FixuploadSdk' into develop
Fix tracciati upload SDK
2024-02-06 10:14:13 +01:00
Samuele Locatelli 4ce5157489 Merge branch 'release/FixuploadSdk' 2024-02-06 10:14:06 +01:00
Samuele Locatelli 162c6ff3a4 Merge branch 'develop' into SDK 2024-02-06 10:13:42 +01:00
Samuele Locatelli befbccc9a2 Fix chiamate REST di upload 2024-02-06 10:13:36 +01:00
Samuele Locatelli 6c84f84e53 Merge tag 'UpdMenuTopSpace01' into develop
Fix gestione spazio top menu
2024-02-06 08:45:47 +01:00
Samuele Locatelli 9a54256dbd Merge branch 'release/UpdMenuTopSpace01' 2024-02-06 08:45:38 +01:00
Samuele Locatelli c85f99bf10 Merge branch 'develop' into SDK 2024-02-06 08:44:56 +01:00
Samuele Locatelli 8d7d8d2f71 Fix header 2024-02-06 08:44:42 +01:00
Samuele Locatelli c01bf85968 Update SDK x gestione IP senza special port 2024-02-06 08:44:38 +01:00
Samuele Locatelli cec8aa22e4 Fix salvataggio pickup/deposit 2024-02-05 15:02:27 +01:00
Samuele Locatelli e6751ee3ba Fix display top, fix sel cliente 2024-02-05 15:02:19 +01:00
Samuele Locatelli 4055ce8426 Prima versione deposit/pickup da verificare 2024-02-02 19:38:42 +01:00
Samuele Locatelli e55610870c Merge tag 'AddSelNumKey' into develop
Aggiunta gestione NumKey via MessageService
2024-02-02 11:33:34 +01:00
Samuele Locatelli ddd7c1e98b Merge branch 'release/AddSelNumKey' 2024-02-02 11:31:51 +01:00
Samuele Locatelli f54e5702c2 Fix selezione key in cascata 2024-02-02 11:31:24 +01:00
Samuele Locatelli abd4f94279 Fix orientamento centrale QRCode JS 2024-02-02 09:13:21 +01:00
Samuele Locatelli 4b7097e941 Merge branch 'develop' into SDK 2024-01-31 08:53:28 +01:00
74 changed files with 3119 additions and 725 deletions
+21
View File
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EgwProxy.MagMan.DTO
{
public class AliasDTO
{
/// <summary>
/// Codice originale (da trasformare)
/// </summary>
public string ValOrig { get; set; } = "";
/// <summary>
/// Codice Alias in cui viene convertito
/// </summary>
public string ValAlias { get; set; } = "";
}
}
+601 -143
View File
@@ -1,6 +1,8 @@
using EgwProxy.MagMan.DTO;
using Newtonsoft.Json;
using NLog;
using RestSharp;
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.NetworkInformation;
@@ -16,12 +18,31 @@ namespace EgwProxy.MagMan
/// <summary>
/// Inizializza la libreria di comunicazione con il token assegnato
/// </summary>
/// <param name="UserToken"></param>
public DataSyncro(string serverUrl, string UserToken)
/// <param name="serverUrl">URL del server</param>
/// <param name="authToken">Token di autorizzazione</param>
public DataSyncro(string serverUrl, string authToken)
{
RestToken = UserToken;
RestToken = authToken;
servAddr = serverUrl;
apiUrl = $"https://{servAddr}/api/";
rcOptions = new RestClientOptions { BaseUrl = new Uri(apiUrl), MaxTimeout = callTimeout };
Log.Info($"DataSyncro initialized | api: {apiUrl} | timeout: {callTimeout}");
}
/// <summary>
/// Inizializza la libreria di comunicazione con il token assegnato
/// </summary>
/// <param name="serverUrl">URL del server</param>
/// <param name="authToken">Token di autorizzazione</param>
/// <param name="timeout">Timeout chiamate in ms</param>
public DataSyncro(string serverUrl, string authToken, int timeout)
{
RestToken = authToken;
servAddr = serverUrl;
callTimeout = timeout;
apiUrl = $"https://{servAddr}/api/";
rcOptions = new RestClientOptions { BaseUrl = new Uri(apiUrl), MaxTimeout = callTimeout };
Log.Info($"DataSyncro initialized | api: {apiUrl} | timeout: {callTimeout}");
}
#endregion Public Constructors
@@ -31,7 +52,7 @@ namespace EgwProxy.MagMan
/// <summary>
/// Test ping x indirizzo indicato
/// </summary>
/// <param name="tgtAddr"></param>
/// <param name="tgtAddr">Indirizzo da pingare</param>
/// <returns></returns>
public static IPStatus pingAddress(string tgtAddr)
{
@@ -64,6 +85,153 @@ namespace EgwProxy.MagMan
return answ;
}
/// <summary>
/// Test ping x indirizzo indicato
/// </summary>
/// <param name="tgtAddr">Indirizzo da pingare</param>
/// <param name="timeout">Timeout chiamata in ms</param>
/// <returns></returns>
public static IPStatus pingAddress(string tgtAddr, int timeout)
{
IPStatus answ = IPStatus.Unknown;
IPAddress address;
PingReply reply;
using (Ping pingSender = new Ping())
{
address = IPAddress.Loopback;
int pingMsTimeout = timeout;
IPAddress.TryParse(tgtAddr, out address);
try
{
// se != null --> uso tgtAddr...
if (address != null)
{
reply = pingSender.Send(address, pingMsTimeout);
}
else
{
reply = pingSender.Send(tgtAddr, pingMsTimeout);
}
}
catch
{
reply = pingSender.Send(IPAddress.Loopback, pingMsTimeout);
}
answ = reply.Status;
}
return answ;
}
/// <summary>
/// Elenco Alias dato RestToken
/// </summary>
public List<AliasDTO> AliasGet()
{
List<AliasDTO> answ = new List<AliasDTO>();
// cerco online
using (RestClient client = new RestClient(rcOptions))
{
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
var request = new RestRequest($"Alias/{MKeyEnc}", Method.Get);
var response = client.Get(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
// contenuto serializzato
string rawData = $"{response.Content}";
answ = JsonConvert.DeserializeObject<List<AliasDTO>>(rawData);
}
}
return answ;
}
/// <summary>
/// Versione Async Elenco Alias dato RestToken
/// </summary>
public async Task<List<AliasDTO>> AliasGetAsync()
{
List<AliasDTO> answ = new List<AliasDTO>();
// cerco online
using (RestClient client = new RestClient(rcOptions))
{
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
var request = new RestRequest($"Alias/{MKeyEnc}", Method.Get);
var response = await client.GetAsync(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
// contenuto serializzato
string rawData = $"{response.Content}";
answ = JsonConvert.DeserializeObject<List<AliasDTO>>(rawData);
}
}
return await Task.FromResult(answ);
}
/// <summary>
/// Invio elenco (anche parziale) di Alias, il server farà il merge
/// </summary>
public bool AliasSend(List<AliasDTO> List2Merge)
{
bool answ = false;
// cerco online
using (RestClient client = new RestClient(rcOptions))
{
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
// impacchetto dati x invio...
RestPayload.Alias newPayload = new RestPayload.Alias()
{
AliasList = List2Merge
};
var jsonBody = JsonConvert.SerializeObject(newPayload);
var request = new RestRequest($"Alias/upsert/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
var response = client.Post(request);
Log.Debug($"AliasSend | Response StatusCode: {response.StatusCode}");
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
answ = true;
}
else
{
Log.Error($"AliasSend | Response StatusCode: {response.StatusCode} | content: {response.Content}");
}
}
return answ;
}
/// <summary>
/// Versione async Invio elenco (anche parziale) di Alias, il server farà il merge
/// </summary>
public async Task<bool> AliasSendAsync(List<AliasDTO> List2Merge)
{
bool answ = false;
// cerco online
using (RestClient client = new RestClient(rcOptions))
{
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
// impacchetto dati x invio...
RestPayload.Alias newPayload = new RestPayload.Alias()
{
AliasList = List2Merge
};
var jsonBody = JsonConvert.SerializeObject(newPayload);
var request = new RestRequest($"Alias/upsert/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
var response = await client.PostAsync(request);
Log.Debug($"AliasSendAsync | Response StatusCode: {response.StatusCode}");
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
answ = true;
}
else
{
Log.Error($"AliasSendAsync | Response StatusCode: {response.StatusCode} | content: {response.Content}");
}
}
return await Task.FromResult(answ);
}
/// <summary>
/// Effettua chiamata test sul server (ping)
/// </summary>
@@ -71,8 +239,12 @@ namespace EgwProxy.MagMan
public bool CheckRemote()
{
IPAddress address = IPAddress.Loopback;
string srvIp = servAddr.Substring(0, servAddr.IndexOf(":"));
return pingAddress(srvIp) == IPStatus.Success;
string srvIp = servAddr;
if (servAddr.Contains(":"))
{
srvIp = servAddr.Substring(0, servAddr.IndexOf(":"));
}
return pingAddress(srvIp, callTimeout) == IPStatus.Success;
}
/// <summary>
@@ -80,43 +252,111 @@ namespace EgwProxy.MagMan
/// </summary>
/// <param name="MatID">Se 0 = tutto</param>
/// <returns></returns>
public async Task<List<MaterialDTO>> InventoryGet(int MatID)
public List<MaterialDTO> InventoryGet(int MatID)
{
List<MaterialDTO> answ = new List<MaterialDTO>();
// cerco online
RestClient client = new RestClient(apiUrl);
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
var request = new RestRequest($"Inventory/{MKeyEnc}?MatCloudId={MatID}", Method.Get);
var response = await client.GetAsync(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
using (RestClient client = new RestClient(rcOptions))
{
// contenuto serializzato
string rawData = $"{response.Content}";
answ = JsonConvert.DeserializeObject<List<MaterialDTO>>(rawData);
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
var request = new RestRequest($"Inventory/{MKeyEnc}?MatCloudId={MatID}", Method.Get);
var response = client.Get(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
// contenuto serializzato
string rawData = $"{response.Content}";
answ = JsonConvert.DeserializeObject<List<MaterialDTO>>(rawData);
}
}
return answ;
}
/// <summary>
/// Versione Async Inventario per materiale
/// </summary>
/// <param name="MatID">Se 0 = tutto</param>
/// <returns></returns>
public async Task<List<MaterialDTO>> InventoryGetAsync(int MatID)
{
List<MaterialDTO> answ = new List<MaterialDTO>();
// cerco online
using (RestClient client = new RestClient(rcOptions))
{
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
var request = new RestRequest($"Inventory/{MKeyEnc}?MatCloudId={MatID}", Method.Get);
var response = await client.GetAsync(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
// 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
/// Invio elenco di RawItems associati ad un singolo materiale, il server farà il merge
/// <param name="rec2send">record da inviare</param>
/// </summary>
public async Task<bool> InventorySend(MaterialDTO rec2send)
public bool InventorySend(List<ItemDTO> rec2send)
{
bool answ = false;
// cerco online
var client = new RestClient(apiUrl);
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
var jsonBody = JsonConvert.SerializeObject(rec2send.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)
using (RestClient client = new RestClient(rcOptions))
{
// contenuto serializzato
string rawData = $"{response.Content}";
answ = rawData == "OK";
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
// impacchetto dati x invio...
RestPayload.Items newPayload = new RestPayload.Items()
{
ItemList = rec2send
};
var jsonBody = JsonConvert.SerializeObject(newPayload);
var request = new RestRequest($"Inventory/upsert/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
var response = client.Post(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
answ = true;
}
else
{
Log.Error($"InventorySend | Response StatusCode: {response.StatusCode} | content: {response.Content}");
}
}
return answ;
}
/// <summary>
/// Versione Async Invio elenco di RawItems associati ad un singolo materiale, il server
/// farà il merge <param name="rec2send">record da inviare</param>
/// </summary>
public async Task<bool> InventorySendAsync(List<ItemDTO> rec2send)
{
bool answ = false;
// cerco online
using (RestClient client = new RestClient(rcOptions))
{
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
// impacchetto dati x invio...
RestPayload.Items newPayload = new RestPayload.Items()
{
ItemList = rec2send
};
var jsonBody = JsonConvert.SerializeObject(newPayload);
var request = new RestRequest($"Inventory/upsert/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
var response = await client.PostAsync(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
answ = true;
}
else
{
Log.Error($"InventorySendAsync | Response StatusCode: {response.StatusCode} | content: {response.Content}");
}
}
return await Task.FromResult(answ);
}
@@ -124,42 +364,109 @@ namespace EgwProxy.MagMan
/// <summary>
/// Elenco Materiali dato RestToken
/// </summary>
public async Task<List<MaterialDTO>> MaterialsGet()
public List<MaterialDTO> MaterialsGet()
{
List<MaterialDTO> answ = new List<MaterialDTO>();
// cerco online
RestClient client = new RestClient(apiUrl);
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
var request = new RestRequest($"Materials/{MKeyEnc}", Method.Get);
var response = await client.GetAsync(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
using (RestClient client = new RestClient(rcOptions))
{
// contenuto serializzato
string rawData = $"{response.Content}";
answ = JsonConvert.DeserializeObject<List<MaterialDTO>>(rawData);
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
var request = new RestRequest($"Materials/{MKeyEnc}", Method.Get);
var response = client.Get(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
// contenuto serializzato
string rawData = $"{response.Content}";
answ = JsonConvert.DeserializeObject<List<MaterialDTO>>(rawData);
}
}
return answ;
}
/// <summary>
/// Versione Async Elenco Materiali dato RestToken
/// </summary>
public async Task<List<MaterialDTO>> MaterialsGetAsync()
{
List<MaterialDTO> answ = new List<MaterialDTO>();
// cerco online
using (RestClient client = new RestClient(rcOptions))
{
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
var request = new RestRequest($"Materials/{MKeyEnc}", Method.Get);
var response = await client.GetAsync(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
// 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
/// Invio elenco (anche parziale) di Materiali, il server farà il merge
/// </summary>
public async Task<bool> MaterialsSend(List<MaterialDTO> List2Merge)
public 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)
using (RestClient client = new RestClient(rcOptions))
{
// contenuto serializzato
string rawData = $"{response.Content}";
answ = rawData == "OK";
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
// impacchetto dati x invio...
RestPayload.Materials newPayload = new RestPayload.Materials()
{
MatList = List2Merge
};
var jsonBody = JsonConvert.SerializeObject(newPayload);
var request = new RestRequest($"Materials/upsert/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
var response = client.Post(request);
Log.Debug($"MaterialsSend | Response StatusCode: {response.StatusCode}");
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
answ = true;
}
else
{
Log.Error($"MaterialsSend | Response StatusCode: {response.StatusCode} | content: {response.Content}");
}
}
return answ;
}
/// <summary>
/// Versione async Invio elenco (anche parziale) di Materiali, il server farà il merge
/// </summary>
public async Task<bool> MaterialsSendAsync(List<MaterialDTO> List2Merge)
{
bool answ = false;
// cerco online
using (RestClient client = new RestClient(rcOptions))
{
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
// impacchetto dati x invio...
RestPayload.Materials newPayload = new RestPayload.Materials()
{
MatList = List2Merge
};
var jsonBody = JsonConvert.SerializeObject(newPayload);
var request = new RestRequest($"Materials/upsert/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
var response = await client.PostAsync(request);
Log.Debug($"MaterialsSendAsync | Response StatusCode: {response.StatusCode}");
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
answ = true;
}
else
{
Log.Error($"MaterialsSendAsync | Response StatusCode: {response.StatusCode} | content: {response.Content}");
}
}
return await Task.FromResult(answ);
}
@@ -167,96 +474,168 @@ namespace EgwProxy.MagMan
/// <summary>
/// Elenco progetti associati a chiave
/// </summary>
/// <param name="MatID">Se 0 = tutto</param>
/// <param name="NumKey">Se 0 = tutto</param>
/// <returns></returns>
public async Task<List<ProjectDTO>> ProjectGet(int NumKey)
public List<ProjectDTO> ProjectGet(int NumKey)
{
List<ProjectDTO> answ = new List<ProjectDTO>();
// cerco online
RestClient client = new RestClient(apiUrl);
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
var request = new RestRequest($"Projects/{MKeyEnc}?KeyNum={NumKey}", Method.Get);
var response = await client.GetAsync(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
using (RestClient client = new RestClient(rcOptions))
{
// contenuto serializzato
string rawData = $"{response.Content}";
answ = JsonConvert.DeserializeObject<List<ProjectDTO>>(rawData);
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
var request = new RestRequest($"Projects/{MKeyEnc}?KeyNum={NumKey}", Method.Get);
var response = client.Get(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
// contenuto serializzato
string rawData = $"{response.Content}";
answ = JsonConvert.DeserializeObject<List<ProjectDTO>>(rawData);
}
}
return answ;
}
/// <summary>
/// Versione Async Elenco progetti associati a chiave
/// </summary>
/// <param name="MatID">Se 0 = tutto</param>
/// <returns></returns>
public async Task<List<ProjectDTO>> ProjectGetAsync(int NumKey)
{
List<ProjectDTO> answ = new List<ProjectDTO>();
// cerco online
using (RestClient client = new RestClient(rcOptions))
{
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
var request = new RestRequest($"Projects/{MKeyEnc}?KeyNum={NumKey}", Method.Get);
var response = await client.GetAsync(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
// contenuto serializzato
string rawData = $"{response.Content}";
answ = JsonConvert.DeserializeObject<List<ProjectDTO>>(rawData);
}
}
return await Task.FromResult(answ);
}
/// <summary>
/// Invia un elenco di RawItems associati ad un singolo materiale, il server farà il merge
/// Record progetto da Key/ID
/// </summary>
/// <param name="ProjCloudId">Se 0 = tutto</param>
/// <returns></returns>
public ProjectDTO ProjectGetSingle(int ProjCloudId)
{
ProjectDTO answ = new ProjectDTO();
// cerco online
using (RestClient client = new RestClient(rcOptions))
{
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
var request = new RestRequest($"Projects/single/{MKeyEnc}?ProjCloudId={ProjCloudId}", Method.Get);
var response = client.Get(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
// contenuto serializzato
string rawData = $"{response.Content}";
answ = JsonConvert.DeserializeObject<ProjectDTO>(rawData);
}
}
return answ;
}
/// <summary>
/// Record progetto da Key/ID
/// </summary>
/// <param name="ProjCloudId">Se 0 = tutto</param>
/// <returns></returns>
public async Task<ProjectDTO> ProjectGetSingleAsync(int ProjCloudId)
{
ProjectDTO answ = new ProjectDTO();
// cerco online
using (RestClient client = new RestClient(rcOptions))
{
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
var request = new RestRequest($"Projects/single/{MKeyEnc}?ProjCloudId={ProjCloudId}", Method.Get);
var response = await client.GetAsync(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
// contenuto serializzato
string rawData = $"{response.Content}";
answ = JsonConvert.DeserializeObject<ProjectDTO>(rawData);
}
}
return await Task.FromResult(answ);
}
/// <summary>
/// Invio record Proj x upsert
/// <param name="rec2send">record da inviare</param>
/// </summary>
public async Task<bool> ProjectSend(ProjectDTO rec2send)
/// <returns>ProjCloudId (essitente o nuovo)</returns>
public int ProjectSend(ProjectDTO rec2send)
{
bool answ = false;
int answ = 0;
// cerco online
var client = new RestClient(apiUrl);
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
var jsonBody = JsonConvert.SerializeObject(rec2send);
var request = new RestRequest($"Projects/upsert/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
var response = await client.PostAsync(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
using (RestClient client = new RestClient(rcOptions))
{
// contenuto serializzato
string rawData = $"{response.Content}";
answ = rawData == "OK";
}
return await Task.FromResult(answ);
}
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
// impacchetto dati x invio...
RestPayload.Projects newPayload = new RestPayload.Projects()
{
Project = rec2send
};
var jsonBody = JsonConvert.SerializeObject(newPayload);
var request = new RestRequest($"Projects/upsert/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
var response = client.Post(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
int.TryParse(response.Content, out answ);
#if false
/// <summary>
/// Elenco risorse STIMATE associate a chiave + progetti
/// </summary>
/// <param name="projDbId">ID DB del progetto</param>
/// <returns></returns>
public async Task<List<ResourceExpDTO>> ResourceConsumedGet(int projDbId)
{
List<ResourceExpDTO> answ = new List<ResourceExpDTO>();
// cerco online
RestClient client = new RestClient(apiUrl);
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
var request = new RestRequest($"Resources/{MKeyEnc}?projDbId={projDbId}&isEstim=false", Method.Get);
var response = await client.GetAsync(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
// contenuto serializzato
string rawData = $"{response.Content}";
answ = JsonConvert.DeserializeObject<List<ResourceExpDTO>>(rawData);
}
else
{
Log.Error($"ProjectSend | Response StatusCode: {response.StatusCode} | content: {response.Content}");
}
}
return await Task.FromResult(answ);
return answ;
}
/// <summary>
/// Elenco risorse STIMATE associate a chiave + progetti
/// Versione async Invio elenco di RawItems associati ad un singolo materiale, il server
/// farà il merge <param name="rec2send">record da inviare</param>
/// </summary>
/// <param name="projDbId">ID DB del progetto</param>
/// <returns></returns>
public async Task<List<ResourceExpDTO>> ResourceEstimateGet(int projDbId)
public async Task<int> ProjectSendAsync(ProjectDTO rec2send)
{
List<ResourceExpDTO> answ = new List<ResourceExpDTO>();
int answ = 0;
// cerco online
RestClient client = new RestClient(apiUrl);
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
var request = new RestRequest($"Resources/{MKeyEnc}?projDbId={projDbId}&isEstim=true", Method.Get);
var response = await client.GetAsync(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
using (RestClient client = new RestClient(rcOptions))
{
// contenuto serializzato
string rawData = $"{response.Content}";
answ = JsonConvert.DeserializeObject<List<ResourceExpDTO>>(rawData);
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
// impacchetto dati x invio...
RestPayload.Projects newPayload = new RestPayload.Projects()
{
Project = rec2send
};
var jsonBody = JsonConvert.SerializeObject(newPayload);
var request = new RestRequest($"Projects/upsert/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
var response = await client.PostAsync(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
int.TryParse(response.Content, out answ);
}
else
{
Log.Error($"ProjectSendAsync | Response StatusCode: {response.StatusCode} | content: {response.Content}");
}
}
return await Task.FromResult(answ);
}
#endif
}
/// <summary>
/// Elenco risorse associate a progetto
@@ -264,55 +643,122 @@ namespace EgwProxy.MagMan
/// <param name="projDbId">ID DB del progetto</param>
/// <param name="isEstim">true = solo stimate/ false = consumi reali</param>
/// <returns></returns>
public async Task<List<ResourceExpDTO>> ResourceGet(int projDbId, bool isEstim)
public List<ResourceExpDTO> ResourceGet(int projDbId, bool isEstim)
{
List<ResourceExpDTO> answ = new List<ResourceExpDTO>();
// cerco online
RestClient client = new RestClient(apiUrl);
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
var request = new RestRequest($"Resources/{MKeyEnc}?projDbId={projDbId}&isEstim={isEstim}", Method.Get);
var response = await client.GetAsync(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
using (RestClient client = new RestClient(rcOptions))
{
// contenuto serializzato
string rawData = $"{response.Content}";
answ = JsonConvert.DeserializeObject<List<ResourceExpDTO>>(rawData);
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
var request = new RestRequest($"Resources/{MKeyEnc}?projDbId={projDbId}&isEstim={isEstim}", Method.Get);
var response = client.Get(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
// contenuto serializzato
string rawData = $"{response.Content}";
answ = JsonConvert.DeserializeObject<List<ResourceExpDTO>>(rawData);
}
}
return answ;
}
/// <summary>
/// Versione async Elenco risorse associate a progetto
/// </summary>
/// <param name="projDbId">ID DB del progetto</param>
/// <param name="isEstim">true = solo stimate/ false = consumi reali</param>
/// <returns></returns>
public async Task<List<ResourceExpDTO>> ResourceGetAsync(int projDbId, bool isEstim)
{
List<ResourceExpDTO> answ = new List<ResourceExpDTO>();
// cerco online
using (RestClient client = new RestClient(rcOptions))
{
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
var request = new RestRequest($"Resources/{MKeyEnc}?projDbId={projDbId}&isEstim={isEstim}", Method.Get);
var response = await client.GetAsync(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
// contenuto serializzato
string rawData = $"{response.Content}";
answ = JsonConvert.DeserializeObject<List<ResourceExpDTO>>(rawData);
}
}
return await Task.FromResult(answ);
}
/// <summary>
/// Invia un elenco di risorse associate ad un progetto
/// Invio elenco di risorse associate ad un progetto
/// </summary>
/// <param name="idxProjDbId">DbId del progetto da inviare</param>
/// <param name="recType">tipo di registrazione da inviare (stima, consumo, ...)</param>
/// <param name="rec2send">record da inviare, se consumo Qty deve essere negativa</param>
/// <returns></returns>
public async Task<bool> ResourceSend(int idxProjDbId, ProjResState recType, List<ResourceDTO> rec2send)
public bool ResourceSend(int idxProjDbId, ProjResState recType, List<ResourceDTO> rec2send)
{
bool answ = false;
// cerco online
var client = new RestClient(apiUrl);
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
// impacchetto dati x invio...
RestPayload.Resources data2send = new RestPayload.Resources()
using (RestClient client = new RestClient(rcOptions))
{
ProjExtDbId = idxProjDbId,
ReqState = recType,
ResourceList = rec2send
};
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
// impacchetto dati x invio...
RestPayload.Resources newPayload = new RestPayload.Resources()
{
ProjCloudId = idxProjDbId,
ReqState = recType,
ResourceList = rec2send
};
var jsonBody = JsonConvert.SerializeObject(newPayload);
var request = new RestRequest($"Resources/track/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
var response = client.Post(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
answ = true;
}
else
{
Log.Error($"ResourceSend | Response StatusCode: {response.StatusCode} | content: {response.Content}");
}
}
return answ;
}
var jsonBody = JsonConvert.SerializeObject(data2send);
var request = new RestRequest($"Projects/Resources/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
var response = await client.PostAsync(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
/// <summary>
/// Versione async Invio elenco di risorse associate ad un progetto
/// </summary>
/// <param name="idxProjDbId">DbId del progetto da inviare</param>
/// <param name="recType">tipo di registrazione da inviare (stima, consumo, ...)</param>
/// <param name="rec2send">record da inviare, se consumo Qty deve essere negativa</param>
/// <returns></returns>
public async Task<bool> ResourceSendAsync(int idxProjDbId, ProjResState recType, List<ResourceDTO> rec2send)
{
bool answ = false;
// cerco online
using (RestClient client = new RestClient(rcOptions))
{
// contenuto serializzato
string rawData = $"{response.Content}";
answ = rawData == "OK";
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
// impacchetto dati x invio...
RestPayload.Resources newPayload = new RestPayload.Resources()
{
ProjCloudId = idxProjDbId,
ReqState = recType,
ResourceList = rec2send
};
var jsonBody = JsonConvert.SerializeObject(newPayload);
var request = new RestRequest($"Resources/track/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
var response = await client.PostAsync(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
answ = true;
}
else
{
Log.Error($"ResourceSendAsync | Response StatusCode: {response.StatusCode} | content: {response.Content}");
}
}
return await Task.FromResult(answ);
}
@@ -326,6 +772,18 @@ namespace EgwProxy.MagMan
/// </summary>
private string apiUrl = $"";
private int callTimeout = 500;
/// <summary>
/// Istanza logger
/// </summary>
private Logger Log = LogManager.GetCurrentClassLogger();
/// <summary>
/// Opzioni standard di chiamata
/// </summary>
private RestClientOptions rcOptions = new RestClientOptions();
/// <summary>
/// Token di chiamata per l'applicazione
/// </summary>
+6
View File
@@ -37,6 +37,9 @@
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.5.0.1\lib\net46\NLog.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>
</Reference>
@@ -44,7 +47,9 @@
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
@@ -77,6 +82,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="DataSyncro.cs" />
<Compile Include="DTO\AliasDTO.cs" />
<Compile Include="DTO\ItemDTO.cs" />
<Compile Include="DTO\MaterialDTO.cs" />
<Compile Include="DTO\ProjectDTO.cs" />
+42 -9
View File
@@ -9,42 +9,75 @@ namespace EgwProxy.MagMan
{
public class RestPayload
{
public class Materials
#region Public Classes
public class Alias
{
#region Public Properties
/// <summary>
/// Elenco materiali x invio POST
/// Elenco decodifica Alias Materiali x invio POST
/// </summary>
public List<MaterialDTO> MatList { get; set; }
public List<AliasDTO> AliasList { get; set; } = new List<AliasDTO>();
#endregion Public Properties
}
#if false
public class Items
{
#region Public Properties
/// <summary>
/// Elenco Items x invio POST
/// </summary>
public List<ItemDTO> ItemList { get; set; }
}
#endif
#endregion Public Properties
}
public class Materials
{
#region Public Properties
/// <summary>
/// Elenco materiali x invio POST
/// </summary>
public List<MaterialDTO> MatList { get; set; }
#endregion Public Properties
}
public class Projects
{
#region Public Properties
public ProjectDTO Project { get; set; }
#endregion Public Properties
}
public class Resources
{
#region Public Properties
/// <summary>
/// ID progetto univoco esterno (da associare a KEY)
/// ID progetto univoco su Cloud
/// </summary>
public int ProjExtDbId { get; set; } = 0;
public int ProjCloudId { 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; }
#endregion Public Properties
}
#endregion Public Classes
}
}
}
+1
View File
@@ -2,6 +2,7 @@
<packages>
<package id="Microsoft.Bcl.AsyncInterfaces" version="7.0.0" targetFramework="net472" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
<package id="NLog" version="5.0.1" 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" />
+21
View File
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MagMan.Core.DTO
{
public class AliasDTO
{
/// <summary>
/// Codice originale (da trasformare)
/// </summary>
public string ValOrig { get; set; } = "";
/// <summary>
/// Codice Alias in cui viene convertito
/// </summary>
public string ValAlias { get; set; } = "";
}
}
+1 -1
View File
@@ -46,7 +46,7 @@ namespace MagMan.Core.DTO
/// <summary>
/// Data di schedulazione (prevista)
/// </summary>
public DateTime DtSchedule { get; set; } = DateTime.Today.AddMonths(3);
public DateTime DtSchedule { get; set; } = DateTime.MinValue;
/// <summary>
/// Data Inizio Produzione
+41 -6
View File
@@ -10,40 +10,75 @@ namespace MagMan.Core
{
public class RestPayload
{
public class Materials
#region Public Classes
public class Alias
{
#region Public Properties
/// <summary>
/// Elenco materiali x invio POST
/// Elenco decodifica Alias Materiali x invio POST
/// </summary>
public List<MaterialDTO>? MatList { get; set; }
public List<AliasDTO> AliasList { get; set; } = new List<AliasDTO>();
#endregion Public Properties
}
public class Items
{
#region Public Properties
/// <summary>
/// Elenco Items x invio POST
/// </summary>
public List<ItemDTO>? ItemList { get; set; }
#endregion Public Properties
}
public class Materials
{
#region Public Properties
/// <summary>
/// Elenco materiali x invio POST
/// </summary>
public List<MaterialDTO>? MatList { get; set; }
#endregion Public Properties
}
public class Projects
{
#region Public Properties
public ProjectDTO? Project { get; set; }
#endregion Public Properties
}
public class Resources
{
#region Public Properties
/// <summary>
/// ID progetto univoco esterno (da associare a KEY) BB / LOCAL
/// ID progetto univoco su cloud
/// </summary>
public int ProjLocalId { get; set; } = 0;
public int ProjCloudId { 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; }
#endregion Public Properties
}
#endregion Public Classes
}
}
}
+54 -23
View File
@@ -31,29 +31,11 @@ namespace MagMan.Core.Services
public event Action EA_SearchUpdated = null!;
public event Action EA_ShowSearch = null!;
public event Action EA_CustomerSel = null!;
public event Action EA_KeySel = null!;
public event Action<bool> EA_ShowCustomers = null!;
#endregion Public Events
#if false
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);
#endif
#region Public Properties
@@ -114,7 +96,23 @@ namespace MagMan.Core.Services
}
}
}
}
}
public int KeyNum
{
get => _keyNum;
set
{
if (_keyNum != value)
{
_keyNum = value;
if (EA_KeySel != null)
{
EA_KeySel?.Invoke();
}
}
}
}
public string SelOrderCode { get; set; } = "";
public string SelPlantId { get; set; } = "0";
@@ -145,6 +143,19 @@ namespace MagMan.Core.Services
}
}
public bool ShowCustomers
{
get => _showCustomers;
set
{
_showCustomers = value;
if (EA_ShowCustomers != null)
{
EA_ShowCustomers?.Invoke(value);
}
}
}
/// <summary>
/// Cliente selezionato (da browser data cache)
/// </summary>
@@ -157,9 +168,27 @@ namespace MagMan.Core.Services
/// <summary>
/// Imposta Cliente selezionato (browser data cache)
/// </summary>
public async Task ClientIdSet(int machSel)
public async Task ClientIdSet(int newVal)
{
await localStore.SetItemAsync("ClientID", machSel);
await localStore.SetItemAsync("ClientID", newVal);
}
/// <summary>
/// KeyNum da cliente selezionato (da browser data cache)
/// </summary>
public async Task<int> KeyNumGet()
{
var answ = await localStore.GetItemAsync<int>("KeyNum");
return answ;
}
/// <summary>
/// Imposta KeyNum da cliente selezionato (browser data cache)
/// </summary>
public async Task KeyNumSet(int newVal)
{
await localStore.SetItemAsync("KeyNum", newVal);
}
#endregion Public Properties
@@ -503,7 +532,9 @@ namespace MagMan.Core.Services
private string _pageName = "";
private string _searchVal = "";
private int _customerID = -1;
private int _keyNum = -1;
private bool _showSearch = false;
private bool _showCustomers = true;
private Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
+2 -15
View File
@@ -45,22 +45,9 @@ namespace MagMan.Data.Admin
for (int i = 0; i < users.Count; i++)
{
#if false
// aggiungo ruoli User ed Admin x tutti
userRoles.Add(new IdentityUserRole<string>
{
UserId = users[i].Id,
RoleId = roles.First(q => q.Name == "User").Id
});
userRoles.Add(new IdentityUserRole<string>
{
UserId = users[i].Id,
RoleId = roles.First(q => q.Name == "Admin").Id
});
#endif
// se nei primi 3 aggiungo anche SuperAdmin
if (i < 3)
// nei primi 3 rendo SuperAdmin
if (i < 2)
{
userRoles.Add(new IdentityUserRole<string>
{
+393 -180
View File
@@ -5,6 +5,7 @@ using MagMan.Data.Tenant.Services;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using NLog;
using NLog.LayoutRenderers;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -26,6 +27,151 @@ namespace MagMan.Data.Tenant.Controllers
#region Public Methods
/// <summary>
/// Elimina Alias da magazzino
/// </summary>
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
/// <param name="rec2del">Alias da eliminare</param>
/// <returns></returns>
public bool AliasDelete(string connString, AliasModel rec2del)
{
bool done = false;
using (MagManContext dbCtx = new MagManContext(connString))
{
try
{
var currData = dbCtx
.DbSetAlias
.Where(x => x.Family == rec2del.Family && x.ValueOriginal == rec2del.ValueOriginal)
.FirstOrDefault();
if (currData != null)
{
dbCtx
.DbSetAlias
.Remove(currData);
dbCtx.SaveChanges();
done = true;
}
}
catch (Exception exc)
{
Log.Error($"Eccezione in AliasDelete{Environment.NewLine}{exc}");
}
}
return done;
}
/// <summary>
/// Elenco Alias gestiti a magazzino data famiglia
/// </summary>
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
/// <param name="family">Famiglia richiesta, "" = tutti</param>
/// <returns></returns>
public List<AliasModel> AliasGetFilt(string connString, string family)
{
List<AliasModel> dbResult = new List<AliasModel>();
using (MagManContext dbCtx = new MagManContext(connString))
{
dbResult = dbCtx
.DbSetAlias
.Where(x => (string.IsNullOrEmpty(family) || x.Family == family))
.OrderBy(x => x.ValueOriginal)
.ToList();
}
return dbResult;
}
/// <summary>
/// Upsert record alias
/// </summary>
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
/// <param name="rec2upd">Record da aggiornare/inserire</param>
/// <returns></returns>
public bool AliasUpsert(string connString, AliasModel rec2upd)
{
bool done = false;
using (MagManContext dbCtx = new MagManContext(connString))
{
try
{
/*
* Ricerca record
*/
var currData = dbCtx
.DbSetAlias
.Where(x => x.Family == rec2upd.Family && x.ValueOriginal.ToLower() == rec2upd.ValueOriginal.ToLower())
.FirstOrDefault();
if (currData != null)
{
if (currData.ValueAlias != rec2upd.ValueAlias)
{
currData.ValueAlias = rec2upd.ValueAlias;
dbCtx.Entry(currData).State = EntityState.Modified;
}
}
else
{
dbCtx
.DbSetAlias
.Add(rec2upd);
}
dbCtx.SaveChanges();
done = true;
}
catch (Exception exc)
{
Log.Error($"Eccezione in AliasUpsert{Environment.NewLine}{exc}");
}
}
return done;
}
/// <summary>
/// Upsert record alias
/// </summary>
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
/// <param name="recList">Lista Record da aggiornare/inserire</param>
/// <returns></returns>
public bool AliasUpsert(string connString, List<AliasModel> recList)
{
bool done = false;
using (MagManContext dbCtx = new MagManContext(connString))
{
try
{
foreach (var rec2upd in recList)
{
var currData = dbCtx
.DbSetAlias
.Where(x => x.Family == rec2upd.Family && x.ValueOriginal.ToLower() == rec2upd.ValueOriginal.ToLower())
.FirstOrDefault();
if (currData != null)
{
if (currData.ValueAlias != rec2upd.ValueAlias)
{
currData.ValueAlias = rec2upd.ValueAlias;
dbCtx.Entry(currData).State = EntityState.Modified;
}
}
else
{
dbCtx
.DbSetAlias
.Add(rec2upd);
}
}
dbCtx.SaveChanges();
done = true;
}
catch (Exception exc)
{
Log.Error($"Eccezione in AliasUpsert{Environment.NewLine}{exc}");
}
}
return done;
}
public async Task<bool> DatabaseMigrate(string connString)
{
bool answ = false;
@@ -62,9 +208,15 @@ namespace MagMan.Data.Tenant.Controllers
.FirstOrDefault();
if (currData != null)
{
dbCtx
.DbSetItems
.Remove(currData);
//dbCtx
// .DbSetItems
// .Remove(currData);
// non vera eliminazione ma logica...
currData.IsActive = false;
// registro modifica RawItem
dbCtx.Entry(currData).State = EntityState.Modified;
dbCtx.SaveChanges();
done = true;
}
@@ -77,19 +229,44 @@ namespace MagMan.Data.Tenant.Controllers
return done;
}
/// <summary>
/// Converte il DTO in ItemModel
/// </summary>
/// <param name="origItem">DTO di partenza</param>
/// <param name="isActive">Parametro active da impostare</param>
/// <returns></returns>
public RawItemModel ItemFromDto(ItemDTO origItem, bool isActive)
{
RawItemModel answ = new RawItemModel()
{
MatId = origItem.MatCloudId,
IsRemn = origItem.IsRemn,
Location = origItem.Location,
QtyAvail = origItem.QtyAvail,
HMm = origItem.HMm,
LMm = origItem.LMm,
WMm = origItem.WMm,
Note = origItem.Note,
IsActive = isActive
};
return answ;
}
/// <summary>
/// Elenco Items gestiti a magazzino (all)
/// </summary>
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
/// <param name="onlyActive">Solo attivi (default) o anche cancellati</param>
/// <returns></returns>
public List<RawItemModel> ItemGetAll(string connString)
public List<RawItemModel> ItemGetAll(string connString, bool onlyActive = true)
{
List<RawItemModel> dbResult = new List<RawItemModel>();
using (MagManContext dbCtx = new MagManContext(connString))
{
dbResult = dbCtx
.DbSetItems
//.Where(x => CustomerId == 0 || x.CustomerID == CustomerId)
.Where(x => x.IsActive || !onlyActive)
.Include(c => c.MaterialNav)
.OrderBy(x => x.MatId)
.ToList();
@@ -102,17 +279,17 @@ namespace MagMan.Data.Tenant.Controllers
/// </summary>
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
/// <param name="matID">ID del materiale x cui filtrare, 0 = tutti</param>
/// <param name="onlyActive">Solo attivi (default) o anche cancellati</param>
/// <returns></returns>
public List<RawItemModel> ItemGetByMat(string connString, int matID)
public List<RawItemModel> ItemGetByMat(string connString, int matID, bool onlyActive = true)
{
List<RawItemModel> dbResult = new List<RawItemModel>();
using (MagManContext dbCtx = new MagManContext(connString))
{
dbResult = dbCtx
.DbSetItems
.Where(x => matID == 0 || x.MatId == matID)
.Where(x => (matID == 0 || x.MatId == matID) && (x.IsActive || !onlyActive))
.Include(c => c.MaterialNav)
//.OrderBy(x => x.MatCloudId)
.OrderBy(x => x.WMm)
.ThenBy(x => x.HMm)
.ThenBy(x => x.LMm)
@@ -121,15 +298,39 @@ 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>
/// <param name="userId">User corrente (SE applicabile)</param>
/// <summary>
/// Elenco Items gestiti a magazzino dato Materiale
/// </summary>
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
/// <param name="QrCode">QrCode/Dtmx cercato</param>
/// <returns></returns>
public bool ItemModQty(string connString, RawItemModel rec2upd, int deltaQty, string userId)
public RawItemModel ItemGetByQr(string connString, string qrCode)
{
RawItemModel? dbResult = new RawItemModel();
using (MagManContext dbCtx = new MagManContext(connString))
{
var rawList = dbCtx
.DbSetItems
.Include(m => m.MaterialNav)
.ToList();
dbResult = rawList
.Where(x => x.ItemDtmx == qrCode)
.FirstOrDefault();
if (dbResult == null)
{
dbResult = new RawItemModel();
}
}
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> <param name="userId">User corrente (SE
/// applicabile)</param> <param name="msgAdd">Messaggio registrato x variazione
/// positiva</param> <param name="msgRem">Messaggio registrato x variazione negativa</param> <returns></returns>
public bool ItemModQty(string connString, RawItemModel rec2upd, int deltaQty, string userId, string msgAdd, string msgRem)
{
bool done = false;
using (MagManContext dbCtx = new MagManContext(connString))
@@ -148,21 +349,28 @@ namespace MagMan.Data.Tenant.Controllers
.FirstOrDefault();
if (currData != null)
{
MovMagModel recMovMag = new MovMagModel()
{
DtRec = DateTime.Now,
RawItemId = rec2upd.RawItemId,
QtyRec = deltaQty,
UserId = userId,
Note = deltaQty > 0 ? "M01+: Rettifica Inventariale" : "M01-: Rettifica Inventariale"
};
dbCtx.DbSetMovMag.Add(recMovMag);
// calcolo variazione
currData.QtyAvail += deltaQty;
dbCtx.Entry(currData).State = EntityState.Modified;
// salvo SOLO SE è >=0,,,
if (currData.QtyAvail >= 0)
{
MovMagModel recMovMag = new MovMagModel()
{
DtRec = DateTime.Now,
RawItemId = rec2upd.RawItemId,
QtyRec = deltaQty,
UserId = userId,
Note = deltaQty > 0 ? msgAdd : msgRem
};
// registro movimento
dbCtx.DbSetMovMag.Add(recMovMag);
// registro modifica RawItem
dbCtx.Entry(currData).State = EntityState.Modified;
// salvo il tutto
dbCtx.SaveChanges();
done = true;
}
}
dbCtx.SaveChanges();
done = true;
}
catch (Exception exc)
{
@@ -172,14 +380,50 @@ namespace MagMan.Data.Tenant.Controllers
return done;
}
/// <summary>
/// Converte lista ItemModel in DTO
/// </summary>
/// <param name="origItem">Elenco ItemModel di partenza</param>
/// <returns></returns>
public List<ItemDTO> ItemsToDto(List<RawItemModel> origItem)
{
List<ItemDTO> answ = answ = origItem.Select(x => ItemToDto(x)).ToList();
return answ;
}
/// <summary>
/// Converte ItemModel in DTO
/// </summary>
/// <param name="origItem">ItemModel di partenza</param>
/// <returns></returns>
public ItemDTO ItemToDto(RawItemModel origItem)
{
ItemDTO answ = new ItemDTO()
{
MatCloudId = origItem.MatId,
RawItemCloudId = origItem.RawItemId,
IsRemn = origItem.IsRemn,
Location = origItem.Location,
QtyAvail = origItem.QtyAvail,
HMm = origItem.HMm,
LMm = origItem.LMm,
WMm = origItem.WMm,
Note = origItem.Note,
ItemDtmx = origItem.ItemDtmx
};
return answ;
}
/// <summary>
/// Aggiunge/Modifica un item in magazzino
/// </summary>
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
/// <param name="rec2upd">Record da aggiungere/aggiornare</param>
/// <param name="userId">User corrente (SE applicabile)</param>
/// <param name="forceQty">Se true aggiorna giacenze quantita correnti</param>
/// <returns></returns>
public bool ItemUpdate(string connString, RawItemModel rec2upd, string userId)
public bool ItemUpdate(string connString, RawItemModel rec2upd, string userId, bool forceQty)
{
bool done = false;
using (MagManContext dbCtx = new MagManContext(connString))
@@ -198,24 +442,30 @@ namespace MagMan.Data.Tenant.Controllers
.FirstOrDefault();
if (currData != null)
{
// aggiungo record variazione quantità...
int delta = rec2upd.QtyAvail - currData.QtyAvail;
if (delta != 0)
// SOLO SE modifico quantità...
if (forceQty)
{
MovMagModel recMovMag = new MovMagModel()
// aggiungo record variazione quantità...
int delta = rec2upd.QtyAvail - currData.QtyAvail;
if (delta != 0)
{
DtRec = DateTime.Now,
RawItemId = rec2upd.RawItemId,
QtyRec = delta,
UserId = userId,
Note = delta > 0 ? "M02+: Rettifica Inventariale" : "M02-: Rettifica Inventariale"
};
dbCtx.DbSetMovMag.Add(recMovMag);
MovMagModel recMovMag = new MovMagModel()
{
DtRec = DateTime.Now,
RawItemId = currData.RawItemId,
//RawItemId = rec2upd.RawItemId,
QtyRec = delta,
UserId = userId,
Note = delta > 0 ? "M02+: Rettifica Inventariale" : "M02-: Rettifica Inventariale"
};
dbCtx.DbSetMovMag.Add(recMovMag);
}
// aggiorno qty registrata
currData.QtyAvail = rec2upd.QtyAvail;
}
// sistemo record...
currData.MatId = rec2upd.MatId;
currData.QtyAvail = rec2upd.QtyAvail;
currData.IsActive = rec2upd.IsActive;
currData.IsRemn = rec2upd.IsRemn;
currData.Location = rec2upd.Location;
@@ -227,20 +477,36 @@ namespace MagMan.Data.Tenant.Controllers
}
else
{
// levo il matNav...
if (rec2upd.MaterialNav != null)
{
dbCtx.Entry(rec2upd.MaterialNav).State = EntityState.Unchanged;
}
// se non FORZA la quantità --> la imposto a zero...
if (!forceQty)
{
rec2upd.QtyAvail = 0;
}
// aggiungo record
dbCtx
.DbSetItems
.Add(rec2upd);
dbCtx.SaveChanges();
// aggiungo record variazione quantità...
MovMagModel recMovMag = new MovMagModel()
// di nuovo registro movimento se va impostata quantità
if (forceQty)
{
DtRec = DateTime.Now,
RawItemId = rec2upd.RawItemId,
QtyRec = rec2upd.QtyAvail,
Note = rec2upd.QtyAvail > 0 ? "M03+: Aggiunta Record" : "M03+: Aggiunta Record"
};
dbCtx.DbSetMovMag.Add(recMovMag);
// aggiungo record variazione quantità...
MovMagModel recMovMag = new MovMagModel()
{
DtRec = DateTime.Now,
RawItemId = rec2upd.RawItemId,
QtyRec = rec2upd.QtyAvail,
Note = rec2upd.QtyAvail > 0 ? "M03+: Aggiunta Record" : "M03+: Aggiunta Record"
};
dbCtx.DbSetMovMag.Add(recMovMag);
}
}
dbCtx.SaveChanges();
done = true;
@@ -312,8 +578,8 @@ namespace MagMan.Data.Tenant.Controllers
HMm = x.HMm,
LMm = x.LMm,
WMm = x.WMm,
SizeNum = x.RawItemList == null ? 0 : x.RawItemList.Count,
QtyTot = x.RawItemList == null ? 0 : x.RawItemList.Sum(r => r.QtyAvail),
SizeNum = x.RawItemList == null ? 0 : x.RawItemList.Where(x => x.IsActive).Count(),
QtyTot = x.RawItemList == null ? 0 : x.RawItemList.Where(x => x.IsActive).Sum(r => r.QtyAvail),
MatDtmx = x.MatDtmx,
IsBeam = x.IsBeam,
IsWall = x.IsWall,
@@ -372,64 +638,6 @@ namespace MagMan.Data.Tenant.Controllers
return dbResult;
}
/// <summary>
/// Converte il DTO in ItemModel
/// </summary>
/// <param name="origItem">DTO di partenza</param>
/// <param name="isActive">Parametro active da impostare</param>
/// <returns></returns>
public RawItemModel ItemFromDto(ItemDTO origItem, bool isActive)
{
RawItemModel answ = new RawItemModel()
{
MatId = origItem.MatCloudId,
IsRemn = origItem.IsRemn,
Location = origItem.Location,
QtyAvail = origItem.QtyAvail,
HMm = origItem.HMm,
LMm = origItem.LMm,
WMm = origItem.WMm,
Note = origItem.Note,
IsActive = isActive
};
return answ;
}
/// <summary>
/// Converte ItemModel in DTO
/// </summary>
/// <param name="origItem">ItemModel di partenza</param>
/// <returns></returns>
public ItemDTO ItemToDto(RawItemModel origItem)
{
ItemDTO answ = new ItemDTO()
{
MatCloudId = origItem.MatId,
RawItemCloudId = origItem.RawItemId,
IsRemn = origItem.IsRemn,
Location = origItem.Location,
QtyAvail = origItem.QtyAvail,
HMm = origItem.HMm,
LMm = origItem.LMm,
WMm = origItem.WMm,
Note = origItem.Note,
ItemDtmx = origItem.ItemDtmx
};
return answ;
}
/// <summary>
/// Converte lista ItemModel in DTO
/// </summary>
/// <param name="origItem">Elenco ItemModel di partenza</param>
/// <returns></returns>
public List<ItemDTO> ItemsToDto(List<RawItemModel> origItem)
{
List<ItemDTO> answ = answ = origItem.Select(x => ItemToDto(x)).ToList();
return answ;
}
/// <summary>
/// Elenco Materiali gestiti a magazzino
/// </summary>
@@ -630,6 +838,29 @@ namespace MagMan.Data.Tenant.Controllers
return dbResult;
}
/// <summary>
/// Record progetto dato cliente e Key (ID)
/// </summary>
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
/// <param name="ProjCloudId">Key del record cercato (&gt;0)</param>
/// <returns></returns>
public ProjModel ProjectGetById(string connString, int ProjCloudId)
{
ProjModel? dbResult = new ProjModel();
using (MagManContext dbCtx = new MagManContext(connString))
{
dbResult = dbCtx
.DbSetProjects
.Where(x => ProjCloudId > 0 && x.ProjDbId == ProjCloudId)
.FirstOrDefault();
if (dbResult == null)
{
dbResult = new ProjModel();
}
}
return dbResult;
}
/// <summary>
/// Elenco progetti dato cliente e macchina
/// </summary>
@@ -651,11 +882,11 @@ namespace MagMan.Data.Tenant.Controllers
}
/// <summary>
/// Elenco Items gestiti a magazzino dato Materiale
/// Elenco progetti dato cliente e macchina + periodo
/// </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>
/// <param name="period">periodo x filtraggio</param>
/// <returns></returns>
public List<ProjModel> ProjectGetFilt(string connString, int numKey, SelectData period)
{
@@ -676,28 +907,28 @@ namespace MagMan.Data.Tenant.Controllers
}
/// <summary>
/// Aggiunge/Modifica un record Project
///Upsert di 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)
/// <returns>ID del progetto creato/aggiornato da usare come CloudId</returns>
public int ProjectUpsert(string connString, ProjModel rec2upd)
{
bool done = false;
int newId = 0;
using (MagManContext dbCtx = new MagManContext(connString))
{
try
{
/*
* Ricerca:
* - DbId corrisponde
* - Key + Id remoti corrispondono
* - DbId corrisponde e > 0...
* [[ RIMOSSO - 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))
.Where(x => (rec2upd.ProjDbId > 0 && x.ProjDbId == rec2upd.ProjDbId))
//.Where(x => (rec2upd.ProjDbId > 0 && x.ProjDbId == rec2upd.ProjDbId) ||
// ((x.ProjExtDbId == rec2upd.ProjExtDbId && x.KeyNum == rec2upd.KeyNum) && (x.ProjExtId == rec2upd.ProjExtId && x.KeyNum == rec2upd.KeyNum)))
.FirstOrDefault();
if (currData != null)
{
@@ -727,14 +958,15 @@ namespace MagMan.Data.Tenant.Controllers
.Add(rec2upd);
}
dbCtx.SaveChanges();
done = true;
// il mio ID è quello originale o appena creato post save...
newId = rec2upd.ProjDbId;
}
catch (Exception exc)
{
Log.Error($"Eccezione in ItemUpdate{Environment.NewLine}{exc}");
Log.Error($"Eccezione in ProjectUpsert{Environment.NewLine}{exc}");
}
}
return done;
return newId;
}
/// <summary>
@@ -770,11 +1002,11 @@ namespace MagMan.Data.Tenant.Controllers
else
{
// se NON di consumo prima rendo disattivi altri....
if (rec2upd.ReqState > Core.Enums.ProjResState.Consumed)
if (rec2upd.ReqState > Enums.ProjResState.Consumed)
{
var rec2disable = dbCtx
.DbSetReqPlan
.Where(x => x.IsActive && x.ProjDbId == rec2upd.ProjDbId && x.ReqState > Core.Enums.ProjResState.Consumed)
.Where(x => x.IsActive && x.ProjDbId == rec2upd.ProjDbId && x.ReqState > Enums.ProjResState.Consumed)
.ToList();
if (rec2disable != null)
{
@@ -893,16 +1125,33 @@ namespace MagMan.Data.Tenant.Controllers
}
return dbResult;
}
/// <summary>
/// Converte il DTO in ResourceModel
/// </summary>
/// <param name="origItem">DTO di partenza</param>
/// <returns></returns>
public ResourceModel ResourceFromDto(ResourceDTO origItem, int reqId)
{
ResourceModel answ = new ResourceModel()
{
Qty = origItem.Qty,
RawItemId = origItem.RawItemCloudId,
RequestId = reqId,
ResourceId = 0
};
return answ;
}
/// <summary>
/// Aggiunge/Modifica un elenco di Resource (+ eventuali update giacenze)
/// </summary>
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
/// <param name="requestPlanId">Key della richiesta di riferimento</param>
/// <param name="recList">Elenco record da aggiungere/aggiornare</param>
/// <param name="resState">Tipo di aggiornamento da registratre</param>
/// <param name="userId">User corrente (SE applicabile)</param>
/// <param name="noteUid">User corrente (SE applicabile)</param>
/// <returns></returns>
public int ResourceUpdate(string connString, List<ResourceModel> recList, Enums.ProjResState resState, string userId)
public int ResourceUpdate(string connString, int requestPlanId, List<ResourceDTO> recList, Enums.ProjResState resState, string noteUid)
{
int numMod = 0;
using (MagManContext dbCtx = new MagManContext(connString))
@@ -911,61 +1160,25 @@ namespace MagMan.Data.Tenant.Controllers
{
foreach (var rec2upd in recList)
{
/*
* Ricerca x Id corrispondente
* */
var currData = dbCtx
.DbSetResources
.Where(x => rec2upd.ResourceId > 0 && x.ResourceId == rec2upd.ResourceId)
.FirstOrDefault();
// aggiorno
if (currData != null)
if (resState == Enums.ProjResState.Consumed)
{
if (resState == Enums.ProjResState.Consumed)
// aggiungo record variazione quantità...
MovMagModel recMovMag = new MovMagModel()
{
// aggiungo record variazione quantità...
int delta = rec2upd.Qty - currData.Qty;
if (delta != 0)
{
MovMagModel recMovMag = new MovMagModel()
{
DtRec = DateTime.Now,
RawItemId = rec2upd.RawItemId,
QtyRec = delta,
UserId = userId,
Note = delta > 0 ? "M04+: Aggiunta Risorsa" : "M04-: Consumo Risorsa"
};
dbCtx.DbSetMovMag.Add(recMovMag);
}
}
// aggiorno le risorse
currData.Qty = rec2upd.Qty;
currData.RawItemId = rec2upd.RawItemId;
dbCtx.Entry(currData).State = EntityState.Modified;
DtRec = DateTime.Now,
RawItemId = rec2upd.RawItemCloudId,
QtyRec = rec2upd.Qty,
UserId = noteUid,
Note = rec2upd.Qty > 0 ? "M05+: Aggiunta Risorsa" : "M05-: Consumo Risorsa"
};
dbCtx.DbSetMovMag.Add(recMovMag);
}
else
{
if (resState == Enums.ProjResState.Consumed)
{
// aggiungo record variazione quantità...
MovMagModel recMovMag = new MovMagModel()
{
DtRec = DateTime.Now,
RawItemId = rec2upd.RawItemId,
QtyRec = rec2upd.Qty,
UserId = userId,
Note = rec2upd.Qty > 0 ? "M05+: Aggiunta Risorsa" : "M05-: Consumo Risorsa"
};
dbCtx.DbSetMovMag.Add(recMovMag);
}
// aggiungo record
dbCtx
.DbSetResources
.Add(rec2upd);
}
// aggiungo record
dbCtx
.DbSetResources
.Add(ResourceFromDto(rec2upd, requestPlanId));
// se si tratta di consumo --> aggiorno giacenze!
if (resState == Enums.ProjResState.Consumed)
{
@@ -973,7 +1186,7 @@ namespace MagMan.Data.Tenant.Controllers
var recGiac = dbCtx
.DbSetItems
.Where(x => x.RawItemId == rec2upd.RawItemId)
.Where(x => x.RawItemId == rec2upd.RawItemCloudId)
.FirstOrDefault();
if (recGiac != null)
{
+2 -2
View File
@@ -24,10 +24,10 @@ namespace MagMan.Data.Tenant
#region Public Methods
public static async Task<bool> migrateDbMain()
public static async Task<bool> migrateDbMain(string connString)
{
bool answ = false;
using (MagManContext dbCtx = new MagManContext())
using (MagManContext dbCtx = new MagManContext(connString))
{
await dbCtx.Database.MigrateAsync();
answ = true;
+2 -2
View File
@@ -36,10 +36,10 @@ namespace MagMan.Data.Tenant
return $"server={server};port=3306;database={dbName};uid={DATABASE_USER};pwd={DATABASE_PWD};sslmode=None";
}
public static bool ExecMigrationMain()
public static bool ExecMigrationMain(string connString)
{
// esecuzione migrazione
var migrateTask = Task.Run(async () => await DbAdmin.migrateDbMain());
var migrateTask = Task.Run(async () => await DbAdmin.migrateDbMain(connString));
migrateTask.Wait();
return migrateTask.Result;
}
+25
View File
@@ -5,6 +5,7 @@ using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MagMan.Data.Tenant.Services;
namespace MagMan.Data.Tenant.DbModels
{
@@ -28,5 +29,29 @@ namespace MagMan.Data.Tenant.DbModels
/// Codice Alias in cui viene convertito
/// </summary>
public string ValueAlias { get; set; } = "";
public override bool Equals(object? obj)
{
if (obj == null)
return false;
if (!(obj is AliasModel item))
return false;
if (Family != item.Family)
return false;
if (ValueOriginal != item.ValueOriginal)
return false;
if (ValueAlias != item.ValueAlias)
return false;
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
}
+1 -1
View File
@@ -32,7 +32,7 @@ namespace MagMan.Data.Tenant.DbModels
public int QtyAvail { get; set; } = 0;
/// <summary>
/// Check if is a Remnant
/// Active, for logical delete...
/// </summary>
public bool IsActive { get; set; } = false;
+1 -7
View File
@@ -49,9 +49,6 @@ namespace MagMan.Data.Tenant
public virtual DbSet<MovMagModel> DbSetMovMag { get; set; } = null!;
#if false
public virtual DbSet<PrintJobQueueModel> DbSetPrintJob { get; set; } = null!;
#endif
private string connString = "";
@@ -70,9 +67,6 @@ namespace MagMan.Data.Tenant
{
if (!optionsBuilder.IsConfigured)
{
#if DEBUG
connString = "Server=localhost;port=3306;database=MagMan_000470;uid=MagMan_DbUser;pwd=viad@nte16!;sslmode=None;";
#endif
var serverVersion = ServerVersion.AutoDetect(connString);
optionsBuilder.UseMySql(connString, serverVersion);
}
@@ -92,7 +86,7 @@ namespace MagMan.Data.Tenant
});
modelBuilder.Entity<AliasModel>()
.HasKey(c => new { c.Family, c.ValueOriginal});
.HasKey(c => new { c.Family, c.ValueOriginal });
modelBuilder.Seed();
+315 -26
View File
@@ -2,6 +2,7 @@
using MagMan.Core.DTO;
using MagMan.Data.Tenant.Controllers;
using MagMan.Data.Tenant.DbModels;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using NLog;
@@ -11,6 +12,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection.PortableExecutable;
using System.Runtime;
using System.Text;
using System.Text.RegularExpressions;
@@ -55,6 +57,155 @@ namespace MagMan.Data.Tenant.Services
#region Public Methods
/// <summary>
/// Elimina Alias da magazzino + refresh cache
/// </summary>
/// <param name="nKey">Key di riferimento</param>
/// <param name="rec2del">Alias da eliminare</param>
/// <returns></returns>
public async Task<bool> AliasDelete(int nKey, AliasModel rec2del)
{
bool fatto = false;
string cString = ConnString(nKey);
try
{
fatto = dbController.AliasDelete(cString, rec2del);
if (fatto)
{
await FlushRedisCache();
}
}
catch (Exception exc)
{
Log.Error($"Error during AliasDelete:{Environment.NewLine}{exc}");
}
return fatto;
}
/// <summary>
/// Converte il DTO in AliasModel
/// </summary>
/// <param name="origItem"></param>
/// <returns></returns>
public AliasModel AliasFromDto(AliasDTO origItem, string family)
{
AliasModel answ = new AliasModel()
{
Family = family,
ValueOriginal = origItem.ValOrig,
ValueAlias = origItem.ValAlias
};
return answ;
}
/// <summary>
/// Lista Alias gestiti a magazzino
/// </summary>
/// <param name="nKey">Key di riferimento</param>
/// <param name="family">Famiglia richiesta, "" = tutti</param>
/// <returns></returns>
public async Task<List<AliasModel>> AliasGetFilt(int nKey, string family)
{
string source = "DB";
string cString = ConnString(nKey);
List<AliasModel>? dbResult = new List<AliasModel>();
try
{
string dType = string.IsNullOrEmpty(family) ? "***" : family;
string currKey = $"{Const.rKeyConfig}:{nKey}:Alias:{dType}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
if (!string.IsNullOrEmpty(rawData))
{
source = "REDIS";
var tempResult = JsonConvert.DeserializeObject<List<AliasModel>>(rawData);
if (tempResult == null)
{
dbResult = new List<AliasModel>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbController.AliasGetFilt(cString, family);
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, LongCache);
// per evitare loopback uso deserialize...
var tempResult = JsonConvert.DeserializeObject<List<AliasModel>>(rawData);
if (tempResult != null)
{
dbResult = tempResult;
}
}
if (dbResult == null)
{
dbResult = new List<AliasModel>();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"AliasGetFilt | {source} in: {ts.TotalMilliseconds} ms");
}
catch (Exception exc)
{
Log.Error($"Error during AliasGetFilt:{Environment.NewLine}{exc}");
}
return dbResult;
}
/// <summary>
/// Update record Alias + refresh cache
/// </summary>
/// <param name="nKey">Key di riferimento</param>
/// <param name="currItem">Item da aggiornare/inserire</param>
/// <returns></returns>
public async Task<bool> AliasUpsert(int nKey, AliasModel currItem)
{
bool fatto = false;
string cString = ConnString(nKey);
try
{
fatto = dbController.AliasUpsert(cString, currItem);
if (fatto)
{
await FlushRedisCache();
}
}
catch (Exception exc)
{
Log.Error($"Error during AliasUpsert:{Environment.NewLine}{exc}");
}
return fatto;
}
/// <summary>
/// Update lista Alias + refresh cache
/// </summary>
/// <param name="nKey">Key di riferimento</param>
/// <param name="listItem">Elenco Item da aggiornare/inserire</param>
/// <returns></returns>
public async Task<bool> AliasUpsert(int nKey, List<AliasModel> listItem)
{
bool fatto = false;
string cString = ConnString(nKey);
try
{
fatto = dbController.AliasUpsert(cString, listItem);
if (fatto)
{
await FlushRedisCache();
}
}
catch (Exception exc)
{
Log.Error($"Error during AliasUpsert:{Environment.NewLine}{exc}");
}
return fatto;
}
/// <summary>
/// Elimina Item da magazzino + refresh cache
/// </summary>
@@ -80,6 +231,27 @@ namespace MagMan.Data.Tenant.Services
return fatto;
}
/// <summary>
/// Converte il DTO in ItemModel, colmando eventuale mancante nelle note dell'item
/// </summary>
/// <param name="origItem">DTO di partenza</param>
/// <param name="isActive">Parametro active da impostare</param>
/// <param name="nKey">Key di riferimento</param>
/// <returns></returns>
public RawItemModel ItemFromDto(ItemDTO origItem, bool isActive, int nKey)
{
RawItemModel answ = ItemFromDto(origItem, isActive);
if(string.IsNullOrEmpty(answ.Note))
{
string cString = ConnString(nKey);
var matRec = dbController.MaterialGetFilt(cString, origItem.MatCloudId, false).FirstOrDefault();
if (matRec != null)
{
answ.Note = matRec.MatDesc;
}
}
return answ;
}
/// <summary>
/// Converte il DTO in ItemModel
/// </summary>
@@ -159,15 +331,17 @@ namespace MagMan.Data.Tenant.Services
/// </summary>
/// <param name="nKey">Key di riferimento</param>
/// <param name="matID">ID del materiale x cui filtrare, 0 = tutti</param>
/// <param name="onlyActive">Solo attivi (default) o anche cancellati</param>
/// <returns></returns>
public async Task<List<RawItemModel>> ItemGetByMat(int nKey, int matID)
public async Task<List<RawItemModel>> ItemGetByMat(int nKey, int matID, bool onlyActive)
{
string source = "DB";
string cString = ConnString(nKey);
List<RawItemModel>? dbResult = new List<RawItemModel>();
try
{
string currKey = $"{Const.rKeyConfig}:{nKey}:ItemList:{matID}";
string keyAct = onlyActive ? "ACT" : "ALL";
string currKey = $"{Const.rKeyConfig}:{nKey}:ItemList:{matID}:{keyAct}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
@@ -186,7 +360,7 @@ namespace MagMan.Data.Tenant.Services
}
else
{
dbResult = dbController.ItemGetByMat(cString, matID);
dbResult = dbController.ItemGetByMat(cString, matID, onlyActive);
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, LongCache);
}
@@ -205,20 +379,81 @@ namespace MagMan.Data.Tenant.Services
return dbResult;
}
/// <summary>
/// Ricerca item da QrCode
/// </summary>
/// <param name="nKey">Key di riferimento</param>
/// <param name="QrCode">QrCode/Dtmx cercato</param>
/// <returns></returns>
public async Task<RawItemModel> ItemGetByQr(int nKey, string QrCode)
{
RawItemModel? dbResult = new RawItemModel();
string cacheKey = $"{Const.rKeyConfig}:{nKey}:{QrCode}";
string source = "DB";
string cString = ConnString(nKey);
try
{
string currKey = $"{Const.rKeyConfig}:{nKey}:ItemByQr:{QrCode}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
if (!string.IsNullOrEmpty(rawData))
{
source = "REDIS";
var tempResult = JsonConvert.DeserializeObject<RawItemModel>(rawData);
if (tempResult == null)
{
dbResult = new RawItemModel();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbController.ItemGetByQr(cString, QrCode);
if (dbResult != null && dbResult.ItemDtmx.ToUpper() == QrCode.ToUpper())
{
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, LongCache);
}
}
if (dbResult == null)
{
dbResult = new RawItemModel();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"ItemGetByQr | {source} in: {ts.TotalMilliseconds} ms");
}
catch (Exception exc)
{
Log.Error($"Error during ItemGetByQr:{Environment.NewLine}{exc}");
}
return dbResult;
}
/// <summary>
/// Update record Item per quantità + refresh cache
/// </summary>
/// <param name="nKey">Key di riferimento</param>
/// <param name="currItem">Item interesato</param>
/// <param name="userId">User corrente (SE applicabile)</param>
/// <param name="msgAdd">
/// Messaggio registrato x variazione positiva (def: M01+: Rettifica Inventariale)
/// </param>
/// <param name="msgRem">
/// Messaggio registrato x variazione negativa (def: M01-: Rettifica Inventariale)
/// </param>
/// <returns></returns>
public async Task<bool> ItemModQty(int nKey, RawItemModel currItem, int deltaQty, string userId)
public async Task<bool> ItemModQty(int nKey, RawItemModel currItem, int deltaQty, string userId, string msgAdd = "M01+: Rettifica Inventariale", string msgRem = "M01-: Rettifica Inventariale")
{
bool fatto = false;
string cString = ConnString(nKey);
try
{
fatto = dbController.ItemModQty(cString, currItem, deltaQty, userId);
fatto = dbController.ItemModQty(cString, currItem, deltaQty, userId, msgAdd, msgRem);
if (fatto)
{
await FlushRedisCache();
@@ -237,14 +472,15 @@ namespace MagMan.Data.Tenant.Services
/// <param name="nKey">Key di riferimento</param>
/// <param name="currItem">Item interesato</param>
/// <param name="userId">User corrente (SE applicabile)</param>
/// <param name="forceQty">Se true aggiorna giacenze quantita correnti</param>
/// <returns></returns>
public async Task<bool> ItemUpdate(int nKey, RawItemModel currItem, string userId)
public async Task<bool> ItemUpdate(int nKey, RawItemModel currItem, string userId, bool forceQty)
{
bool fatto = false;
string cString = ConnString(nKey);
try
{
fatto = dbController.ItemUpdate(cString, currItem, userId);
fatto = dbController.ItemUpdate(cString, currItem, userId, forceQty);
if (fatto)
{
await FlushRedisCache();
@@ -404,16 +640,27 @@ namespace MagMan.Data.Tenant.Services
/// </summary>
/// <param name="origItem"></param>
/// <returns></returns>
public MaterialModel? MaterialFromDto(MaterialDTO? origItem)
public MaterialModel MaterialFromDto(MaterialDTO origItem)
{
MaterialModel? answ = null;
MaterialModel answ = new MaterialModel();
// calcolo descrizione se fosse vuota
string matDescr = origItem.MatDesc;
if (string.IsNullOrEmpty(origItem.MatDesc))
{
matDescr = origItem.MatCode;
if (origItem.WMm > 0)
{
matDescr += $" {origItem.WMm}";
}
matDescr += $"x{origItem.HMm}";
}
if (origItem != null)
{
answ = new MaterialModel()
{
MatId = origItem.MatCloudId,
MatCode = origItem.MatCode,
MatDesc = origItem.MatDesc,
MatDesc = matDescr,
LMm = origItem.LMm,
WMm = origItem.WMm,
HMm = origItem.HMm
@@ -569,7 +816,7 @@ namespace MagMan.Data.Tenant.Services
/// Update record Materiale + refresh cache
/// </summary>
/// <param name="nKey">Key di riferimento</param>
/// <param name="currItem"></param>
/// <param name="currItem">Item da aggiornare/inserire</param>
/// <returns></returns>
public async Task<bool> MaterialUpdate(int nKey, MaterialModel currItem)
{
@@ -678,10 +925,11 @@ namespace MagMan.Data.Tenant.Services
{
ProjModel answ = new ProjModel()
{
MachineID = origItem.MachineCloudId,
KeyNum = origItem.KeyNum,
ProjDbId = origItem.ProjCloudId,
ProjExtDbId = origItem.ProjLocalId,
ProjExtId = origItem.ProjExtId,
MachineID = origItem.MachineCloudId,
KeyNum = origItem.KeyNum,
BTLFileName = origItem.BTLFileName,
PType = origItem.PType,
Machine = origItem.Machine,
@@ -750,6 +998,47 @@ namespace MagMan.Data.Tenant.Services
return dbResult;
}
/// <summary>
/// Record progetto dato cliente e Key (ID)
/// </summary>
/// <param name="nKey">Key di riferimento</param>
/// <param name="ProjCloudId">Key del record cercato (&gt;0)</param>
/// <returns></returns>
public async Task<ProjModel> ProjectGetById(int nKey, int ProjCloudId)
{
string source = "DB";
string cString = ConnString(nKey);
ProjModel dbResult = new ProjModel();
ProjModel? tempResult = null;
try
{
string currKey = $"{Const.rKeyConfig}:{nKey}:ProjRec:{ProjCloudId}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
if (!string.IsNullOrEmpty(rawData))
{
source = "REDIS";
tempResult = JsonConvert.DeserializeObject<ProjModel>(rawData);
}
else
{
tempResult = dbController.ProjectGetById(cString, ProjCloudId);
rawData = JsonConvert.SerializeObject(tempResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, LongCache);
}
dbResult = tempResult == null ? new ProjModel() : tempResult;
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"ProjectGetById | {source} in: {ts.TotalMilliseconds} ms");
}
catch (Exception exc)
{
Log.Error($"Error during ProjectGetById:{Environment.NewLine}{exc}");
}
return dbResult;
}
/// <summary>
/// Lista progetti x macchina
/// </summary>
@@ -834,28 +1123,28 @@ namespace MagMan.Data.Tenant.Services
}
/// <summary>
/// Update record Item + refresh cache
/// Upsert 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)
/// <returns>ID del progetto creato/aggiornato da usare come CloudId</returns>
public async Task<int> ProjectUpsert(int nKey, ProjModel currItem)
{
bool fatto = false;
int prjCloudId = 0;
string cString = ConnString(nKey);
try
{
fatto = dbController.ProjectUpdate(cString, currItem);
if (fatto)
prjCloudId = dbController.ProjectUpsert(cString, currItem);
if (prjCloudId > 0)
{
await FlushRedisCache();
}
}
catch (Exception exc)
{
Log.Error($"Error during ProjectUpdate:{Environment.NewLine}{exc}");
Log.Error($"Error during ProjectUpsert:{Environment.NewLine}{exc}");
}
return fatto;
return prjCloudId;
}
/// <summary>
@@ -1015,18 +1304,18 @@ namespace MagMan.Data.Tenant.Services
/// Aggiunge/Modifica un record Resource
/// </summary>
/// <param name="nKey">Key di riferimento</param>
/// <param name="requestPlanId">Key della richiesta di riferimento</param>
/// <param name="recList">Elenco record da aggiungere/aggiornare</param>
/// &gt;
/// <param name="resState">Tipo di aggiornamento da registratre</param>
/// <param name="userId">User corrente (SE applicabile)</param>
/// <param name="noteUid">Note / UserId (SE applicabile)</param>
/// <returns></returns>
public async Task<int> ResourceUpdate(int nKey, List<ResourceModel> recList, Enums.ProjResState resState, string userId)
public async Task<int> ResourceUpdate(int nKey, int requestPlanId, List<ResourceDTO> recList, Enums.ProjResState resState, string noteUid)
{
int newId = 0;
string cString = ConnString(nKey);
try
{
newId = dbController.ResourceUpdate(cString, recList, resState, userId);
newId = dbController.ResourceUpdate(cString, requestPlanId, recList, resState, noteUid);
if (newId > 0)
{
await FlushRedisCache();
@@ -1077,7 +1366,7 @@ namespace MagMan.Data.Tenant.Services
// verifico eventuale creazione/migrazione...
DbConfig.InitDb(DbServerAddr, nKey);
// verifico se serve applicazione migrazioni
DbConfig.ExecMigrationMain();
DbConfig.ExecMigrationMain(answ);
// aggiungo a LUT
ConnStringLUT.Add(nKey, answ);
}
+18
View File
@@ -0,0 +1,18 @@
@if (CurrRecord != null)
{
<div class="row g-1">
<div class="col-md-12">
<div class="input-group">
<div class="form-floating">
<input type="text" class="form-control" @bind="@CurrRecord.ValueOriginal">
<label class="small">Valore Originale</label>
</div>
<div class="form-floating">
<input type="text" class="form-control" @bind="@CurrRecord.ValueAlias">
<label class="small">Valore Alias</label>
</div>
<button class="btn btn-success" @onclick="() => DoSave()"><i class="fa-solid fa-floppy-disk"></i> Save</button>
</div>
</div>
</div>
}
+55
View File
@@ -0,0 +1,55 @@
using MagMan.Data.Admin.DbModels;
using MagMan.Data.Admin.Services;
using MagMan.Data.Tenant.DbModels;
using MagMan.Data.Tenant.Services;
using Microsoft.AspNetCore.Components;
namespace MagMan.UI.Components
{
public partial class AliasEdit
{
#region Public Properties
[Parameter]
public AliasModel? CurrRecord { get; set; } = null;
[Parameter]
public EventCallback<bool> EC_update { get; set; }
[Parameter]
public int KeyNum { get; set; } = 0;
#endregion Public Properties
#region Protected Properties
[Inject]
protected TenantService TService { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected async Task DoCancel()
{
await EC_update.InvokeAsync(true);
}
protected async Task DoSave()
{
bool fatto = false;
await Task.Delay(1);
if (CurrRecord != null)
{
fatto = await TService.AliasUpsert(KeyNum, CurrRecord);
}
if (fatto)
{
await EC_update.InvokeAsync(true);
}
}
#endregion Protected Methods
}
}
+91
View File
@@ -0,0 +1,91 @@
<div class="card">
<div class="card-header">
<div class="d-flex justify-content-between">
<div class="px-2">
<h3>Alias Materiali</h3>
</div>
<div class="px-2">
@if (CurrItem == null)
{
<button class="btn btn-success px-3" @onclick="()=>CreateNew()"><i class="fa-solid fa-square-plus"></i> Add New</button>
}
else
{
<button class="btn btn-warning px-5" @onclick="()=> ForceReload(true)"><i class="fa-solid fa-ban"></i> Cancel</button>
}
</div>
</div>
@if (CurrItem != null)
{
<hr />
<AliasEdit CurrRecord="CurrItem" KeyNum="@KeyNum" EC_update="ForceReload"></AliasEdit>
}
</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="() => ForceReload(true)"><i class="fa-solid fa-rotate"></i></button>
</th>
<th>Valore Originale (file) <Sorter ParamName="ValOrig" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
<th>Valore Alias (magazzino) <Sorter ParamName="ValOrig" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
<AuthorizeView Roles="SuperAdmin, Admin">
<Authorized>
<th></th>
</Authorized>
</AuthorizeView>
</tr>
</thead>
<tbody>
@foreach (var item in ListRecords)
{
<tr class="align-middle @CheckSel(item)">
<td>
@if (CurrItem == null)
{
@* <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="() => DoSelect(item)"><i class="fa-solid fa-edit"></i></button>
}
else
{
<button class="btn btn-secondary btn-sm" disabled><i class="fa-solid fa-search"></i></button>
<button class="btn btn-secondary btn-sm" disabled><i class="fa-solid fa-edit"></i></button>
}
</td>
<td>
@item.ValueOriginal
</td>
<td>
@item.ValueAlias
</td>
<AuthorizeView Roles="SuperAdmin, Admin">
<Authorized>
<td class="text-end">
<button class="btn btn-danger btn-sm" @onclick="() => DeleteRecord(item)"><i class="fa-solid fa-trash"></i></button>
</td>
</Authorized>
</AuthorizeView>
</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>
+231
View File
@@ -0,0 +1,231 @@
using EgwCoreLib.Razor;
using MagMan.Core.DTO;
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 AliasMan : IDisposable
{
#region Public Properties
[Parameter]
public int CustomerId { get; set; } = 0;
[Parameter]
public EventCallback<MaterialModel?> E_MaterialSel { get; set; }
[Parameter]
public int KeyNum { get; set; } = 0;
#endregion Public Properties
#region Public Methods
public void Dispose()
{
AppMService.EA_SearchUpdated -= AppMService_EA_SearchUpdated;
}
#endregion Public Methods
#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(AliasModel curItem)
{
string answ = curItem.Equals(CurrItem) ? "table-info" : "";
return answ;
}
protected async Task CreateNew()
{
string dtCode = $"{DateTime.Now:yyMMdd_HHmmss}";
CurrItem = new AliasModel()
{
Family="MatCode",
ValueOriginal = $"Orig_{dtCode}",
ValueAlias= $"Alias_{dtCode}"
};
await InvokeAsync(StateHasChanged);
}
protected async Task DeleteRecord(AliasModel selItem)
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler eliminare il record?"))
return;
if (selItem != null)
{
bool fatto = await TService.AliasDelete(KeyNum, selItem);
}
await ReloadData();
}
protected void DoSelect(AliasModel? editRec)
{
CurrItem = editRec;
}
protected async Task ForceReload(bool force)
{
DoSelect(null);
await ReloadData();
}
protected override void OnInitialized()
{
currSearch = "";
AppMService.EA_SearchUpdated += AppMService_EA_SearchUpdated;
}
protected override async Task OnParametersSetAsync()
{
await ReloadData();
}
protected void SetNumRec(int newNum)
{
numRecord = newNum;
currPage = 1;
InvokeAsync(ReloadData);
}
protected void SetPage(int newNum)
{
currPage = newNum;
DoSelect(null);
InvokeAsync(ReloadData);
}
protected async Task SortRequested(Sorter.SortCallBack e)
{
sortField = e.ParamName;
sortAsc = e.IsAscending;
await ReloadData();
}
#endregion Protected Methods
#region Private Fields
private AliasModel? CurrItem = null;
private string currSearch = "";
private int filtType = 0;
private List<AliasModel>? ListRecords = null;
private int MaterialId = 0;
private List<AliasModel>? SearchRecords = null;
private bool sortAsc = true;
private string sortField = "";
#endregion Private Fields
#region Private Properties
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 void AppMService_EA_SearchUpdated()
{
currSearch = AppMService.SearchVal;
await ReloadData();
}
private async Task ReloadData()
{
isLoading = true;
await InvokeAsync(StateHasChanged);
ListRecords = null;
SearchRecords = await TService.AliasGetFilt(KeyNum, "MatCode");
// verifico filtro per ricerca
if (!string.IsNullOrEmpty(currSearch))
{
SearchRecords = SearchRecords.Where(x => x.ValueAlias.Contains(currSearch, StringComparison.InvariantCultureIgnoreCase) || x.ValueOriginal.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 "ValOrig":
if (sortAsc)
{
SearchRecords = SearchRecords.OrderBy(x => x.ValueOriginal).ToList();
}
else
{
SearchRecords = SearchRecords.OrderByDescending(x => x.ValueOriginal).ToList();
}
break;
case "ValAlias":
if (sortAsc)
{
SearchRecords = SearchRecords.OrderBy(x => x.ValueAlias).ToList();
}
else
{
SearchRecords = SearchRecords.OrderByDescending(x => x.ValueAlias).ToList();
}
break;
default:
break;
}
}
// filtro x display
ListRecords = SearchRecords
.Skip(numRecord * (currPage - 1))
.Take(numRecord)
.ToList();
}
else
{
ListRecords = new List<AliasModel>();
}
}
#endregion Private Methods
}
}
+19 -7
View File
@@ -1,13 +1,25 @@
<div class="input-group input-group-sm">
<label class="input-group-text">Cliente</label>
<select class="form-select" @bind="@CustomerID">
<option value="0">--- Selezionare Cliente ---</option>
@* <label class="input-group-text">Cliente</label> *@
<select class="form-select form-select-sm" @bind="@CustomerID" disabled="@selDisabled">
<option value="0">--- Sel. Cliente ---</option>
@if (CustomersList != null)
{
@foreach (var item in CustomersList)
{
<option value="@item.CustomerID">@item.Name [@item.CustomerID]</option>
}
<AuthorizeView Roles="SuperAdmin, Admin">
<Authorized>
@foreach (var item in CustomersList)
{
<option value="@item.CustomerID">@item.Name [@item.CustomerID/@item.MainKey]</option>
}
</Authorized>
</AuthorizeView>
<AuthorizeView Roles="User">
<Authorized>
@foreach (var item in CustomersList)
{
<option value="@item.CustomerID">@item.Name [@item.CustomerID]</option>
}
</Authorized>
</AuthorizeView>
}
</select>
</div>
+73 -1
View File
@@ -1,7 +1,9 @@
using k8s.KubeConfigModels;
using MagMan.Core.Services;
using MagMan.Data.Admin.DbModels;
using MagMan.Data.Admin.Services;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
namespace MagMan.UI.Components
{
@@ -21,15 +23,31 @@ namespace MagMan.UI.Components
{
customerID = value;
InvokeAsync(() => AppMService.ClientIdSet(value));
// gestione KeyNum
if (CustomersList != null)
{
var currRec = CustomersList.Find(x => x.CustomerID == customerID);
if (currRec != null)
{
int mKeyNum = currRec.MainKey;
InvokeAsync(() => AppMService.KeyNumSet(mKeyNum));
AppMService.KeyNum = mKeyNum;
}
}
AppMService.CustomerID = value;
InvokeAsync(StateHasChanged);
}
}
}
[Inject]
protected MTAdminService MTService { get; set; } = null!;
protected bool selDisabled = false;
#endregion Protected Properties
#region Protected Methods
@@ -40,6 +58,12 @@ namespace MagMan.UI.Components
{
CustomerID = await AppMService.ClientIdGet();
}
// verifico sia valido...
bool hasCust = CustomersList != null && CustomersList.Where(x => x.CustomerID == CustomerID).Any();
if (!hasCust && ClaimCustomerId > 0)
{
CustomerID = ClaimCustomerId;
}
}
protected override async Task OnInitializedAsync()
@@ -49,11 +73,30 @@ namespace MagMan.UI.Components
protected async Task ReloadData()
{
CustomersList = await MTService.CustomerGetAll();
await GetClaimsData();
var rawList = await MTService.CustomerGetAll();
// se ho un plantId valido --> altrimenti non abilitato
if (ClaimCustomerId == 0)
{
CustomersList = rawList;
}
else if (ClaimCustomerId > 0)
{
CustomersList = rawList.Where(x => x.CustomerID == ClaimCustomerId).ToList();
}
else
{
CustomersList = new List<CustomerModel>();
}
}
#endregion Protected Methods
/// <summary>
/// Valore CustomerID filtrato da claim
/// </summary>
protected int ClaimCustomerId = -1;
#region Private Fields
private int customerID = -1;
@@ -61,5 +104,34 @@ namespace MagMan.UI.Components
private List<CustomerModel>? CustomersList = null;
#endregion Private Fields
[Inject]
protected AuthenticationStateProvider AuthenticationStateProvider { get; set; } = null!;
/// <summary>
/// Recupero Claims dell'utente...
///
/// https://docs.microsoft.com/it-it/aspnet/core/blazor/security/?view=aspnetcore-6.0
/// </summary>
/// <returns></returns>
private async Task GetClaimsData()
{
// recupero auth
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
var user = authState.User;
// se autenticato --> controllo i claims
if (user.Identity != null && user.Identity.IsAuthenticated)
{
// cerco il claim PlantId...
var custClaim = user.FindFirst(c => c.Type == "CustomerID")?.Value;
int.TryParse(custClaim, out ClaimCustomerId);
// verifico se sia SuperAdmin --> disabilito selezione altrimenti
selDisabled = !user.IsInRole("SuperAdmin");
}
else
{
ClaimCustomerId = -1;
}
}
}
}
+22 -12
View File
@@ -1,23 +1,33 @@
<div class="row pt-3">
<div class="col-6 col-md-6 col-lg-4">
<LoginDisplay></LoginDisplay>
<div class="row pt-2">
<div class="col-5 px-0">
<div class="d-flex">
<div>
<LoginDisplay></LoginDisplay>
</div>
<CascadingAuthenticationState>
<AuthorizeView>
<Authorized>
@if (ShowCustomers)
{
<div>
<CmpSelCliente></CmpSelCliente>
</div>
}
</Authorized>
</AuthorizeView>
</CascadingAuthenticationState>
</div>
</div>
<div class="col-12 col-lg-4 d-none d-lg-block text-center h4 text-truncate">
<div class="col-2 px-0 d-none d-lg-block text-center h4 text-truncate">
<span><i class="@PageIcon" aria-hidden="true"></i> @PageName</span>
</div>
<div class="col-6 col-md-6 col-lg-4 text-end d-flex flex-row-reverse">
<div class="col-5 px-0 text-end d-flex flex-row-reverse">
@if (ShowSearch)
{
<div class="w-50">
<SearchMod></SearchMod>
</div>
}
<div class="w-50">
<AuthorizeView Roles="SuperAdmin, Admin">
<Authorized>
<CmpSelCliente></CmpSelCliente>
</Authorized>
</AuthorizeView>
</div>
&nbsp;
</div>
</div>
+3 -2
View File
@@ -49,11 +49,12 @@ namespace MagMan.UI.Components
private string PageName { get; set; } = "";
[CascadingParameter(Name = "ShowCustomers")]
private bool ShowCustomers { get; set; } = true;
[CascadingParameter(Name = "ShowSearch")]
private bool ShowSearch { get; set; } = false;
#endregion Private Properties
}
}
+60
View File
@@ -0,0 +1,60 @@
<PageTitle>@Title</PageTitle>
<div class="card">
<div class="card-header table-primary py-1 my-0">
<div class="d-flex justify-content-between">
<div class="px-2">
<h2>@Title</h2>
</div>
<div class="px-2">
@if (processing)
{
<span class="spinner-border"></span> <i>...working...</i>
}
<button @onclick="() => Reset()" class="btn btn-primary"><i class="fas fa-sync-alt"></i></button>
</div>
</div>
</div>
<div class="card-body p-1">
<div class="row">
<div class="col-12 form-group">
<input @ref="CodeInput" @bind="@inputValue" class="form-control" autofocus="true"></input>
</div>
@if (!string.IsNullOrEmpty(lastCmd))
{
<div class="col-12 my-1">
@if (IsPickup || IsDeposit)
{
<button class="btn btn-lg w-100 btn-success" @onclick="() => ConfirmOperation()">
@if (IsPickup)
{
<i class="fas fa-download pr-2" aria-hidden="true"></i>
}
else if (IsDeposit)
{
<i class="fas fa-upload pr-2" aria-hidden="true"></i>
}
Confirm @Title
</button>
}
</div>
}
<div class="col-12">
@if (!string.IsNullOrEmpty(alertMessage))
{
<div class="alert alert-danger text-center fade show">
@alertMsg
</div>
}
@if (!string.IsNullOrEmpty(lastMessage))
{
<div class="alert alert-success text-center fade show">
@lastMsg
</div>
}
</div>
</div>
</div>
</div>
+255
View File
@@ -0,0 +1,255 @@
// Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this
// file to you under the MIT license.
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using MagMan.Data.Tenant.DbModels;
using MagMan.Data.Tenant.Services;
using MagMan.Core.Services;
namespace MagMan.UI.Components
{
public partial class CodeReader : IDisposable
{
#region Public Properties
[Parameter]
public bool IsDeposit { get; set; } = true;
[Parameter]
public bool IsPickup { get; set; } = true;
[Parameter]
public string Title { get; set; } = "Pickup/Deposit";
#endregion Public Properties
#region Public Methods
public void Dispose()
{
AppMService.EA_CustomerSel -= AppMService_EA_CustomerSel;
AppMService.EA_KeySel -= AppMService_EA_KeySel;
}
public async Task SetFocusAsync()
{
await Task.Delay(50);
await CodeInput.FocusAsync(true);
}
#endregion Public Methods
#region Protected Properties
[Inject]
protected MessageService AppMService { get; set; } = null!;
protected string currUserId
{
get
{
string userName = "";
var authState = AuthStateProvider.GetAuthenticationStateAsync().Result;
var user = authState.User;
if (user != null && user.Identity != null)
{
if (user.Identity.IsAuthenticated)
{
userName = $"{user.Identity.Name}";
}
else
{
userName = "N.A.";
}
}
return userName;
}
}
#endregion Protected Properties
#region Protected Methods
protected async Task ConfirmOperation()
{
//if (!await JSRuntime.InvokeAsync<bool>("confirm", "Confirm operation?"))
// return;
int qtyMov = 0;
if (IsPickup)
{
qtyMov = -1;
}
else if (IsDeposit)
{
qtyMov = 1;
}
if (qtyMov != 0)
{
if (currRecord != null)
{
await TService.ItemModQty(KeyNum, currRecord, qtyMov, currUserId, "M06+: Deposito Risorsa (Deposit)", "M06-: Prelievo Risorsa (Pickup)");
alertMessage = "";
lastCmd = "";
if (currRecord.MaterialNav != null)
{
lastMessage = $"<h4>Operation Confirmed!</h4><b>{qtyMov} x {currRecord.MaterialNav.MatCode}</b> {currRecord.MaterialNav.MatDesc} <div class=\"small\">{currRecord.LMm:N3}x{currRecord.WMm:N3}x{currRecord.HMm:N3}</div>";
}
else
{
lastMessage = $"<h4>Operation Confirmed!</h4><b>{qtyMov} x ND</b> ??? <div class=\"small\">{currRecord.LMm:N3}x{currRecord.WMm:N3}x{currRecord.HMm:N3}</div>";
}
}
await Task.Delay(1);
StateHasChanged();
await Task.Delay(scanOpDelay);
await ReloadData();
await SetFocusAsync();
}
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await SetFocusAsync();
}
}
protected override async Task OnInitializedAsync()
{
string rawConf = Configuration["OptConf:ScanOpDelay"];
if (rawConf != null)
{
int.TryParse(rawConf, out scanOpDelay);
}
KeyNum = AppMService.KeyNum;
AppMService.EA_CustomerSel += AppMService_EA_CustomerSel;
AppMService.EA_KeySel += AppMService_EA_KeySel;
await ReloadData();
}
protected async Task processInput(string newVal)
{
processing = true;
alertMessage = "";
lastMessage = "";
var remnRecord = await TService.ItemGetByQr(KeyNum, newVal);
if (remnRecord != null && remnRecord.MatId > 0 && remnRecord.ItemDtmx == newVal)
{
currRecord = remnRecord;
lastCmd = newVal;
if (remnRecord.MaterialNav != null)
{
lastMessage = $"<b>{remnRecord.MaterialNav.MatCode}</b> {remnRecord.MaterialNav.MatDesc} <div class=\"small\">{remnRecord.LMm:N3}x{remnRecord.WMm:N3}x{remnRecord.HMm:N3}</div>";
}
else
{
lastMessage = $"<b>ND</b> ??? <div class=\"small\">{remnRecord.LMm:N3}x{remnRecord.WMm:N3}x{remnRecord.HMm:N3}</div>";
}
}
else
{
alertMessage = $"Error: code {newVal} not valid / not found";
lastCmd = "";
}
processing = false;
}
protected async Task Reset()
{
await ReloadData();
await SetFocusAsync();
}
#endregion Protected Methods
#region Private Fields
private string alertMessage = "";
private ElementReference CodeInput;
private RawItemModel? currRecord = null;
private string lastCmd = "";
private string lastMessage = "";
private bool processing = false;
private int scanOpDelay = 5000;
#endregion Private Fields
#region Private Properties
private MarkupString alertMsg { get => (MarkupString)alertMessage; }
[Inject]
private AuthenticationStateProvider AuthStateProvider { get; set; } = null!;
[Inject]
private IConfiguration Configuration { get; set; } = null!;
private int CustomerID { get; set; } = 0;
private string inputValue
{
get
{
return "";
}
set
{
var pUpd = Task.Run(async () =>
{
await processInput(value.Trim());
});
pUpd.Wait();
}
}
[Inject]
private IJSRuntime JSRuntime { get; set; } = null!;
private int KeyNum { get; set; } = 0;
private MarkupString lastMsg { get => (MarkupString)lastMessage; }
[Inject]
private TenantService TService { get; set; } = null!;
#endregion Private Properties
#region Private Methods
private async void AppMService_EA_CustomerSel()
{
CustomerID = AppMService.CustomerID;
//await Task.Delay(1);
await InvokeAsync(StateHasChanged);
}
private async void AppMService_EA_KeySel()
{
KeyNum = AppMService.KeyNum;
//await Task.Delay(1);
await InvokeAsync(StateHasChanged);
}
private async Task ReloadData()
{
currRecord = null;
alertMessage = "";
lastMessage = "";
lastCmd = "";
await Task.Delay(1);
}
#endregion Private Methods
}
}
+4 -3
View File
@@ -48,12 +48,13 @@ namespace MagMan.UI.Components
dbOk = Data.Admin.DbConfig.CheckCustDb(currRec.MainKey);
}
// se ok --> migration...
if (dbOk || true)
if (dbOk)
{
string dbServerAddr = Configuration["DbConfig:Server"];
Data.Tenant.DbConfig.InitDb(dbServerAddr, currRec.MainKey);
//Data.Tenant.DbConfig.InitDb(dbServerAddr, currRec.MainKey);
string connStr = Data.Tenant.DbConfig.CustomerConnString(dbServerAddr, currRec.MainKey);
// verifico se serve applicazione migrazioni
Data.Tenant.DbConfig.ExecMigrationMain();
Data.Tenant.DbConfig.ExecMigrationMain(connStr);
}
// aggiorno comunque status DB...
currRec.HasDb = dbOk;
+1 -1
View File
@@ -43,7 +43,7 @@ namespace MagMan.UI.Components
await Task.Delay(1);
if (CurrRecord != null)
{
fatto = await TService.ItemUpdate(KeyNum, CurrRecord, userName);
fatto = await TService.ItemUpdate(KeyNum, CurrRecord, userName, true);
}
if (fatto)
{
+35 -12
View File
@@ -1,10 +1,20 @@
<div class="card">
<div class="card-header">
<div class="d-flex justify-content-between">
<div class="px-2">
<h3>Articoli</h3>
<div class="px-0">
<div class="d-flex">
<div class="px-0">
<h3>Articoli</h3>
</div>
<div class="px-2">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="flexSwitchCheckDefault" @bind="OnlyActive">
<label class="form-check-label" for="flexSwitchCheckDefault">@actMessage</label>
</div>
</div>
</div>
</div>
<div class="px-2">
<div class="px-0">
<div class="d-flex">
<div class="px-2">
@if (CurrItem == null)
@@ -22,7 +32,7 @@
@if (CurrItem != null)
{
<hr />
<ItemEdit CurrRecord="CurrItem" EC_update="ForceReload"></ItemEdit>
<ItemEdit CurrRecord="CurrItem" KeyNum="@KeyNum" EC_update="ForceReload"></ItemEdit>
}
</div>
<div class="card-body p-1">
@@ -52,13 +62,18 @@
}
@* <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> *@
<AuthorizeView Roles="SuperAdmin, Admin">
<Authorized>
<th></th>
</Authorized>
</AuthorizeView>
</tr>
</thead>
<tbody>
@foreach (var item in ListRecords)
{
<tr class="align-middle @CheckSel(item)">
string cssRow = item.IsActive ? "" : "text-strike";
<tr class="align-middle @CheckSel(item) @cssRow">
<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>
@@ -93,15 +108,23 @@
@($"{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> *@
<AuthorizeView Roles="SuperAdmin, Admin">
<Authorized>
<td class="text-end">
@if (item.QtyAvail == 0 && item.IsActive)
{
<button class="btn btn-danger btn-sm" @onclick="() => DeleteRecord(item)"><i class="fa-solid fa-trash"></i></button>
}
else
{
<button class="btn btn-secondary btn-sm" disabled><i class="fa-solid fa-trash"></i></button>
}
</td>
</Authorized>
</AuthorizeView>
</tr>
}
</tbody>
+58 -7
View File
@@ -3,7 +3,10 @@ using MagMan.Core.Services;
using MagMan.Data.Tenant.DbModels;
using MagMan.Data.Tenant.Services;
using Microsoft.AspNetCore.Components;
using Microsoft.Build.Framework;
using Microsoft.CodeAnalysis.Differencing;
using Microsoft.JSInterop;
using System.Security;
namespace MagMan.UI.Components
{
@@ -21,7 +24,21 @@ namespace MagMan.UI.Components
public int KeyNum { get; set; } = 0;
[Parameter]
public MaterialModel MaterialSel { get; set; } = null!;
public MaterialModel MaterialSel
{
get => materialSel;
set
{
if (materialSel != value)
{
materialSel = value;
CurrItem = null;
RawItemId = 0;
}
}
}
private MaterialModel materialSel { get; set; } = new MaterialModel();
#endregion Public Properties
@@ -36,6 +53,11 @@ namespace MagMan.UI.Components
#region Protected Properties
protected string actMessage
{
get => onlyActive ? "Solo Attivi" : "Mostra Eliminati";
}
[Inject]
protected MessageService AppMService { get; set; } = null!;
@@ -45,6 +67,24 @@ namespace MagMan.UI.Components
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
protected bool OnlyActive
{
get => onlyActive;
set
{
if (onlyActive != value)
{
onlyActive = value;
DoSelect(null);
var pUpd = Task.Run(async () =>
{
await ForceReload(true);
});
pUpd.Wait();
}
}
}
protected int totalCount { get; set; } = 0;
[Inject]
@@ -70,17 +110,29 @@ namespace MagMan.UI.Components
protected async Task CreateNew()
{
string matNote = $"{MaterialSel.MatCode.Replace("_", " ")}";
if (MaterialSel.IsBeam)
{
matNote += $" {MaterialSel.WMm:N0}x{MaterialSel.HMm:N0}";
}
else
{
matNote += $" {MaterialSel.HMm:N0}";
}
CurrItem = new RawItemModel()
{
MatId = MaterialSel.MatId,
Location = "nd",
Note = "...",
Note = matNote,
QtyAvail = 0,
IsActive = true,
IsRemn = false,
MaterialNav = MaterialSel,
HMm = MaterialSel.HMm,
LMm = MaterialSel.LMm,
WMm = MaterialSel.WMm
//LMm = MaterialSel.LMm,
//WMm = MaterialSel.WMm
LMm = 100,
WMm = MaterialSel.IsBeam ? MaterialSel.WMm : 100
};
await InvokeAsync(StateHasChanged);
}
@@ -161,6 +213,7 @@ namespace MagMan.UI.Components
private string currSearch = "";
private int filtType = 0;
private List<RawItemModel>? ListRecords = null;
private bool onlyActive = true;
private int RawItemId = 0;
private List<RawItemModel>? SearchRecords = null;
@@ -205,9 +258,8 @@ namespace MagMan.UI.Components
private async Task ReloadData()
{
isLoading = true;
await InvokeAsync(StateHasChanged);
ListRecords = null;
SearchRecords = await TService.ItemGetByMat(KeyNum, MaterialSel.MatId);
SearchRecords = await TService.ItemGetByMat(KeyNum, MaterialSel.MatId, OnlyActive);
// verifico filtro per ricerca
if (!string.IsNullOrEmpty(currSearch))
{
@@ -216,7 +268,6 @@ namespace MagMan.UI.Components
totalCount = SearchRecords.Count;
SortTable();
isLoading = false;
await InvokeAsync(StateHasChanged);
}
private void SortTable()
+8 -5
View File
@@ -5,14 +5,17 @@
<CascadingAuthenticationState>
<AuthorizeView>
<Authorized>
<div class="input-group text-truncate">
<div class="input-group">
<a title="LogOut" href="Identity/Account/LogOut" class="btn btn-sm btn-danger"><i class="fas fa-sign-out-alt"></i></a>
<a title="Gestione account @userName" href="Identity/Account/Manage" class="btn btn-sm btn-outline-dark mx-0 px-1">
<div class="d-none d-sm-block">
<a title="Gestione account @userName" href="Identity/Account/Manage" class="btn btn-sm btn-outline-dark mx-0 px-1 text-truncate">
<div class="d-none d-xl-block">
<i class="fas fa-user-alt"></i> @StringLim(userName, 30)
</div>
<div class="d-block d-sm-none">
<i class="fas fa-user-alt"></i> @StringLim(userName, 15)
<div class="d-none d-lg-block d-xl-none">
<i class="fas fa-user-alt"></i> @StringLim(userName, 20)
</div>
<div class="d-lg-none">
<i class="fas fa-user-alt"></i> @StringLim(userName, 10)
</div>
</a>
</div>
+17 -7
View File
@@ -16,20 +16,30 @@
<div class="col-md-6">
<div class="d-flex">
<div class="input-group">
@* <button class="btn btn-warning" @onclick="() => DoCancel()"><i class="fa-solid fa-ban"></i> Cancel</button> *@
@if (MatType != 2)
{
<div class="form-floating">
<NumInput CssClass="form-control" DisplFormat="0.00" @bind-Value="@CurrRecord.WMm"></NumInput>
<label class="small">W (mm)</label>
</div>
}
else
{
<div class="form-floating">
<input class="form-control" disabled Value="@($"{CurrRecord.WMm:N2}")" />
<label class="small">W (mm)</label>
</div>
}
<div class="form-floating">
<NumInput CssClass="form-control" DisplFormat="0.00" 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>
<NumInput CssClass="form-control" DisplFormat="0.00" @bind-Value="@CurrRecord.HMm"></NumInput>
<label class="small">H (mm)</label>
</div>
<div class="form-floating">
<NumInput CssClass="form-control" DisplFormat="0.00" Value="@CurrRecord.LMm"></NumInput>
<input class="form-control" disabled Value="@($"{CurrRecord.LMm:N2}")" />
<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>
+13 -8
View File
@@ -1,5 +1,5 @@
// 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 MagMan.Data.Admin.DbModels;
using MagMan.Data.Admin.Services;
using MagMan.Data.Tenant.DbModels;
@@ -15,11 +15,15 @@ namespace MagMan.UI.Components
[Parameter]
public MaterialModel? CurrRecord { get; set; } = null;
[Parameter]
public int KeyNum { get; set; } = 0;
[Parameter]
public EventCallback<bool> EC_update { get; set; }
[Parameter]
public int MatType { get; set; } = 0;
[Parameter]
public int KeyNum { get; set; } = 0;
#endregion Public Properties
#region Protected Properties
@@ -31,6 +35,11 @@ namespace MagMan.UI.Components
#region Protected Methods
protected async Task DoCancel()
{
await EC_update.InvokeAsync(true);
}
protected async Task DoSave()
{
bool fatto = false;
@@ -44,10 +53,6 @@ namespace MagMan.UI.Components
await EC_update.InvokeAsync(true);
}
}
protected async Task DoCancel()
{
await EC_update.InvokeAsync(true);
}
#endregion Protected Methods
}
+33 -6
View File
@@ -9,11 +9,11 @@
<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>
<button class="btn btn-success px-3" @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>
<button class="btn btn-warning px-5" @onclick="()=> ForceReload(true)"><i class="fa-solid fa-ban"></i> Cancel</button>
}
</div>
<div class="px-2">
@@ -32,7 +32,7 @@
@if (CurrItem != null)
{
<hr />
<MaterialEdit CurrRecord="CurrItem" EC_update="ForceReload"></MaterialEdit>
<MaterialEdit CurrRecord="CurrItem" KeyNum="@KeyNum" EC_update="ForceReload" MatType="@FiltType"></MaterialEdit>
}
</div>
<div class="card-body p-1">
@@ -50,7 +50,7 @@
<thead>
<tr class="">
<th>
<button class="btn btn-primary btn-sm" @onclick="() => DoEdit(null)"><i class="fa-solid fa-rotate"></i></button>
<button class="btn btn-primary btn-sm" @onclick="() => ForceReload(true)"><i class="fa-solid fa-rotate"></i></button>
</th>
<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>
@@ -62,6 +62,11 @@
<th class="text-end"><Sorter ParamName="SizeNum" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter> Var.</th>
<th class="text-end"><Sorter ParamName="QtyTot" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter> Qty</th>
}
<AuthorizeView Roles="SuperAdmin, Admin">
<Authorized>
<th></th>
</Authorized>
</AuthorizeView>
</tr>
</thead>
<tbody>
@@ -69,8 +74,16 @@
{
<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>
@if (CurrItem == null)
{
<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>
}
else
{
<button class="btn btn-secondary btn-sm" disabled><i class="fa-solid fa-search"></i></button>
<button class="btn btn-secondary btn-sm" disabled><i class="fa-solid fa-edit"></i></button>
}
</td>
<td>
@if (item.IsBeam)
@@ -115,6 +128,20 @@
@item.QtyTot
</td>
}
<AuthorizeView Roles="SuperAdmin, Admin">
<Authorized>
<td class="text-end">
@if (item.QtyTot == 0)
{
<button class="btn btn-danger btn-sm" @onclick="() => DeleteRecord(item)"><i class="fa-solid fa-trash"></i></button>
}
else
{
<button class="btn btn-secondary btn-sm" disabled><i class="fa-solid fa-trash"></i></button>
}
</td>
</Authorized>
</AuthorizeView>
</tr>
}
</tbody>
+10 -11
View File
@@ -85,20 +85,23 @@ namespace MagMan.UI.Components
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler eliminare il record?"))
return;
await TService.MaterialDelete(KeyNum, TService.MaterialFromDto(selItem));
MaterialId = 0;
var rec2del = TService.MaterialFromDto(selItem);
if (rec2del != null)
{
bool fatto = await TService.MaterialDelete(KeyNum, rec2del);
}
await ReloadData();
}
protected void DoEdit(MaterialDTO? selItem)
{
if (selItem == null)
{
DoSelect(null);
}
else
if (selItem != null)
{
CurrItem = TService.MaterialFromDto(selItem);
}
DoSelect(null);
}
protected void DoSelect(MaterialDTO? selItem)
@@ -117,6 +120,7 @@ namespace MagMan.UI.Components
protected async Task ForceReload(bool force)
{
CurrItem = null;
DoEdit(null);
await ReloadData();
}
@@ -315,11 +319,6 @@ namespace MagMan.UI.Components
}
}
private string textCss(bool isActive)
{
return isActive ? "text-dark" : "text-secondary text-decoration-line-through";
}
#endregion Private Methods
}
}
@@ -1,89 +0,0 @@
@* @using MagMan.Data
@using MagMan.UI.Data
@using MagMan.UI.Components *@
@* @inject GWMSDataService DataService *@
@inject MessageService AppMService
@inject IJSRuntime JSRuntime
@if (!DbAllOk)
{
<div class="row">
<div class="col-3 text-right">
<h3>DB Init</h3>
</div>
@if (!DbUserOk)
{
<div class="col-3">
<button id="btnReset" class="btn btn-danger btn-block" @onclick="initDb">
<i class="fas fa-database"></i> Init Main DB
</button>
</div>
}
else if (!DbIdentity)
{
<div class="col-3">
<button id="btnReset" class="btn btn-warning btn-block" @onclick="initIdent">
<i class="fas fa-user-shield"></i> Init Ident DB
</button>
</div>
}
</div>
}
@code {
[Parameter]
public EventCallback<int> evRefresh { get; set; }
[Parameter]
public EventCallback<int> evProcessing { get; set; }
protected async Task initDb()
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler effettuare inizializzazione/migrazione DB?"))
return;
reportProcess();
await MagMan.Data.Tenant.DbAdmin.migrateDbMain();
await ReloadData();
reportChange();
}
protected async Task initIdent()
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler effettuare inizializzazione/migrazione servizi Identity?"))
return;
reportProcess();
await MagMan.Data.Admin.DbAdmin.MigrateDbIdentity();
await ReloadData();
reportChange();
}
protected bool DbUserOk { get; set; } = false;
protected bool DbIdentity { get; set; } = false;
protected bool DbAllOk { get; set; } = false;
protected override async Task OnInitializedAsync()
{
await ReloadData();
}
protected async Task ReloadData()
{
var resultIden = await Health.Checks.DbIdentity(MagMan.Data.Admin.DbConfig.DATABASE_NAME);
DbIdentity = (resultIden.Status == Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Healthy);
DbAllOk = (DbIdentity);
}
private void reportChange()
{
evRefresh.InvokeAsync(1);
}
private void reportProcess()
{
evProcessing.InvokeAsync(1);
}
}
+2 -2
View File
@@ -80,7 +80,7 @@
@* <button class="btn btn-primary btn-sm" @onclick="() => DoEdit(item)"><i class="fa-solid fa-edit"></i></button> *@
</td>
<td>
<span title="@($"DB Id: {item.ProjExtDbId} | Ext.Id: {item.ProjExtId}")">
<span title="@($"Cloud Id: {item.ProjDbId} | Rem DB Id: {item.ProjExtDbId} | Ext.Id: {item.ProjExtId}")">
@if (item.PType == Enums.BWType.BEAM)
{
<span class="border border-primary rounded px-1">
@@ -93,7 +93,7 @@
<i class="fa-solid fa-draw-polygon"></i>
</span>
}
&nbsp;@item.ProjExtId
&nbsp;@item.ProjDbId
</span>
</td>
@if (ProjDbId == 0)
+4 -4
View File
@@ -59,9 +59,9 @@
{
<CmpClaimEdit Value="CurrentUserClaims"></CmpClaimEdit>
@* foreach (var cClaim in CurrentUserClaims)
{
<CmpClaimEdit CurrClaim="cClaim" E_Added="AddClaim" E_Removed="RemClaim" ></CmpClaimEdit>
} *@
{
<CmpClaimEdit CurrClaim="cClaim" E_Added="AddClaim" E_Removed="RemClaim" ></CmpClaimEdit>
} *@
}
else
{
@@ -96,7 +96,7 @@
</div>
</div>
</div>
<div class="col-6 text-right">
<div class="col-6">
<!-- Only show Id if not a new user -->
@if (objUser.Id != "")
{
+120
View File
@@ -0,0 +1,120 @@
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 Org.BouncyCastle.Asn1.Pkcs;
using static MagMan.Core.RestPayload;
namespace MagMan.UI.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class AliasController : 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 AliasController(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 AliasController");
}
/// <summary>
/// Controllo status Alive
/// GET: api/Alias/alive
/// </summary>
/// <returns></returns>
[HttpGet("alive")]
public string alive()
{
//Log.Debug("Chiamata alive");
return $"OK";
}
// GET api/Alias
[HttpGet]
public async Task<List<AliasModel>> Get()
{
// se non ho chaive --> vuoto!
List<AliasModel> ListRecords = new List<AliasModel>();
await Task.Delay(100);
return ListRecords;
}
/// <summary>
/// Elenco Materiali dato RestToken
/// </summary>
/// <param name="id">Rest Token cliente</param>
/// <returns></returns>
// GET api/Alias/00000000-0000-0000-0000-000000000000
[HttpGet("{id}")]
public async Task<List<AliasDTO>> Get(string id)
{
List<AliasDTO> ListDto = new List<AliasDTO>();
// in primis recupero codice chiave da token...
int nKey = await MTAdmService.MainKeyByToken(id);
// ora recupero direttamente elenco Alias x MatCode, cablato
var rawData = await TService.AliasGetFilt(nKey, "MatCode");
if (rawData != null && rawData.Count > 0)
{
ListDto = rawData.Select(x => new AliasDTO() { ValOrig = x.ValueOriginal, ValAlias = x.ValueAlias }).ToList();
}
return ListDto;
}
/// <summary>
/// Processa una chiamata POST per l'invio di un array Json di oggetti AliasDTO da salvare
/// PUT: api/Materials/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.Alias rawList)
{
string answ = "ND";
bool fatto = false;
// verifico ci sia valore
if (!string.IsNullOrEmpty(id) && rawList != null && rawList.AliasList != null)
{
// in primis recupero codice chiave da token...
int nKey = await MTAdmService.MainKeyByToken(id);
if (nKey > 0)
{
// creo oggetti materiale da lista ricevuta
List<AliasModel> recList = rawList.AliasList.Select(jpl => TService.AliasFromDto(jpl, "MatCode")).ToList();
try
{
fatto = await TService.AliasUpsert(nKey, recList);
}
catch (Exception exc)
{
Log.Error($"AliasController.upsert | Errore in fase salvataggio AliasDto{Environment.NewLine}{exc}");
fatto = false;
}
// resetto cache redis
await MTAdmService.FlushRedisCache();
}
}
answ = fatto ? "OK" : "NO";
return answ;
}
}
}
+4 -3
View File
@@ -95,13 +95,14 @@ namespace MagMan.UI.Controllers
if (nKey > 0)
{
// creo oggetti materiale da lista ricevuta
List<RawItemModel> matList = rawList.ItemList.Select(jpl => TService.ItemFromDto(jpl, true)).ToList();
List<RawItemModel> currList = rawList.ItemList.Select(jpl => TService.ItemFromDto(jpl, true, nKey)).ToList();
foreach (var item in matList)
foreach (var item in currList)
{
try
{
await TService.ItemUpdate(nKey, item, $"Key: {nKey}");
// chiamo metodo SENZA aggiornamento forzato quantità (x upload da EgtBW)
await TService.ItemUpdate(nKey, item, $"Key: {nKey}", false);
fatto = true;
}
catch (Exception exc)
@@ -94,7 +94,6 @@ namespace MagMan.UI.Controllers
{
// creo oggetti materiale da lista ricevuta
List<MaterialModel> matList = rawList.MatList.Select(jpl => TService.MaterialFromDto(jpl)).ToList();
foreach (var item in matList)
{
try
+56 -20
View File
@@ -18,13 +18,8 @@ namespace MagMan.UI.Controllers
[ApiController]
public class ProjectsController : 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!;
#region Public Constructors
public ProjectsController(MTAdminService MTDataService, TenantService TDataService)
{
MTAdmService = MTDataService;
@@ -37,6 +32,10 @@ namespace MagMan.UI.Controllers
Log.Info("Avviata classe ProjectsController");
}
#endregion Public Constructors
#region Public Methods
/// <summary>
/// Controllo status Alive
/// GET: api/Machines/alive
@@ -60,7 +59,7 @@ namespace MagMan.UI.Controllers
}
/// <summary>
/// Elenco Progetti dato RestToken
/// Elenco Progetti dato RestToken
/// </summary>
/// <param name="id">Rest Token cliente</param>
/// <param name="KeyNum">Chiave associata ai progetti</param>
@@ -75,22 +74,43 @@ namespace MagMan.UI.Controllers
// in primis recupero codice chiave da token...
int nKey = await MTAdmService.MainKeyByToken(id);
var rawList = await TService.ProjectGetAll(nKey);
ListRecords=rawList.Select(x => TService.ProjectToDto(x)).ToList();
ListRecords = rawList.Select(x => TService.ProjectToDto(x)).ToList();
}
return ListRecords;
}
/// <summary>
/// Processa una chiamata POST per l'invio di un oggetto di aggiornamento progetto
/// Elenco Progetti dato RestToken
/// </summary>
/// <param name="id">Rest Token cliente</param>
/// <param name="KeyNum">Chiave associata ai progetti</param>
/// <param name="ProjCloudId">Key del proj</param>
/// <returns></returns>
// GET api/Machines/2cba60c7-7be4-40b1-aa0d-52e7c71fc1a7
[HttpGet("single/{id}")]
public async Task<ProjectDTO> GetSingle(string id, int ProjCloudId)
{
ProjectDTO CurrRec = new ProjectDTO();
if (!string.IsNullOrEmpty(id))
{
// in primis recupero codice chiave da token...
int nKey = await MTAdmService.MainKeyByToken(id);
var rawResult = await TService.ProjectGetById(nKey, ProjCloudId);
CurrRec = rawResult != null ? TService.ProjectToDto(rawResult) : new ProjectDTO();
}
return CurrRec;
}
/// <summary>
/// Processa una chiamata POST per l'invio di un oggetto di upsert progetto
/// PUT: api/Inventory/upsert/00000000-0000-0000-0000-000000000000
/// </summary>
/// <param name="id">token comunicazione</param>
/// <returns></returns>
/// <returns>ID del progetto creato da usare come CloudId</returns>
[HttpPost("upsert/{id}")]
public async Task<string> upsert(string id, [FromBody] RestPayload.Projects rawData)
public async Task<int> upsert(string id, [FromBody] RestPayload.Projects rawData)
{
string answ = "ND";
bool fatto = false;
int answ = 0;
// verifico ci sia valore
if (!string.IsNullOrEmpty(id) && rawData != null && rawData.Project != null)
{
@@ -102,21 +122,37 @@ namespace MagMan.UI.Controllers
var currRec = TService.ProjectFromDto(rawData.Project);
try
{
await TService.ProjectUpdate(nKey, currRec);
fatto = true;
answ = await TService.ProjectUpsert(nKey, currRec);
}
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;
}
#endregion Public Methods
#region Private Fields
private static JsonSerializerSettings? JSSettings;
/// <summary>
/// Classe per logging
/// </summary>
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
#region Private Properties
private MTAdminService MTAdmService { get; set; } = null!;
private TenantService TService { get; set; } = null!;
#endregion Private Properties
}
}
}
+21 -25
View File
@@ -81,13 +81,13 @@ namespace MagMan.UI.Controllers
}
/// <summary>
/// Processa una chiamata POST per l'invio di un oggetto di aggiornamento risorse progetto (RestPayload.Resources)
/// PUT: api/Resources/upsert/00000000-0000-0000-0000-000000000000
/// Processa una chiamata POST per l'invio di un oggetto di TRACKING risorse progetto (RestPayload.Resources)
/// PUT: api/Resources/track/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)
[HttpPost("track/{id}")]
public async Task<string> track(string id, [FromBody] RestPayload.Resources projectData)
{
string answ = "ND";
bool fatto = false;
@@ -98,44 +98,40 @@ namespace MagMan.UI.Controllers
int nKey = await MTAdmService.MainKeyByToken(id);
if (nKey > 0)
{
// recupero ID interno da id esterno...
int ProjDbId = 0;
ProjModel? projRec = null;
var allProj = await TService.ProjectGetByMachine(nKey, 0);
if (allProj != null)
{
projRec = allProj.Find(x => x.ProjExtDbId == projectData.ProjLocalId);
if (projRec != null)
{
ProjDbId = projRec.ProjDbId;
}
}
if (ProjDbId > 0)
// nel projData ho le info x gestire aggiornamento PER INTERO
int ProjCloudId = projectData.ProjCloudId;
// proseguo solo se ho un Id valido
if (ProjCloudId > 0)
{
// recupero info del progetto con cui registrare le note
var projRec = await TService.ProjectGetById(nKey, ProjCloudId);
// in primis registro il record RequestPlan...
var recPlan = new RequestPlanModel()
{
DtRequest = DateTime.Now,
IsActive = true,
ReqState = projectData.ReqState,
ProjDbId = ProjDbId
ProjDbId = ProjCloudId
};
int reqId = await TService.ReqPlanUpdate(nKey, recPlan);
// registro richiesta prima dei movimenti...
int RequestPlanId = await TService.ReqPlanUpdate(nKey, recPlan);
// per ogni riga risorsa registro le info relative...
List<ResourceModel> listRes = new List<ResourceModel>();
if (projectData.ResourceList != null)
{
listRes = projectData.ResourceList.Select(x => TService.ResourceFromDto(x, reqId)).ToList();
List<ResourceModel> listRes = projectData.ResourceList.Select(x => TService.ResourceFromDto(x, RequestPlanId)).ToList();
try
{
string kDesc = $"K{nKey}";
string prDesc = kDesc;
string prDesc = $"K{nKey}";
if (projRec != null)
{
prDesc = $"P: {projRec.ProjExtId}.{projRec.ProjExtDbId} | {projRec.ProjDescription} ({projRec.Machine})";
prDesc += $" | P.{ProjCloudId} | {projRec.ProjDescription} ({projRec.Machine})";
}
await TService.ResourceUpdate(nKey, listRes, projectData.ReqState, $"{prDesc} | {kDesc}");
// rivedere SIA consumi che gestione stime...
await TService.ResourceUpdate(nKey, RequestPlanId, projectData.ResourceList, projectData.ReqState, prDesc);
fatto = true;
}
catch (Exception exc)
+1 -1
View File
@@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>1.0.2402.0119</Version>
<Version>1.0.2403.0108</Version>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
+2 -1
View File
@@ -37,8 +37,9 @@ namespace MagMan.UI.Pages
protected override void OnInitialized()
{
AppMService.ShowSearch = false;
AppMService.ShowCustomers = true;
AppMService.PageName = "Admin Area";
AppMService.PageIcon = "fa-solid fa-house pr-2";
AppMService.PageIcon = "fa-solid fa-building pr-2";
AppMService.EA_CustomerSel += AppMService_EA_CustomerSel;
CustomerID = AppMService.CustomerID;
}
+16
View File
@@ -0,0 +1,16 @@
@page "/Alias"
<PageTitle>Alias Area</PageTitle>
@if (isLoading)
{
<LoadingData></LoadingData>
}
else if (CustomerID == 0)
{
<CmpCustomerUndef></CmpCustomerUndef>
}
else
{
<AliasMan CustomerId="@CustomerID" KeyNum="@nKey"></AliasMan>
}
+89
View File
@@ -0,0 +1,89 @@
// Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this
// file to you under the MIT license.
using MagMan.Core.Services;
using MagMan.Data.Admin.Services;
using MagMan.Data.Tenant.DbModels;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components;
namespace MagMan.UI.Pages
{
[Authorize(Roles = "SuperAdmin, Admin, User")]
public partial class Alias
{
#region Public Methods
public void Dispose()
{
AppMService.EA_CustomerSel -= AppMService_EA_CustomerSel;
AppMService.EA_KeySel -= AppMService_EA_KeySel;
}
#endregion Public Methods
#region Protected Fields
protected int nKey = 0;
#endregion Protected Fields
#region Protected Properties
[Inject]
protected MessageService AppMService { get; set; } = null!;
[Inject]
protected MTAdminService MTService { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected override async Task OnInitializedAsync()
{
AppMService.ShowSearch = true;
AppMService.ShowCustomers = true;
AppMService.PageName = "Alias";
AppMService.PageIcon = "fa-solid fa-tags pr-2";
AppMService.EA_CustomerSel += AppMService_EA_CustomerSel;
AppMService.EA_KeySel += AppMService_EA_KeySel;
CustomerID = AppMService.CustomerID;
nKey = AppMService.KeyNum;
// rileggo dati
await ReloadData();
}
#endregion Protected Methods
#region Private Properties
private int CustomerID { get; set; } = 0;
private bool isLoading { get; set; } = false;
#endregion Private Properties
#region Private Methods
private async void AppMService_EA_CustomerSel()
{
CustomerID = AppMService.CustomerID;
await InvokeAsync(StateHasChanged);
}
private async void AppMService_EA_KeySel()
{
nKey = AppMService.KeyNum;
await InvokeAsync(StateHasChanged);
}
private async Task ReloadData()
{
isLoading = true;
await Task.Delay(50);
isLoading = false;
}
#endregion Private Methods
}
}
+14
View File
@@ -0,0 +1,14 @@
@page "/Deposit"
@inject MessageService AppMService
<CodeReader IsPickup="false" IsDeposit="true" Title="Deposit"></CodeReader>
@code {
protected override void OnInitialized()
{
AppMService.ShowSearch = false;
AppMService.ShowCustomers = true;
AppMService.PageName = "Deposit";
AppMService.PageIcon = "fa-solid fa-upload pr-2";
}
}
+42 -42
View File
@@ -7,7 +7,7 @@
@attribute [AllowAnonymous]
<div class="mt-4 p-3 bg-light text-dark border border-light rounded shadow-lg">
<div class="mt-4 p-4 bg-primary bg-gradient bg-opacity-25 border border-light text-dark rounded shadow">
<div class="row">
<div class="col-6 col-md-8 pr-0">
<h1>Mag-Man</h1>
@@ -28,64 +28,64 @@
</div>
<div class="card mt-2 shadow my-lg-5">
<div class="card-body">
@*
<AuthorizeView Roles="SuperAdmin, Admin">
<Authorized>
<div class="d-flex justify-content-around">
<div class="px-2 w-75">
<SetupDiagnostics></SetupDiagnostics>
</div>
</div>
</Authorized>
</AuthorizeView>*@
<div class="d-flex justify-content-around mb-1">
<div class="px-2 fs-1">
<div class="p-4 fs-1">
<h1>
<img class="img-fluid" src="images/LogoEgw.png" width="48" />&nbsp;Egalware
<img class="img-fluid" src="images/LogoEgw.png" width="48" />&nbsp;<b>Egalware</b>
</h1>
</div>
</div>
<div class="row px-5">
<div class="col-6 col-md-3">
<AuthorizeView Roles="SuperAdmin, Admin">
<Authorized>
<NavLink type="button" class="btn btn-block btn-primary text-light p-3 m-2 w-100" title="Scheda Fornitore" href="AdminArea">
<div class="row px-3">
<AuthorizeView Roles="SuperAdmin, Admin">
<Authorized>
<div class="col-6 col-md-4 col-lg-3 mb-3">
<NavLink type="button" class="btn btn-primary bg-gradient text-light p-3 w-100" title="Scheda Fornitore" href="AdminArea">
<i class="fa-solid fa-building fa-2x mb-2" aria-hidden="true"></i>
<h4>Admin Area</h4>
</NavLink>
</Authorized>
</AuthorizeView>
</div>
<div class="col-6 col-md-3">
<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="MachineStatus">
</div>
</Authorized>
</AuthorizeView>
<AuthorizeView Roles="SuperAdmin, Admin, User">
<Authorized>
<div class="col-6 col-md-4 col-lg-3 mb-3">
<NavLink type="button" class="btn btn-primary bg-gradient text-light p-3 w-100" title="Dati Macchine" href="MachineStatus">
<i class="fa-solid fa-screwdriver-wrench fa-2x mb-2" aria-hidden="true"></i>
<h4>Dati Macchine</h4>
</NavLink>
</Authorized>
</AuthorizeView>
</div>
<div class="col-6 col-md-3">
<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="ProjectsStatus">
</div>
<div class="col-6 col-md-4 col-lg-3 mb-3">
<NavLink type="button" class="btn btn-primary bg-gradient text-light p-3 w-100" title="Stato Impianti" href="ProjectsStatus">
<i class="fa-solid fa-chart-gantt fa-2x mb-2" aria-hidden="true"></i>
<h4>Progetti</h4>
</NavLink>
</Authorized>
</AuthorizeView>
</div>
<div class="col-6 col-md-3">
<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="WareHouse">
</div>
<div class="col-6 col-md-4 col-lg-3 mb-3">
<NavLink type="button" class="btn btn-primary bg-gradient text-light p-3 w-100" title="Alias Materiali" href="Alias">
<i class="fa-solid fa-tags fa-2x mb-2" aria-hidden="true"></i>
<h4>Alias Materiali</h4>
</NavLink>
</div>
<div class="col-6 col-md-4 col-lg-3 mb-3">
<NavLink type="button" class="btn btn-primary bg-gradient text-light p-3 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>
</Authorized>
</AuthorizeView>
</div>
</div>
<div class="col-6 col-md-4 col-lg-3 mb-3">
<NavLink type="button" class="btn btn-primary bg-gradient text-light p-3 w-100" title="Scheda Stazione" href="Deposit">
<i class="fa-solid fa-upload fa-2x mb-2" aria-hidden="true"></i>
<h4>Deposit</h4>
</NavLink>
</div>
<div class="col-6 col-md-4 col-lg-3 mb-3">
<NavLink type="button" class="btn btn-primary bg-gradient text-light p-3 w-100" title="Scheda Stazione" href="PickUp">
<i class="fa-solid fa-download fa-2x mb-2" aria-hidden="true"></i>
<h4>Pickup</h4>
</NavLink>
</div>
</Authorized>
</AuthorizeView>
</div>
</div>
</div>
+14 -1
View File
@@ -5,10 +5,23 @@ namespace MagMan.UI.Pages
{
public partial class Index
{
#region Protected Properties
[Inject]
protected MessageService AppMService { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected override void OnInitialized()
{
AppMService.ShowSearch = false;
AppMService.ShowCustomers = true;
AppMService.PageName = "Home";
AppMService.PageIcon = "fa-solid fa-home pr-2";
}
#endregion Protected Methods
}
}
+15
View File
@@ -0,0 +1,15 @@
@page "/PickUp"
@inject MessageService AppMService
<CodeReader IsPickup="true" IsDeposit="false" Title="PickUp"></CodeReader>
@code {
protected override void OnInitialized()
{
AppMService.ShowSearch = false;
AppMService.ShowCustomers = true;
AppMService.PageName = "Pickup";
AppMService.PageIcon = "fa-solid fa-download pr-2";
}
}
+1
View File
@@ -33,6 +33,7 @@ namespace MagMan.UI.Pages
protected override async Task OnInitializedAsync()
{
AppMService.ShowSearch = true;
AppMService.ShowCustomers = true;
AppMService.PageName = "Progetti";
AppMService.PageIcon = "fa-solid fa-chart-gantt pr-2";
AppMService.EA_CustomerSel += AppMService_EA_CustomerSel;
+10 -4
View File
@@ -1,6 +1,7 @@
using MagMan.Core.Services;
using MagMan.Data.Admin.Services;
using Microsoft.AspNetCore.Components;
using YamlDotNet.Core.Tokens;
namespace MagMan.UI.Pages
{
@@ -17,12 +18,17 @@ namespace MagMan.UI.Pages
protected override async Task OnInitializedAsync()
{
// salvo cliente selezionato...
int currCustId = AppMServ.CustomerID;
// resetto local/session storage utente
await MServ.StoreSessClear();
await MServ.StoreLocalClear();
await AppMServ.StoreSessClear();
await AppMServ.StoreLocalClear();
// resetto cache redis
await MTService.FlushRedisCache();
string baseAppPath = Configuration["OptConf:BaseAddr"];
// reimposto cliente
AppMServ.CustomerID = currCustId;
await AppMServ.ClientIdSet(currCustId);
NavMan.NavigateTo(baseAppPath, true);
}
@@ -31,10 +37,10 @@ namespace MagMan.UI.Pages
#region Private Properties
[Inject]
private IConfiguration Configuration { get; set; } = null!;
private MessageService AppMServ { get; set; } = null!;
[Inject]
private MessageService MServ { get; set; } = null!;
private IConfiguration Configuration { get; set; } = null!;
[Inject]
private NavigationManager NavMan { get; set; } = null!;
+16 -4
View File
@@ -16,6 +16,7 @@ namespace MagMan.UI.Pages
public void Dispose()
{
AppMService.EA_CustomerSel -= AppMService_EA_CustomerSel;
AppMService.EA_KeySel -= AppMService_EA_KeySel;
}
#endregion Public Methods
@@ -46,10 +47,13 @@ namespace MagMan.UI.Pages
protected override async Task OnInitializedAsync()
{
AppMService.ShowSearch = true;
AppMService.ShowCustomers = true;
AppMService.PageName = "Magazzino";
AppMService.PageIcon = "fa-solid fa-warehouse pr-2";
AppMService.EA_CustomerSel += AppMService_EA_CustomerSel;
AppMService.EA_KeySel += AppMService_EA_KeySel;
CustomerID = AppMService.CustomerID;
nKey = AppMService.KeyNum;
// rileggo dati
await ReloadData();
}
@@ -62,14 +66,15 @@ namespace MagMan.UI.Pages
protected void SaveMat(MaterialModel? newMat)
{
MaterialSel = newMat;
RawItemSel = null;
}
#endregion Protected Methods
#region Private Fields
private int KeyNum = 0;
private MaterialModel? MaterialSel = null;
private RawItemModel? RawItemSel = null;
#endregion Private Fields
@@ -77,6 +82,7 @@ namespace MagMan.UI.Pages
#region Private Properties
private int CustomerID { get; set; } = 0;
private bool isLoading { get; set; } = false;
#endregion Private Properties
@@ -86,15 +92,21 @@ namespace MagMan.UI.Pages
private async void AppMService_EA_CustomerSel()
{
CustomerID = AppMService.CustomerID;
await Task.Delay(10);
await ReloadData();
//await Task.Delay(1);
await InvokeAsync(StateHasChanged);
}
private async void AppMService_EA_KeySel()
{
nKey = AppMService.KeyNum;
//await Task.Delay(1);
await InvokeAsync(StateHasChanged);
}
private async Task ReloadData()
{
isLoading = true;
nKey = await MTService.MainKeyByCustomer(CustomerID);
await Task.Delay(50);
isLoading = false;
}
+21 -1
View File
@@ -39,7 +39,27 @@
</div>
<script src="lib/bootstrap/js/bootstrap.bundle.js"></script>
<script src="_framework/blazor.server.js"></script>
<script src="_framework/blazor.server.js" autostart="false"></script>
@*Gestione autoriconnessione: https://github.com/dotnet/aspnetcore/issues/38305 (vedere anche https://docs.microsoft.com/it-it/aspnet/core/blazor/fundamentals/signalr?view=aspnetcore-6.0#modify-the-reconnection-handler-blazor-server)*@
<script>
Blazor.start({
reconnectionOptions: {
maxRetries: 600,
retryIntervalMilliseconds: 1000
},
reconnectionHandler: {
onConnectionDown: (options, error) => console.error(error),
onConnectionUp: () => console.log("Client reconnected!")
}
}).then(() => {
Blazor.defaultReconnectionHandler._reconnectCallback = function (d) {
document.location.reload();
}
});
</script>
<script type="text/javascript" src="lib/qrcode.js"></script>
<script type="text/javascript" src="lib/dispQr.js"></script>
</body>
+2
View File
@@ -9,9 +9,11 @@
<div class="main mr-1 w-100">
<CascadingValue Name="ShowSearch" Value=@ShowSearch>
<CascadingValue Name="ShowCustomers" Value=@ShowCustomers>
<div class="top-row">
<CmpTop></CmpTop>
</div>
</CascadingValue>
</CascadingValue>
@* <article class="content px-4"> *@
<article class="content pt-1 pt-lg-2 mb-5 px-0 px-lg-1">
+13 -5
View File
@@ -9,8 +9,8 @@ namespace MagMan.UI.Shared
public void Dispose()
{
MessageService.EA_ShowSearch -= OnShowSearch;
MessageService.EA_ShowSearch -= OnHideSearch;
AppMService.EA_ShowSearch -= OnShowSearch;
AppMService.EA_ShowSearch -= OnHideSearch;
}
public void OnHideSearch()
@@ -36,7 +36,7 @@ namespace MagMan.UI.Shared
#region Protected Properties
[Inject]
protected MessageService MessageService { get; set; } = null!;
protected MessageService AppMService { get; set; } = null!;
protected bool navLarge { get; set; } = true;
protected string sideClass { get; set; } = "sidebar";
@@ -47,8 +47,14 @@ namespace MagMan.UI.Shared
protected override void OnInitialized()
{
MessageService.EA_ShowSearch += OnShowSearch;
MessageService.EA_HideSearch += OnHideSearch;
AppMService.EA_ShowSearch += OnShowSearch;
AppMService.EA_HideSearch += OnHideSearch;
AppMService.EA_ShowCustomers += AppMService_EA_ShowCustomers;
}
private void AppMService_EA_ShowCustomers(bool obj)
{
ShowCustomers = obj;
}
protected void UpdateNavDisplay()
@@ -63,6 +69,8 @@ namespace MagMan.UI.Shared
private bool ShowSearch { get; set; } = false;
private bool ShowCustomers { get; set; } = false;
#endregion Private Properties
}
}
+15
View File
@@ -51,11 +51,26 @@
<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="Alias">
<i class="fa-solid fa-tags pe-2" aria-hidden="true"></i>Alias Materiali
</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
</NavLink>
</div>
<div class="nav-item px-2">
<NavLink class="nav-link py-0 px-2 mb-0" href="Deposit">
<i class="fa-solid fa-upload pe-2" aria-hidden="true"></i>Deposit
</NavLink>
</div>
<div class="nav-item px-2">
<NavLink class="nav-link py-0 px-2 mb-0" href="PickUp">
<i class="fa-solid fa-download pe-2" aria-hidden="true"></i>Pickup
</NavLink>
</div>
<div class="nav-item px-2">
<NavLink class="nav-link py-0 px-2 mb-0" href="ResetCache">
<i class="fa-solid fa-exclamation-triangle pe-2"></i> Reset Cache
+3 -2
View File
@@ -7,7 +7,7 @@
},
"AllowedHosts": "*",
"ConnectionStrings": {
"Redis": "localhost:6379",
"Redis": "localhost:6379,DefaultDatabase=14,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false",
"UserIdentityDbContextConnection": "Server=localhost;port=3306;database=MagMan_Dev;user=MagMan;pwd=MagMan_secret_pwd;sslmode=None;",
"AuthConnection": "Server=localhost;port=3306;database=MagMan_Dev;user=MagMan;pwd=MagMan_secret_pwd;sslmode=None;",
"DefaultConnection": "Server=localhost;port=3306;database=MagMan_Dev;user=MagMan;pwd=MagMan_secret_pwd;sslmode=None;",
@@ -33,7 +33,8 @@
"jumpRedir": "~/../../",
"CodModulo": "MagMan",
"MultiRoleEnab": false,
"MultiClaimEnab": true
"MultiClaimEnab": true,
"ScanOpDelay": 3000
},
"AlarmDest": "samuele.locatelli@egalware.com, ceo@steamware.net",
"MailKitMailSettings": {
+3
View File
@@ -40,6 +40,9 @@ a,
.validation-message {
color: red;
}
.text-strike {
text-decoration: line-through;
}
#blazor-error-ui {
background: lightyellow;
bottom: 0;
+4
View File
@@ -36,6 +36,10 @@ a, .btn-link {
color: red;
}
.text-strike {
text-decoration: line-through;
}
#blazor-error-ui {
background: lightyellow;
bottom: 0;
+1 -1
View File
@@ -1 +1 @@
@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');h1,h2,h3,h4,h5,h6,b,display-1,display-2,display-3,display-4{font-family:'Lato',sans-serif;}html,body,.textCondensed{font-family:'Roboto Condensed',sans-serif;}a,.btn-link{color:#0366d6;}.btn-primary{color:#fff;background-color:#1b6ec2;border-color:#1861ac;}.content{padding-top:1.1rem;}.valid.modified:not([type=checkbox]){outline:1px solid #26b050;}.invalid{outline:1px solid #f00;}.validation-message{color:#f00;}#blazor-error-ui{background:#ffffe0;bottom:0;box-shadow:0 -1px 2px rgba(0,0,0,.2);display:none;left:0;padding:.6rem 1.25rem .7rem 1.25rem;position:fixed;width:100%;z-index:1000;}#blazor-error-ui .dismiss{cursor:pointer;position:absolute;right:.75rem;top:.5rem;}.footer{line-height:1.8em;}.shortcuts{text-align:center;}.shortcuts .shortcut-icon{font-size:2rem;}.shortcuts .shortcut{min-width:9rem;min-height:5rem;display:inline-block;padding:2rem/3 0;margin:0 2px 1em;vertical-align:top;text-decoration:none;background:#f3f3f3;background-image:-webkit-gradient(linear,left 0%,left 100%,from(#fff),to(#eee));background-image:-webkit-linear-gradient(top,#fff,0%,#eee,100%);background-image:-moz-linear-gradient(top,#fff 0%,#eee 100%);background-image:linear-gradient(to bottom,#fff 0%,#eee 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff',endColorstr='#ffeeeeee',GradientType=0);border:1px solid #ddd;box-sizing:border-box;border-radius:1rem/2;}.shortcuts .shortcut-sm{min-width:4.5rem;min-height:3rem;display:inline-block;padding:1rem/4 0;margin:0 2px 1em;vertical-align:top;text-decoration:none;background:#f3f3f3;background-image:-webkit-gradient(linear,left 0%,left 100%,from(#fff),to(#eee));background-image:-webkit-linear-gradient(top,#fff,0%,#eee,100%);background-image:-moz-linear-gradient(top,#fff 0%,#eee 100%);background-image:linear-gradient(to bottom,#fff 0%,#eee 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff',endColorstr='#ffeeeeee',GradientType=0);border:1px solid #ddd;box-sizing:border-box;border-radius:1rem/2;}.shortcuts .shortcut .shortcut-icon{width:100%;margin-top:0;margin-bottom:0;font-size:2rem;color:#333;}.shortcuts .shortcut-sm .shortcut-icon{width:100%;margin-top:0;margin-bottom:0;font-size:2rem;color:#333;}.shortcuts .shortcut:hover{background:#e8e8e8;background-image:-webkit-gradient(linear,left 0%,left 100%,from(#fafafa),to(#e1e1e1));background-image:-webkit-linear-gradient(top,#fafafa,0%,#e1e1e1,100%);background-image:-moz-linear-gradient(top,#fafafa 0%,#e1e1e1 100%);background-image:linear-gradient(to bottom,#fafafa 0%,#e1e1e1 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffafafa',endColorstr='#ffe1e1e1',GradientType=0);}.shortcuts .shortcut-sm:hover{background:#e8e8e8;background-image:-webkit-gradient(linear,left 0%,left 100%,from(#fafafa),to(#e1e1e1));background-image:-webkit-linear-gradient(top,#fafafa,0%,#e1e1e1,100%);background-image:-moz-linear-gradient(top,#fafafa 0%,#e1e1e1 100%);background-image:linear-gradient(to bottom,#fafafa 0%,#e1e1e1 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffafafa',endColorstr='#ffe1e1e1',GradientType=0);}.shortcuts .shortcut:active{box-shadow:inset 0 3px 5px rgba(0,0,0,.125);}.shortcuts .shortcut-sm:active{box-shadow:inset 0 3px 5px rgba(0,0,0,.125);}.shortcuts .shortcut:hover .shortcut-icon{color:#c93;}.shortcuts .shortcut-sm:hover .shortcut-icon{color:#666;}.shortcuts .shortcut-label{display:block;margin-top:.75em;font-weight:400;color:#666;}@media(max-width:640px){.shortcuts .shortcut{min-width:8rem;min-height:4rem;}body{font-size:.8em;}}
@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');h1,h2,h3,h4,h5,h6,b,display-1,display-2,display-3,display-4{font-family:'Lato',sans-serif;}html,body,.textCondensed{font-family:'Roboto Condensed',sans-serif;}a,.btn-link{color:#0366d6;}.btn-primary{color:#fff;background-color:#1b6ec2;border-color:#1861ac;}.content{padding-top:1.1rem;}.valid.modified:not([type=checkbox]){outline:1px solid #26b050;}.invalid{outline:1px solid #f00;}.validation-message{color:#f00;}.text-strike{text-decoration:line-through;}#blazor-error-ui{background:#ffffe0;bottom:0;box-shadow:0 -1px 2px rgba(0,0,0,.2);display:none;left:0;padding:.6rem 1.25rem .7rem 1.25rem;position:fixed;width:100%;z-index:1000;}#blazor-error-ui .dismiss{cursor:pointer;position:absolute;right:.75rem;top:.5rem;}.footer{line-height:1.8em;}.shortcuts{text-align:center;}.shortcuts .shortcut-icon{font-size:2rem;}.shortcuts .shortcut{min-width:9rem;min-height:5rem;display:inline-block;padding:2rem/3 0;margin:0 2px 1em;vertical-align:top;text-decoration:none;background:#f3f3f3;background-image:-webkit-gradient(linear,left 0%,left 100%,from(#fff),to(#eee));background-image:-webkit-linear-gradient(top,#fff,0%,#eee,100%);background-image:-moz-linear-gradient(top,#fff 0%,#eee 100%);background-image:linear-gradient(to bottom,#fff 0%,#eee 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff',endColorstr='#ffeeeeee',GradientType=0);border:1px solid #ddd;box-sizing:border-box;border-radius:1rem/2;}.shortcuts .shortcut-sm{min-width:4.5rem;min-height:3rem;display:inline-block;padding:1rem/4 0;margin:0 2px 1em;vertical-align:top;text-decoration:none;background:#f3f3f3;background-image:-webkit-gradient(linear,left 0%,left 100%,from(#fff),to(#eee));background-image:-webkit-linear-gradient(top,#fff,0%,#eee,100%);background-image:-moz-linear-gradient(top,#fff 0%,#eee 100%);background-image:linear-gradient(to bottom,#fff 0%,#eee 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff',endColorstr='#ffeeeeee',GradientType=0);border:1px solid #ddd;box-sizing:border-box;border-radius:1rem/2;}.shortcuts .shortcut .shortcut-icon{width:100%;margin-top:0;margin-bottom:0;font-size:2rem;color:#333;}.shortcuts .shortcut-sm .shortcut-icon{width:100%;margin-top:0;margin-bottom:0;font-size:2rem;color:#333;}.shortcuts .shortcut:hover{background:#e8e8e8;background-image:-webkit-gradient(linear,left 0%,left 100%,from(#fafafa),to(#e1e1e1));background-image:-webkit-linear-gradient(top,#fafafa,0%,#e1e1e1,100%);background-image:-moz-linear-gradient(top,#fafafa 0%,#e1e1e1 100%);background-image:linear-gradient(to bottom,#fafafa 0%,#e1e1e1 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffafafa',endColorstr='#ffe1e1e1',GradientType=0);}.shortcuts .shortcut-sm:hover{background:#e8e8e8;background-image:-webkit-gradient(linear,left 0%,left 100%,from(#fafafa),to(#e1e1e1));background-image:-webkit-linear-gradient(top,#fafafa,0%,#e1e1e1,100%);background-image:-moz-linear-gradient(top,#fafafa 0%,#e1e1e1 100%);background-image:linear-gradient(to bottom,#fafafa 0%,#e1e1e1 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffafafa',endColorstr='#ffe1e1e1',GradientType=0);}.shortcuts .shortcut:active{box-shadow:inset 0 3px 5px rgba(0,0,0,.125);}.shortcuts .shortcut-sm:active{box-shadow:inset 0 3px 5px rgba(0,0,0,.125);}.shortcuts .shortcut:hover .shortcut-icon{color:#c93;}.shortcuts .shortcut-sm:hover .shortcut-icon{color:#666;}.shortcuts .shortcut-label{display:block;margin-top:.75em;font-weight:400;color:#666;}@media(max-width:640px){.shortcuts .shortcut{min-width:8rem;min-height:4rem;}body{font-size:.8em;}}
+4 -4
View File
@@ -362,7 +362,7 @@ var QRCode;
this._elImage.src = this._elCanvas.toDataURL("image/png");
this._elImage.style.display = "block";
this._elCanvas.style.display = "none";
this._elImage.className = "img-fluid";
this._elImage.className = "img-fluid mx-auto d-block";
}
// Android 2.1 bug workaround
@@ -448,9 +448,9 @@ var QRCode;
this._oContext = this._elCanvas.getContext("2d");
this._bIsPainted = false;
this._elImage = document.createElement("img");
this._elImage.alt = "Scan me!";
this._elImage.alt = "Scan me!!!";
this._elImage.style.display = "none";
this._elImage.className = "img-fluid";
this._elImage.className = "img-fluid mx-auto d-block";
this._el.appendChild(this._elImage);
this._bSupportDataURI = null;
};
@@ -472,7 +472,7 @@ var QRCode;
var nRoundedHeight = Math.round(nHeight);
_elImage.style.display = "none";
_elImage.className = "img-fluid";
_elImage.className = "img-fluid mx-auto d-block";
this.clear();
for (var row = 0; row < nCount; row++) {
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>MagMan - Wood Warehouse Management System</i>
<h4>Versione: 1.0.2402.0119</h4>
<h4>Versione: 1.0.2403.0108</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.0.2402.0119
1.0.2403.0108
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.0.2402.0119</version>
<version>1.0.2403.0108</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>
+75 -13
View File
@@ -1,4 +1,5 @@
using EgwProxy.MagMan;
using EgwProxy.MagMan.DTO;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -44,7 +45,7 @@ namespace DemoApp
Console.WriteLine("Premere un tasto per lettura archivio materiali");
answ = Console.ReadLine();
// leggo materiali
var matList = await commLib.MaterialsGet();
var matList = commLib.MaterialsGet();
if (matList != null)
{
foreach (var item in matList)
@@ -67,7 +68,7 @@ namespace DemoApp
answ = Console.ReadLine();
// leggo inventario
var inventList = await commLib.InventoryGet(0);
var inventList = commLib.InventoryGet(0);
if (inventList != null)
{
foreach (var itemMat in inventList)
@@ -104,27 +105,88 @@ namespace DemoApp
answ = Console.ReadLine();
// leggo projectList
var projList = await commLib.ProjectGet(470);
var projList = commLib.ProjectGet(470);
if (projList != null)
{
foreach (var itemMat in projList)
foreach (var itemProj in projList)
{
Console.WriteLine(sep);
Console.WriteLine($"MachineId: {itemMat.MachineCloudId}");
Console.WriteLine($"Key: {itemMat.KeyNum}");
Console.WriteLine($"ProjLocalId: {itemMat.ProjLocalId}");
Console.WriteLine($"ProjExtId: {itemMat.ProjExtId}");
Console.WriteLine($"BTL filename: {itemMat.BTLFileName}");
Console.WriteLine($"PType: {itemMat.PType}");
Console.WriteLine($"Machine: {itemMat.Machine}");
Console.WriteLine($"Descript: {itemMat.ProjDescription}");
Console.WriteLine($"Proc time est/real: {itemMat.ProcTimeEst:N1} / {itemMat.ProcTimeReal:N1}");
Console.WriteLine($"MachineId: {itemProj.MachineCloudId}");
Console.WriteLine($"Key: {itemProj.KeyNum}");
Console.WriteLine($"ProjLocalId: {itemProj.ProjLocalId}");
Console.WriteLine($"ProjExtId: {itemProj.ProjExtId}");
Console.WriteLine($"BTL filename: {itemProj.BTLFileName}");
Console.WriteLine($"PType: {itemProj.PType}");
Console.WriteLine($"Machine: {itemProj.Machine}");
Console.WriteLine($"Descript: {itemProj.ProjDescription}");
Console.WriteLine($"Proc time est/real: {itemProj.ProcTimeEst:N1} / {itemProj.ProcTimeReal:N1}");
Console.WriteLine(sep);
Console.WriteLine();
}
}
Console.WriteLine("Enter to next step: numb of proj to read");
answ = Console.ReadLine();
int projId = 1;
int.TryParse(answ, out projId);
var singleProj = commLib.ProjectGetSingle(projId);
if (singleProj != null)
{
Console.WriteLine(sep);
Console.WriteLine($"Proj {projId} data:");
Console.WriteLine($"MachineId: {singleProj.MachineCloudId}");
Console.WriteLine($"Key: {singleProj.KeyNum}");
Console.WriteLine($"ProjLocalId: {singleProj.ProjLocalId}");
Console.WriteLine($"ProjExtId: {singleProj.ProjExtId}");
Console.WriteLine($"BTL filename: {singleProj.BTLFileName}");
Console.WriteLine($"PType: {singleProj.PType}");
Console.WriteLine($"Machine: {singleProj.Machine}");
Console.WriteLine($"Descript: {singleProj.ProjDescription}");
Console.WriteLine($"Proc time est/real: {singleProj.ProcTimeEst:N1} / {singleProj.ProcTimeReal:N1}");
Console.WriteLine(sep);
Console.WriteLine();
}
answ = Console.ReadLine();
Console.WriteLine("Inserire Qty materiale syncronizzare (Demo, WxHxL: 100x100x0):");
var sQty = Console.ReadLine();
int newQty = 0;
int.TryParse(sQty, out newQty);
MaterialDTO newMat = new MaterialDTO()
{
MatCode = "DEMO",
MatDesc = $"DEMO material @{DateTime.Now:HH:mm:ss}",
HMm = 100,
WMm = 100,
LMm = 0,
QtyTot = newQty
};
// creo lista
List<MaterialDTO> newMaterials = new List<MaterialDTO>();
newMaterials.Add(newMat);
// invio
commLib.MaterialsSend(newMaterials);
answ = Console.ReadLine();
var listAlias = commLib.AliasGet();
if (listAlias != null)
{
Console.WriteLine(sep);
Console.WriteLine("ALIAS LIST");
Console.WriteLine(sep);
foreach (var itemAlias in listAlias)
{
Console.WriteLine($"{itemAlias.ValOrig} --> {itemAlias.ValAlias}");
}
Console.WriteLine(sep);
}
List<AliasDTO> alias2send = new List<AliasDTO>();
alias2send.Add(new AliasDTO() { ValOrig = "Item01", ValAlias = "Gl24h" });
alias2send.Add(new AliasDTO() { ValOrig = "Item02", ValAlias = "Gl24h" });
var resAliasSend = commLib.AliasSend(alias2send);
Console.WriteLine("Enter to close");
answ = Console.ReadLine();
+5
View File
@@ -36,6 +36,9 @@
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.5.0.1\lib\net46\NLog.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>
</Reference>
@@ -43,7 +46,9 @@
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
+1
View File
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl.AsyncInterfaces" version="7.0.0" targetFramework="net472" />
<package id="NLog" version="5.0.1" 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" />
+5
View File
@@ -57,6 +57,9 @@
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.5.0.1\lib\net46\NLog.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>
</Reference>
@@ -64,9 +67,11 @@
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
+1
View File
@@ -3,6 +3,7 @@
<package id="EgwProxy.MagMan" version="0.9.2401.2309" targetFramework="net472" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="7.0.0" targetFramework="net472" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
<package id="NLog" version="5.0.1" 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" />