static void Main(string[] args) { if (args.Length < 1) { Console.WriteLine("Usage: RptToXml.exe <RPT filename | wildcard> [outputfilename]"); Console.WriteLine(" outputfilename argument is valid only with single filename in first argument"); return; } string rptPathArg = args[0]; bool wildCard = rptPathArg.Contains("*"); if (!wildCard && !ReportFilenameValid(rptPathArg)) { return; } if (wildCard && args.Length > 1) { Console.WriteLine("Output filename may not be specified with wildcard."); return; } Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); var rptPaths = new List <string>(); if (!wildCard) { rptPaths.Add(rptPathArg); } else { var directory = Path.GetDirectoryName(rptPathArg); if (String.IsNullOrEmpty(directory)) { directory = "."; } var matchingFiles = Directory.GetFiles(directory, searchPattern: Path.GetFileName(rptPathArg)); rptPaths.AddRange(matchingFiles.Where(ReportFilenameValid)); } if (rptPaths.Count == 0) { Trace.WriteLine("No reports matched the wildcard."); } foreach (string rptPath in rptPaths) { Trace.WriteLine("Dumping " + rptPath); using (var writer = new RptDefinitionWriter(rptPath)) { string xmlPath = args.Length > 1 ? args[1] : Path.ChangeExtension(rptPath, "xml"); writer.WriteToXml(xmlPath); } } }
static void RunOptions(Options opts) { string rptPathArg = opts.Files.First(); bool wildCard = rptPathArg.Contains("*"); if (!wildCard && !ReportFilenameValid(rptPathArg)) { return; } if (wildCard && opts.Files.Count() > 1) { Console.WriteLine("Output filename may not be specified with wildcard."); return; } Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); var rptPaths = new List <string>(); if (!wildCard) { rptPaths.Add(rptPathArg); } else { var directory = Path.GetDirectoryName(rptPathArg); if (String.IsNullOrEmpty(directory)) { directory = "."; } SearchOption searchOption = SearchOption.TopDirectoryOnly; if (opts.Recursive) { searchOption = SearchOption.AllDirectories; } var matchingFiles = Directory.GetFiles(directory, searchPattern: Path.GetFileName(rptPathArg), searchOption: searchOption); rptPaths.AddRange(matchingFiles.Where(ReportFilenameValid)); } if (rptPaths.Count == 0) { Trace.WriteLine("No reports matched the wildcard."); } foreach (string rptPath in rptPaths) { Trace.WriteLine("Dumping " + rptPath); using (var writer = new RptDefinitionWriter(rptPath)) { string xmlPath = opts.Files.Count() > 1 ? opts.Files.ElementAt(1) : Path.ChangeExtension(rptPath, "xml"); writer.WriteToXml(xmlPath); } } }
static void Main(string[] args) { if (args.Length < 1) { Console.WriteLine("Usage: RptToXml.exe <RPT filename | wildcard> [outputfilename]"); Console.WriteLine(" outputfilename argument is valid only with single filename in first argument"); return; } string rptPathArg = args[0]; bool wildCard = rptPathArg.Contains("*"); if (!wildCard && !ReportFilenameValid(rptPathArg)) return; if (wildCard && args.Length > 1) { Console.WriteLine("Output filename may not be specified with wildcard."); return; } Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); var rptPaths = new List<string>(); if (!wildCard) { rptPaths.Add(rptPathArg); } else { var directory = Path.GetDirectoryName(rptPathArg); if (String.IsNullOrEmpty(directory)) { directory = "."; } var matchingFiles = Directory.GetFiles(directory, searchPattern: Path.GetFileName(rptPathArg)); rptPaths.AddRange(matchingFiles.Where(ReportFilenameValid)); } if (rptPaths.Count == 0) { Trace.WriteLine("No reports matched the wildcard."); } foreach (string rptPath in rptPaths) { Trace.WriteLine("Dumping " + rptPath); using (var writer = new RptDefinitionWriter(rptPath)) { string xmlPath = args.Length > 1 ? args[1] : Path.ChangeExtension(rptPath, "xml"); writer.WriteToXml(xmlPath); } } }
static void Main(string[] args) { if (args.Length != 1) { Console.WriteLine("Usage: RptToXml.exe <RPT filename | wildcard>"); return; } string rptPathArg = args[0]; bool wildCard = rptPathArg.Contains("*"); if (!wildCard && !ValidateReportFilename(rptPathArg)) { return; } Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); var rptPaths = new List <string>(); if (!wildCard) { rptPaths.Add(rptPathArg); } else { var matchingFiles = Directory.GetFiles(Path.GetDirectoryName(rptPathArg), Path.GetFileName(rptPathArg)); rptPaths.AddRange(matchingFiles); } foreach (string rptPath in rptPaths) { Trace.WriteLine("Dumping " + rptPath); RptDefinitionWriter writer = new RptDefinitionWriter(rptPath); string xmlPath = Path.ChangeExtension(rptPath, "xml"); writer.WriteToXml(xmlPath); } }
static void Main(string[] args) { if (args.Length != 1) { Console.WriteLine("Usage: RptToXml.exe <RPT filename | wildcard>"); return; } string rptPathArg = args[0]; bool wildCard = rptPathArg.Contains("*"); if (!wildCard && !ValidateReportFilename(rptPathArg)) return; Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); var rptPaths = new List<string>(); if (!wildCard) { rptPaths.Add(rptPathArg); } else { var matchingFiles = Directory.GetFiles(Path.GetDirectoryName(rptPathArg), Path.GetFileName(rptPathArg)); rptPaths.AddRange(matchingFiles); } foreach (string rptPath in rptPaths) { Trace.WriteLine("Dumping " + rptPath); RptDefinitionWriter writer = new RptDefinitionWriter(rptPath); string xmlPath = Path.ChangeExtension(rptPath, "xml"); writer.WriteToXml(xmlPath); } }