private static void AMLXCompress(string sourceAMLFile = "") { string target, newFile; bool AnotherFile; List <string> FilesToAdd = new List <string>(); PrintHelper.DeCompressor_Choosage(true); if (String.IsNullOrEmpty(sourceAMLFile)) { PrintHelper.printCentredLine("What is your Input AML-File?\n\n"); sourceAMLFile = PrintHelper.GetFile("AML-File", "*.AML"); } // User Aborted Compress if (String.IsNullOrEmpty(sourceAMLFile)) { return; } PrintHelper.printCentredLine("Do you want to add another File?(Yes/No)\n\n"); AnotherFile = Console.ReadLine().ToUpper() == "YES"; while (AnotherFile) { newFile = PrintHelper.GetFile(); if (!String.IsNullOrEmpty(newFile)) { if (FilesToAdd.Contains(newFile) || newFile == sourceAMLFile) { PrintHelper.printCentredLine("You already added this File"); } else { FilesToAdd.Add(newFile); } PrintHelper.printCentredLine("Do you want to add more Files?(Yes/No)\n\n"); AnotherFile = Console.ReadLine().ToUpper() == "YES"; } else { break; } } PrintHelper.printCentredLine("Where do you want to save the Output?\n\n\n"); target = PrintHelper.GetDirectory(); if (String.IsNullOrEmpty(target)) { return; } DeCompressor.Compress(sourceAMLFile, target, FilesToAdd); }
private static void AMLXDeCompress() { string src, target; PrintHelper.DeCompressor_Choosage(false); PrintHelper.printCentredLine("What is your Input?\n\n"); src = PrintHelper.GetFile("AMLX-File", "*.AMLX"); if (String.IsNullOrEmpty(src) || (Path.GetExtension(src).ToUpper() != ".AMLX")) { return; } PrintHelper.printCentredLine("Where do you want to save the Output?\n\n"); target = PrintHelper.GetDirectory(); if (String.IsNullOrEmpty(target)) { return; } DeCompressor.DeCompress(src, target); }
public void validate(CAEXDocument doc, string path, ref Options CurrentOptions) { // start validating aml try { ValidatorService service = ValidatorService.Register(); var enumerator = service.ValidateAll(doc).GetEnumerator(); bool FileChanged = false; while (enumerator.MoveNext()) { if (CurrentOptions.PrintAllVal) { printALLData_for_ValidationElement(enumerator.Current); } // print Error print_Error(enumerator.Current); if (!CurrentOptions.AutoRepair) { PrintHelper.println("Type yes to repair the error\n\n", ConsoleColor.Yellow); } // try reparing if (CurrentOptions.AutoRepair || "YES".StartsWith(Console.ReadLine().ToUpper().Trim())) { // start reparing FileChanged = true; service.Repair(enumerator.Current); PrintHelper.println($"Repair results: {enumerator.Current.RepairResult}\n\n", ConsoleColor.Cyan); } } // no Errors in mistake if (enumerator.Current == null) { Console.WriteLine("\n\n"); PrintHelper.println("No errors found\n\n", ConsoleColor.Green); } else if (FileChanged) { PrintHelper.println("Override file ? (Yes/No)\n\n", this.default_foreground); // if override file if ("YES".StartsWith(Console.ReadLine().ToUpper().Trim())) { doc.SaveToFile(path, true); PrintHelper.println($"saved to file {path}\n\n", ConsoleColor.Cyan); } else { // save to new file PrintHelper.printCentredLine("Please insert the Path for the File you want to save:\n\n"); string new_path = PrintHelper.GetDirectory(); // Only when User entered a valid Path if (!String.IsNullOrEmpty(new_path)) { PrintHelper.printCentredLine("What should be the Name of the Repaired AML-File?\n"); string FileName = Path.Combine(new_path, Console.ReadLine()); PrintHelper.printCentredLine("\n"); while (File.Exists(@FileName)) { PrintHelper.printCentredLine("File already exists in Directory. Please Choose another name.\n"); FileName = Path.Combine(new_path, Console.ReadLine()); PrintHelper.printCentredLine("\n"); } doc.SaveToFile(FileName, true); PrintHelper.println($"saved to file {FileName}\n\n", ConsoleColor.Cyan); } } } ValidatorService.UnRegister(); } catch (Exception e) { Console.WriteLine("Exception: " + e.ToString() + "\n\n"); PrintHelper.println("Couldn't Validate File\n\n", ConsoleColor.Red); } PrintHelper.Exit("Returning to Main Menu"); }