From 3677c6ac193607824e4ab67dd9980f7480c472e4 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 8 Oct 2019 06:56:03 +0000 Subject: [PATCH] Integration 2.1j3 : - aggiunto lancio check prima di generazione se non ancora fatto. --- IntegrationEgaltech/Generator.cs | 54 ++++++++++++++++--- .../Properties/AssemblyInfo.cs | 4 +- 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/IntegrationEgaltech/Generator.cs b/IntegrationEgaltech/Generator.cs index de4aef2..29444a2 100644 --- a/IntegrationEgaltech/Generator.cs +++ b/IntegrationEgaltech/Generator.cs @@ -117,11 +117,16 @@ namespace ib.essetre.integration.egaltech else GetListaTasks( btlObject) ; + // Recupero lo stato della barra + int nBarState = 0 ; + if ( ! pattInfo.IsFromProject) + nBarState = GetBarStateP( btlObject.patternId, btlObject.productionId) ; + // Dialog con Progress Bar - float progValue = (float) 1 / numBars ; - string sProgress = ( progValue * ( i + 1) * 100).ToString("F1", CultureInfo.InvariantCulture) ; - callback.Progress( progValue * ( i + 1), - " Progress: " + sProgress + "%" + "\n" + + float progValue1 = (float) 1 / numBars ; + string sProgress1 = ( progValue1 * ( i + 0.2) * 100).ToString("F1", CultureInfo.InvariantCulture) ; + callback.Progress( progValue1 * ( i + 0.2f), + " Progress: " + sProgress1 + "%" + "\n" + " Count: " + ( i + 1) + " / " + numBars, ref bCancel) ; if ( bCancel) { @@ -145,13 +150,16 @@ namespace ib.essetre.integration.egaltech // Esecuzione di EgtCAM5 con parametri path BTL, nome macchina e modo Process process = new Process() ; process.StartInfo.FileName = ExePath ; - process.StartInfo.Arguments = "\"" + BtlPath + "\" " + parameters.MachineName + " " + (int)parameters.UIMode ; + int nMode = (int)parameters.UIMode ; + if ( parameters.UIMode == InOutParameters.UIModes.HIDDEN && nBarState != 0) + nMode = 4 ; + process.StartInfo.Arguments = "\"" + BtlPath + "\" " + parameters.MachineName + " " + nMode.ToString() ; process.StartInfo.UseShellExecute = false ; process.Start() ; // Attendo il termine del processo while ( ! process.HasExited) { process.Refresh() ; - System.Threading.Thread.Sleep( 50) ; + Thread.Sleep( 50) ; } } @@ -308,6 +316,7 @@ namespace ib.essetre.integration.egaltech } callback.Progress( 1, "End", ref bCancel) ; + Thread.Sleep( 300) ; callback.Done( parameters) ; //fine } @@ -598,6 +607,35 @@ namespace ib.essetre.integration.egaltech return barLength ; } + //------------------------------------------------------------------------------------------------------------- + // Recupera lo stato della barra nel caso Produzione (colonna "state") + private static int GetBarStateP( int patternId, int productionId) + { + int barState = 16 ; + + string sqlBarLength = "SELECT state " + + "FROM dbo.vw_Pattern " + + "WHERE patternId = @firstId " + + "AND productionId = @secondId" ; + + // Connessione al DB ed esecuzione query + using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) { + cn.Open() ; + using ( SqlCommand sqlCommand = new SqlCommand( sqlBarLength, cn)) { + sqlCommand.Parameters.Add( "@firstId", SqlDbType.Int) ; + sqlCommand.Parameters.Add( "@secondId", SqlDbType.Int) ; + sqlCommand.Parameters["@firstId"].Value = patternId ; + sqlCommand.Parameters["@secondId"].Value = productionId ; + SqlDataReader reader = sqlCommand.ExecuteReader() ; + while ( reader.Read()) { + barState = Convert.ToInt32( reader["state"]) ; + } + } + } + + return barState ; + } + //------------------------------------------------------------------------------------------------------------- // Recupera la lunghezza della barra nel caso Ordine (colonna "length", ovvero la lunghezza della singola trave) // a cui aggiungiamo un valore fisso (es. 2000) @@ -654,7 +692,7 @@ namespace ib.essetre.integration.egaltech // Attendo il termine del processo while ( ! process.HasExited) { process.Refresh() ; - System.Threading.Thread.Sleep( 50) ; + Thread.Sleep( 50) ; } return true ; } @@ -676,7 +714,7 @@ namespace ib.essetre.integration.egaltech // Attendo il termine del processo while ( ! process.HasExited) { process.Refresh() ; - System.Threading.Thread.Sleep( 50) ; + Thread.Sleep( 50) ; } return true ; } diff --git a/IntegrationEgaltech/Properties/AssemblyInfo.cs b/IntegrationEgaltech/Properties/AssemblyInfo.cs index 88c3ba1..38ef9b5 100644 --- a/IntegrationEgaltech/Properties/AssemblyInfo.cs +++ b/IntegrationEgaltech/Properties/AssemblyInfo.cs @@ -36,5 +36,5 @@ using System.Runtime.InteropServices; // È 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.9.2")] -[assembly: AssemblyFileVersion("2.1.9.2")] +[assembly: AssemblyVersion("2.1.10.3")] +[assembly: AssemblyFileVersion("2.1.10.3")]