Exemplo n.º 1
0
        public void SaveFile(string filename)
        {
            if (tabset.SelectedTab == textPage)
            {
                textpad.SaveFile(filename);
            }
            else if (tabset.SelectedTab == gridPage)
            {
                Notepad pad = new Notepad();

                ResultFormat format = (ResultFormat)UserOptions.GetEnumeration(
                    "results/general/format", typeof(ResultFormat));

                if (format == ResultFormat.ColumnAligned)
                {
                    ReportText((Database.Query)grid.Tag, pad);
                }
                else
                {
                    ReportDelimitedText((Database.Query)grid.Tag, format, pad);
                }

                pad.SaveFile(filename);
            }
        }
Exemplo n.º 2
0
        //========================================================================================
        // GetStatementCollection()
        //========================================================================================

        /// <summary>
        /// Builds a statement collection from the selected text and formats it according
        /// to user options.  If there are more one statement, the user may be prompted
        /// to select a specific parse mode.
        /// </summary>
        /// <param name="parseMode">The default or explicit parse mode.</param>
        /// <param name="text">The text to parse into statements.</param>
        /// <returns>A StatementCollection of one or more formatted statements.</returns>

        private StatementCollection GetStatementCollection(ParseMode parseMode, string text)
        {
            var parser = new StatementParser();
            StatementCollection statements = parser.Parse(text);

            if ((parseMode == ParseMode.None) && (statements.Count > 1))
            {
                parseMode = (ParseMode)UserOptions.GetEnumeration(
                    "connections/parseMode", typeof(ParseMode));

                if (parseMode == ParseMode.Prompt)
                {
                    var          dialog = new Dialogs.AlgorithmDialog(statements.Count, false);
                    DialogResult result = dialog.ShowDialog(this);

                    if (result == DialogResult.Cancel)
                    {
                        return(null);
                    }

                    parseMode = dialog.Mode;

                    if (dialog.StoreSelection)
                    {
                        UserOptions.SetValue("connections/parseMode", dialog.Mode.ToString());
                        UserOptions.Save();
                    }
                }
            }


            if (parseMode == ParseMode.Wrapped)
            {
                statements.Wrap(dbase.DefaultSchema);
            }
            else if (parseMode == ParseMode.Block)
            {
                statements.Combine();
            }

            return(statements);
        }
Exemplo n.º 3
0
        //========================================================================================
        // Add()
        //========================================================================================

        /// <summary>
        /// Displays the results of the given query.
        /// </summary>
        /// <param name="query">The query to report.</param>

        public void Add(Database.Query query)
        {
            Logger.WriteLine("Adding result with target [" + resultTarget + "]");

            Notepad msgTarget = textpad;

            if ((int)resultTarget < 0)                                          // TODO: why!?
            {
                resultTarget = ResultTarget.Text;
            }

            if (!query.HideResults)
            {
                if (query.QueryType == QueryType.SqlPlus)
                {
                    LoadFile(query.OutputFilename);
                }
                else
                {
                    switch (resultTarget)
                    {
                    case ResultTarget.Text:
                        ResultFormat format = (ResultFormat)UserOptions.GetEnumeration(
                            "results/general/format", typeof(ResultFormat));

                        if (format == ResultFormat.ColumnAligned)
                        {
                            ReportText(query);
                        }
                        else
                        {
                            ReportDelimitedText(query, format);
                        }
                        break;

                    case ResultTarget.Grid:
                        ReportGrid(query);
                        msgTarget = msgpad;
                        break;

                    case ResultTarget.Xml:
                        ReportXml(query);
                        break;
                    }
                }
            }

            if (query.Messages.Count > 0)
            {
                ReportMessages(query.Messages, msgTarget, query.HideResults);
            }
            else if (query.HideResults)
            {
                textpad.WriteNote(CR + RxNoMessages);
            }

            if (UserOptions.GetBoolean("results/general/dbmsOutput"))
            {
                if (query.OutputLines.Count > 0)
                {
                    ReportOutputLines(query.OutputLines);
                }
            }

            resultCount++;
        }