public static IMatrixData getGSA(Parameters param, IMatrixData mdata, string workingDirectory, int option, ProcessInfo processInfo, out string errorString) { string folderDir = null; if (option == 0) { folderDir = "degradationGSA"; } else if (option == 1) { folderDir = "synthesisGSA"; } errorString = null; string modulePath = param.GetParam <string>(PECAParameters.networkFile).Value; string newWorkingDir = folderDir == null ? workingDirectory : Path.Combine(workingDirectory, @folderDir); string moduleDestination = Path.Combine(newWorkingDir, "networkFile.txt"); //string moduleDestination = Path.Combine(@workingDirectory, "networkFile.txt"); Directory.CreateDirectory(newWorkingDir); File.Copy(modulePath, moduleDestination, true); //copy output if (option == 0 || option == 1) { string oldCPSoutputLoc = Path.Combine(workingDirectory, @"data_R_CPS.txt"); string newCPSOutputLoc = Path.Combine(newWorkingDir, @"data_R_CPS.txt"); File.Copy(oldCPSoutputLoc, newCPSOutputLoc, true); } string convertErr = ConvertUnix2Dos(moduleDestination, processInfo); if (convertErr != null) { errorString = convertErr; return(mdata); } //insert option here if (WriteGSAInputParam(param, option, newWorkingDir) != 0) { errorString = "Unable To Process GSA Parameters"; return(mdata); } string exeCPS = System.IO.Path.Combine(Directory.GetCurrentDirectory(), @".\bin\PECAInstallations\gsa.exe"); string inputCPSLocation = "\"" + System.IO.Path.Combine(@newWorkingDir, @".\gsa_input") + "\""; if (ExternalProcess.RunExe(exeCPS, inputCPSLocation, newWorkingDir, processInfo.Status, processInfo.Progress, -1, -1, out string processInfoErrString4) != 0) { errorString = processInfoErrString4; return(mdata); } //processInfo.ErrString = processInfoErrString5; //supplTables = new IMatrixData[] { PluginPECA.Utils.GetGOEnr(mdata, workingDirectory) }; return(GetGOEnr(mdata, @newWorkingDir, option)); }
//unix2dos is part of dos2unix which is released under FreeDSB //go https://waterlan.home.xs4all.nl/dos2unix/COPYING.txt for full license details public static string ConvertUnix2Dos(string filename, ProcessInfo processInfo) { string unix2dos = System.IO.Path.Combine(Directory.GetCurrentDirectory(), @".\bin\PECAInstallations\unix2dos.exe"); string filepath = "\"" + filename + "\""; if (ExternalProcess.RunExe(unix2dos, filepath, null, processInfo.Status, processInfo.Progress, -1, -1, out string processInfoErrString) != 0) { return(processInfoErrString); } return(null); }