Code refactor x riorganizzazione + preparazione test finale
This commit is contained in:
@@ -1,40 +1,48 @@
|
||||
using System.IO;
|
||||
|
||||
namespace BinsTracker.INI
|
||||
namespace EgwProxy.Icoel.Test.INI
|
||||
{
|
||||
public class Settaggi
|
||||
{
|
||||
|
||||
private const string NameFile = "conf.ini";
|
||||
private readonly IniFile _sett;
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public Settaggi()
|
||||
{
|
||||
_sett = new IniFile();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public string IndirizzoIpSizer
|
||||
{
|
||||
get { return _sett.GetKeyValue("Sizer", "IndirizzoIp"); }
|
||||
set { _sett.SetKeyValue("Sizer", "IndirizzoIp", value); }
|
||||
}
|
||||
|
||||
public string IndirizzoIpSizerClient
|
||||
{
|
||||
get { return _sett.GetKeyValue("Sizer", "IndirizzoIpTracciabilità"); }
|
||||
set { _sett.SetKeyValue("Sizer", "IndirizzoIpTracciabilità", value); }
|
||||
}
|
||||
|
||||
public string SizerTcpPort
|
||||
{
|
||||
get { return _sett.GetKeyValue("Sizer", "TcpPort"); }
|
||||
set { _sett.SetKeyValue("Sizer", "TcpPort", value); }
|
||||
}
|
||||
public string IndirizzoIpSizerClient
|
||||
{
|
||||
get { return _sett.GetKeyValue("Sizer", "IndirizzoIpTracciabilità"); }
|
||||
set { _sett.SetKeyValue("Sizer", "IndirizzoIpTracciabilità", value); }
|
||||
}
|
||||
|
||||
public string TcpPortSizerClient
|
||||
{
|
||||
get { return _sett.GetKeyValue("Sizer", "TcpPortTracciabilità"); }
|
||||
set { _sett.SetKeyValue("Sizer", "TcpPortTracciabilità", value); }
|
||||
}
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public void Load()
|
||||
{
|
||||
if (!File.Exists(NameFile))
|
||||
@@ -49,5 +57,14 @@ namespace BinsTracker.INI
|
||||
{
|
||||
_sett.Save(NameFile);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private const string NameFile = "conf.ini";
|
||||
private readonly IniFile _sett;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using EgwProxy.Icoel.SizerService;
|
||||
using EgwProxy.Icoel.Test.INI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -180,18 +181,14 @@ namespace EgwProxy.Icoel.Test
|
||||
/// <param name="args"></param>
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
// ersempio funzionamento connector via console app setp 1: legge conf da file ini che
|
||||
// si trovano in bin (riportati come conf principali)
|
||||
// leggo conf da file ini (ip/port)
|
||||
Console.WriteLine("Loading Files...");
|
||||
Settaggi setup = new Settaggi();
|
||||
string userInput = "";
|
||||
// oggetto x connessione
|
||||
Connector IcoelSizer = new Connector(setup.IndirizzoIpSizer, setup.TcpPortSizerClient);
|
||||
|
||||
Connector IcoelSizer = new Connector("192.168.137.50", "8001");
|
||||
|
||||
#if false
|
||||
Connector.Load();
|
||||
#endif
|
||||
|
||||
// ora effettua lettura Varietà e Layout disponibili
|
||||
|
||||
// ora effettua un pò di letture/scritture
|
||||
try
|
||||
{
|
||||
Console.WriteLine("------------ TUTTE variety ------------");
|
||||
@@ -202,6 +199,9 @@ namespace EgwProxy.Icoel.Test
|
||||
DisplayVarietyLayout(varietyData);
|
||||
}
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Premere un tasto x continuare...");
|
||||
userInput = Console.ReadLine();
|
||||
|
||||
// solo attive
|
||||
Console.WriteLine("------------ solo attive ------------");
|
||||
varList = IcoelSizer.GetVarietyList();
|
||||
@@ -211,16 +211,21 @@ namespace EgwProxy.Icoel.Test
|
||||
DisplayVarietyLayout(varietyData);
|
||||
}
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Premere un tasto x continuare...");
|
||||
userInput = Console.ReadLine();
|
||||
|
||||
Console.WriteLine("------------ BATCH correnti ------------");
|
||||
var currBatch = IcoelSizer.GetCurrentBatch();
|
||||
foreach (var item in currBatch)
|
||||
{
|
||||
string lato = item.Key == 1 ? "SX" : "DX";
|
||||
Console.WriteLine($"[{item.Key}-{lato}] Grower code: {item.Value.GrowerCode} | Layout Name: {item.Value.LayoutName} | Totalling: [{item.Value.TotallingVarietyCode}] {item.Value.TotallingVariety} | Sizing: {item.Value.SizingProfileName} | Start {item.Value.StartTime} | End {item.Value.EndTime}");
|
||||
}
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Premere un tasto x continuare...");
|
||||
userInput = Console.ReadLine();
|
||||
|
||||
// verifico grower (se non ci fosse crea)
|
||||
|
||||
Console.WriteLine("------------ Prova invio BATCH ------------");
|
||||
// recupero GUID x variety e layout
|
||||
var varGuid = selVariety(IcoelSizer);
|
||||
var layGuid = selLayout(IcoelSizer, varGuid);
|
||||
@@ -230,7 +235,8 @@ namespace EgwProxy.Icoel.Test
|
||||
|
||||
IcoelSizer.GetCurrentBatch();
|
||||
|
||||
Console.WriteLine("Done.");
|
||||
Console.WriteLine("Test completato");
|
||||
Console.WriteLine("Premere un tasto x chiudere");
|
||||
Console.ReadKey();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -5,21 +5,10 @@ using System.ServiceModel;
|
||||
|
||||
namespace EgwProxy.Icoel.Compac
|
||||
{
|
||||
public class ComClient:IDisposable
|
||||
public class ComClient : IDisposable
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Inidirizzo IP
|
||||
/// </summary>
|
||||
internal string ipAddress { get; set; } = "127.0.0.1";
|
||||
|
||||
/// <summary>
|
||||
/// Porta del webservice (SOAP)
|
||||
/// </summary>
|
||||
internal string tcpPort { get; set; } = "8001";
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto client comunicazione con sizer ICOEL per invio/recupero informazioni di
|
||||
/// produzione (batch)
|
||||
@@ -38,7 +27,6 @@ namespace EgwProxy.Icoel.Compac
|
||||
SSClient = new SizerServiceClient("WSHttpBinding_ISizerService", epa);
|
||||
}
|
||||
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
@@ -63,6 +51,49 @@ namespace EgwProxy.Icoel.Compac
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Dispose dell'oggetto
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Internal Properties
|
||||
|
||||
/// <summary>
|
||||
/// Inidirizzo IP
|
||||
/// </summary>
|
||||
internal string ipAddress { get; set; } = "127.0.0.1";
|
||||
|
||||
/// <summary>
|
||||
/// Porta del webservice (SOAP)
|
||||
/// </summary>
|
||||
internal string tcpPort { get; set; } = "8001";
|
||||
|
||||
#endregion Internal Properties
|
||||
|
||||
#region Internal Methods
|
||||
|
||||
/// <summary>
|
||||
/// Verifica del grower da codice/nome con eventuale creazione se mancante
|
||||
/// </summary>
|
||||
/// <param name="growerCode">Codice del produttore</param>
|
||||
/// <param name="growerName">Denominazione del produttore</param>
|
||||
internal void CheckGrower(string growerCode, string growerName)
|
||||
{
|
||||
var grower = SSClient.GetGrower(growerCode);
|
||||
|
||||
if (grower == null)
|
||||
{
|
||||
var nuovo = new Grower() { Code = growerCode, Name = growerName };
|
||||
|
||||
SSClient.AddGrower(nuovo);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua chiusura del proxy di comunicazione
|
||||
/// </summary>
|
||||
@@ -74,10 +105,6 @@ namespace EgwProxy.Icoel.Compac
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Internal Methods
|
||||
|
||||
/// <summary>
|
||||
/// Elenco dei layout attivi della varietà
|
||||
/// </summary>
|
||||
@@ -96,6 +123,7 @@ namespace EgwProxy.Icoel.Compac
|
||||
{
|
||||
return SSClient.GetActiveVarieties();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco varietà (tutte)
|
||||
/// </summary>
|
||||
@@ -143,31 +171,6 @@ namespace EgwProxy.Icoel.Compac
|
||||
SSClient.AddBatch(batch);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifica del grower da codice/nome con eventuale creazione se mancante
|
||||
/// </summary>
|
||||
/// <param name="growerCode">Codice del produttore</param>
|
||||
/// <param name="growerName">Denominazione del produttore</param>
|
||||
internal void CheckGrower(string growerCode, string growerName)
|
||||
{
|
||||
var grower = SSClient.GetGrower(growerCode);
|
||||
|
||||
if (grower == null)
|
||||
{
|
||||
var nuovo = new Grower() { Code = growerCode, Name = growerName };
|
||||
|
||||
SSClient.AddGrower(nuovo);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose dell'oggetto
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
#endregion Internal Methods
|
||||
|
||||
#region Private Properties
|
||||
|
||||
+12
-93
@@ -24,6 +24,10 @@ namespace EgwProxy.Icoel
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Verifica il fornitore e se non ci fosse crea
|
||||
/// </summary>
|
||||
/// <param name="GrowerData"></param>
|
||||
public void CheckGrower(GrowerInfo GrowerData)
|
||||
{
|
||||
using (var Client = new ComClient(ipAddress, tcpPort))
|
||||
@@ -150,76 +154,6 @@ namespace EgwProxy.Icoel
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Verifica il fornitore, se non esistesse lo crea
|
||||
/// </summary>
|
||||
/// <param name="GrowerData">Oggetto dati del fornitore</param>
|
||||
#if false
|
||||
public void MettiLottoInCoda()
|
||||
{
|
||||
using (var Client = new ComClient(ipAddress, tcpPort))
|
||||
{
|
||||
// recupero varietà x selezione
|
||||
var varList = GetVarietyList(true);
|
||||
|
||||
int idxVar = -1;
|
||||
int idxLay = -1;
|
||||
|
||||
Guid varGuid = Guid.NewGuid();
|
||||
Guid layGuid = Guid.NewGuid();
|
||||
|
||||
// recupero layout della varietà
|
||||
var layoutList = Client.GetLayouts(varGuid);
|
||||
// recupero layout x varietà
|
||||
while (idxLay <= 0)
|
||||
{
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("indicare layout");
|
||||
var rawData = Console.ReadLine();
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
int.TryParse(rawData, out idxLay);
|
||||
// verifico sia valida..
|
||||
if (layoutList.Length >= idxLay)
|
||||
{
|
||||
layGuid = layoutList[idxLay - 1].Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
idxLay = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// compongo batch e metto in coda
|
||||
GrowerInfo GrowerData = new GrowerInfo();
|
||||
Batch newBatch = CreateBatch(GrowerData, varGuid, layGuid, sizingProfile);
|
||||
|
||||
Client.MettiLottoInCoda(newBatch);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Mette in coda un lotto con valori default
|
||||
/// </summary>
|
||||
public void EnqueueBatchDefault()
|
||||
{
|
||||
using (var Client = new ComClient(ipAddress, tcpPort))
|
||||
{
|
||||
Client.VerificaEsistenzaGrower(Details.GrowerCode, Details.GrowerName);
|
||||
Client.MettiLottoInCoda(GeneraBatchDaFile());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Dettaglio dei batch
|
||||
/// </summary>
|
||||
private GrowerInfo GrowerData { get; set; } = new GrowerInfo();
|
||||
#endif
|
||||
|
||||
#region Private Properties
|
||||
|
||||
/// <summary>
|
||||
@@ -234,31 +168,16 @@ namespace EgwProxy.Icoel
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#if false
|
||||
private Batch GeneraBatchDaFile()
|
||||
{
|
||||
var batch = new Batch();
|
||||
|
||||
batch.GrowerCode = Details.GrowerCode;
|
||||
|
||||
batch.AvoidLayoutChange = true;
|
||||
batch.AvoidSavingOldLayouts = true;
|
||||
|
||||
batch.Comments = new string[Details.Comments.Count];
|
||||
batch.Comments = Details.Comments.ToArray();
|
||||
|
||||
using (var Client = new ComClient(ipAddress, tcpPort))
|
||||
{
|
||||
batch.VarietyId = Client.GetCurrentBatch().VarietyId;
|
||||
batch.LayoutId = Client.GetCurrentBatch().LayoutId;
|
||||
batch.SizingProfileName = Client.GetCurrentBatch().SizingProfileName;
|
||||
}
|
||||
return batch;
|
||||
}
|
||||
#endif
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Genera un obj batch dati i parametri necessari
|
||||
/// </summary>
|
||||
/// <param name="GrowerData"></param>
|
||||
/// <param name="VarietyId"></param>
|
||||
/// <param name="LayoutId"></param>
|
||||
/// <param name="SizingProfileName"></param>
|
||||
/// <returns></returns>
|
||||
private Batch CreateBatch(GrowerInfo GrowerData, Guid VarietyId, Guid LayoutId, string SizingProfileName)
|
||||
{
|
||||
var batch = new Batch();
|
||||
|
||||
@@ -9,6 +9,11 @@ namespace EgwProxy.Icoel
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Riga commento 01
|
||||
/// </summary>
|
||||
public List<string> Comments { get; set; } = new List<string>() { "Commento 01", "Commento 02", "Commento 01" };
|
||||
|
||||
/// <summary>
|
||||
/// Codice univoco fornitore
|
||||
/// </summary>
|
||||
@@ -19,11 +24,6 @@ namespace EgwProxy.Icoel
|
||||
/// </summary>
|
||||
public string GrowerName { get; set; } = "Egalware";
|
||||
|
||||
/// <summary>
|
||||
/// Riga commento 01
|
||||
/// </summary>
|
||||
public List<string> Comments { get; set; } = new List<string>() { "Commento 01" , "Commento 02", "Commento 01" };
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user