static int Main(string[] args) { Logger.Initialize("Res1dToPI.log", true); Logger.AddLog(Logger.TypeEnum.Info, $"Res1dToPI started with parameters \"{string.Join("\", \"", args)}\"."); if (args.Length < 2) { Logger.AddLog(Logger.TypeEnum.Error, $"Wrong number of arguments must be at least 2. \n Syntax: \n InputRes1dFilePath\n OutputPIFilePath\n [OutputConfigurationXMLFile]"); Logger.Write(); return(-1); } string inputRes1dPath = args[0].Replace("/", "\\");; string outputPIPath = args[1].Replace("/", "\\");; string configXMLPath = string.Empty; if (args.Count() > 2) { configXMLPath = args[2]; } var res1dReader = new Res1DReader(inputRes1dPath); if (!string.IsNullOrEmpty(configXMLPath)) { res1dReader.LoadSelectionXML(configXMLPath); } var pi = res1dReader.AddAllTS(); var pis = new List <PI>(); pis.Add(pi); PIWriter.Write(outputPIPath, pis); Logger.Write(); return(0); }
static int Main(string[] args) { Logger.Initialize("Dfs0ToPI.log", true); Logger.AddLog(Logger.TypeEnum.Info, $"Dfs0ToPI started with parameters \"{string.Join("\", \"", args)}\"."); if (args.Length < 6) { Logger.AddLog(Logger.TypeEnum.Error, $"Wrong number of arguments must be at least 6. \n Syntax: \n OutputPIFilePath\n ModelRoot\n EnsembleId\n EnsembleMemberId\n EnsembleMemberIndex\n InputDfs0FilePath\n [InputDfs0FilePath]\n..."); Logger.Write(); return(-1); } string ensembleId = ""; string ensembleMemberId = ""; int ensembleMemberIndex = -1; string outputFileName = "..\\pi-output\\pi-output.xml"; if (!string.IsNullOrEmpty(args[0])) { outputFileName = args[0]; } string modelRootPath = args[1]; ensembleId = args[2]; ensembleMemberId = args[3]; if (!int.TryParse(args[4], out ensembleMemberIndex)) { ensembleMemberIndex = -1; } var dfs0FileList = new List <string>(); for (int i = 5; i < args.Length; i++) { dfs0FileList.Add(args[i]); } var pis = new List <PI>(); Logger.Write(); foreach (var filePath in dfs0FileList) { if (File.Exists(Path.Combine(modelRootPath, filePath))) { var pi_dfs0 = new PI(); var dfs0Reader = new ReadDfs0(); try { dfs0Reader.ReadDfs0File(ref pi_dfs0, modelRootPath, filePath, ensembleId, ensembleMemberId, ensembleMemberIndex); } catch (Exception ex) { Logger.AddLog(Logger.TypeEnum.Error, $"File {Path.Combine(modelRootPath, filePath)} read error {ex.Message}"); Logger.Write(); return(-1); } Logger.AddLog(Logger.TypeEnum.Info, $"File {Path.Combine(modelRootPath, filePath)} parsed."); pis.Add(pi_dfs0); } else { Logger.AddLog(Logger.TypeEnum.Error, $"File {Path.Combine(modelRootPath, filePath)} did not exist"); Logger.Write(); return(-1); } } PIWriter.Write(outputFileName, pis); Logger.Write(); return(0); }