コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="writer"></param>
        void PrintSummary(TextWriter writer)
        {
            if (writer == null)
            {
                return;
            }

            NotesScanner ns = ScanNotes(writer, StatusReporter.OutputQueries);

            Dictionary <string, string> msgs = new Dictionary <string, string>();

            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;

            writer.WriteLine("\n------------------------------------");
            ns.DisplaySummaryInfo(writer, msgs);
            //writer.WriteLine(ResStr.MSG_NUM_OF_OK_QUERIES, numQueries - nokQueries);
            //writer.WriteLine(ResStr.MSG_NUM_OF_NOK_QUERIES, nokQueries);
            writer.WriteLine(ResStr.MSG_NUM_OF_QUERIES, StatusReporter.InputQueriesCount);
        }
コード例 #2
0
        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);
            }
        }