From c83cd9cc8a2d6d38e0cc41f7c2074dbbc25c501f Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 10 Jul 2025 12:52:35 +0200 Subject: [PATCH] Bozza lib Emmegi (probab non necessaria) --- EgwProxy.Emmegi.Test/App.config | 6 ++ .../EgwProxy.Emmegi.Test.csproj | 59 +++++++++++++++++ EgwProxy.Emmegi.Test/Program.cs | 53 +++++++++++++++ .../Properties/AssemblyInfo.cs | 33 ++++++++++ EgwProxy.Emmegi/CallManager.cs | 57 +++++++++++++++++ EgwProxy.Emmegi/DTO/StatusDTO.cs | 64 +++++++++++++++++++ EgwProxy.Emmegi/EgwProxy.Emmegi.csproj | 50 +++++++++++++++ EgwProxy.Emmegi/Enums.cs | 22 +++++++ EgwProxy.Emmegi/Properties/AssemblyInfo.cs | 33 ++++++++++ 9 files changed, 377 insertions(+) create mode 100644 EgwProxy.Emmegi.Test/App.config create mode 100644 EgwProxy.Emmegi.Test/EgwProxy.Emmegi.Test.csproj create mode 100644 EgwProxy.Emmegi.Test/Program.cs create mode 100644 EgwProxy.Emmegi.Test/Properties/AssemblyInfo.cs create mode 100644 EgwProxy.Emmegi/CallManager.cs create mode 100644 EgwProxy.Emmegi/DTO/StatusDTO.cs create mode 100644 EgwProxy.Emmegi/EgwProxy.Emmegi.csproj create mode 100644 EgwProxy.Emmegi/Enums.cs create mode 100644 EgwProxy.Emmegi/Properties/AssemblyInfo.cs diff --git a/EgwProxy.Emmegi.Test/App.config b/EgwProxy.Emmegi.Test/App.config new file mode 100644 index 0000000..b50c74f --- /dev/null +++ b/EgwProxy.Emmegi.Test/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/EgwProxy.Emmegi.Test/EgwProxy.Emmegi.Test.csproj b/EgwProxy.Emmegi.Test/EgwProxy.Emmegi.Test.csproj new file mode 100644 index 0000000..4782b94 --- /dev/null +++ b/EgwProxy.Emmegi.Test/EgwProxy.Emmegi.Test.csproj @@ -0,0 +1,59 @@ + + + + + Debug + AnyCPU + {A5DDEF7B-98C3-4391-B8BC-16CFC469B77E} + Exe + EgwProxy.Emmegi.Test + EgwProxy.Emmegi.Test + v4.6.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + {f3c0f746-b4fb-4cbb-92bd-9c9a686a21bb} + EgwProxy.Emmegi + + + + \ No newline at end of file diff --git a/EgwProxy.Emmegi.Test/Program.cs b/EgwProxy.Emmegi.Test/Program.cs new file mode 100644 index 0000000..f5b6cda --- /dev/null +++ b/EgwProxy.Emmegi.Test/Program.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EgwProxy.Emmegi.Test +{ + internal class Program + { + static void Main(string[] args) + { + string linea = "-----------------------------"; + Console.WriteLine(linea); + Console.WriteLine("Test comunicazione Emmegi"); + Console.WriteLine(linea); + Console.WriteLine(); + + string escimi = "N"; + EgwProxy.Emmegi.CallManager EmmegiMan = new CallManager("http://192.168.100.59", 8090, "C129696"); + + + + Console.WriteLine("Premere un tasto per iniziare test."); + escimi = Console.ReadLine().ToUpper(); + + int idxReq = 10; + // lettura + while (escimi != "E") + { + string output = ""; + Console.WriteLine("Cosa vuoi fare ora? S = Status, E = Uscita"); + escimi = Console.ReadLine().ToUpper(); + DateTime adesso = DateTime.Now; + // invio pesata + if (escimi == "S") + { + try + { + var answ = EmmegiMan.GetCurrentStatus(); + output = $"Dt: {answ.Workstation.StatusTimestamp} | WrkId: {answ.Workstation.Id.IdValue} | Operatore: {answ.Workstation.Operator} | Job: {answ.Workstation.JobId} | Status: {answ.Workstation.Status} | # Tagli Job: {answ.Workstation.Operations} | # Tot Tagli: {answ.Workstation.TotalOperations}"; + Console.WriteLine(output); + Console.WriteLine(); + } + catch (Exception exc) + { + Console.WriteLine($"Errore:{Environment.NewLine}{exc}"); + } + } + } + } + } +} diff --git a/EgwProxy.Emmegi.Test/Properties/AssemblyInfo.cs b/EgwProxy.Emmegi.Test/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..5c97631 --- /dev/null +++ b/EgwProxy.Emmegi.Test/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("EgwProxy.Emmegi.Test")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("EgwProxy.Emmegi.Test")] +[assembly: AssemblyCopyright("Copyright © 2025")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a5ddef7b-98c3-4391-b8bc-16cfc469b77e")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/EgwProxy.Emmegi/CallManager.cs b/EgwProxy.Emmegi/CallManager.cs new file mode 100644 index 0000000..701b36b --- /dev/null +++ b/EgwProxy.Emmegi/CallManager.cs @@ -0,0 +1,57 @@ +using EgwProxy.Emmegi.DTO; +using System; +using System.Collections.Generic; +using System.Data.SqlTypes; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace EgwProxy.Emmegi +{ + public class CallManager + { + + public CallManager(string baseUrl, int port, string workstationId) + { + BaseUrl = baseUrl; + Port= port; + WorkstationId = workstationId; + } + + /// + /// restituisce stato impianto nel formato specifico + /// + /// + public StatusDTO GetCurrentStatus() + { + StatusDTO answ = new StatusDTO(); + + // chiamo + string xmlRaw = @" + + + + ON + 2025-07-10 11:30:31 + unknown + TAGLIO SINGOLO + 194312 + 194312 + + "; + // deserializzo + var serializer = new XmlSerializer(typeof(StatusDTO)); + using (var reader = new StringReader(xmlRaw)) + { + answ = (StatusDTO)serializer.Deserialize(reader); + } + return answ; + } + + private string BaseUrl = ""; + private int Port = 0; + private string WorkstationId = ""; + } +} diff --git a/EgwProxy.Emmegi/DTO/StatusDTO.cs b/EgwProxy.Emmegi/DTO/StatusDTO.cs new file mode 100644 index 0000000..1d973c9 --- /dev/null +++ b/EgwProxy.Emmegi/DTO/StatusDTO.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices.ComTypes; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace EgwProxy.Emmegi.DTO +{ + + [XmlRoot("result_workstation_status")] + public class StatusDTO + { + [XmlElement("workstation")] + public Workstation Workstation { get; set; } + } + + /// + /// Obj workstation + /// + public class Workstation + { + + [XmlElement("id")] + public WorkstationId Id { get; set; } + + [XmlElement("status")] + public Enums.MachineStatus Status { get; set; } + + [XmlElement("status_timestamp")] + public string StatusTimestampRaw { get; set; } + + [XmlIgnore] + public DateTime StatusTimestamp + { + get => DateTime.ParseExact(StatusTimestampRaw, "yyyy-MM-dd HH:mm:ss", null); + } + + [XmlElement("operator")] + public string Operator { get; set; } + + [XmlElement("job_id")] + public string JobId { get; set; } + + [XmlElement("operations")] + public int Operations { get; set; } + + [XmlElement("tot_operations")] + public int TotalOperations { get; set; } + } + + /// + /// Obj WorkstationId + /// + public class WorkstationId + { + [XmlAttribute("id")] + public string IdValue { get; set; } + } + +} + + diff --git a/EgwProxy.Emmegi/EgwProxy.Emmegi.csproj b/EgwProxy.Emmegi/EgwProxy.Emmegi.csproj new file mode 100644 index 0000000..e4fbd84 --- /dev/null +++ b/EgwProxy.Emmegi/EgwProxy.Emmegi.csproj @@ -0,0 +1,50 @@ + + + + + Debug + AnyCPU + {F3C0F746-B4FB-4CBB-92BD-9C9A686A21BB} + Library + Properties + EgwProxy.Emmegi + EgwProxy.Emmegi + v4.6.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/EgwProxy.Emmegi/Enums.cs b/EgwProxy.Emmegi/Enums.cs new file mode 100644 index 0000000..4d385d9 --- /dev/null +++ b/EgwProxy.Emmegi/Enums.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EgwProxy.Emmegi +{ + public class Enums + { + public enum MachineStatus + { + ON, + WORKING, + OFF_LINE, + + OFF, + WAIT, + ERROR + } + } +} diff --git a/EgwProxy.Emmegi/Properties/AssemblyInfo.cs b/EgwProxy.Emmegi/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..3125454 --- /dev/null +++ b/EgwProxy.Emmegi/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("EgwProxy.Emmegi")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("EgwProxy.Emmegi")] +[assembly: AssemblyCopyright("Copyright © 2025")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("f3c0f746-b4fb-4cbb-92bd-9c9a686a21bb")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")]