private static void initFileInteractive(Dictionary <string, string> inputArgs) { FilePatternMapper file; StreamWriter patternFile; bool hasNext = false; int auxSearchLocation = 0; string patternFileName = ""; string mapperFileName = ""; string pythonFileName = ""; try { mapperFileName = Path.GetFullPath(Path.Combine(FileMapper.workDirectory, inputArgs.GetValueOrDefault("INIT") + ".json")); patternFileName = Path.GetFullPath(Path.Combine(FileMapper.workDirectory, inputArgs.GetValueOrDefault("INIT") + ".txt")); pythonFileName = Path.GetFullPath(Path.Combine(FileMapper.workDirectory, inputArgs.GetValueOrDefault("INIT") + ".py")); file = new FilePatternMapper() { Name = inputArgs.GetValueOrDefault("INIT"), DirFilter = "", FileFilter = "", OutputFileName = "", OutputFolder = "", Variables = new List <FilePatternVariables>() }; Console.WriteLine("Directory filter (default ''): "); file.DirFilter = Console.ReadLine(); Console.WriteLine("File filter (default ''): "); file.FileFilter = Console.ReadLine(); Console.WriteLine("Directory exclusion filter (default ''): "); file.DirFilter = Console.ReadLine(); Console.WriteLine("File exclusion filter (default ''): "); file.FileFilter = Console.ReadLine(); Console.WriteLine("Inform variables? (y or n)"); if (Console.ReadLine().Equals("Y", StringComparison.InvariantCultureIgnoreCase)) { do { file.Variables.Add(new FilePatternVariables()); Console.WriteLine("Variable name:"); file.Variables.Last().Name = Console.ReadLine(); Console.WriteLine("Search location (0 - content, 1 - File name, 2 - File Directory, 3 - File Path, 4 - Literal):"); if (int.TryParse(Console.ReadLine(), out auxSearchLocation)) { file.Variables.Last().SearchLocation = (ESearchLocation)auxSearchLocation; } else { file.Variables.Last().SearchLocation = ESearchLocation.Content; } Console.WriteLine("Variable search pattern:"); file.Variables.Last().SearchPatern = Console.ReadLine(); hasNext = false; Console.WriteLine("do you want to inform another variable? (y or n)"); if (Console.ReadLine().Equals("Y", StringComparison.InvariantCultureIgnoreCase)) { hasNext = true; } } while (hasNext); } file.save(mapperFileName); patternFile = new StreamWriter(patternFileName, false); foreach (FilePatternVariables filePatternVariable in file.Variables) { patternFile.WriteLine("<%" + filePatternVariable.Name + "%>"); } patternFile.Close(); patternFile.Dispose(); Console.WriteLine("Saved: " + inputArgs.GetValueOrDefault("INIT")); Console.WriteLine("Do you want to open the patern files? (y or n)"); if (Console.ReadLine().Equals("Y", StringComparison.InvariantCultureIgnoreCase)) { var p1 = new Process(); p1.StartInfo = new ProcessStartInfo(@patternFileName) { UseShellExecute = true }; p1.Start(); var p2 = new Process(); p2.StartInfo = new ProcessStartInfo(@mapperFileName) { UseShellExecute = true }; p2.Start(); var p3 = new Process(); p3.StartInfo = new ProcessStartInfo(@pythonFileName) { UseShellExecute = true }; p3.Start(); } } catch (Exception e) { Console.WriteLine(e); } }
private static void initFile(Dictionary <string, string> inputArgs) { FilePatternMapper file; StreamWriter patternFile; string patternFileName = ""; string mapperFileName = ""; string pythonFileName = ""; try { mapperFileName = Path.GetFullPath(Path.Combine(FileMapper.workDirectory, inputArgs.GetValueOrDefault("INIT") + ".json")); patternFileName = Path.GetFullPath(Path.Combine(FileMapper.workDirectory, inputArgs.GetValueOrDefault("INIT") + ".txt")); pythonFileName = Path.GetFullPath(Path.Combine(FileMapper.workDirectory, inputArgs.GetValueOrDefault("INIT") + ".py")); file = new FilePatternMapper() { Name = inputArgs.GetValueOrDefault("INIT"), DirFilter = "", FileFilter = "", OutputFileName = "", OutputFolder = "", Variables = new List <FilePatternVariables>() { new FilePatternVariables() { Name = "Variabe_Name", SearchLocation = ESearchLocation.Content, SearchPatern = "" } } }; file.save(mapperFileName); patternFile = new StreamWriter(patternFileName); patternFile.WriteLine("<%variable_name%>"); patternFile.Close(); patternFile.Dispose(); Console.WriteLine("Saved: " + inputArgs.GetValueOrDefault("INIT")); Console.WriteLine("Do you want to open the generated files? (y or n)"); if (Console.ReadLine().Equals("Y", StringComparison.InvariantCultureIgnoreCase)) { var p1 = new Process(); p1.StartInfo = new ProcessStartInfo(@patternFileName) { UseShellExecute = true }; p1.Start(); var p2 = new Process(); p2.StartInfo = new ProcessStartInfo(@mapperFileName) { UseShellExecute = true }; p2.Start(); var p3 = new Process(); p3.StartInfo = new ProcessStartInfo(@pythonFileName) { UseShellExecute = true }; p3.Start(); } } catch (Exception e) { Console.WriteLine(e); } }