Bozza lib Emmegi (probab non necessaria)

This commit is contained in:
Samuele Locatelli
2025-07-10 12:52:35 +02:00
parent f735bcecb7
commit c83cd9cc8a
9 changed files with 377 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup>
</configuration>
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A5DDEF7B-98C3-4391-B8BC-16CFC469B77E}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>EgwProxy.Emmegi.Test</RootNamespace>
<AssemblyName>EgwProxy.Emmegi.Test</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EgwProxy.Emmegi\EgwProxy.Emmegi.csproj">
<Project>{f3c0f746-b4fb-4cbb-92bd-9c9a686a21bb}</Project>
<Name>EgwProxy.Emmegi</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
+53
View File
@@ -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}");
}
}
}
}
}
}
@@ -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")]
+57
View File
@@ -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;
}
/// <summary>
/// restituisce stato impianto nel formato specifico
/// </summary>
/// <returns></returns>
public StatusDTO GetCurrentStatus()
{
StatusDTO answ = new StatusDTO();
// chiamo
string xmlRaw = @"<?xml version=""1.0"" encoding=""UTF-8""?>
<result_workstation_status>
<workstation>
<id id=""C129696"" />
<status>ON</status>
<status_timestamp>2025-07-10 11:30:31</status_timestamp>
<operator>unknown</operator>
<job_id>TAGLIO SINGOLO</job_id>
<operations>194312</operations>
<tot_operations>194312</tot_operations>
</workstation>
</result_workstation_status>";
// 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 = "";
}
}
+64
View File
@@ -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; }
}
/// <summary>
/// Obj workstation
/// </summary>
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; }
}
/// <summary>
/// Obj WorkstationId
/// </summary>
public class WorkstationId
{
[XmlAttribute("id")]
public string IdValue { get; set; }
}
}
+50
View File
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F3C0F746-B4FB-4CBB-92BD-9C9A686A21BB}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>EgwProxy.Emmegi</RootNamespace>
<AssemblyName>EgwProxy.Emmegi</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CallManager.cs" />
<Compile Include="DTO\StatusDTO.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Enums.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
+22
View File
@@ -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
}
}
}
@@ -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")]