Index: DamFailureMechanisms/damMacroStability/tags/19.3.1/release/DDAMStiWriter.exe =================================================================== diff -u Binary files differ Index: DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStabilityInwards/DamMacroStabilityInwardsKernelWrapper.cs =================================================================== diff -u -r4296 -r4297 --- DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStabilityInwards/DamMacroStabilityInwardsKernelWrapper.cs (.../DamMacroStabilityInwardsKernelWrapper.cs) (revision 4296) +++ DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStabilityInwards/DamMacroStabilityInwardsKernelWrapper.cs (.../DamMacroStabilityInwardsKernelWrapper.cs) (revision 4297) @@ -24,6 +24,7 @@ using System.Data; using System.Diagnostics; using System.IO; +using System.Text; using System.Threading; using System.Xml.Linq; using Deltares.DamEngine.Calculators.DikesDesign; @@ -229,7 +230,7 @@ try { // start (first) calculation - var stabilityOutputItem = ExcecuteCalculation(kernelDataInput, messages); + var stabilityOutputItem = ExecuteCalculation(kernelDataInput, messages); if (stabilityOutputItem != null) { damMacroStabilityOutput.StabilityOutputItems.Add(stabilityOutputItem); @@ -247,7 +248,7 @@ input.DGeoStabilityInputFileName = input.DGeoStabilityInputFileNameSecondModel; try { - var stabilityOutputItemSecondModel = ExcecuteCalculation(kernelDataInput, messages); + var stabilityOutputItemSecondModel = ExecuteCalculation(kernelDataInput, messages); if (stabilityOutputItemSecondModel != null) { damMacroStabilityOutput.StabilityOutputItems.Add(stabilityOutputItemSecondModel); @@ -278,8 +279,9 @@ } } - private static DamMacroStabilityOutputItem ExcecuteCalculation(IKernelDataInput kernelDataInput, List messages) + private static DamMacroStabilityOutputItem ExecuteCalculation(IKernelDataInput kernelDataInput, List messages) { + System.Threading.Thread.Sleep(40); var input = (DamMacroStabilityInput)kernelDataInput; var calculator = StabilityCalculator(kernelDataInput); try @@ -351,29 +353,87 @@ internal bool CreateStiFile(string stabilityXmlFile, string exePath) { - const string stiWriter = "DDAMStiWriter.exe"; - var exeFolder = Path.GetDirectoryName(exePath); - string str = string.Format("/f \"{0}\"", (object) stabilityXmlFile + ".xml"); - string stabilityExePath = exeFolder + "\\" + stiWriter; - Process process = new Process() + if (File.Exists(stabilityXmlFile + ".xml")) { - StartInfo = { - FileName = stabilityExePath, - Arguments = str, - UseShellExecute = false + const string stiWriter = "DDAMStiWriter.exe"; + var exeFolder = Path.GetDirectoryName(exePath); + string str = string.Format("/f \"{0}\"", (object)stabilityXmlFile + ".xml"); + string stabilityExePath = exeFolder + "\\" + stiWriter; + int exitCode; + var errors = new StringBuilder(); + var output = new StringBuilder(); + var hadErrors = false; + string stdOut = ""; + string stdErr = ""; + Process process = new Process() + { + StartInfo = + { + WindowStyle = ProcessWindowStyle.Hidden, + CreateNoWindow = true, + RedirectStandardError = true, + RedirectStandardOutput = true, + FileName = stabilityExePath, + Arguments = str, + UseShellExecute = false + } + }; + try + { + process.EnableRaisingEvents = true; + process.OutputDataReceived += (s, d) => { output.Append(d.Data); }; + process.ErrorDataReceived += (s, d) => + { + if (!hadErrors) + { + hadErrors = !String.IsNullOrEmpty(d.Data); + } + errors.Append(d.Data); + }; + process.Start(); + try + { + process.BeginErrorReadLine(); + process.BeginOutputReadLine(); + process.WaitForExit(); + exitCode = process.ExitCode; + stdOut = output.ToString(); + stdErr = errors.ToString(); + + } + catch (ThreadInterruptedException ex) + { + return false; + } } - }; - process.Start(); - try - { - process.WaitForExit(); + catch (Exception e) + { + var message = string.Format(Resources.DamMacroStabilityKernelWrapper_ConvertStiXmlToStiError, + e.Message); + throw new MacroStabilityException((message)); + } + + if (!File.Exists(stabilityXmlFile)) + { + string errorMessage = "no error"; + if (exitCode !=0 || hadErrors) + { + errorMessage = stdErr; + } + var message = string.Format(Resources.DamMacroStabilityKernelWrapper_ConvertStiXmlToStiError, + stabilityXmlFile + " exit code = " + exitCode + " error = " + errorMessage + " output = " + + stdOut); + throw new MacroStabilityException(message); + } + + return true; } - catch (ThreadInterruptedException ex) + else { - return false; + var message = string.Format(Resources.DamMacroStabilityKernelWrapper_ConvertStiXmlToStiError, + "The xml file is not there (yet) for : " + stabilityXmlFile); + throw new MacroStabilityException(message); } - - return true; } internal static StabilityCalculator StabilityCalculator(IKernelDataInput kernelDataInput) Index: DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/Properties/Resources.resx =================================================================== diff -u -r3737 -r4297 --- DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/Properties/Resources.resx (.../Resources.resx) (revision 3737) +++ DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/Properties/Resources.resx (.../Resources.resx) (revision 4297) @@ -306,4 +306,7 @@ No segments with failure mechanism {0} present + + The conversion of the sti.xml to sti file failed: {0}. + \ No newline at end of file Index: DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/Properties/Resources.Designer.cs =================================================================== diff -u -r3737 -r4297 --- DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 3737) +++ DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 4297) @@ -1,7 +1,6 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -79,6 +78,15 @@ } /// + /// Looks up a localized string similar to The conversion of the sti.xml to sti file failed: {0}.. + /// + internal static string DamMacroStabilityKernelWrapper_ConvertStiXmlToStiError { + get { + return ResourceManager.GetString("DamMacroStabilityKernelWrapper_ConvertStiXmlToStiError", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Design not support for this model ({0}).. /// internal static string DamMacroStabilityKernelWrapper_DesignNotSupportedForModel { @@ -136,6 +144,15 @@ } /// + /// Looks up a localized string similar to Required safety factor must be specified. + /// + internal static string DamMacroStabilityOutwardsKernelWrapper_Prepare_NoRequiredSafetyFactor { + get { + return ResourceManager.GetString("DamMacroStabilityOutwardsKernelWrapper_Prepare_NoRequiredSafetyFactor", resourceCulture); + } + } + + /// /// Looks up a localized string similar to No Dam input object defined for Bligh. /// internal static string DamPipingBlighKernelWrapper_NoDamInputObjectDefinedForBligh {