/// <summary>
        /// Call case fixing for given statements
        /// </summary>
        /// <param name="translatedStatement">Statements to be translated</param>
        /// <param name="infoWriter">Stream for info/summary, may be null.</param>
        private void CaseFixStatements(Statement translatedStatement, TextWriter infoWriter)
        {
            if (translatedStatement == null)
            {
                return;
            }

            CharacterCaseFixer fixer = new CharacterCaseFixer(Config.DBServer, Config.DBSchema, Config.DBUser, Config.DBPasswd);
            bool displayWarn         = true;

            if (Config.UseCaseFixer)
            {
                StatusReporter.SetStage(ResStr.MSG_CASEFIXING_STEP);
            }

            if (translatedStatement is BlockStatement)
            {
                foreach (Statement st in ((BlockStatement)translatedStatement).Statements)
                {
                    displayWarn = CaseFixStatement(fixer, st, infoWriter, displayWarn);
                }
            }
            else
            {
                displayWarn = CaseFixStatement(fixer, translatedStatement, infoWriter, true);
            }
        }
        /// <summary>
        /// Apply case fixcing for given statement. Return new value for display warning
        /// </summary>
        /// <param name="fixer">Initialized case fixed object</param>
        /// <param name="statement">Statement for case fixing</param>
        /// <param name="infoWriter">Writter for info/summary stream</param>
        /// <param name="displayWarning">Display info warning or not</param>
        /// <returns>Returns false when display warning have been displayed</returns>
        bool CaseFixStatement(CharacterCaseFixer fixer, Statement statement, TextWriter infoWriter, bool displayWarning)
        {
            fixer.ClearIdentifiersTables();
            fixer.Scan(statement);

            if (Config.UseCaseFixer && (statement is SqlStartStatement) == false)
            {
                string res = fixer.CorrectIdentifiers();
                if (!string.IsNullOrEmpty(res) && displayWarning)
                {
                    if (infoWriter != null)
                    {
                        infoWriter.WriteLine(ResStr.MSG_UNABLE_TO_VERIFY_IDENTFIERS);
                        infoWriter.WriteLine(ResStr.MSG_TECHNICAL_INFO + " " + res);
                    }
                    displayWarning = false;
                }
            }

            return(displayWarning);
        }
        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);
            }
        }