Merge branch 'release/AddMagManSdk02'

This commit is contained in:
Samuele Locatelli
2024-01-23 09:15:42 +01:00
19 changed files with 299 additions and 20 deletions
+100
View File
@@ -0,0 +1,100 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EgwProxy.MagMan.DTO
{
public class ProjectDTO
{
#region Public Properties
/// <summary>
/// Nome file BTL originale
/// </summary>
public string BTLFileName { get; set; } = "";
/// <summary>
/// Data Creazione progetto
/// </summary>
public DateTime DtCreated { get; set; } = DateTime.Now;
/// <summary>
/// Data ora ultima operazione registrata
/// </summary>
public DateTime DtLastAction { get; set; } = DateTime.MinValue;
/// <summary>
/// Data di schedulazione (prevista)
/// </summary>
public DateTime DtSchedule { get; set; } = DateTime.Today.AddMonths(3);
/// <summary>
/// Data Inizio Produzione
/// </summary>
public DateTime DtStartProd { get; set; } = DateTime.MinValue;
/// <summary>
/// Record attivo (se false == cancellazione logica)
/// </summary>
public bool IsActive { get; set; } = true;
/// <summary>
/// Stato Archiviato = NON visualizzabile normalmente, già prodotto/chiuso
/// </summary>
public bool IsArchived { get; set; } = false;
/// <summary>
/// Key di riferimento per il progetto
/// </summary>
public int KeyNum { get; set; } = 0;
/// <summary>
/// ListName del BTL
/// </summary>
public string ListName { get; set; } = "";
/// <summary>
/// Macchina (Costruttore/Modello)
/// </summary>
public string Machine { get; set; } = "";
/// <summary>
/// Id macchina (MagMan)
/// </summary>
public int MachineID { get; set; } = 0;
/// <summary>
/// Tempo lavorazione previsto (stima) in minuti
/// </summary>
public double ProcTimeEst { get; set; } = 0;
/// <summary>
/// Tempo lavorazione reale in minuti (parziale o totale se chiuso/completato/archiviato)
/// </summary>
public double ProcTimeReal { get; set; } = 0;
/// <summary>
/// Descrizione progetto (copiata da BTLFileName inizialmente)
/// </summary>
public string ProjDescription { get; set; } = "";
/// <summary>
/// ID del DB EgtBW, univoco con KeyNum
/// </summary>
public int ProjExtDbId { get; set; } = 0;
/// <summary>
/// ID esterno (da EgtBW)
/// </summary>
public int ProjExtId { get; set; } = 0;
/// <summary>
/// Tipologia del progetto (Travi, Pareti, ...)
/// </summary>
public BWType PType { get; set; } = BWType.NULL;
#endregion Public Properties
}
}
+49 -2
View File
@@ -141,14 +141,15 @@ namespace EgwProxy.MagMan
}
/// <summary>
/// Invia un 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 Mat2Merge)
public async Task<bool> InventorySend(MaterialDTO rec2send)
{
bool answ = false;
// cerco online
var client = new RestClient(apiUrl);
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
var jsonBody = JsonConvert.SerializeObject(Mat2Merge.ItemList);
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
@@ -163,6 +164,52 @@ namespace EgwProxy.MagMan
#endregion Public Methods
/// <summary>
/// Elenco progetti associati a chiave
/// </summary>
/// <param name="MatID">Se 0 = tutto</param>
/// <returns></returns>
public async Task<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)
{
// 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
/// <param name="rec2send">record da inviare</param>
/// </summary>
public async Task<bool> ProjectSend(ProjectDTO rec2send)
{
bool answ = false;
// 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)
{
// contenuto serializzato
string rawData = $"{response.Content}";
answ = rawData == "OK";
}
return await Task.FromResult(answ);
}
#region Private Fields
/// <summary>
+2
View File
@@ -79,6 +79,8 @@
<Compile Include="DataSyncro.cs" />
<Compile Include="DTO\ItemDTO.cs" />
<Compile Include="DTO\MaterialDTO.cs" />
<Compile Include="DTO\ProjectDTO.cs" />
<Compile Include="Enums.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
+38
View File
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EgwProxy.MagMan
{
public enum BWType
{
NULL = 0,
BEAM = 1,
WALL = 2
}
public enum ProjResState
{
/// <summary>
/// Registrazione consumo effettivo (update giacenza su tab RawItemList)
/// </summary>
Consumed = -1,
/// <summary>
/// Non definito
/// </summary>
ND = 0,
/// <summary>
/// Consumo stimato da nesting (solo simulazione)
/// </summary>
Estimated,
/// <summary>
/// Consumo confermato (da ordinare)
/// </summary>
Confirmed,
/// <summary>
/// Riservato (utile x calcolo quantità da ordinare)
/// </summary>
Reserved
}
}
+1 -1
View File
@@ -8,7 +8,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="RestSharp" publicKeyToken="598062e77f915f75" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-110.2.1.0" newVersion="110.2.1.0" />
<bindingRedirect oldVersion="0.0.0.0-110.1.0.0" newVersion="110.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
+5
View File
@@ -25,6 +25,11 @@ namespace MagMan.Core
public List<ItemDTO>? ItemList { get; set; }
}
public class Projects
{
public ProjectDTO? Project { get; set; }
}
public class Resources
{
/// <summary>
+14 -6
View File
@@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using NLog;
using Org.BouncyCastle.Asn1.Pkcs;
using System.Diagnostics;
namespace MagMan.UI.Controllers
@@ -59,15 +60,22 @@ namespace MagMan.UI.Controllers
}
/// <summary>
/// Elenco Macchine dato RestToken
/// Elenco Progetti dato RestToken
/// </summary>
/// <param name="id">Rest Token cliente</param>
/// <param name="KeyNum">Chiave associata ai progetti</param>
/// <returns></returns>
// GET api/Machines/2cba60c7-7be4-40b1-aa0d-52e7c71fc1a7
[HttpGet("{id}")]
public async Task<List<MachineModel>> Get(string id, int KeyNum)
public async Task<List<ProjModel>> Get(string id, int KeyNum)
{
var ListRecords = await MTAdmService.MachineGetByToken(id);
List<ProjModel> ListRecords = new List<ProjModel>();
if (!string.IsNullOrEmpty(id))
{
// in primis recupero codice chiave da token...
int nKey = await MTAdmService.MainKeyByToken(id);
ListRecords = await TService.ProjectGetAll(nKey);
}
return ListRecords;
}
@@ -78,19 +86,19 @@ namespace MagMan.UI.Controllers
/// <param name="id">token comunicazione</param>
/// <returns></returns>
[HttpPost("upsert/{id}")]
public async Task<string> upsert(string id, [FromBody] ProjectDTO projectData)
public async Task<string> upsert(string id, [FromBody] RestPayload.Projects rawData)
{
string answ = "ND";
bool fatto = false;
// verifico ci sia valore
if (!string.IsNullOrEmpty(id) && projectData != null)
if (!string.IsNullOrEmpty(id) && rawData != null && rawData.Project != null)
{
// in primis recupero codice chiave da token...
int nKey = await MTAdmService.MainKeyByToken(id);
if (nKey > 0)
{
// converto ProjDto --> DB
var currRec = TService.ProjectFromDto(projectData);
var currRec = TService.ProjectFromDto(rawData.Project);
try
{
await TService.ProjectUpdate(nKey, currRec);
@@ -61,6 +61,7 @@ namespace MagMan.UI.Controllers
/// Elenco Macchine dato RestToken
/// </summary>
/// <param name="id">Rest Token cliente</param>
/// <param name="KeyNum">Chiave associata ai progetti</param>
/// <returns></returns>
// GET api/Machines/2cba60c7-7be4-40b1-aa0d-52e7c71fc1a7
[HttpGet("{id}")]
+1 -1
View File
@@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>1.0.2401.2220</Version>
<Version>1.0.2401.2309</Version>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>MagMan - Wood Warehouse Management System</i>
<h4>Versione: 1.0.2401.2220</h4>
<h4>Versione: 1.0.2401.2309</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.0.2401.2220
1.0.2401.2309
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.0.2401.2220</version>
<version>1.0.2401.2309</version>
<url>http://nexus.steamware.net/repository/SWS/MagMan/stable/0/MagMan.UI.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/MagMan/stable/0/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+1 -1
View File
@@ -11,7 +11,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="RestSharp" publicKeyToken="598062e77f915f75" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-110.2.1.0" newVersion="110.2.1.0" />
<bindingRedirect oldVersion="0.0.0.0-110.1.0.0" newVersion="110.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
+29 -1
View File
@@ -21,7 +21,7 @@ namespace DemoApp
// token di auth
string testToken = "91f4fec6-7e9c-4130-9df2-702d729ccdd3";
#else
// Indirizzo server (DEBUG)
// Indirizzo server (RELEASE)
string servAddr = "magman.egalware.com";
// token di auth
@@ -63,7 +63,9 @@ namespace DemoApp
Console.WriteLine();
}
}
Console.WriteLine("Enter to next step");
answ = Console.ReadLine();
// leggo inventario
var inventList = await commLib.InventoryGet(0);
if (inventList != null)
@@ -98,7 +100,33 @@ namespace DemoApp
Console.WriteLine();
}
}
Console.WriteLine("Enter to next step");
answ = Console.ReadLine();
// leggo projectList
var projList = await commLib.ProjectGet(470);
if (projList != null)
{
foreach (var itemMat in projList)
{
Console.WriteLine(sep);
Console.WriteLine($"MachineId: {itemMat.MachineID}");
Console.WriteLine($"Key: {itemMat.KeyNum}");
Console.WriteLine($"ProjExtDbId: {itemMat.ProjExtDbId}");
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(sep);
Console.WriteLine();
}
}
answ = Console.ReadLine();
Console.WriteLine("Enter to close");
answ = Console.ReadLine();
}
}
+33
View File
@@ -33,8 +33,40 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<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="RestSharp, Version=110.2.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.110.2.0\lib\net471\RestSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<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.Core" />
<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>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Text.Encodings.Web, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encodings.Web.7.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json, Version=7.0.0.3, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.7.0.3\lib\net462\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@@ -48,6 +80,7 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EgwProxy.MagMan\EgwProxy.MagMan.csproj">
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl.AsyncInterfaces" version="7.0.0" targetFramework="net472" />
<package id="RestSharp" version="110.2.0" targetFramework="net472" />
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net472" />
<package id="System.Text.Encodings.Web" version="7.0.0" targetFramework="net472" />
<package id="System.Text.Json" version="7.0.3" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
</packages>
+4
View File
@@ -9,6 +9,10 @@
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.3" newVersion="7.0.0.3" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
+3 -3
View File
@@ -55,7 +55,7 @@
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="RestSharp, Version=110.2.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.110.2.0\lib\net471\RestSharp.dll</HintPath>
@@ -80,8 +80,8 @@
<Reference Include="System.Text.Encodings.Web, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encodings.Web.7.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json, Version=7.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.7.0.2\lib\net462\System.Text.Json.dll</HintPath>
<Reference Include="System.Text.Json, Version=7.0.0.3, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.7.0.3\lib\net462\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
+2 -2
View File
@@ -2,14 +2,14 @@
<packages>
<package id="EgwProxy.MagMan" version="0.9.2401-beta.1719" targetFramework="net472" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="7.0.0" targetFramework="net472" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
<package id="RestSharp" version="110.2.0" targetFramework="net472" />
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net472" />
<package id="System.Text.Encodings.Web" version="7.0.0" targetFramework="net472" />
<package id="System.Text.Json" version="7.0.2" targetFramework="net472" />
<package id="System.Text.Json" version="7.0.3" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
</packages>