NotesScanner ScanNotes(TextWriter writer, Statement statement) { NotesScanner ns = new NotesScanner(writer); ns.SetFilter(Config.CommentsFilter); ns.WriteNotesToWritter(false); ns.ClearSummaryInfo(); ns.Scan(StatusReporter.OutputQueries); ns.SetFilter(Config.InfoFilter); return(ns); }
public string ReturnNotes() { string ret = string.Empty; if (!Config.DisableComments) { List <string> list = new List <string>(); NotesScanner Ns = new NotesScanner(list); Ns.SetFilter(Config.CommentsFilter); Ns.WriteNotesToWritter(true); Ns.Scan(this); if (list.Count > 0) { ret = list.Distinct().Aggregate((i, j) => i + Environment.NewLine + j); ret += Environment.NewLine; } } return(ret); }
void TranslateStatements(IList <Statement> statements) { string outputFile = Config.OutputFile; Dictionary <string, string> msgs = new Dictionary <string, string>(); int errStatement = 0; msgs[Note.CASEFIXER] = ResStr.MSG_CORRECTED_IDENTIFIERS; msgs[Note.ERR_CASEFIXER] = ResStr.MSG_COLUMNS_NOT_FOUND; msgs[Note.STRINGIFIER] = ResStr.MSG_SUMINFO_UNSUPPORTED_FEATURES; msgs[Note.ERR_MODIFIER] = ResStr.MSG_ERRORS_LIMITATIONS; if (outputFile != "") { using (StreamWriter writer = CreateOutputFile(outputFile)) { CharacterCaseFixer fixer = new CharacterCaseFixer(Config.DBServer, Config.DBSchema, Config.DBUser, Config.DBPasswd); NotesScanner ns = new NotesScanner(writer); ns.SetFilter(Config.CommentsFilter); ns.WriteNotesToWritter(false); bool displayWarning = true; int idx = 1; Console.WriteLine(ResStr.MSG_TRANSLATING_QUERY, idx++, statements.Count); Modifier md = new Modifier(); BlockStatement RootStatement; if (Config.CreateProcedure && !(statements[1] is CreateProcedureStatement)) { CreateProcedureStatement procedure = new CreateProcedureStatement(new DbObject(new Identifier(IdentifierType.Plain, md.ProcPool.GetNewProcedureName())), -1, new List <ProcedureParameter> { }, null, false, statements as List <Statement>); procedure.Declarations = new BlockStatement(); RootStatement = new BlockStatement(procedure); } else { RootStatement = new BlockStatement(statements); } md.Scan(RootStatement); ns.ClearSummaryInfo(); ns.SetFilter(Config.CommentsFilter); Statement translated = md.Statement; if (translated != null) { if (translated is BlockStatement) { foreach (Statement st in ((BlockStatement)translated).Statements) { fixer.ClearIdentifiersTables(); fixer.Scan(st); if (Config.UseCaseFixer && (translated is SqlStartStatement) == false) { string res = fixer.CorrectIdentifiers(); if (!string.IsNullOrEmpty(res) && displayWarning) { Console.WriteLine(ResStr.MSG_UNABLE_TO_VERIFY_IDENTFIERS); Console.WriteLine(ResStr.MSG_TECHNICAL_INFO + " " + res); displayWarning = false; } } } } else { fixer.ClearIdentifiersTables(); fixer.Scan(translated); if (Config.UseCaseFixer && (translated is SqlStartStatement) == false) { string res = fixer.CorrectIdentifiers(); if (!string.IsNullOrEmpty(res) && displayWarning) { Console.WriteLine(ResStr.MSG_UNABLE_TO_VERIFY_IDENTFIERS); Console.WriteLine(ResStr.MSG_TECHNICAL_INFO + " " + res); displayWarning = false; } } } if (Config.Formatter) { Formatter formatter = new Formatter(); formatter.Add(translated); writer.Write(formatter.Statement); } else { Stringifier stringifier = new Stringifier(); stringifier.Add(translated); writer.Write(stringifier.Statement); } ns.Scan(translated); } ns.SetFilter(Config.InfoFilter); ns.DisplaySummaryInfo(Console.Out, msgs); if (ns.NotesCount(Note.STRINGIFIER) > 0 || ns.NotesCount(Note.ERR_MODIFIER) > 0 || ns.NotesCount(Note.ERR_CASEFIXER) > 0) { ++errStatement; } } DbUtil.ReleaseSingleton(); Console.WriteLine("================================================================="); Console.WriteLine(ResStr.MSG_NUM_OF_OK_QUERIES, statements.Count - errStatement); Console.WriteLine(ResStr.MSG_NUM_OF_NOK_QUERIES, errStatement); Console.WriteLine(ResStr.MSG_NUM_OF_QUERIES, statements.Count); } }