Integration 2.1a1 :

- primo rilascio.
This commit is contained in:
Renzo Lanza
2019-01-17 15:54:00 +00:00
parent e1bdc21153
commit 54249c1766
16 changed files with 1633 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.2016
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntegrationEgaltech", "IntegrationEgaltech\IntegrationEgaltech.csproj", "{A80D9CFF-5312-40C7-8F67-AC5D62C18824}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A80D9CFF-5312-40C7-8F67-AC5D62C18824}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A80D9CFF-5312-40C7-8F67-AC5D62C18824}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A80D9CFF-5312-40C7-8F67-AC5D62C18824}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A80D9CFF-5312-40C7-8F67-AC5D62C18824}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0480452B-8808-41BE-BC4F-641636CA6449}
EndGlobalSection
EndGlobal
+3
View File
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
</configuration>
+23
View File
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Integration
{
public interface ICallBack
{
/// <summary>
/// Mostra a video una eventuale progressione
/// </summary>
/// <param name="value">da 0 a 1 (la percentuale)</param>
/// <param name="message">Messaggio da mostrare a video</param>
void Progress(float value, string message);
/// <summary>
/// Elaborazione completata
/// </summary>
/// <param name="parameters"></param>
void Done(InOutParameters parameters);
}
}
+25
View File
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Integration
{
public interface IGenerator
{
/// <summary>
/// Genera l'iso per con programma esterno (la chiamata è già assincrona, si aspetta un done nel callback)
/// </summary>
/// <param name="parameters">Parametri per l'elaborazione</param>
/// <param name="callback">Classe di callback</param>
/// <returns></returns>
void Run(InOutParameters parameters, ICallBack callback);
/// <summary>
/// Annulla l'operazione
/// </summary>
void Abort();
}
}
+13
View File
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Integration
{
public interface IIniReader
{
string Read(string section, string key, string defvalue);
}
}
+105
View File
@@ -0,0 +1,105 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Integration
{
public class InOutParameters
{
private string _connectionString;
private PatternInfo[] _patterns;
private UIModes _uiMode;
private int _timeout;
private string _machineName;
private int _configurationId;
private IIniReader _reader;
public enum UIModes
{
CHECK = 3,
HIDDEN = 0,
SHOWUI = 1,
SIMULAZIONE = 2
}
/// <summary>
/// Legge una configurazione dal ini del programma
/// </summary>
/// <param name="section"></param>
/// <param name="key"></param>
/// <param name="defvalue"></param>
/// <returns></returns>
public string Read(string section, string key, string defvalue)
{
return _reader.Read(section, key, defvalue);
}
public InOutParameters(string connectionString, PatternInfo[] patterns, UIModes UIMode, int timeout, string machineName, int configurationId, IIniReader reader)
{
_connectionString = connectionString;
_patterns = patterns;
_uiMode = UIMode;
_timeout = timeout;
_machineName = machineName;
_configurationId = configurationId;
_reader = reader;
}
/// <summary>
/// elenco degli eschemi da elaborare
/// </summary>
public PatternInfo[] Patterns
{
get
{
return _patterns;
}
}
/// <summary>
/// Restituisce la stringa
/// </summary>
public string MachineName
{
get
{
return _machineName;
}
}
/// <summary>
/// Restituisce l'id della conf attiva
/// </summary>
public int ConfigurationId
{
get
{
return _configurationId;
}
}
/// <summary>
/// Stile interfaccia
/// </summary>
public UIModes UIMode { get { return _uiMode; } }
/// <summary>
/// Stringa di connessione al database
/// </summary>
public string ConnectionString
{
get
{
return _connectionString;
}
}
/// <summary>
/// numero di millisecondi lasciati alla elaborazione
/// </summary>
public int Timeout
{
get
{
return _timeout;
}
}
}
}
+55
View File
@@ -0,0 +1,55 @@
<?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>{00347903-5C3B-4824-8822-22014A4A0A8E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Integration</RootNamespace>
<AssemblyName>Integration</AssemblyName>
<TargetFrameworkVersion>v4.6.1</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="ICallback.cs" />
<Compile Include="IGenerator.cs" />
<Compile Include="IIniReader.cs" />
<Compile Include="InOutParameters.cs" />
<Compile Include="PatternInfo.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Config.ini" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
+152
View File
@@ -0,0 +1,152 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Integration
{
public class PatternInfo
{
public enum Results
{
NONE = 0,
OK = 1,
ERROR = 2
}
private bool _transformable;
private Int32 _patternId;
private Int32 _productionId;
private string _filename;
private System.Collections.Generic.Dictionary<int, CutChanged> _changed = new System.Collections.Generic.Dictionary<int, CutChanged>();
private System.Collections.Generic.Dictionary<Tuple<int, int>, Tuple<Results, string>> _states = new System.Collections.Generic.Dictionary<Tuple<int, int>, Tuple<Results, string>>();
public class CutChanged
{
private int _cutId;
private System.Collections.Generic.Dictionary<string, double> _values = new System.Collections.Generic.Dictionary<string, double>();
public CutChanged(int cutId)
{
_cutId = cutId;
}
public void AddChange(string key, double value)
{
key = key.ToUpper().Trim();
if (_values.ContainsKey(key))
{
_values[key] = value;
}
else
{
_values.Add(key, value);
}
}
public System.Collections.Generic.Dictionary<string, double> Values
{
get
{
return _values;
}
}
}
/// <summary>
/// Segnala un cambiamento delle carateristiche dello schema
/// </summary>
/// <param name="key">la caratteristica (nome campo db)</param>
/// <param name="value">il nuovo valore</param>
public void AddPatternChange(string key, double value)
{
int cutId = -1;
if (_changed.ContainsKey(cutId))
{
_changed[cutId].AddChange(key, value);
}
else
{
CutChanged cut = new CutChanged(cutId);
cut.AddChange(key, value);
_changed.Add(cutId, cut);
}
}
/// <summary>
/// Imposta uno stato al taglio
/// </summary>
/// <param name="cutId">L'id del taglio</param>
/// <param name="value">il nuovo valore</param>
public void SetTaskState(int cutId, int taskId, Results value, string message)
{
Tuple<int, int> key = new Tuple<int, int>(cutId, taskId);
if (_states.ContainsKey(key))
{
_states[key] = new Tuple<Results, string>(value, message);
}
else
{
_states.Add(key, new Tuple<Results, string>(value, message));
}
}
/// <summary>
/// Segnala un cambiamento delle carateristiche del taglio nello schema
/// </summary>
/// <param name="cutId">L'id del taglio</param>
/// <param name="key">la caratteristica (nome campo db)</param>
/// <param name="value">il nuovo valore</param>
public void AddCutChange(int cutId, string key, double value)
{
if (_changed.ContainsKey(cutId))
{
_changed[cutId].AddChange(key, value);
}
else
{
CutChanged cut = new CutChanged(cutId);
cut.AddChange(key, value);
_changed.Add(cutId, cut);
}
}
public PatternInfo(Int32 productionId, Int32 patternId, bool transformable, string filename)
{
_patternId = patternId;
_productionId = productionId;
_transformable = transformable;
_filename = filename;
}
/// <summary>
/// chiave produzione
/// </summary>
public Int32 ProductionId { get { return _productionId; } }
/// <summary>
/// chiave scherma
/// </summary>
public Int32 PatternId { get { return _patternId; } }
/// <summary>
/// Messaggio eventuale di errore
/// </summary>
public string Message { get; set; }
/// <summary>
/// file iso generato
/// </summary>
public string OutputFilename { get { return _filename; } }
/// <summary>
/// indica lo stato di generazione
/// </summary>
public Results Result { get; set; }
/// <summary>
/// Iso generato
/// </summary>
public String Iso { get; set; }
/// <summary>
/// Specifica se è possibile trasformare o ruotare lo schema
/// </summary>
public bool Transformable { get; set; }
/// <summary>
/// Libero
/// </summary>
public object Tag { get; set; }
}
}
+36
View File
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Le informazioni generali relative a un assembly sono controllate dal seguente
// set di attributi. Modificare i valori di questi attributi per modificare le informazioni
// associate a un assembly.
[assembly: AssemblyTitle("Integration")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Integration")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Se si imposta ComVisible su false, i tipi in questo assembly non saranno visibili
// ai componenti COM. Se è necessario accedere a un tipo in questo assembly da
// COM, impostare su true l'attributo ComVisible per tale tipo.
[assembly: ComVisible(false)]
// Se il progetto viene esposto a COM, il GUID seguente verrà utilizzato come ID della libreria dei tipi
[assembly: Guid("00347903-5c3b-4824-8822-22014a4a0a8e")]
// Le informazioni sulla versione di un assembly sono costituite dai seguenti quattro valori:
//
// Versione principale
// Versione secondaria
// Numero di build
// Revisione
//
// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build
// usando l'asterisco '*' come illustrato di seguito:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
+338
View File
@@ -0,0 +1,338 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ib.essetre.integration.egaltech
{
// La classe BTL rappresenta un singolo file BTL e come esso può contenere una o più Part (ovvero le travi di legno)
// ed ogni Part può contenere una o più Feature (ovvero i tagli da effettuare)
public class BTL
{
public string projectNumber;
public string scaleUnit;
public string barLength;
public List<Part> parts;
public List<Feature> features;
//I seguenti Id servono per il nome del file BTL
public int productionId;
public int patternId;
public string fileName;
public int projectId;
public int elementId;
public BTL()
{
}
public BTL(string projectNumber, string scaleUnit, List<Part> parts, List<Feature> features)
{
this.projectNumber = projectNumber;
this.scaleUnit = scaleUnit;
this.parts = parts;
this.features = features;
}
public string writeIntoFile(bool isFromProject)
{
// La directory in cui salvare il file viene qui inizializzata
DirectoryInfo di = new DirectoryInfo(Path.GetTempPath() + @"FileBTL\");
// Se la directory non esiste viene creata
if (!di.Exists)
{
di.Create();
}
//Il nome del file cambia a seconda che si tratti del caso Produzione o caso Ordine
string typeName = null;
if (isFromProject)
typeName = "part";
else
typeName = "bar";
// Si combina in un'unica stringa il percorso della directory e il nome del file da salvare
fileName = String.Format("{0}.btl", typeName + "_" + this.productionId + "_" + this.patternId); // DateTime.Now.ToString("yyyy-MM-dd HH.mm.ss")));
string filePath = Path.Combine(di.FullName, fileName); // DateTime.Now.ToString("yyyy-MM-dd HH.mm.ss")));
// Se un file txt (contenente messaggio di errore) con lo stesso nome esiste già viene cancellato
if (File.Exists(filePath.Replace(".btl", ".txt")))
{
File.Delete(filePath.Replace(".btl", ".txt"));
}
// Il seguente blocco 'using' si occupa della scrittura del file di testo, poi salvato in .btl
using (var tw = new StreamWriter(filePath, false))
{
tw.WriteLine(Constants.VERSION);
tw.WriteLine(Constants.BUILD);
tw.WriteLine(Constants.GENERAL);
tw.WriteLine(Constants.PROJECT_NUMBER + this.projectNumber);
tw.WriteLine(Constants.SCALE_UNIT + this.scaleUnit);
if (isFromProject)
tw.WriteLine(Constants.USERATTRIBUTE + "\"BARLEN\":" + "\"N/A\""); // Nel caso Ordine non c'è il BarLength (colonna "l" nel DB)
else
tw.WriteLine(Constants.USERATTRIBUTE + "\"BARLEN\":" + "\"" + this.barLength + "\"");
foreach (Part singlePart in parts)
{
tw.WriteLine(Constants.PART);
tw.WriteLine(Constants.SINGLE_MEMBER_NUMBER + singlePart.singleMemberNumber);
tw.WriteLine(Constants.COUNT + singlePart.count);
double len = (Convert.ToDouble(singlePart.length)) * Math.Pow(10, Constants.scaleUnit);
int intLen = (Convert.ToInt32(len));
tw.WriteLine(Constants.LENGTH + intLen.ToString("D8"));
double hei = (Convert.ToDouble(singlePart.height)) * Math.Pow(10, Constants.scaleUnit);
int intHei = (Convert.ToInt32(hei));
tw.WriteLine(Constants.HEIGHT + intHei.ToString("D8"));
double wid = (Convert.ToDouble(singlePart.width)) * Math.Pow(10, Constants.scaleUnit);
int intWid = (Convert.ToInt32(wid));
tw.WriteLine(Constants.WIDTH + intWid.ToString("D8"));
string posX = singlePart.x.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture);
tw.WriteLine(Constants.USERATTRIBUTE + "\"POSX\":" + "\"" + posX + "\"");
string inv = singlePart.inverted.ToString(); // "0.00", System.Globalization.CultureInfo.InvariantCulture);
tw.WriteLine(Constants.USERATTRIBUTE + "\"INVERTED\":" + "\"" + inv + "\"");
string rot = singlePart.rotated.ToString(); // "0.00", System.Globalization.CultureInfo.InvariantCulture);
tw.WriteLine(Constants.USERATTRIBUTE + "\"ROTATED\":" + "\"" + rot + "\"");
if (isFromProject)
tw.WriteLine(Constants.USERATTRIBUTE + "\"ELEMENTID\":" + "\"" + singlePart.elementId + "\"");
else
tw.WriteLine(Constants.USERATTRIBUTE + "\"CUTID\":" + "\"" + singlePart.cutId + "\"");
foreach (Feature singleFeature in singlePart.features)
{
// se il processKey contiene "250" allora si tratta di un Contorno Libero e viene analizzato come tale
if (singleFeature.processKey.Contains("250"))
{
FreeContourAnalyzer(singleFeature.sag1, tw, singleFeature);
}
else
{
tw.WriteLine(Constants.PROCESS_KEY + singleFeature.processKey + " " + singleFeature.designation);
tw.Write(Constants.PROCESS_PARAMETERS);
int i = 1;
foreach (string singleParameter in singleFeature.processParameters)
{
if (i < 27) // I parametri Pnn arrivano al 26, dopo arrivano i parametri Qnn
{
// Stampo i vari parametri Pnn
if (i != 15)
tw.Write("P" + i.ToString("D2") + ":" + MultAndConvertTo8(singleParameter) + " ");
else
tw.Write("P" + i.ToString("D2") + ":" + "\"\" "); // P15: ""
}
else
{
// Stampo i vari parametri Qnn preceduti da "COMMENT:"
if (i == 27)
{
tw.WriteLine(" "); // Vado a capo
tw.Write(Constants.COMMENT);
}
tw.Write("Q" + (i - 26).ToString("D2") + ":" + MultAndConvertTo8(singleParameter) + " ");
}
//Convert.ToInt16(i);
i++;
}
tw.WriteLine(" "); // Vado a capo
tw.WriteLine(Constants.PROCESS_IDENT + singleFeature.processIdent);
tw.WriteLine(Constants.PROCESS + singleFeature.process);
}
if (isFromProject)
tw.WriteLine(Constants.USERATTRIBUTE + "\"PROCESSID\":" + "\"" + singleFeature.processId + "\"");
else
tw.WriteLine(Constants.USERATTRIBUTE + "\"TASKID\":" + "\"" + singleFeature.taskId + "\"");
}
}
}
return filePath;
}
// Il seguente metodo analizza il campo sag1 della singleFeature passata: se non è vuoto allora la stringa
// viene splittata nei parametri P di POLY ed analizzata
public void FreeContourAnalyzer(string sag1, StreamWriter tw, Feature singleFeature)
{
if (sag1 != "")
{
string[] arrParam = sag1.Split(new string[] { "POLY([P(", ")],'P','C')", "),P(" }, StringSplitOptions.RemoveEmptyEntries);
int count = 0; // Nel caso in cui ci troviamo alla fine di un Arco questa viene incrmentata di 1, in modo da scrivere il numero parametro corretto nei seguenti cicli
Boolean flagArco = false; // Nel caso in cui ci troviamo all'inizio di un Arco questa viene posta a TRUE, in modo da passare nel percorso dedicato nel prossimo ciclo
for (int i = 0; i < arrParam.Length; i++)
{
string[] parts = arrParam[i].Split(','); // ogni parametro P di POLY viene splittato in più parti
switch (parts[0]) // il primo elemento di parts[] indica se ci troviamo all'inizio di un Arco o no
{
case "0":
if (i == 0) // Caso StartPoint
{
tw.WriteLine(Constants.PROCESS_KEY + singleFeature.processKey + " " + singleFeature.designation);
tw.Write(Constants.PROCESS_PARAMETERS);
tw.Write("P01:" + MultAndConvertTo8(parts[1]) + " "); // x
tw.Write("P02:" + MultAndConvertTo8(parts[2]) + " "); // y
tw.Write("P03:" + MultAndConvertTo8(parts[3]) + " "); // z
tw.Write("P05:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P06:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P07:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P08:" + Constants.EIGHT_ZEROS + " ");
if (i == arrParam.Length - 1) // Verifica se ci troviamo all'ultimo parametro di POLY
tw.Write("P09:" + Constants.EIGHT_ZEROS + " "); // L'ultimo elemento di POLY deve avere "P09: 00000000"
else
tw.Write("P09:" + MultAndConvertTo8((Convert.ToDouble(singleFeature.processParameters[8]) + i - count).ToString()) + " ");
tw.Write("P10:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P11:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P12:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P13:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P14:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P15:" + Constants.EIGHT_ZEROS + " ");
tw.WriteLine(" ");
tw.WriteLine(Constants.PROCESS_IDENT + (Convert.ToInt16(singleFeature.processIdent) + i - count));
tw.WriteLine(Constants.PROCESS + singleFeature.process);
//tw.WriteLine(Constants.USERATTRIBUTE + "\"TASKID\":" + "\"" + singleFeature.taskId + "\"");
}
else if (flagArco) // Caso FineArco
{
count++;
flagArco = false;
}
else // Caso StraightLine
{
tw.WriteLine(Constants.PROCESS_KEY + singleFeature.processKey + " " + singleFeature.designation);
tw.Write(Constants.PROCESS_PARAMETERS);
tw.Write("P01:" + MultAndConvertTo8(parts[1]) + " "); // x
tw.Write("P02:" + MultAndConvertTo8(parts[2]) + " "); // y
tw.Write("P03:" + MultAndConvertTo8(parts[3]) + " "); // z
tw.Write("P05:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P06:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P07:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P08:" + "00000100" + " ");
if (i == arrParam.Length - 1)
tw.Write("P09:" + Constants.EIGHT_ZEROS + " ");
else
tw.Write("P09:" + MultAndConvertTo8((Convert.ToDouble(singleFeature.processParameters[8]) + i - count).ToString()) + " ");
tw.Write("P10:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P11:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P12:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P13:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P14:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P15:" + Constants.EIGHT_ZEROS + " ");
tw.WriteLine(" ");
tw.WriteLine(Constants.PROCESS_IDENT + (Convert.ToInt16(singleFeature.processIdent) + i - count));
tw.WriteLine(Constants.PROCESS + singleFeature.process);
//tw.WriteLine(Constants.USERATTRIBUTE + "\"TASK\":" + "\"" + singleFeature.taskId + "\"");
}
break;
case "1": // Caso InizioArco
tw.WriteLine(Constants.PROCESS_KEY + singleFeature.processKey + " " + singleFeature.designation);
tw.Write(Constants.PROCESS_PARAMETERS);
string[] nextParts = arrParam[i + 1].Split(',');
tw.Write("P01:" + MultAndConvertTo8(nextParts[1]) + " "); // x (EndPoint Arc)
tw.Write("P02:" + MultAndConvertTo8(nextParts[2]) + " "); // y (EndPoint Arc)
tw.Write("P03:" + MultAndConvertTo8(nextParts[3]) + " "); // z (Endpoint Arc)
tw.Write("P05:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P06:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P07:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P08:" + "00000200" + " ");
if (i == arrParam.Length - 1)
tw.Write("P09:" + Constants.EIGHT_ZEROS + " ");
else
tw.Write("P09:" + MultAndConvertTo8((Convert.ToDouble(singleFeature.processParameters[8]) + i - count).ToString()) + " ");
tw.Write("P10:" + MultAndConvertTo8(parts[1]) + " "); // x (Point on Arc)
tw.Write("P11:" + MultAndConvertTo8(parts[2]) + " "); // y (Point on Arc)
tw.Write("P12:" + MultAndConvertTo8(parts[3]) + " "); // z (Point on Arc)
tw.Write("P13:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P14:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P15:" + Constants.EIGHT_ZEROS + " ");
tw.WriteLine(" ");
tw.WriteLine(Constants.PROCESS_IDENT + (Convert.ToInt16(singleFeature.processIdent) + i - count));
tw.WriteLine(Constants.PROCESS + singleFeature.process);
//tw.WriteLine(Constants.USERATTRIBUTE + "\"TASK\":" + "\"" + singleFeature.taskId + "\"");
flagArco = true;
break;
default:
tw.WriteLine(Constants.PROCESS_KEY + singleFeature.processKey + " " + singleFeature.designation);
tw.Write(Constants.PROCESS_PARAMETERS);
tw.Write("P01:" + MultAndConvertTo8(parts[1]) + " ");
tw.Write("P02:" + MultAndConvertTo8(parts[2]) + " ");
tw.Write("P03:" + MultAndConvertTo8(parts[3]) + " ");
tw.Write("P05:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P06:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P07:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P08:" + Constants.EIGHT_ZEROS + " ");
if (i == arrParam.Length - 1)
tw.Write("P09:" + Constants.EIGHT_ZEROS + " ");
else
tw.Write("P09:" + MultAndConvertTo8((Convert.ToDouble(singleFeature.processParameters[8]) + i - count).ToString()) + " ");
tw.Write("P10:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P11:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P12:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P13:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P14:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P15:" + Constants.EIGHT_ZEROS + " ");
tw.WriteLine(" ");
tw.WriteLine(Constants.PROCESS_IDENT + (Convert.ToInt16(singleFeature.processIdent) + i - count));
tw.WriteLine(Constants.PROCESS + singleFeature.process);
//tw.WriteLine(Constants.USERATTRIBUTE + "\"TASK\":" + "\"" + singleFeature.taskId + "\"");
break;
}
}
}
}
// Il seguente metodo prende il valore di un process parameter, lo moltiplica per 10^scaleUnit
// e lo converte in una stringa di 8 caratteri (i caratteri mancanti sono degli 0)
public string MultAndConvertTo8(string processParameter)
{
double sp = 0;
string rp = processParameter.Replace(",", ".");
sp = (Convert.ToDouble(rp, CultureInfo.InvariantCulture)) * Math.Pow(10, Constants.scaleUnit);
int intSp = (Convert.ToInt32(sp));
string s8 = intSp.ToString("D8");
return s8;
}
// Le 2 seguenti struct dichiarano i campi necessari alla costruzione di una Part e di una Feature
public struct Part
{
public string singleMemberNumber;
public string count;
public string length;
public string height;
public string width;
public List<Feature> features;
public double x;
public string inverted;
public string rotated;
public int elementId;
public int cutId;
}
public struct Feature
{
public string taskId;
public string processKey;
public string designation;
public List<string> processParameters;
public string processIdent;
public string process;
public string sag1;
public string processId;
}
}
}
+22
View File
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ib.essetre.integration;
namespace ib.essetre.integration.egaltech
{
public class CallBack : ib.essetre.integration.ICallBack
{
public void Done(InOutParameters parameters)
{
Console.WriteLine("Finito ");
}
public void Progress(float value, string message)
{
Console.WriteLine(message + ": L'avanzamento è al " + value * 100 + "%");
}
}
}
+56
View File
@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ib.essetre.integration.egaltech
{
class Constants
{
// Le seguenti costanti sottoforma di stringa sono delle componenti di testo da scrivere
// all'interno del file BTL da generare
public const string VERSION = "VERSION: BTL V10.6";
public const string BUILD = "BUILD: \"10600\"";
public const string GENERAL = "[GENERAL]";
public const string PART = "[PART]";
public const string PROJECT_NUMBER = "PROJECTNUMBER: ";
public const string SCALE_UNIT = "SCALEUNIT: ";
public const string SINGLE_MEMBER_NUMBER = "SINGLEMEMBERNUMBER: ";
public const string DESIGNATION = "DESIGNATION: ";
public const string COUNT = "COUNT: ";
public const string LENGTH = "LENGTH: ";
public const string HEIGHT = "HEIGHT: ";
public const string WIDTH = "WIDTH: ";
public const string PROCESS_KEY = "PROCESSKEY: ";
public const string PROCESS_PARAMETERS = "PROCESSPARAMETERS: ";
public const string PROCESS_IDENT = "PROCESSIDENT: ";
public const string PROCESS = "PROCESS: ";
public const string COMMENT = "COMMENT: ";
public const string USERATTRIBUTE = "USERATTRIBUTE: ";
public const string EIGHT_ZEROS = "00000000";
// Questa costante specifica l'esponente della potenza in base 10 per cui moltiplicare alcuni
// parametri come length, width, height e i process parameters
public const int scaleUnit = 2;
// Stringa contenente i parametri di connessione al DB
public const string ConnectionString = @"Data Source=localhost\SQLEssetre;Initial Catalog=ESSETRE;User ID=sa;Password=essetre";
// Query al DB che estrae i campi specificati dal join tra vw_Task e vw_Cut in base ad un patternId
// specificato laddove questa costante venga usata nel codice
public const string sqlSelectJoinTaskCutByPattern = "SELECT vw_Task.productionId, " +
"vw_Task.patternId, vw_Task.cutId ,taskId, info1, info2, enabled, level, " +
"inTools,outTools,isChecked,vw_Task.done,isoType,ax,ay,az, vw_Cut.x, vw_Cut.y, vw_Cut.z, " +
"vw_Task.flagDeleted, [group], [key], face, edge, des, p01, p02, p03, p04, p05, p06, " +
"p07, p08, p09, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, " +
"p26, q01, q02, q03, q04, q05, q06, q07, q08, q09, q10, q11, q12, q13, q14, q15, q16, q17, " +
"q18, q19, q20, priority, processIdent, processingQuality, sag1, projectId, elementId, cutStart, cutEnd, " +
"inverted, rotated, doneTime, startAngle, endAngle, referenceCutId, length, width, height " +
"FROM ESSETRE.dbo.vw_Task " +
"INNER JOIN vw_Cut ON " +
"(vw_Task.cutId = vw_Cut.cutId AND vw_Task.patternId = vw_Cut.patternId AND vw_Task.productionId = vw_Cut.productionId) " +
"WHERE vw_Task.patternId = ";
}
}
+70
View File
@@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
namespace ib.essetre.integration.egaltech
{
static class ErrorManager
{
public enum ErrorType
{
[DescriptionAttribute("Nessun errore")]
NONE = 0,
[DescriptionAttribute("Errore da definire 1")]
ERROR1 = 1,
[DescriptionAttribute("Errore da definire 2")]
ERROR2 = 2,
[DescriptionAttribute("Errore da definire 3")]
ERROR3 = 3,
[DescriptionAttribute("Errore da definire 4")]
ERROR4 = 4
}
public static void writeErrorToFile(ErrorType et, string BTLname)
{
//DirectoryInfo di = new DirectoryInfo(Path.GetTempPath() + @"TestoErrore\");
//// Se la directory non esiste viene creata
//if (!di.Exists)
//{
// di.Create();
//}
//string filename = Path.Combine(di.FullName, String.Format("{0}.txt", "Prova" + DateTime.Now.ToString("yyyy-MM-dd HH.mm.ss")));
string filePath = "C:\\Temp\\" + BTLname + ".txt";
using (StreamWriter writer = new StreamWriter(filePath, true))
{
writer.WriteLine("Errore: " + (int)et);
writer.WriteLine();
writer.WriteLine("Descrizione : " + GetDescription(et) + " (" + DateTime.Now.ToString() + ") ");
writer.WriteLine();
}
}
public static string GetDescription(this Enum currentEnum)
{
string description = String.Empty;
DescriptionAttribute da;
FieldInfo fi = currentEnum.GetType().GetField(currentEnum.ToString());
da = (DescriptionAttribute)Attribute.GetCustomAttribute(fi, typeof(DescriptionAttribute));
if (da != null)
description = da.Description;
else
description = currentEnum.ToString();
return description;
}
}
}
+613
View File
@@ -0,0 +1,613 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using ib.essetre.integration;
using ib.essetre.integration.egaltech;
namespace ib.essetre.integration.egaltech
{
public class Generator : ib.essetre.integration.IGenerator
{
public System.Threading.Thread _thread;
public static DataSet ds = new DataSet();
//public static BTL btlObject = new BTL();
public Generator()
{
Console.WriteLine("Inizializzato");
}
//public void Run(BTL btlObject, ICallBack callback)
//{
// _thread = new Thread(() => DoJob(btlObject, callback));
// _thread.Start();
//}
//private static void DoJob(BTL btlObject, ICallBack callback)
//{
// string filePath = btlObject.writeIntoFile(); // Constants.fullPath);
// System.Windows.Forms.MessageBox.Show("File scritto!");
// //System.Diagnostics.Process.Start(filePath);
// Process process = Process.Start("C:\\EgtProg\\EgtCAM5\\EgtCAM5R32.exe", "\"" + filePath + "\"");
// string cMyProcessName = process.ProcessName;
// Process[] processlist = Process.GetProcessesByName(cMyProcessName);
// while (processlist.Length != 0)
// {
// Console.WriteLine("Il processo EgtCAM5 è attivo.");
// Thread.Sleep(10000);
// processlist = Process.GetProcessesByName(cMyProcessName);
// }
//}
public void Run(InOutParameters parameters, ICallBack callback)
{
_thread = new Thread(() => DoJob(parameters, callback));
_thread.Start();
}
private delegate void dDoJob(InOutParameters parameters, ICallBack callback);
//campo data ultima modifica nel DATABASE [lastModified]
private static void DoJob(InOutParameters parameters, ICallBack callback)
{
PatternInfo.Results r = PatternInfo.Results.OK;
PatternInfo.Results o;
string msg;
parameters.Patterns[0].SetTaskState(0, 0, r, "prova");
if (parameters.Patterns[0].GetTaskState(0, 0, out o, out msg))
System.Windows.Forms.MessageBox.Show("Result: " + o + "\n" + "Msg: " + msg);
callback.Progress(0, "Init");
//int configurationId = parameters.ConfigurationId; //id cofigurazione macchina condizione where per tool e parametri glob
//String connectionString = parameters.ConnectionString; //stringa connessione db
//parameters.Patterns //EventLogEntryCollection schemi da elaborare
//int timeout = parameters.Timeout; //numero millisecondo per l'elaborazione
//parameters.UIMode = InOutParameters.UIModes.HIDDEN //nascosto
//parameters.UIMode = InOutParameters.UIModes.SHOWUI //con interfaccia
//parameters.Owner // Form padre da specificare, opzionale
//CHECK = 3,
//HIDDEN = 0,
//SHOWUI = 1,
//SIMULAZIONE = 2
//String percorsoExe = parameters.Read("EGTCAM5", "PATH_EXE", ""); //Config.ini
//String connectionString = parameters.ConnectionString;
//parameters.Patterns(0).OutputFilename
// 2 PARAMETRI AGGIUNTI DA NOI
//parameters.Flag;
//parameters.Modifiable;
//using (System.Data.SqlClient.SqlConnection cn = new System.Data.SqlClient.SqlConnection(connectionString))
//{
//cn.Open();
//String sql = $"SELECT [cutId],[projectId],[elementId],[x],[y],[z],[cutStart],[cutEnd],[inverted],[rotated],[done],[doneTime], [startAngle],[endAngle],"
// + "[referenceCutId], [length], [width], [height] FROM[dbo].[vw_Cut] WHERE[productionId] = @productionId and[patternId] = @patternId";
int numBars = parameters.Patterns.Length;
for (int i = 0; i < numBars; i++)
{
BTL btlObject = new BTL();
String sqlProduction = "SELECT vw_Task.productionId, " +
"vw_Task.patternId, vw_Task.cutId ,taskId, info1, info2, enabled, level, " +
"inTools,outTools,isChecked,vw_Task.done,isoType,ax,ay,az, vw_Cut.x, vw_Cut.y, vw_Cut.z, " +
"vw_Task.flagDeleted, [group], [key], face, edge, des, p01, p02, p03, p04, p05, p06, " +
"p07, p08, p09, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, " +
"p26, q01, q02, q03, q04, q05, q06, q07, q08, q09, q10, q11, q12, q13, q14, q15, q16, q17, " +
"q18, q19, q20, priority, processIdent, processingQuality, sag1, projectId, elementId, cutStart, cutEnd, " +
"inverted, rotated, doneTime, startAngle, endAngle, referenceCutId, length, width, height " +
"FROM ESSETRE.dbo.vw_Task " +
"INNER JOIN vw_Cut ON " +
"(vw_Task.cutId = vw_Cut.cutId AND vw_Task.patternId = vw_Cut.patternId AND vw_Task.productionId = vw_Cut.productionId) " +
"WHERE vw_Task.patternId = " + (Int32)parameters.Patterns[i].PatternId +
" and vw_Task.productionId = " + (Int32)parameters.Patterns[i].ProductionId;
String sqlProject = "SELECT vw_Process.projectId, " +
"vw_Process.elementId, cutId, processId, info1, info2, enabled, level, " +
"inTools, outTools, isChecked, vw_Process.done, isoType, ax, ay, az, vw_Process.x, vw_Process.y, vw_Process.z, " +
"vw_Process.flagDeleted, vw_Process.[group], [key], face, edge, des, p01, p02, p03, p04, p05, p06, " +
"p07, p08, p09, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, " +
"p26, q01, q02, q03, q04, q05, q06, q07, q08, q09, q10, q11, q12, q13, q14, q15, q16, q17, " +
"q18, q19, q20, priority, processIdent, processingQuality, sag1, productionId, patternId, cutId, cutStart, cutEnd, " +
"inverted, rotated, doneTime, startAngle, endAngle, referenceCutId, vw_Cut.length, vw_Cut.width, vw_Cut.height " +
"FROM ESSETRE.dbo.vw_Process " +
//"INNER JOIN vw_Element ON " +
//"(vw_Process.projectId = vw_Element.projectId AND vw_Process.elementId = vw_Element.elementId) " +
"INNER JOIN vw_Cut ON " +
"(vw_Cut.projectId = vw_Process.projectId AND vw_Cut.elementId = vw_Process.elementId) " +
"WHERE vw_Process.projectId = " + (Int32)parameters.Patterns[i].ProjectId +
" and vw_Process.elementId = " + (Int32)parameters.Patterns[i].ElementId;
string sql = null;
// Se il parametro IsFromProject è TRUE viene eseguita la query sulle tabelle Project,
// se invece è FALSE viene eseguita la query sulle tabelle Production
if (parameters.Patterns[i].IsFromProject)
sql = sqlProject;
else
sql = sqlProduction;
var cn = new SqlConnection(Constants.ConnectionString);
SqlCommand cmd = new SqlCommand(sql, cn);
cn.Open();
var dataAdapter = new SqlDataAdapter(cmd);
//var commandBuilder = new SqlCommandBuilder(dataAdapter);
var tempDs = new DataSet();
dataAdapter.Fill(tempDs);
//ds = tempDs;
//for(int iTable = 0; iTable < ds.Tables.Count; iTable++)
//{
// if (AreTablesTheSame(ds.Tables[iTable], tempDs.Tables[0]))
// ds.Tables.Remove(ds.Tables[iTable]);
//}
//tempDs.Tables[0].TableName = "Table" + ds.Tables.Count;
//ds.Tables.Add(tempDs.Tables[0].Copy());
if(ds.Tables.Count != 0)
ds.Tables.Remove(ds.Tables[0]);
ds.Tables.Add(tempDs.Tables[0].Copy());
//tempDs.Tables[0].TableName = "Table1";
//ds.Tables.Add(tempDs.Tables[0].Copy());
//tempDs.Tables[0].TableName = "Table2";
//ds.Tables.Add(tempDs.Tables[0].Copy());
//string prova = ds.Tables[0].TableName;
//string prova2 = ds.Tables[1].TableName;
if (parameters.Patterns[i].IsFromProject)
getListaProcesses(btlObject, i);
else
getListaTasks(btlObject, i);
System.Threading.Thread.Sleep(1000); // solo di test
float progValue = (float)1 / numBars;
callback.Progress(progValue * (i+1),
" Progresso: " + (progValue * (i + 1) * 100) + "%" + "\n" +
" BTL generati: " + (i+1) + " su " + numBars);
string filePath = btlObject.writeIntoFile(parameters.Patterns[i].IsFromProject); // Constants.fullPath);
//System.Windows.Forms.MessageBox.Show("File scritto!");
//ErrorManager.writeErrorToFile(ErrorManager.ErrorType.NONE, btlObject.fileName);
//System.Diagnostics.Process.Start(filePath);
string path = "\"" + filePath + "\" " + parameters.MachineName + " " + (int)parameters.UIMode + " " + parameters.Patterns[i].OutputFilename;
Process process = Process.Start("C:\\EgtProg\\EgtCAM5\\EgtCAM5R32.exe", path); // "\"" + filePath + "\" "
//+ parameters.MachineName + " " + parameters.UIMode + " " + parameters.Patterns[0].OutputFilename);
// Aspetta che il file txt dell'errore venga creato da EgtCAM5
while (!File.Exists(filePath.Replace(".btl", ".txt")))
{
// Se siamo ad un ciclo successivo al numero max di istanze che EgtCAM5 può aprire
// il programma cicla in questo while all'infinito ---> SISTEMARE
System.Threading.Thread.Sleep(1000);
}
string text = System.IO.File.ReadAllText(filePath.Replace(".btl", ".txt"));
//parameters.Patterns[i].SetTaskState(btlObject.cutId, parameters.Patterns[i]. btlObject.features., PatternInfo.Results.ERROR, text);
//parameters.Patterns[i].GetTaskState(cutId, taskId, PatternInfo.Results, text);
System.Windows.Forms.MessageBox.Show(text, "Error");
////imposta le modifiche
////solo se parameters.Patterns[i].Transformable
//parameters.Patterns[i].AddCutChange(2, "inverted", 180);
//parameters.Patterns[i].AddPatternChange("StartX", 20);
//public enum Results
//{
// NONE = 0,
// OK = 1,
// ERROR = 2
//}
////fattibile o non fattibile
////parameters.Patterns[i].Iso;=.... //stringa iso
////parameters.Patterns[i].OutputFilename; //nome file da generare
////parameters.Patterns[i].SetTaskState(cutId, taskId, value, message); //Cutid del db
//parameters.Patterns[i].Result = PatternInfo.Results.OK;
//parameters.Patterns[i].Message = ""; //eventuale errore messaggio
// }
//esempio di apertura db, usare solo le viste (iniziano per vw_)
// chiavi
//parameters.Patterns(0).ProductionId
//cn.Close();
//}
}
//callback.Progress(0, "Init"); //mostra descrizione a video con progressione 0-1 (0-100%)
//System.Threading.Thread.Sleep(5000); //qui calcola 'pausa solo di test
//callback.Progress(0.5F, "Init2");
//System.Threading.Thread.Sleep(5000); // solo di test
//callback.Progress(1, "End");
//per tutti gli schemi parameters.Patterns.Length
//parameters.UIMode = InOutParameters.UIModes.SHOWUI //mostrare il vostro programma
callback.Progress(1, "End");
callback.Done(parameters); //fine
}
public void Abort()
{
//non implementata al momento
}
// DA SISTEMARE: i vari ds.Tables[0] (e forse anche i Rows[0]) probabilmente han bisogno dell'indice i
// in conseguenza al vettore di travi in input (al posto del vettore singolo)
// Il seguente metodo prende i record visualizzati in ds (Caso: Produzione) e li carica in un oggetto BTL
public static void getListaTasks(BTL btlObject, int i)
{
Int32 listaTasksCount = ds.Tables[i].Rows.Count;
Int32 TaskElementsCount = ds.Tables[i].Columns.Count;
btlObject.projectNumber = ds.Tables[i].Rows[0]["projectId"].ToString();
btlObject.scaleUnit = Convert.ToString(2);
btlObject.barLength = Convert.ToString(getBarLengthP((int)ds.Tables[i].Rows[0]["patternId"],
(int)ds.Tables[i].Rows[i]["productionId"]));
btlObject.parts = new List<BTL.Part>();
btlObject.productionId = (int)ds.Tables[i].Rows[0]["productionId"];
btlObject.patternId = (int)ds.Tables[i].Rows[0]["patternId"];
List<int> ListaCutParts = new List<int>();
ListaCutParts = getListaCutIdP((int)ds.Tables[i].Rows[0]["patternId"],
(int)ds.Tables[i].Rows[i]["productionId"]);
//RunIntegration();
if (listaTasksCount > 0)
{
for (int c = 0; c < ListaCutParts.Count; c++)
{
BTL.Part readPart = new BTL.Part();
for (int ltc = 0; ltc < listaTasksCount; ltc++)
{
if ((int)ds.Tables[i].Rows[ltc]["cutId"] == ListaCutParts[c])
{
readPart.singleMemberNumber = ds.Tables[i].Rows[ltc]["productionId"].ToString();
readPart.count = Convert.ToString(1); // Deve essere 1 o tanto quante sono le Part?
readPart.length = ds.Tables[i].Rows[ltc]["length"].ToString();
readPart.height = ds.Tables[i].Rows[ltc]["height"].ToString();
readPart.width = ds.Tables[i].Rows[ltc]["width"].ToString();
readPart.x = (double)ds.Tables[i].Rows[ltc]["x"];
readPart.inverted = ds.Tables[i].Rows[ltc]["inverted"].ToString();
readPart.rotated = ds.Tables[i].Rows[ltc]["rotated"].ToString();
}
readPart.features = new List<BTL.Feature>();
for (int f = 0; f < listaTasksCount; f++)
{
if ((int)ds.Tables[i].Rows[f]["cutId"] == ListaCutParts[c])
{
BTL.Feature readFeature = new BTL.Feature();
readFeature.taskId = ds.Tables[i].Rows[f]["taskId"].ToString();
readFeature.processKey = ds.Tables[i].Rows[f]["group"].ToString() +
"-" + ds.Tables[i].Rows[f]["key"].ToString().Substring(1, 3) +
"-" + ds.Tables[i].Rows[f]["face"].ToString();
readFeature.designation = ds.Tables[i].Rows[f]["des"].ToString();
readFeature.processIdent = ds.Tables[i].Rows[f]["processIdent"].ToString();
readFeature.sag1 = ds.Tables[i].Rows[f]["sag1"].ToString();
if (Convert.ToInt16(ds.Tables[i].Rows[f]["enabled"]) == 1)
readFeature.process = Convert.ToString("YES");
else if (Convert.ToInt16(ds.Tables[i].Rows[f]["enabled"]) == 0)
readFeature.process = Convert.ToString("NO");
readFeature.processParameters = new List<string>();
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p01"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p02"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p03"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p04"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p05"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p06"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p07"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p08"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p09"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p10"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p11"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p12"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p13"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p14"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p15"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p16"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p17"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p18"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p19"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p20"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p21"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p22"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p23"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p24"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p25"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p26"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q01"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q02"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q03"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q04"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q05"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q06"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q07"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q08"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q09"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q10"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q11"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q12"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q13"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q14"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q15"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q16"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q17"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q18"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q19"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q20"].ToString());
readPart.features.Add(readFeature);
}
}
}
btlObject.parts.Add(readPart);
}
}
// L'ordinamento delle Part in un oggetto BTL avviene col confronto del parametro x, estratto dalla tabella vw_Cut
btlObject.parts.Sort((p, q) => p.x.CompareTo(q.x));
}
// Il seguente metodo prende i record visualizzati in ds (Caso: Ordine) e li carica in un oggetto BTL
public static void getListaProcesses(BTL btlObject, int i)
{
Int32 listaProcessesCount = ds.Tables[i].Rows.Count;
Int32 ProcessElementsCount = ds.Tables[i].Columns.Count;
btlObject.projectNumber = ds.Tables[i].Rows[0]["projectId"].ToString();
btlObject.scaleUnit = Convert.ToString(2);
//btlObject.barLength = Convert.ToString(getBarLengthO((int)ds.Tables[0].Rows[0]["elementId"],
// (int)ds.Tables[0].Rows[0]["projectId"]));
btlObject.parts = new List<BTL.Part>();
btlObject.projectId = (int)ds.Tables[i].Rows[0]["projectId"];
btlObject.elementId = (int)ds.Tables[i].Rows[0]["elementId"];
List<int> ListaCutParts = new List<int>();
ListaCutParts = getListaCutIdO((int)ds.Tables[i].Rows[0]["elementId"],
(int)ds.Tables[i].Rows[0]["projectId"]);
//RunIntegration();
if (listaProcessesCount > 0)
{
for (int c = 0; c < ListaCutParts.Count; c++)
{
BTL.Part readPart = new BTL.Part();
for (int ltc = 0; ltc < listaProcessesCount; ltc++)
{
if ((int)ds.Tables[i].Rows[ltc]["cutId"] == ListaCutParts[c])
{
readPart.singleMemberNumber = " "; // ds.Tables[0].Rows[ltc]["productionId"].ToString(); //In questo caso ci vuole?
readPart.count = Convert.ToString(1); // Deve essere 1 o tanto quante sono le Part?
readPart.length = ds.Tables[i].Rows[ltc]["length"].ToString();
readPart.height = ds.Tables[i].Rows[ltc]["height"].ToString();
readPart.width = ds.Tables[i].Rows[ltc]["width"].ToString();
readPart.x = (double)ds.Tables[i].Rows[ltc]["x"];
readPart.inverted = ds.Tables[i].Rows[ltc]["inverted"].ToString();
readPart.rotated = ds.Tables[i].Rows[ltc]["rotated"].ToString();
}
readPart.features = new List<BTL.Feature>();
for (int f = 0; f < listaProcessesCount; f++)
{
if ((int)ds.Tables[i].Rows[f]["cutId"] == ListaCutParts[c])
{
BTL.Feature readFeature = new BTL.Feature();
readFeature.processId = ds.Tables[i].Rows[f]["processId"].ToString(); //readFeature.taskId = ds.Tables[0].Rows[f]["taskId"].ToString();
readFeature.processKey = ds.Tables[i].Rows[f]["group"].ToString() +
"-" + ds.Tables[i].Rows[f]["key"].ToString().Substring(1, 3) +
"-" + ds.Tables[i].Rows[f]["face"].ToString();
readFeature.designation = ds.Tables[i].Rows[f]["des"].ToString();
readFeature.processIdent = ds.Tables[i].Rows[f]["processIdent"].ToString();
readFeature.sag1 = ds.Tables[i].Rows[f]["sag1"].ToString();
if (Convert.ToInt16(ds.Tables[i].Rows[f]["enabled"]) == 1)
readFeature.process = Convert.ToString("YES");
else if (Convert.ToInt16(ds.Tables[i].Rows[f]["enabled"]) == 0)
readFeature.process = Convert.ToString("NO");
readFeature.processParameters = new List<string>();
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p01"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p02"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p03"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p04"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p05"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p06"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p07"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p08"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p09"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p10"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p11"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p12"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p13"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p14"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p15"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p16"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p17"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p18"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p19"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p20"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p21"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p22"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p23"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p24"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p25"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["p26"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q01"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q02"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q03"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q04"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q05"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q06"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q07"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q08"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q09"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q10"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q11"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q12"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q13"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q14"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q15"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q16"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q17"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q18"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q19"].ToString());
readFeature.processParameters.Add(ds.Tables[i].Rows[f]["q20"].ToString());
readPart.features.Add(readFeature);
}
}
}
btlObject.parts.Add(readPart);
}
}
// L'ordinamento delle Part in un oggetto BTL avviene col confronto del parametro x, estratto dalla tabella vw_Cut
btlObject.parts.Sort((p, q) => p.x.CompareTo(q.x));
}
// Il seguente metodo si connette al Database per estrarre tramite una query i cutId della tabella vw_Cut
// aventi patternId e ProductionId che corrispondono a quelli passati come argomento
private static List<int> getListaCutIdP(int patternId, int productionId)
{
List<int> ListaCutId = new List<int>();
string sqlCutId = "SELECT cutId FROM dbo.vw_Cut WHERE patternId = " + patternId +
"AND productionId = " + productionId;
using (SqlConnection cn = new SqlConnection(Constants.ConnectionString))
{
cn.Open();
SqlCommand sqlCommand = new SqlCommand(sqlCutId, cn);
SqlDataReader reader = sqlCommand.ExecuteReader();
while (reader.Read())
{
ListaCutId.Add((int)reader["cutId"]);
}
cn.Close();
}
return ListaCutId;
}
// Il seguente metodo si connette al Database per estrarre tramite una query i cutId della tabella vw_Cut
// aventi elementId e projectId che corrispondono a quelli passati come argomento
private static List<int> getListaCutIdO(int elementId, int projectId)
{
List<int> ListaCutId = new List<int>();
string sqlCutId = "SELECT cutId FROM dbo.vw_Cut WHERE elementId = " + elementId +
"AND projectId = " + projectId;
using (SqlConnection cn = new SqlConnection(Constants.ConnectionString))
{
cn.Open();
SqlCommand sqlCommand = new SqlCommand(sqlCutId, cn);
SqlDataReader reader = sqlCommand.ExecuteReader();
while (reader.Read())
{
ListaCutId.Add((int)reader["cutId"]);
}
cn.Close();
}
return ListaCutId;
}
//Ottiene la lunghezza della barra ed è usato solo nel caso Produzione perché nelle tabelle
//del caso Ordine non c'è la colonna "l"
private static int getBarLengthP(int patternId, int productionId)
{
int barLength = 0;
string sqlBarLength = "SELECT l FROM dbo.vw_Pattern WHERE patternId = " + patternId +
"AND productionId = " + productionId;
using (SqlConnection cn = new SqlConnection(Constants.ConnectionString))
{
cn.Open();
SqlCommand sqlCommand = new SqlCommand(sqlBarLength, cn);
SqlDataReader reader = sqlCommand.ExecuteReader();
while (reader.Read())
{
barLength = Convert.ToInt16(reader["l"]);
}
cn.Close();
}
return barLength;
}
//private static int getBarLengthO(int elementId, int projectId)
//{
// int barLength = 0;
// // SISTEMARE: vw_Element non ha l come vW_Pattern
// string sqlBarLength = "SELECT l FROM dbo.vw_Element WHERE elementId = " + elementId +
// "AND projectId = " + projectId;
// using (SqlConnection cn = new SqlConnection(Constants.ConnectionString))
// {
// cn.Open();
// SqlCommand sqlCommand = new SqlCommand(sqlBarLength, cn);
// SqlDataReader reader = sqlCommand.ExecuteReader();
// while (reader.Read())
// {
// barLength = Convert.ToInt16(reader["l"]);
// }
// cn.Close();
// }
// return barLength;
//}
public static bool AreTablesTheSame(DataTable tbl1, DataTable tbl2)
{
if (tbl1.Rows.Count != tbl2.Rows.Count || tbl1.Columns.Count != tbl2.Columns.Count)
return false;
for (int i = 0; i < tbl1.Rows.Count; i++)
{
for (int c = 0; c < tbl1.Columns.Count; c++)
{
if (!Equals(tbl1.Rows[i][c], tbl2.Rows[i][c]))
return false;
}
}
return true;
}
}
}
@@ -0,0 +1,61 @@
<?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>{A80D9CFF-5312-40C7-8F67-AC5D62C18824}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ib.essetre.integration.egaltech</RootNamespace>
<AssemblyName>ib.essetre.integration.egaltech</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>C:\TechnoEssetre7\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</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="ib.essetre.integration">
<HintPath>C:\TechnoEssetre7\ib.essetre.integration.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="BTL.cs" />
<Compile Include="CallBack.cs" />
<Compile Include="Constants.cs" />
<Compile Include="ErrorManager.cs" />
<Compile Include="Generator.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Le informazioni generali relative a un assembly sono controllate dal seguente
// set di attributi. Modificare i valori di questi attributi per modificare le informazioni
// associate a un assembly.
[assembly: AssemblyTitle("IntegrationEgaltech")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("IntegrationEgaltech")]
[assembly: AssemblyCopyright("Copyright © 2018-2019 by EgalTech s.r.l.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Se si imposta ComVisible su false, i tipi in questo assembly non saranno visibili
// ai componenti COM. Se è necessario accedere a un tipo in questo assembly da
// COM, impostare su true l'attributo ComVisible per tale tipo.
[assembly: ComVisible(false)]
// Se il progetto viene esposto a COM, il GUID seguente verrà utilizzato come ID della libreria dei tipi
[assembly: Guid("a80d9cff-5312-40c7-8f67-ac5d62c18824")]
// Le informazioni sulla versione di un assembly sono costituite dai seguenti quattro valori:
//
// Versione principale
// Versione secondaria
// Numero di build
// Revisione
//
// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build
// usando l'asterisco '*' come illustrato di seguito:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.1.2")]
[assembly: AssemblyFileVersion("2.1.1.2")]