In the main query Q2 all the steps are fine. I will only detail here the powershell call. This call is based on a SQL function call linked to a Script ES1 FUNCTION runps(@command NVARCHAR) NVARCHAR AS SCRIPT [S PS] ENTRY 'Script.runps'; VALUE @p NVARCHAR = runps(CAST(@zone AS NVARCHAR)); the only parameter send is the id of the current zone for the external app to target the right dem and mask files the script is // C# // $reference: system.dll using System; using System.Diagnostics; class Script { public static string runps(string command) { Manifold.Application app = Manifold.Application; var processStartInfo = new ProcessStartInfo(); processStartInfo.WorkingDirectory = "C:\\ps"; processStartInfo.FileName = "powershell.exe"; processStartInfo.Arguments = "-Command \".\\ps.exe -l 15 -m c:\\ps\\dem\\mask_"+command+".grd c:\\ps\\dem\\dem_"+command+".grd\""; processStartInfo.UseShellExecute = false; processStartInfo.RedirectStandardOutput = true; var process = new Process(); process.StartInfo = processStartInfo; process.Start(); //string output = process.StandardOutput.ReadToEnd(); string rslt = "none"; while (!process.StandardOutput.EndOfStream) { string line = process.StandardOutput.ReadLine(); if ( line.Contains("complete") == false) { app.Log(line); if ( line.Contains("rock_hachures")) { rslt = line.Replace("save_img: ", ""); rslt = rslt.Replace(" min 0.000000 max 1.000000", ""); app.Log("filename:**"+rslt+"**"); } } } return rslt; } static Manifold.Context Manifold; static void Main() { } } this part works fine also but the process will pass from one to the next one, taking a long time for complex dem structures. Which is why I wanted to parallelize this call.
|