Files
Mapo-IOB-WIN/Icoel.Soap/Compac/CompacClient.cs
T
2022-05-13 12:24:14 +02:00

115 lines
2.8 KiB
C#

using Icoel.Soap.SizerService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
namespace Tracker_GUI.Riempitori
{
public class CompacClient
{
/// <summary>
/// Client che inoltra le richieste al Sizer
/// </summary>
private SizerServiceClient Client { get; set; }
public bool connected
{
get
{
bool answ = false;
if (Client != null)
{
answ = Client.State == CommunicationState.Opened;
}
return answ;
}
}
public CompacClient(string Sizerip, string port)
{
var url = "http://" + Sizerip + ":" + port + "/SizerService/";
var epa = new EndpointAddress(new Uri(url));
Client = new SizerServiceClient("WSHttpBinding_ISizerService", epa);
}
internal void VerificaEsistenzaGrower(string growerCode, string growerName)
{
var grower = Client.GetGrower(growerCode);
if (grower == null)
{
var nuovo = new Grower() { Code = growerCode, Name = growerName };
Client.AddGrower(nuovo);
}
}
internal void Close()
{
if (Client.State != CommunicationState.Closed)
{
Client.Close();
}
}
internal Batch GetCurrentBatchByLane(int v)
{
return Client.GetCurrentBatchByLane(v);
}
internal Variety[] GetActiveVarieties()
{
return Client.GetActiveVarieties();
}
internal Layout GetActiveLayout(Guid VarietyId)
{
return Client.GetActiveLayout(VarietyId);
}
internal Layout[] GetLayouts(Guid VarietyId)
{
return Client.GetLayouts(VarietyId);
}
internal void MettiLottoInCoda(Batch batch)
{
Client.AddBatch(batch);
}
internal Batch GetCurrentBatch()
{
return Client.GetCurrentBatch();
}
}
[Serializable]
internal class IcoelSizerException : Exception
{
private Exception ex;
public IcoelSizerException()
{
}
public IcoelSizerException(Exception ex)
{
this.ex = ex;
}
public IcoelSizerException(string message) : base(message)
{
}
public IcoelSizerException(string message, Exception innerException) : base(message, innerException)
{
}
protected IcoelSizerException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}