190 lines
7.5 KiB
C#
190 lines
7.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Diagnostics;
|
|
|
|
namespace EgwProxy.Ftp.Test
|
|
{
|
|
internal class Program
|
|
{
|
|
#region Private Methods
|
|
|
|
/// <summary>
|
|
/// legge conf in formato stringa
|
|
/// </summary>
|
|
/// <param name="key"></param>
|
|
/// <returns></returns>
|
|
protected static string ReadSetting(string key)
|
|
{
|
|
string answ = "";
|
|
try
|
|
{
|
|
answ = $"{ConfigurationManager.AppSettings[key]}" ?? "";
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
Console.Write("Eccezione in ReadSettings");
|
|
Console.Write(exc.Message);
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Programma principale
|
|
/// </summary>
|
|
/// <param name="args"></param>
|
|
private static void Main(string[] args)
|
|
{
|
|
Console.WriteLine("------------ Connessione Server FTP ------------");
|
|
string sSkipCert = ReadSetting("skipCert");
|
|
bool skipCert = false;
|
|
bool.TryParse(sSkipCert, out skipCert);
|
|
var ftpClient = new Manager(ReadSetting("server"), ReadSetting("userName"), ReadSetting("passwd"), ReadSetting("rawCert"), skipCert);
|
|
Console.WriteLine();
|
|
var testServer = ftpClient.serverOk();
|
|
Console.WriteLine($"Test connessione: esito {testServer}");
|
|
var srvType = ftpClient.serverType();
|
|
Console.WriteLine($"Server: {srvType}");
|
|
Console.WriteLine();
|
|
|
|
|
|
Console.WriteLine("--- Folder ---");
|
|
var testExists = ftpClient.dirExists($"data/test_folder");
|
|
if (testExists)
|
|
{
|
|
Console.WriteLine("Folder already exists!");
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("--- Create folder ---");
|
|
var testCreate = ftpClient.createDir($"data/test_folder");
|
|
Console.WriteLine();
|
|
}
|
|
|
|
Console.WriteLine("Contenuto folder remota: ");
|
|
var folderContent = ftpClient.listDir("data/", true);
|
|
foreach (var item in folderContent)
|
|
{
|
|
Console.WriteLine(item);
|
|
}
|
|
Console.WriteLine();
|
|
Console.WriteLine("Premere un tasto x continuare...");
|
|
Console.ReadKey();
|
|
|
|
|
|
Console.WriteLine("--- Upload file ---");
|
|
ftpClient.sendFile("test/FileProva.txt", "data/test_folder/FileProva.txt");
|
|
Console.WriteLine("Contenuto folder remota: ");
|
|
folderContent = ftpClient.listDir("data/", true);
|
|
foreach (var item in folderContent)
|
|
{
|
|
Console.WriteLine(item);
|
|
}
|
|
|
|
Console.WriteLine();
|
|
Console.WriteLine("Premere un tasto x continuare...");
|
|
Console.ReadKey();
|
|
|
|
|
|
Console.WriteLine("--- Download File ---");
|
|
|
|
ftpClient.getFile("test/FileProva_02.txt", "data/test_folder/FileProva.txt");
|
|
Console.WriteLine("Contenuto folder remota: ");
|
|
folderContent = ftpClient.listDir("data/", true);
|
|
foreach (var item in folderContent)
|
|
{
|
|
Console.WriteLine(item);
|
|
}
|
|
|
|
Console.WriteLine();
|
|
Console.WriteLine("Premere un tasto x continuare...");
|
|
Console.ReadKey();
|
|
|
|
#if false
|
|
// oggetto x connessione al sizer icoel
|
|
Connector IcoelSizer = new Connector(ReadSetting("IndirizzoIpSizer"), ReadSetting("SizerTcpPort"));
|
|
//Connector IcoelSizer = new Connector(setup.IndirizzoIpSizer, setup.SizerTcpPort);
|
|
|
|
Console.WriteLine("------------ Parametri CurrBatch rilevati ------------");
|
|
var cBatch = IcoelSizer.GetCurrBatchData();
|
|
if (cBatch != null)
|
|
{
|
|
DisplayCurrBatch(cBatch);
|
|
}
|
|
|
|
// ora effettua un pò di letture/scritture
|
|
try
|
|
{
|
|
Console.WriteLine("------------ TUTTE variety ------------");
|
|
var varList = IcoelSizer.GetVarietyList(false);
|
|
var varietyData = IcoelSizer.GetLayoutForVarietyList(varList);
|
|
if (varietyData != null)
|
|
{
|
|
DisplayVarietyLayout(varietyData);
|
|
}
|
|
Console.WriteLine();
|
|
Console.WriteLine("Premere un tasto x continuare...");
|
|
userInput = Console.ReadLine();
|
|
|
|
Console.WriteLine("------------ Parametri velocità rilevati ------------");
|
|
var perfMeter = IcoelSizer.GetPerfMeters();
|
|
if (perfMeter != null)
|
|
{
|
|
DisplayPerfMeter(perfMeter);
|
|
}
|
|
Console.WriteLine();
|
|
Console.WriteLine("Premere un tasto x continuare...");
|
|
userInput = Console.ReadLine();
|
|
|
|
// solo attive
|
|
Console.WriteLine("------------ solo attive ------------");
|
|
varList = IcoelSizer.GetVarietyList();
|
|
varietyData = IcoelSizer.GetLayoutForVarietyList(varList);
|
|
if (varietyData != null)
|
|
{
|
|
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();
|
|
|
|
Console.WriteLine("------------ Prova invio BATCH ------------");
|
|
// recupero GUID x variety e layout
|
|
var varGuid = selVariety(IcoelSizer);
|
|
var layGuid = selLayout(IcoelSizer, varGuid);
|
|
|
|
GrowerInfo GrowerData = new GrowerInfo();
|
|
IcoelSizer.EnqueueBatch(GrowerData, varGuid, layGuid);
|
|
|
|
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("Test completato");
|
|
Console.WriteLine("Premere un tasto x chiudere");
|
|
Console.ReadKey();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine("ECCEZIONE" + ex.Message + ex.StackTrace);
|
|
Console.ReadKey();
|
|
}
|
|
#endif
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |