diff --git a/EgwProxy.MagMan/DTO/ItemDTO.cs b/EgwProxy.MagMan/DTO/ItemDTO.cs
new file mode 100644
index 0000000..4018507
--- /dev/null
+++ b/EgwProxy.MagMan/DTO/ItemDTO.cs
@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EgwProxy.MagMan.DTO
+{
+ public class ItemDTO
+ {
+
+ ///
+ /// Codice Univoco (DB)
+ ///
+ public int ItemID { get; set; } = 0;
+ ///
+ /// Codice Materiale di provenienza
+ ///
+ public int MatID { get; set; } = 0;
+
+ ///
+ /// Check if is a Remnant
+ ///
+ public bool IsRemn { get; set; } = false;
+
+ ///
+ /// Location
+ ///
+ public string Location { get; set; } = "";
+ ///
+ /// Qty available on wharehouse
+ ///
+ public int QtyAvail { get; set; } = 0;
+
+ ///
+ /// DateTime last modification
+ ///
+ public DateTime DtMod { get; set; } = DateTime.Now.AddYears(10);
+
+ ///
+ /// Item's Lenght
+ ///
+ public decimal LMm { get; set; } = 0;
+
+ ///
+ /// Item's Width
+ ///
+ public decimal WMm { get; set; } = 0;
+
+ ///
+ /// Item's Thikness
+ ///
+ public decimal TMm { get; set; } = 0;
+ ///
+ /// Note
+ ///
+ public string Note { get; set; } = "";
+
+ ///
+ /// Codice QR/Matrix Item
+ ///
+ public string ItemDtmx { get; set; } = "";
+ }
+}
diff --git a/EgwProxy.MagMan/DTO/MaterialDTO.cs b/EgwProxy.MagMan/DTO/MaterialDTO.cs
index dcdf72b..7965698 100644
--- a/EgwProxy.MagMan/DTO/MaterialDTO.cs
+++ b/EgwProxy.MagMan/DTO/MaterialDTO.cs
@@ -8,7 +8,6 @@ namespace EgwProxy.MagMan.DTO
{
public class MaterialDTO
{
-
///
/// Codice Univoco (DB)
///
@@ -35,8 +34,13 @@ namespace EgwProxy.MagMan.DTO
///
public decimal TMm { get; set; } = 0;
///
- /// Codice QR/Matrix materiale materiale
+ /// Codice QR/Matrix materiale
///
public string MatDtmx { get; set; } = "";
+
+ ///
+ /// Elenco item e giancenze
+ ///
+ public List ItemNav { get; set; } = new List();
}
}
diff --git a/EgwProxy.MagMan/DataSyncro.cs b/EgwProxy.MagMan/DataSyncro.cs
index 36eae08..de7206e 100644
--- a/EgwProxy.MagMan/DataSyncro.cs
+++ b/EgwProxy.MagMan/DataSyncro.cs
@@ -15,30 +15,23 @@ namespace EgwProxy.MagMan
{
public class DataSyncro
{
+ #region Public Constructors
+
///
/// Inizializza la libreria di comunicazione con il token assegnato
///
///
- public DataSyncro(string UserToken)
+ public DataSyncro(string serverUrl, string UserToken)
{
RestToken = UserToken;
+ servAddr = serverUrl;
+ apiUrl = $"https://{servAddr}/api/";
}
- ///
- /// Token di chiamata per l'applicazione
- ///
- string RestToken = "";
+ #endregion Public Constructors
+
+ #region Public Methods
- ///
- /// Effettua chiamata test sul server (ping)
- ///
- ///
- public bool CheckRemote()
- {
- IPAddress address = IPAddress.Loopback;
- string srvIp = servAddr.Substring(0, servAddr.IndexOf(":"));
- return pingAddress(srvIp) == IPStatus.Success;
- }
///
/// Test ping x indirizzo indicato
///
@@ -74,21 +67,17 @@ namespace EgwProxy.MagMan
}
return answ;
}
-#if DEBUG
+
///
- /// Indirizzo server (DEBUG)
+ /// Effettua chiamata test sul server (ping)
///
- private static string servAddr = "localhost:7207";
-#else
- ///
- /// Indirizzo server (Release)
- ///
- private static string servAddr = "magman.egalware.com";
-#endif
- ///
- /// URL dell'API x chiamate gestione licenze
- ///
- private static string apiUrl = $"https://{servAddr}/api/";
+ ///
+ public bool CheckRemote()
+ {
+ IPAddress address = IPAddress.Loopback;
+ string srvIp = servAddr.Substring(0, servAddr.IndexOf(":"));
+ return pingAddress(srvIp) == IPStatus.Success;
+ }
///
/// Elenco Materiali dato RestToken
@@ -98,7 +87,6 @@ namespace EgwProxy.MagMan
List answ = new List();
// cerco online
RestClient client = new RestClient(apiUrl);
- //client.Authenticator = new HttpBasicAuthenticator("username", "password");
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
var request = new RestRequest($"Materials/{MKeyEnc}", Method.Get);
var response = await client.GetAsync(request);
@@ -111,5 +99,49 @@ namespace EgwProxy.MagMan
}
return await Task.FromResult(answ);
}
+
+ ///
+ /// Inventario per materiale
+ ///
+ /// Se 0 = tutto
+ ///
+ public async Task> GetInventario(int MatID)
+ {
+ List answ = new List();
+ // cerco online
+ RestClient client = new RestClient(apiUrl);
+ string MKeyEnc = HttpUtility.UrlEncode(RestToken);
+ var request = new RestRequest($"Inventory/{MKeyEnc}?MatId={MatID}", Method.Get);
+ var response = await client.GetAsync(request);
+ // controllo risposta
+ if (response.StatusCode == System.Net.HttpStatusCode.OK)
+ {
+ // salvo in redis contenuto serializzato
+ string rawData = $"{response.Content}";
+ answ = JsonConvert.DeserializeObject>(rawData);
+ }
+ return await Task.FromResult(answ);
+ }
+
+ #endregion Public Methods
+
+ #region Private Fields
+
+ ///
+ /// URL dell'API x chiamate gestione licenze
+ ///
+ private string apiUrl = $"";
+
+ ///
+ /// Token di chiamata per l'applicazione
+ ///
+ private string RestToken = "";
+
+ ///
+ /// Indirizzo server (URL con eventuale porta)
+ ///
+ private string servAddr = $"";
+
+ #endregion Private Fields
}
-}
+}
\ No newline at end of file
diff --git a/EgwProxy.MagMan/EgwProxy.MagMan.csproj b/EgwProxy.MagMan/EgwProxy.MagMan.csproj
index c4cc27a..52d493b 100644
--- a/EgwProxy.MagMan/EgwProxy.MagMan.csproj
+++ b/EgwProxy.MagMan/EgwProxy.MagMan.csproj
@@ -77,6 +77,7 @@
+
diff --git a/TestConsoleApp/Program.cs b/TestConsoleApp/Program.cs
index 331a1ec..abe6c0c 100644
--- a/TestConsoleApp/Program.cs
+++ b/TestConsoleApp/Program.cs
@@ -13,14 +13,29 @@ namespace DemoApp
static async Task Main(string[] args)
{
+
+#if DEBUG
+ // Indirizzo server (DEBUG)
+ string servAddr = "localhost:7207";
+
+ // token di auth
string testToken = "91f4fec6-7e9c-4130-9df2-702d729ccdd3";
+#else
+ // Indirizzo server (DEBUG)
+ string servAddr = "magman.egalware.com";
+
+ // token di auth
+ string testToken = "22fa4426-6670-41ad-ac2b-d7b5c3dfe849";
+#endif
+
string sep = "--------------------------------------------";
+ string sepShort = "------------------";
Console.WriteLine(sep);
Console.WriteLine("- MagMan REST Demo App");
Console.WriteLine(sep);
Console.WriteLine();
string answ = "";
- DataSyncro commLib = new DataSyncro(testToken);
+ DataSyncro commLib = new DataSyncro(servAddr, testToken);
Console.WriteLine("Premere ENT per check ping");
answ = Console.ReadLine();
bool servOk = commLib.CheckRemote();
@@ -28,21 +43,63 @@ namespace DemoApp
Console.WriteLine($"Esito controllo server: {esito}");
Console.WriteLine("Premere un tasto per lettura archivio materiali");
answ = Console.ReadLine();
+ // leggo materiali
var matList = await commLib.GetMaterials();
if (matList != null)
{
foreach (var item in matList)
{
Console.WriteLine(sep);
+ Console.WriteLine($"Mat ID: {item.MatID}");
Console.WriteLine($"Mat Code: {item.MatExtCode}");
Console.WriteLine($"Dtmx Code: {item.MatDtmx}");
Console.WriteLine($"descript: {item.MatDesc}");
Console.WriteLine($"Dimensions W x T x L: {item.WMm:N3} x {item.TMm:N3} x {item.LMm:N3}");
+ if (item.ItemNav != null)
+ {
+ Console.WriteLine($"Items count: {item.ItemNav.Count}");
+ }
Console.WriteLine(sep);
Console.WriteLine();
}
}
answ = Console.ReadLine();
+ // leggo inventario
+ var inventList = await commLib.GetInventario(0);
+ if (inventList != null)
+ {
+ foreach (var itemMat in inventList)
+ {
+ Console.WriteLine(sep);
+ Console.WriteLine($"Mat ID: {itemMat.MatID}");
+ Console.WriteLine($"Mat Code: {itemMat.MatExtCode}");
+ Console.WriteLine($"Dtmx Code: {itemMat.MatDtmx}");
+ Console.WriteLine($"descript: {itemMat.MatDesc}");
+ Console.WriteLine($"Dimensions W x T x L: {itemMat.WMm:N3} x {itemMat.TMm:N3} x {itemMat.LMm:N3}");
+ if (itemMat.ItemNav != null)
+ {
+ Console.WriteLine($"Items count: {itemMat.ItemNav.Count}");
+ if (itemMat.ItemNav.Count > 0)
+ {
+ Console.WriteLine("Inventario:");
+ foreach (var itemInv in itemMat.ItemNav)
+ {
+ Console.WriteLine(sepShort);
+ Console.WriteLine($"ID: {itemInv.ItemID}");
+ Console.WriteLine($"Location: {itemInv.Location}");
+ Console.WriteLine($"Descript: {itemInv.Note}");
+ Console.WriteLine($"Giacenza: {itemInv.QtyAvail}");
+ Console.WriteLine($"Dimensions W x T x L: {itemInv.WMm:N3} x {itemInv.TMm:N3} x {itemInv.LMm:N3}");
+ Console.WriteLine($"Dtmx Code: {itemInv.ItemDtmx}");
+ }
+ }
+ }
+ Console.WriteLine(sep);
+ Console.WriteLine();
+ }
+ }
+
+ answ = Console.ReadLine();
}
}
}
diff --git a/TestWinFormVB/Form1.vb b/TestWinFormVB/Form1.vb
index 7b3fd50..d63ade4 100644
--- a/TestWinFormVB/Form1.vb
+++ b/TestWinFormVB/Form1.vb
@@ -38,6 +38,7 @@ Public Class Form1
result += $"Dtmx Code: {item.MatDtmx}{Environment.NewLine}"
result += $"descript: {item.MatDesc}{Environment.NewLine}"
result += $"Dimensions W x T x L: {item.WMm:N3} x {item.TMm:N3} x {item.LMm:N3}{Environment.NewLine}"
+ 'result += $"Items count: {item.ItemList.Count}"
result += $"{Environment.NewLine}"
Next
End If