Inizio modifiche calsse Icoel da ritestare x gestione corretta dll
This commit is contained in:
@@ -43,11 +43,20 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="INI\BatchDetails.cs" />
|
||||
<Compile Include="INI\IniFileCs.cs" />
|
||||
<Compile Include="INI\Settaggi.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="batch.ini">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="conf.ini">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\EgwProxy.Icoel\EgwProxy.Icoel.csproj">
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EgwProxy.Icoel.INI
|
||||
{
|
||||
class BatchDetails
|
||||
{
|
||||
private const string NameFile = "batch.ini";
|
||||
private readonly IniFile _sett;
|
||||
|
||||
|
||||
public BatchDetails()
|
||||
{
|
||||
_sett = new IniFile();
|
||||
}
|
||||
public string GrowerCode
|
||||
{
|
||||
get { return _sett.GetKeyValue("Batch", "GrowerCode"); }
|
||||
set { _sett.SetKeyValue("Batch", "GrowerCode", value); }
|
||||
}
|
||||
|
||||
public string GrowerName
|
||||
{
|
||||
get { return _sett.GetKeyValue("Batch", "GrowerName"); }
|
||||
set { _sett.SetKeyValue("Batch", "GrowerName", value); }
|
||||
}
|
||||
public string Comment1
|
||||
{
|
||||
get { return _sett.GetKeyValue("Batch", "Comment1"); }
|
||||
set { _sett.SetKeyValue("Batch", "Comment1", value); }
|
||||
}
|
||||
public string Comment2
|
||||
{
|
||||
get { return _sett.GetKeyValue("Batch", "Comment2"); }
|
||||
set { _sett.SetKeyValue("Batch", "Comment2", value); }
|
||||
}
|
||||
public string Comment3
|
||||
{
|
||||
get { return _sett.GetKeyValue("Batch", "Comment3"); }
|
||||
set { _sett.SetKeyValue("Batch", "Comment3", value); }
|
||||
}
|
||||
|
||||
public void Load()
|
||||
{
|
||||
if (!File.Exists(NameFile))
|
||||
{
|
||||
var fs = File.Create(NameFile);
|
||||
fs.Close();
|
||||
}
|
||||
_sett.Load(NameFile, false);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
_sett.Save(NameFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,479 @@
|
||||
/*
|
||||
Date: 08\23\2010 - Ludvik Jerabek - Initial Release
|
||||
Version: 1.0
|
||||
Comment: Allow INI manipulation in .NET
|
||||
License: CPOL
|
||||
|
||||
Revisions:
|
||||
|
||||
08\23\2010 - Ludvik Jerabek - Initial Release
|
||||
11\12\2010 - Ludvik Jerabek - Fixed section regex matching on key values with brackets
|
||||
06\20\2015 - Ludvik Jerabek - Fixed key parsing regex to account for keys with spaces in names
|
||||
|
||||
|
||||
**DISCLAIMER**
|
||||
THIS MATERIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
|
||||
EITHER EXPRESS OR IMPLIED, INCLUDING, BUT Not LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE, OR NON-INFRINGEMENT. SOME JURISDICTIONS DO NOT ALLOW THE
|
||||
EXCLUSION OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSION MAY NOT
|
||||
APPLY TO YOU. IN NO EVENT WILL I BE LIABLE TO ANY PARTY FOR ANY
|
||||
DIRECT, INDIRECT, SPECIAL OR OTHER CONSEQUENTIAL DAMAGES FOR ANY
|
||||
USE OF THIS MATERIAL INCLUDING, WITHOUT LIMITATION, ANY LOST
|
||||
PROFITS, BUSINESS INTERRUPTION, LOSS OF PROGRAMS OR OTHER DATA ON
|
||||
YOUR INFORMATION HANDLING SYSTEM OR OTHERWISE, EVEN If WE ARE
|
||||
EXPRESSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*/
|
||||
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Collections;
|
||||
using System.Diagnostics;
|
||||
using System;
|
||||
|
||||
// IniFile class used to read and write ini files by loading the file into memory
|
||||
public class IniFile
|
||||
{
|
||||
// List of IniSection objects keeps track of all the sections in the INI file
|
||||
private Hashtable m_sections;
|
||||
|
||||
// Public constructor
|
||||
public IniFile()
|
||||
{
|
||||
m_sections = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
// Loads the Reads the data in the ini file into the IniFile object
|
||||
public void Load(string sFileName )
|
||||
{
|
||||
Load(sFileName, false);
|
||||
}
|
||||
|
||||
// Loads the Reads the data in the ini file into the IniFile object
|
||||
public void Load(string sFileName, bool bMerge )
|
||||
{
|
||||
if (!bMerge)
|
||||
{
|
||||
RemoveAllSections();
|
||||
}
|
||||
// Clear the object...
|
||||
IniSection tempsection = null;
|
||||
StreamReader oReader = new StreamReader(sFileName);
|
||||
Regex regexcomment = new Regex("^([\\s]*#.*)", (RegexOptions.Singleline | RegexOptions.IgnoreCase));
|
||||
Regex regexsection = new Regex("^[\\s]*\\[[\\s]*([^\\[\\s].*[^\\s\\]])[\\s]*\\][\\s]*$", (RegexOptions.Singleline | RegexOptions.IgnoreCase));
|
||||
Regex regexkey = new Regex("^\\s*([^=]*[^\\s=])\\s*=(.*)", (RegexOptions.Singleline | RegexOptions.IgnoreCase));
|
||||
|
||||
while (!oReader.EndOfStream)
|
||||
{
|
||||
string line = oReader.ReadLine();
|
||||
if (line != string.Empty)
|
||||
{
|
||||
Match m = null;
|
||||
if (regexcomment.Match(line).Success)
|
||||
{
|
||||
m = regexcomment.Match(line);
|
||||
Trace.WriteLine(string.Format("Skipping Comment: {0}", m.Groups[0].Value));
|
||||
}
|
||||
else if (regexsection.Match(line).Success)
|
||||
{
|
||||
m = regexsection.Match(line);
|
||||
Trace.WriteLine(string.Format("Adding section [{0}]", m.Groups[1].Value));
|
||||
tempsection = AddSection(m.Groups[1].Value);
|
||||
}
|
||||
else if ( regexkey.Match(line).Success && tempsection != null)
|
||||
{
|
||||
m = regexkey.Match(line);
|
||||
Trace.WriteLine(string.Format("Adding Key [{0}]=[{1}]", m.Groups[1].Value, m.Groups[2].Value));
|
||||
tempsection.AddKey(m.Groups[1].Value).Value = m.Groups[2].Value;
|
||||
}
|
||||
else if ( tempsection != null )
|
||||
{
|
||||
// Handle Key without Value
|
||||
Trace.WriteLine(string.Format("Adding Key [{0}]", line));
|
||||
tempsection.AddKey(line);
|
||||
}
|
||||
else
|
||||
{
|
||||
// This should not occur unless the tempsection is not created yet...
|
||||
Trace.WriteLine(string.Format("Skipping unknown type of data: {0}", line));
|
||||
}
|
||||
}
|
||||
}
|
||||
oReader.Close();
|
||||
}
|
||||
|
||||
// Used to save the data back to the file or your choice
|
||||
public void Save(string sFileName)
|
||||
{
|
||||
StreamWriter oWriter = new StreamWriter(sFileName, false);
|
||||
foreach (IniSection s in Sections)
|
||||
{
|
||||
Trace.WriteLine(string.Format("Writing Section: [{0}]", s.Name));
|
||||
oWriter.WriteLine(string.Format("[{0}]", s.Name));
|
||||
foreach (IniSection.IniKey k in s.Keys)
|
||||
{
|
||||
if (k.Value != string.Empty)
|
||||
{
|
||||
Trace.WriteLine(string.Format("Writing Key: {0}={1}", k.Name, k.Value));
|
||||
oWriter.WriteLine(string.Format("{0}={1}", k.Name, k.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
Trace.WriteLine(string.Format("Writing Key: {0}", k.Name));
|
||||
oWriter.WriteLine(string.Format("{0}", k.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
oWriter.Close();
|
||||
}
|
||||
|
||||
// Gets all the sections names
|
||||
public System.Collections.ICollection Sections
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_sections.Values;
|
||||
}
|
||||
}
|
||||
|
||||
// Adds a section to the IniFile object, returns a IniSection object to the new or existing object
|
||||
public IniSection AddSection(string sSection )
|
||||
{
|
||||
IniSection s = null;
|
||||
sSection = sSection.Trim();
|
||||
// Trim spaces
|
||||
if (m_sections.ContainsKey(sSection))
|
||||
{
|
||||
s = (IniSection)m_sections[sSection];
|
||||
}
|
||||
else
|
||||
{
|
||||
s = new IniSection(this, sSection);
|
||||
m_sections[sSection] = s;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
// Removes a section by its name sSection, returns trus on success
|
||||
public bool RemoveSection(string sSection)
|
||||
{
|
||||
sSection = sSection.Trim();
|
||||
return RemoveSection(GetSection(sSection));
|
||||
}
|
||||
|
||||
// Removes section by object, returns trus on success
|
||||
public bool RemoveSection(IniSection Section)
|
||||
{
|
||||
if (Section != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_sections.Remove(Section.Name);
|
||||
return true;
|
||||
}
|
||||
catch( Exception ex )
|
||||
{
|
||||
Trace.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Removes all existing sections, returns trus on success
|
||||
public bool RemoveAllSections()
|
||||
{
|
||||
m_sections.Clear();
|
||||
return (m_sections.Count == 0);
|
||||
}
|
||||
|
||||
// Returns an IniSection to the section by name, NULL if it was not found
|
||||
public IniSection GetSection(string sSection)
|
||||
{
|
||||
sSection = sSection.Trim();
|
||||
// Trim spaces
|
||||
if (m_sections.ContainsKey(sSection))
|
||||
{
|
||||
return (IniSection)m_sections[sSection];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Returns a KeyValue in a certain section
|
||||
public string GetKeyValue(string sSection, string sKey)
|
||||
{
|
||||
IniSection s = GetSection(sSection);
|
||||
if (s != null)
|
||||
{
|
||||
IniSection.IniKey k = s.GetKey(sKey);
|
||||
if (k != null)
|
||||
{
|
||||
return k.Value;
|
||||
}
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
// Sets a KeyValuePair in a certain section
|
||||
public bool SetKeyValue(string sSection, string sKey, string sValue)
|
||||
{
|
||||
IniSection s = AddSection(sSection);
|
||||
if (s != null)
|
||||
{
|
||||
IniSection.IniKey k = s.AddKey(sKey);
|
||||
if (k != null)
|
||||
{
|
||||
k.Value = sValue;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Renames an existing section returns true on success, false if the section didn't exist or there was another section with the same sNewSection
|
||||
public bool RenameSection(string sSection, string sNewSection)
|
||||
{
|
||||
// Note string trims are done in lower calls.
|
||||
bool bRval = false;
|
||||
IniSection s = GetSection(sSection);
|
||||
if (s != null)
|
||||
{
|
||||
bRval = s.SetName(sNewSection);
|
||||
}
|
||||
return bRval;
|
||||
}
|
||||
|
||||
// Renames an existing key returns true on success, false if the key didn't exist or there was another section with the same sNewKey
|
||||
public bool RenameKey(string sSection, string sKey, string sNewKey)
|
||||
{
|
||||
// Note string trims are done in lower calls.
|
||||
IniSection s = GetSection(sSection);
|
||||
if (s != null)
|
||||
{
|
||||
IniSection.IniKey k = s.GetKey(sKey);
|
||||
if (k != null)
|
||||
{
|
||||
return k.SetName(sNewKey);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// IniSection class
|
||||
public class IniSection
|
||||
{
|
||||
// IniFile IniFile object instance
|
||||
private IniFile m_pIniFile;
|
||||
// Name of the section
|
||||
private string m_sSection;
|
||||
// List of IniKeys in the section
|
||||
private Hashtable m_keys;
|
||||
|
||||
// Constuctor so objects are internally managed
|
||||
protected internal IniSection(IniFile parent, string sSection)
|
||||
{
|
||||
m_pIniFile = parent;
|
||||
m_sSection = sSection;
|
||||
m_keys = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
// Returns and hashtable of keys associated with the section
|
||||
public System.Collections.ICollection Keys
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_keys.Values;
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the section name
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_sSection;
|
||||
}
|
||||
}
|
||||
|
||||
// Adds a key to the IniSection object, returns a IniKey object to the new or existing object
|
||||
public IniKey AddKey(string sKey)
|
||||
{
|
||||
sKey = sKey.Trim();
|
||||
IniSection.IniKey k = null;
|
||||
if (sKey.Length != 0)
|
||||
{
|
||||
if (m_keys.ContainsKey(sKey))
|
||||
{
|
||||
k = (IniKey)m_keys[sKey];
|
||||
}
|
||||
else
|
||||
{
|
||||
k = new IniSection.IniKey(this, sKey);
|
||||
m_keys[sKey] = k;
|
||||
}
|
||||
}
|
||||
return k;
|
||||
}
|
||||
|
||||
// Removes a single key by string
|
||||
public bool RemoveKey(string sKey)
|
||||
{
|
||||
return RemoveKey(GetKey(sKey));
|
||||
}
|
||||
|
||||
// Removes a single key by IniKey object
|
||||
public bool RemoveKey(IniKey Key)
|
||||
{
|
||||
if (Key != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_keys.Remove(Key.Name);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Trace.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Removes all the keys in the section
|
||||
public bool RemoveAllKeys()
|
||||
{
|
||||
m_keys.Clear();
|
||||
return (m_keys.Count == 0);
|
||||
}
|
||||
|
||||
// Returns a IniKey object to the key by name, NULL if it was not found
|
||||
public IniKey GetKey(string sKey)
|
||||
{
|
||||
sKey = sKey.Trim();
|
||||
if (m_keys.ContainsKey(sKey))
|
||||
{
|
||||
return (IniKey)m_keys[sKey];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Sets the section name, returns true on success, fails if the section
|
||||
// name sSection already exists
|
||||
public bool SetName(string sSection)
|
||||
{
|
||||
sSection = sSection.Trim();
|
||||
if (sSection.Length != 0)
|
||||
{
|
||||
// Get existing section if it even exists...
|
||||
IniSection s = m_pIniFile.GetSection(sSection);
|
||||
if (s != this && s != null) return false;
|
||||
try
|
||||
{
|
||||
// Remove the current section
|
||||
m_pIniFile.m_sections.Remove(m_sSection);
|
||||
// Set the new section name to this object
|
||||
m_pIniFile.m_sections[sSection] = this;
|
||||
// Set the new section name
|
||||
m_sSection = sSection;
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Trace.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Returns the section name
|
||||
public string GetName()
|
||||
{
|
||||
return m_sSection;
|
||||
}
|
||||
|
||||
// IniKey class
|
||||
public class IniKey
|
||||
{
|
||||
// Name of the Key
|
||||
private string m_sKey;
|
||||
// Value associated
|
||||
private string m_sValue;
|
||||
// Pointer to the parent CIniSection
|
||||
private IniSection m_section;
|
||||
|
||||
// Constuctor so objects are internally managed
|
||||
protected internal IniKey(IniSection parent, string sKey)
|
||||
{
|
||||
m_section = parent;
|
||||
m_sKey = sKey;
|
||||
}
|
||||
|
||||
// Returns the name of the Key
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_sKey;
|
||||
}
|
||||
}
|
||||
|
||||
// Sets or Gets the Value of the key
|
||||
public string Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_sValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_sValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Sets the Value of the key
|
||||
public void SetValue(string sValue)
|
||||
{
|
||||
m_sValue = sValue;
|
||||
}
|
||||
// Returns the Value of the Key
|
||||
public string GetValue()
|
||||
{
|
||||
return m_sValue;
|
||||
}
|
||||
|
||||
// Sets the key name
|
||||
// Returns true on success, fails if the section name sKey already exists
|
||||
public bool SetName(string sKey)
|
||||
{
|
||||
sKey = sKey.Trim();
|
||||
if (sKey.Length != 0)
|
||||
{
|
||||
IniKey k = m_section.GetKey(sKey);
|
||||
if (k != this && k != null) return false;
|
||||
try
|
||||
{
|
||||
// Remove the current key
|
||||
m_section.m_keys.Remove(m_sKey);
|
||||
// Set the new key name to this object
|
||||
m_section.m_keys[sKey] = this;
|
||||
// Set the new key name
|
||||
m_sKey = sKey;
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Trace.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Returns the name of the Key
|
||||
public string GetName()
|
||||
{
|
||||
return m_sKey;
|
||||
}
|
||||
} // End of IniKey class
|
||||
} // End of IniSection class
|
||||
} // End of IniFile class
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
using System.IO;
|
||||
|
||||
namespace BinsTracker.INI
|
||||
{
|
||||
public class Settaggi
|
||||
{
|
||||
|
||||
private const string NameFile = "conf.ini";
|
||||
private readonly IniFile _sett;
|
||||
|
||||
|
||||
public Settaggi()
|
||||
{
|
||||
_sett = new IniFile();
|
||||
}
|
||||
public string IndirizzoIpSizer
|
||||
{
|
||||
get { return _sett.GetKeyValue("Sizer", "IndirizzoIp"); }
|
||||
set { _sett.SetKeyValue("Sizer", "IndirizzoIp", 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); }
|
||||
}
|
||||
|
||||
public void Load()
|
||||
{
|
||||
if (!File.Exists(NameFile))
|
||||
{
|
||||
var fs = File.Create(NameFile);
|
||||
fs.Close();
|
||||
}
|
||||
_sett.Load(NameFile, false);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
_sett.Save(NameFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
[Batch]
|
||||
GrowerCode=02
|
||||
GrowerName=Egalware
|
||||
Comment1=Prova Invio
|
||||
Comment2=Console app
|
||||
Comment3=Selezionato Variety e layout
|
||||
@@ -0,0 +1,3 @@
|
||||
[Sizer]
|
||||
IndirizzoIp=192.168.137.50
|
||||
TcpPort=8001
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace EgwProxy.Icoel
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe parametri del Batch
|
||||
/// </summary>
|
||||
public class BatchInfo
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Codice univoco fornitore
|
||||
/// </summary>
|
||||
public string GrowerCode { get; set; } = "02";
|
||||
|
||||
/// <summary>
|
||||
/// Denominazione del fornitore
|
||||
/// </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
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,17 @@ namespace EgwProxy.Icoel.Compac
|
||||
{
|
||||
#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)
|
||||
@@ -17,8 +28,13 @@ namespace EgwProxy.Icoel.Compac
|
||||
/// <param name="port">Porta di connessione del sizer (def: 8001)</param>
|
||||
public ComClient(string sizerIp, string port)
|
||||
{
|
||||
// Salvo IP e porta
|
||||
ipAddress = sizerIp;
|
||||
tcpPort = port;
|
||||
|
||||
// inizializzazione servizio comunicazione
|
||||
var url = "http://" + sizerIp + ":" + port + "/SizerService/";
|
||||
var epa = new EndpointAddress(new Uri(url));
|
||||
EndpointAddress epa = new EndpointAddress(new Uri(url));
|
||||
SSClient = new SizerServiceClient("WSHttpBinding_ISizerService", epa);
|
||||
}
|
||||
|
||||
|
||||
+44
-68
@@ -6,15 +6,38 @@ using System;
|
||||
|
||||
namespace EgwProxy.Icoel
|
||||
{
|
||||
public static class Connector
|
||||
public class Connector
|
||||
{
|
||||
/// <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>
|
||||
/// Inizializazzione classe con salvataggio ip/porta del webservice del sizer
|
||||
/// </summary>
|
||||
/// <param name="ipAddress"></param>
|
||||
/// <param name="tcpPort"></param>
|
||||
public Connector(string ipAddress, string tcpPort)
|
||||
{
|
||||
this.ipAddress = ipAddress;
|
||||
this.tcpPort = tcpPort;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public static void DisplayVarietyLayout(Variety[] varietiesList)
|
||||
public void DisplayVarietyLayout(Variety[] varietiesList)
|
||||
{
|
||||
if (Client == null || !Client.connected)
|
||||
{
|
||||
Client = new ComClient(Settaggi.IndirizzoIpSizer, Settaggi.SizerTcpPort);
|
||||
Client = new ComClient(ipAddress, tcpPort);
|
||||
}
|
||||
foreach (var item in varietiesList)
|
||||
{
|
||||
@@ -70,9 +93,9 @@ namespace EgwProxy.Icoel
|
||||
Details.Load();
|
||||
}
|
||||
|
||||
public static void MettiLottoInCoda()
|
||||
public void MettiLottoInCoda()
|
||||
{
|
||||
Client = new ComClient(Settaggi.IndirizzoIpSizer, Settaggi.SizerTcpPort);
|
||||
Client = new ComClient(ipAddress, tcpPort);
|
||||
|
||||
Client.VerificaEsistenzaGrower(Details.GrowerCode, Details.GrowerName);
|
||||
|
||||
@@ -111,7 +134,7 @@ namespace EgwProxy.Icoel
|
||||
}
|
||||
if (Client == null || !Client.connected)
|
||||
{
|
||||
Client = new ComClient(Settaggi.IndirizzoIpSizer, Settaggi.SizerTcpPort);
|
||||
Client = new ComClient(ipAddress, tcpPort);
|
||||
} // recupero layout della varietà
|
||||
var layoutList = Client.GetLayouts(varGuid);
|
||||
// recupero layout x varietà
|
||||
@@ -143,9 +166,9 @@ namespace EgwProxy.Icoel
|
||||
Client.Close();
|
||||
}
|
||||
|
||||
public static void MettiLottoInCodaDefault()
|
||||
public void MettiLottoInCodaDefault()
|
||||
{
|
||||
Client = new ComClient(Settaggi.IndirizzoIpSizer, Settaggi.SizerTcpPort);
|
||||
Client = new ComClient(ipAddress, tcpPort);
|
||||
|
||||
Client.VerificaEsistenzaGrower(Details.GrowerCode, Details.GrowerName);
|
||||
|
||||
@@ -154,64 +177,23 @@ namespace EgwProxy.Icoel
|
||||
Client.Close();
|
||||
}
|
||||
|
||||
public static Variety[] RecuperaVarietyLayout()
|
||||
public Variety[] RecuperaVarietyLayout()
|
||||
{
|
||||
//Client = new CompacClient(Settaggi.IndirizzoIpSizer, Settaggi.SizerTcpPort);
|
||||
if (Client == null || !Client.connected)
|
||||
{
|
||||
Client = new ComClient(Settaggi.IndirizzoIpSizer, Settaggi.SizerTcpPort);
|
||||
Client = new ComClient(ipAddress, tcpPort);
|
||||
}
|
||||
Variety[] varietiesList;
|
||||
varietiesList = Client.GetActiveVarieties();
|
||||
#if false
|
||||
foreach (var item in varietiesList)
|
||||
{
|
||||
Console.WriteLine("--------------------------");
|
||||
Console.WriteLine($"Variety Id: {item.Id} | Variety Name: {item.Name}");
|
||||
Console.WriteLine(" - Qualities");
|
||||
foreach (var quality in item.Qualities)
|
||||
{
|
||||
Console.WriteLine($" Name: {quality.Name}");
|
||||
}
|
||||
Console.WriteLine(" - Grades");
|
||||
foreach (var grade in item.Grades)
|
||||
{
|
||||
Console.WriteLine($" Name: {grade.Name}");
|
||||
}
|
||||
Console.WriteLine(" - Sizes");
|
||||
foreach (var size in item.SizingMaps)
|
||||
{
|
||||
Console.WriteLine($" Name: {size.Name}");
|
||||
}
|
||||
// recupero layout della varietà
|
||||
var layoutList = Client.GetLayouts(item.Id);
|
||||
Console.WriteLine(" - LAYOUTS");
|
||||
foreach (var layout in layoutList)
|
||||
{
|
||||
Console.WriteLine($" Id: {layout.Id} | Name: {layout.Name}");
|
||||
// ciclo su sub info
|
||||
Console.WriteLine(" - Assignments");
|
||||
foreach (var assign in layout.Assignments)
|
||||
{
|
||||
Console.WriteLine($" Key: {assign.Key} | Val: {assign.Value}");
|
||||
}
|
||||
Console.WriteLine(" - Products");
|
||||
foreach (var product in layout.Products)
|
||||
{
|
||||
Console.WriteLine($" Id: {product.Id} | Name: {product.Name} | DisplayName: {product.DisplayName} | Pack: {product.Pack}");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Client.Close();
|
||||
|
||||
return varietiesList;
|
||||
}
|
||||
|
||||
public static void VerificaLottoCorrente()
|
||||
public void VerificaLottoCorrente()
|
||||
{
|
||||
Client = new ComClient(Settaggi.IndirizzoIpSizer, Settaggi.SizerTcpPort);
|
||||
Client = new ComClient(ipAddress, tcpPort);
|
||||
|
||||
//Client.GetCurrentBatch();
|
||||
var batch = Client.GetCurrentBatchByLane(1);
|
||||
@@ -231,20 +213,18 @@ namespace EgwProxy.Icoel
|
||||
/// Oggetto di connessione client
|
||||
/// </summary>
|
||||
internal static ComClient Client { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Dettaglio dei batch
|
||||
/// </summary>
|
||||
internal static BatchDetails Details { get; set; }
|
||||
/// <summary>
|
||||
/// Parametri di setup
|
||||
/// </summary>
|
||||
internal static Settaggi Settaggi { get; set; }
|
||||
internal BatchInfo Details { get; set; } = new BatchInfo();
|
||||
|
||||
|
||||
#endregion Internal Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private static Batch GeneraBatchDaFile()
|
||||
private Batch GeneraBatchDaFile()
|
||||
{
|
||||
var batch = new Batch();
|
||||
|
||||
@@ -253,10 +233,8 @@ namespace EgwProxy.Icoel
|
||||
batch.AvoidLayoutChange = true;
|
||||
batch.AvoidSavingOldLayouts = true;
|
||||
|
||||
batch.Comments = new string[3];
|
||||
batch.Comments[0] = Details.Comment1;
|
||||
batch.Comments[1] = Details.Comment2;
|
||||
batch.Comments[2] = Details.Comment3;
|
||||
batch.Comments = new string[Details.Comments.Count];
|
||||
batch.Comments = Details.Comments.ToArray();
|
||||
|
||||
batch.VarietyId = Client.GetCurrentBatch().VarietyId;
|
||||
batch.LayoutId = Client.GetCurrentBatch().LayoutId;
|
||||
@@ -265,7 +243,7 @@ namespace EgwProxy.Icoel
|
||||
return batch;
|
||||
}
|
||||
|
||||
private static Batch GeneraBatchDaSelezione(Guid VarietyId, Guid LayoutId, string SizingProfileName)
|
||||
private Batch GeneraBatchDaSelezione(Guid VarietyId, Guid LayoutId, string SizingProfileName)
|
||||
{
|
||||
var batch = new Batch();
|
||||
|
||||
@@ -273,10 +251,8 @@ namespace EgwProxy.Icoel
|
||||
batch.AvoidSavingOldLayouts = true;
|
||||
|
||||
batch.GrowerCode = Details.GrowerCode;
|
||||
batch.Comments = new string[3];
|
||||
batch.Comments[0] = Details.Comment1;
|
||||
batch.Comments[1] = Details.Comment2;
|
||||
batch.Comments[2] = Details.Comment3;
|
||||
batch.Comments = new string[Details.Comments.Count];
|
||||
batch.Comments = Details.Comments.ToArray();
|
||||
|
||||
batch.VarietyId = VarietyId;
|
||||
batch.LayoutId = LayoutId;
|
||||
|
||||
@@ -54,14 +54,12 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Compac\ComClient.cs" />
|
||||
<Compile Include="BatchInfo.cs" />
|
||||
<Compile Include="Connected Services\SizerService\Reference.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Reference.svcmap</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="INI\BatchDetails.cs" />
|
||||
<Compile Include="INI\IniFileCs.cs" />
|
||||
<Compile Include="INI\Settaggi.cs" />
|
||||
<Compile Include="Connector.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
@@ -70,12 +68,6 @@
|
||||
<None Include="App.config" />
|
||||
<None Include="articles\intro.md" />
|
||||
<None Include="articles\toc.md" />
|
||||
<None Include="batch.ini">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="conf.ini">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Connected Services\SizerService\Arrays.xsd">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -87,17 +87,20 @@
|
||||
<HintPath>..\packages\EasyModbusTCP.5.6.0\lib\net40\EasyModbus.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EgwProxy.MultiCncLib, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EgwProxy.MultiCncLib.3.6.2205.1913\lib\net40\EgwProxy.MultiCncLib.dll</HintPath>
|
||||
<HintPath>..\packages\EgwProxy.MultiCncLib.3.6.2205.1917\lib\EgwProxy.MultiCncLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EgwProxy.OsaiCncLib, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EgwProxy.OsaiCncLib.3.6.2205.1913\lib\net40\EgwProxy.OsaiCncLib.dll</HintPath>
|
||||
<HintPath>..\packages\EgwProxy.OsaiCncLib.3.6.2205.1917\lib\EgwProxy.OsaiCncLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EgwProxy.OsaiCncLib.XmlSerializers, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EgwProxy.OsaiCncLib.3.6.2205.1917\lib\EgwProxy.OsaiCncLib.XmlSerializers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="krcc, Version=0.0.0.0, Culture=neutral, processorArchitecture=x86">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>ExtLib\krcc.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MapoSDK, Version=6.14.2204.2115, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MapoSDK.6.14.2204.2115\lib\net40\MapoSDK.dll</HintPath>
|
||||
<Reference Include="MapoSDK, Version=6.14.2204.2616, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MapoSDK.6.14.2204.2616\lib\MapoSDK.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MathNet.Numerics, Version=4.15.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MathNet.Numerics.4.15.0\lib\net461\MathNet.Numerics.dll</HintPath>
|
||||
@@ -308,14 +311,10 @@
|
||||
<None Include="DATA\CONF\IobOpcUaClient.Config.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<Content Include="arstcomm.ico" />
|
||||
<Content Include="ExtLib\CndexLinkDotNet.dll" />
|
||||
<Content Include="ExtLib\krcc.dll">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="ExtLib\krcc64.dll" />
|
||||
<Content Include="ExtLib\Siemens.Sinumerik.Operate.Services.dll" />
|
||||
<Content Include="ExtLib\Siemens.Sinumerik.Operate.Services.Wrapper.dll" />
|
||||
<Content Include="ExtLib\S_Fwlib32_V6.3.1.exe" />
|
||||
<Content Include="logs\.placeholder.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 766 B |
@@ -2,9 +2,9 @@
|
||||
<packages>
|
||||
<package id="Autoupdater.NET.Official" version="1.7.0" targetFramework="net462" />
|
||||
<package id="EasyModbusTCP" version="5.6.0" targetFramework="net462" />
|
||||
<package id="EgwProxy.MultiCncLib" version="3.6.2205.1913" targetFramework="net462" />
|
||||
<package id="EgwProxy.OsaiCncLib" version="3.6.2205.1913" targetFramework="net462" />
|
||||
<package id="MapoSDK" version="6.14.2204.2115" targetFramework="net462" />
|
||||
<package id="EgwProxy.MultiCncLib" version="3.6.2205.1917" targetFramework="net462" />
|
||||
<package id="EgwProxy.OsaiCncLib" version="3.6.2205.1917" targetFramework="net462" />
|
||||
<package id="MapoSDK" version="6.14.2204.2616" targetFramework="net462" />
|
||||
<package id="MathNet.Numerics" version="4.15.0" targetFramework="net462" />
|
||||
<package id="Microsoft.CodeAnalysis.NetAnalyzers" version="6.0.0" targetFramework="net462" developmentDependency="true" />
|
||||
<package id="Microsoft.VisualStudio.SlowCheetah" version="4.0.8" targetFramework="net462" developmentDependency="true" />
|
||||
|
||||
Reference in New Issue
Block a user