static public string Main() { using (OutToFile redir = new OutToFile(System.Web.HttpContext.Current.Server.MapPath(@"~/Redirect.txt"))) Console.WriteLine("Entering in the Validation Process "); StreamReader inputStream = null; try { string path = System.Web.HttpContext.Current.Server.MapPath(@"~/temp.txt"); inputStream = new StreamReader(path); AntlrInputStream input = new AntlrInputStream(inputStream); TestingLexer lexer = new TestingLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); TestingParser parser = new TestingParser(tokens); TestingParser.GramContext sContext = parser.gram(); //TestingParser.InitContext iContext = parser.init(); TestVisitor visitor = new TestVisitor(); visitor.VisitGram(sContext); //visitor.VisitInit(iContext);*/ } catch (Exception e) { using (OutToFile redir = new OutToFile(System.Web.HttpContext.Current.Server.MapPath(@"~/Redirect.txt"))) { Console.WriteLine("Error--->>" + e); Console.WriteLine("Cannot open Redirect.txt for writing"); Console.WriteLine(e.Message); } return("Failed! Message:\n" + e.Message); } finally { using (OutToFile redir = new OutToFile(System.Web.HttpContext.Current.Server.MapPath(@"~/Redirect.txt"))) Console.WriteLine(" "); using (OutToFile redir = new OutToFile(System.Web.HttpContext.Current.Server.MapPath(@"~/Redirect.txt"))) Console.WriteLine("Finished"); using (new OutToFile(System.Web.HttpContext.Current.Server.MapPath(@"~/Redirect.txt"))) Console.WriteLine(" Thank You for using SQLVAL"); inputStream.Close(); } return("Success!"); //Console.ReadKey(); }
public Dictionary <string, List <string> > this[string key] { get { if (!dictionary.TryGetValue(key, out inner)) { inner = new Dictionary <string, List <string> >(); // using (OutToFile redir = new OutToFile(System.Web.HttpContext.Current.Server.MapPath(@"~/Redirect.txt")) ) // Console.WriteLine("in dict" + inner+"---"+key); dictionary[key] = inner; } else { using (OutToFile redir = new OutToFile(System.Web.HttpContext.Current.Server.MapPath(@"~/Redirect.txt"))) Console.WriteLine("ERROR : COLUMN " + key + "already exists"); } return(inner); } }
static void Main(string[] args) { var commandLineArgs = Option.Parse(args); //read the existing file, and parse it into something we can use. var inputFileArg = commandLineArgs.Where(arg => arg.Name == "InputFile").First(); var filePath = inputFileArg.Arguments.First(); var assumeHeaders = commandLineArgs.Where(arg => arg.Name == "InputHeaders").FirstOrDefault() != null; IEnumerable <SourceFile> sourceFiles = null; if (assumeHeaders) { sourceFiles = System.IO.File.ReadLines(filePath).Skip(1).Select(line => new SourceFile(line)); } else { sourceFiles = System.IO.File.ReadLines(filePath).Select(line => new SourceFile(line)); } var destFiles = sourceFiles.Select(f => new DestinationFile(f)); var outputToConsole = commandLineArgs.Where(arg => arg.Name == "OutputFile").FirstOrDefault() == null; var writeHeaders = commandLineArgs.Where(arg => arg.Name == "OutputHeaders").FirstOrDefault() != null; if (outputToConsole) { WriteItems(destFiles, writeHeaders); } else { var outputFileName = commandLineArgs.Where(arg => arg.Name == "OutputFile").First().Arguments.First(); using (var redirect = new OutToFile(outputFileName)) { WriteItems(destFiles, writeHeaders); } } }