Exemple #1
0
/// <summary>
/// Show the specified query in a new PopupResults form
/// </summary>
/// <param name="qm"></param>
/// <param name="html"></param>
/// <param name="title"></param>

        public static void ShowHtml(         // navigate browser to a document
            QueryManager qm,
            string html,
            string title)
        {
            string uri;
            int    pi;

            Progress.Hide();             // hide any progress so popup gets focus

            uri = ClientDirs.TempDir + @"\PopupResults" + "1" + ".htm";

            StreamWriter sw = new StreamWriter(uri);

            sw.Write(html);
            sw.Close();

            PopupResults pr = new PopupResults();

            UIMisc.PositionPopupForm(pr);
            pr.Text = title;

            QueryResultsControl qrc = pr.QueryResultsControl;

            qm.LinkMember(qrc);
            Query q = qm.Query;

            qrc.BuildResultsPagesTabs(q);

            for (pi = 0; pi < q.ResultsPages.Pages.Count; pi++)
            {
                ResultsPage page = q.ResultsPages.Pages[pi];
                for (int vi = 0; vi < page.Views.Count; vi++)
                {
                    ResultsViewProps view = page.Views[vi];
                    if (view.ViewType == ResultsViewType.HtmlTable)
                    {
                        view.Title      = title;
                        view.ContentUri = uri;                         // plug in file name for uri
                    }
                }
            }

            pr.Show();
            qrc.ConfigureResultsPage(0);             // render the first page

            UIMisc.BringFormToFront(pr);
            return;
        }
Exemple #2
0
        /// <summary>
        /// Show popup results in a results window
        /// </summary>
        /// <param name="qm"></param>
        /// <param name="title"></param>

        public static void Show(
            QueryManager qm)
        {
            string uri;
            int    pi, posDelta = 20;

            Progress.Hide();             // hide any progress so popup gets focus

            string title = qm.Query.UserObject.Name;

            PopupResults pr = new PopupResults();

            UIMisc.PositionPopupForm(pr);
            pr.Text = title;

            QueryResultsControl qrc = pr.QueryResultsControl;

            qm.LinkMember(qrc);
            Query q = qm.Query;

            qrc.BuildResultsPagesTabs(q);

            if (q.ResultsPages.Pages.Count <= 1)             // hide tabs if only one
            {
                qrc.ResultsLabel.Visible = qrc.Tabs.Visible = false;
            }


            //qrc.ToolPanel.Visible = false; // hide tools for now (e.g. Edit Query)

            //if (q.ResultsPages.Pages.Count <= 1) // hide tabs if only one
            //{
            //	PanelControl pc = qrc.ResultsPagePanelContainer;
            //	int delta = pc.Top;
            //	pc.Top = 0;
            //	pc.Height += delta;
            //}

            pr.Show();
            //qrc.ConfigureResultsPage(0); // render the first page
            qrc.SelectPage(q.InitialBrowsePage);             // show the initial browse page

            UIMisc.BringFormToFront(pr);
            return;
        }
Exemple #3
0
        /// <summary>
        /// Run the query
        /// </summary>
        /// <param name="browseExistingResults">If true browse existing results</param>
        /// <returns></returns>

        public string RunQuery3(
            ResultsFormat rf,
            bool saveHitlist,
            bool browseExistingResults)
        {
            Query        modifiedQuery;
            QueryTable   qt;
            QueryColumn  qc;
            ResultsTable rt;
            ResultsField rfld;
            MetaTable    mt;
            MetaColumn   mc;
            string       txt, msg;
            DialogResult dr;
            bool         success;
            CellGraphic  cg;
            Lex          lex = new Lex();
            string       tempfile, tok, command, unrecognizedCommand, response;
            int          ti, gi, rc, i1, i2;

            // Begin execution

            if (rf == null)
            {
                throw new Exception("QueryExec.Run - Null ResultsFormat");
            }

            if (ResultsFormatter == null)
            {
                throw new Exception("QueryExec.Run - Null ResultsFormatter");
            }

            if (rf.Segments == null)
            {
                throw new Exception("QueryExec.Run - Null ResultsFormat.Segments");
            }

            if (Query == null)
            {
                throw new Exception("QueryExec.Run - Null Rf.Query");
            }

            if (Query.Tables == null || Query.Tables.Count <= 0)
            {
                throw new QueryException("QueryExec.Run - No Query Tables");
            }

            QueryManager qm = QueryManager;

            ReturnMsg = "";

            //bool useExistingQueryEngine = Rf.ParentQe != null;
            //bool useExistingDataTable = Query.BrowseExistingResultsWhenOpened && Query.SerializeResults &&
            //  qm.DataTable != null && qm.DataTable.Rows.Count > 0;

            try
            {
                //if (Math.Sqrt(4) == 2) throw new Exception("test"); // debug

                if (!browseExistingResults)                 // normal open of search
                {
                    Progress.Show("Analyzing query...");    // put up a status message to the user as soon as possible to let them know something is happening...

                    dr = ValidateQuery(Query);
                    if (dr == DialogResult.Cancel)
                    {
                        return("");
                    }

                    WriteCurrentListToServerIfNeeded(Query);

                    if (rf.OutputDestination == OutputDest.WinForms)                     // update access stats if grid
                    {
                        UpdateTableUsageStatistics(Query);
                    }

                    Query.ResultsDataTable = null;                     // be sure to get new results

                    qm = BuildQueryManager(Query, rf);

                    Query.ResetViewStates();                     // reset state of views for proper operation

                    if (Rf.ParentQe == null)                     // open search unless using existing query engine
                    {
                        if (!ExecuteSearch(saveHitlist))         // returns false if cancelled by user
                        {
                            Progress.Hide();
                            return("");
                        }
                    }

                    if ((ResultsKeys == null || ResultsKeys.Count == 0) &&                      // nothing for search
                        !Query.Preview &&
                        !MqlUtil.SingleStepExecution(Query) &&
                        qm.DataTable.Rows.Count == 0 &&
                        Query.RetrievesDataFromQueryEngine)
                    {
                        // if (!Rf.PopupDisplay)
                        Progress.Hide();
                        if (qm.StatusBarManager != null)
                        {
                            qm.StatusBarManager.DisplayStatusMessage("");
                        }
                        // if (QueryEngine.Cancelled) return ""; // cancelled by user
                        msg = "No data have been found that matches your query.";
                        if (ResultsFormat.PopupOutputFormContext && !ResultsFormat.SuppressNoDataMessage)
                        {
                            MessageBoxMx.Show(msg, "Search Result",
                                              MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return("Command EditQuery");                            // return to edit query menu
                        }
                        else
                        {
                            return(msg);
                        }
                    }

                    //if (ResultsFormat.PopupDisplay)
                    //  SessionManager.DisplayStatusMessage("Retrieving data...");
                    //else Progress.Show("Retrieving data...", UmlautMobius.Value, true, "Cancelling Retrieval...");

                    //Progress.Show("Retrieving data...", UmlautMobius.String, true, "Cancelling Retrieval...");
                    Progress.Hide();                     // hide progress - "Retrieving data..." message now appears as bottom line of grid

                    if (ResultsFormat.Grid)
                    {
                        if (ResultsFormat.SessionOutputFormContext)              // if normal main session form grid display, set browse mode & view state
                        {
                            Query.ResetViewStates();                             // reset view state for all views
                            QbUtil.SetMode(QueryMode.Browse, Query);

                            if (ResultsFormat.Query.LogicType == QueryLogicType.And)                             // log grid query by logic type
                            {
                                UsageDao.LogEvent("QueryGridAnd", "");
                            }
                            else if (ResultsFormat.Query.LogicType == QueryLogicType.Or)
                            {
                                UsageDao.LogEvent("QueryGridOr", "");
                            }
                            else if (ResultsFormat.Query.LogicType == QueryLogicType.Complex)
                            {
                                UsageDao.LogEvent("QueryGridComplex", "");
                            }
                        }

                        else if (ResultsFormat.PopupOutputFormContext)                         // create popup window & configure
                        {
                            PopupResults.Show(qm);
                            //MoleculeGridPanel.ConfigureAndShow(qm, null);
                        }

                        else if (ResultsFormat.ToolOutputFormContext)
                        {
                            ContainerControl    cc;
                            QueryResultsControl qrc = ResultsFormat.OutputContainerControl as QueryResultsControl;
                            AssertMx.IsTrue(qrc != null, "ResultsFormat.OutputContainerControl must be a QueryResultsControl");
                            if (!WindowsHelper.FindContainerControl(qrc, typeof(ToolResultsContainer), out cc))
                            {
                                throw new Exception("ToolResultsContainer not found");
                            }

                            ToolResultsContainer trc = cc as ToolResultsContainer;
                            trc.SetupQueryResultsControlForResultsDisplay(qm);
                        }

                        else
                        {
                            throw new Exception("Invalid OutputformContext: " + ResultsFormat.OutputFormContext);
                        }
                    }
                }

                else                 // reentering display switch to browse tab
                {
                    QbUtil.SetMode(QueryMode.Browse, Query);
                }

                response = ResultsFormatter.BeginFormatting(browseExistingResults); // format the data

                if (ResultsFormat.SessionOutputFormContext)                         // normal display
                {
                    if (MqlUtil.SingleStepExecution(Query))
                    {                     // be sure hit count display is up to date
                        if (ResultsKeys != null)
                        {
                            if (qm.StatusBarManager != null)
                            {
                                qm.StatusBarManager.DisplayCurrentCount();
                            }
                        }
                    }

                    if (saveHitlist)
                    {
                        CidList hitList = new CidList(ResultsKeys);
                        rc = CidListCommand.WriteCurrentList(hitList);
                        SessionManager.DisplayCurrentCount();
                    }
                }

                return(response);
            }             // end of surrounding try

            catch (Exception ex)
            {
                Progress.Hide();
                if (ex is UserQueryException)                 // exception that can occur from user error
                {
                    throw new UserQueryException(ex.Message, ex);
                }

                else
                {
                    msg = DebugLog.FormatExceptionMessage(ex);
                    if (!Lex.Contains(msg, "QueryLogged:"))                     // exception & query
                    {
                        QueryEngine.LogExceptionAndSerializedQuery(msg, Query);
                    }
                    else
                    {
                        ServicesLog.Message(msg);                      // just log exception
                    }
                    throw new Exception(ex.Message, ex);               // pass it up
                }
            }
        }