Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="gridPanel"></param>
        /// <param name="qm"></param>

        public static void DisplayData(
            MoleculeGridPanel gridPanel,
            QueryManager qm)
        {
            if (gridPanel == null)             // if grid panel not defined assume display is in normal results panel
            {
                gridPanel = SessionManager.Instance.QueryResultsControl.MoleculeGridPageControl.MoleculeGridPanel;
                QbUtil.SetMode(QueryMode.Browse);                 // put into browse mode
            }

            else if (gridPanel.Parent is PopupGrid)             // display in popup grid
            {
                PopupGrid pug = gridPanel.Parent as PopupGrid;
                pug.Initialize(qm);                 // be sure popup is initialized
                WindowsHelper.FitFormOnScreen(pug);
                pug.Show();
            }

            MoleculeGridControl grid = qm.MoleculeGrid;

            gridPanel.Visible = true;
            grid.Visible      = true;
            grid.DataSource   = qm.DataTable;           // set the datasource for the grid to the datatable

            RefreshDataDisplay(qm);
        }
Exemple #2
0
        /// <summary>
        /// Edit alert properties
        /// </summary>

        void EditAlert()
        {
            int   alertId = 0;
            Alert alert;

            if (Query.UserObject.Id <= 0)             // query been saved?
            {
                MessageBoxMx.ShowError("This query must be saved before an alert can be defined on it.");
                return;
            }

            if (!Alert.QueryValidForAlert(Query))
            {
                return;                                               // be sure it is valid
            }
            if (!QbUtil.CanRunQueryInBackground(Query))
            {
                return;                                                     // further validity checks
            }
            int newAlertId = AlertProperties.Edit(Query.UserObject.Id, out alert);

            if (newAlertId == 0)
            {
                return;                              // no change
            }
            SetAlertText(alert);
            return;
        }
Exemple #3
0
/// <summary>
/// Edit and existing Spotfire link
/// </summary>
/// <param name="internalName"></param>
/// <returns></returns>

        public static UserObject Edit(string internalName)
        {
            UserObject uo = null;

            if (Lex.IsDefined(internalName))             // get the user object
            {
                uo = UserObject.ParseInternalUserObjectName(internalName, "");
                if (uo != null)
                {
                    uo = UserObjectDao.Read(uo.Id);
                }
                if (uo == null)
                {
                    throw new Exception("User object not found " + internalName);
                }
            }

            else
            {
                uo = null;              // no arg, show open dialog
            }
            UserObject uo2 = Edit(uo);

            if (uo2 != null && uo2.Id > 0)
            {
                QbUtil.UpdateMetaTableCollection(uo2.InternalName);
            }

            return(uo2);
        }
Exemple #4
0
        bool Save(bool prompt)
        {
            UserObject uo2;

            if (!IsValidCalcField())
            {
                return(false);
            }
            if (!GetCalcFieldForm())
            {
                return(false);
            }
            if (prompt)
            {
                uo2 = UserObjectSaveDialog.Show("Save Calculated Field Definition", UoIn);
                if (uo2 == null)
                {
                    return(false);
                }
            }
            else
            {
                uo2 = UoIn.Clone();
            }

            if (!UserObjectUtil.UserHasWriteAccess(uo2))
            {             // is the user authorized to save this?
                MessageBoxMx.ShowError("You are not authorized to save this calculated field");
                return(false);
            }

            SessionManager.DisplayStatusMessage("Saving calculated field...");

            string content = CalcField.Serialize();

            uo2.Content = content;

            //need the name of the folder to which the object will be saved
            MetaTreeNode targetFolder = UserObjectTree.GetValidUserObjectTypeFolder(uo2);

            if (targetFolder == null)
            {
                MessageBoxMx.ShowError("Failed to save your calculated field.");
                return(false);
            }

            UserObjectDao.Write(uo2);

            string tName = "CALCFIELD_" + uo2.Id.ToString();

            QbUtil.UpdateMetaTableCollection(tName);
            MainMenuControl.UpdateMruList(tName);

            string title = "Edit Calculated Field - " + uo2.Name;

            Text = title;
            UoIn = uo2.Clone();             // now becomes input object
            SessionManager.DisplayStatusMessage("");
            return(true);
        }
Exemple #5
0
        private void BrowseQueries_Click(object sender, EventArgs e)
        {
            string     prompt = "Select Query";
            UserObject uo     = UserObjectOpenDialog.ShowDialog(UserObjectType.Query, prompt, QueryUo);

            if (uo == null)
            {
                return;
            }
            Alert existingAlert = Alert.GetAlertByQueryId(uo.Id);

            if (existingAlert != null)                              // only 1 alert per query per user is allowed
            {
                if (Alert.Id <= 0 ||                                // if this is a new alert or
                    (Alert.Id > 0 && Alert.Id != existingAlert.Id)) // another alert exists for the query
                {
                    MessageBoxMx.Show("You already an existing alert for query " + Lex.Dq(uo.Name),
                                      "Mobius", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }

            Query q = QbUtil.ReadQuery(uo.Id);

            if (!Alert.QueryValidForAlert(q))
            {
                return;
            }

            QueryUo        = uo;
            QueryName.Text = QueryUo.Name;
        }
Exemple #6
0
/// <summary>
/// Show the field selector dialog
/// </summary>
/// <param name="prompt"></param>
/// <param name="caption"></param>
        /// <param name="mc"></param>
        /// <param name="checkmarkDefaultColumn">If mc == null checkmark a default column</param>
        /// <returns></returns>

        public static MetaColumn ShowDialog(
            string prompt,
            string caption,
            MetaColumn mc,
            bool selectSummarizedDataByDefault,
            bool checkmarkDefaultColumn)
        {
            Instance = new SelectFieldFromContents();
            Instance.Setup(prompt, caption, mc, selectSummarizedDataByDefault, checkmarkDefaultColumn);

            QbUtil.SetProcessTreeItemOperationMethod(TreeItemOperation);

            DialogResult dr = Instance.ShowDialog(SessionManager.ActiveForm);

            QbUtil.RestoreProcessTreeItemOperationMethod();

            if (dr == DialogResult.OK)
            {
                return(Instance.SelectedMc);
            }
            else
            {
                return(null);
            }
        }
Exemple #7
0
        /// <summary>
        /// Handle special KeyDown events
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void CommandLine_KeyDown(object sender, KeyEventArgs e)
        {
            LastCommandLineControlKeyDownTime = DateTime.Now;

            if (CheckForEscapePressed(e))
            {
            }

            else if (e.KeyCode == Keys.Enter)             // command entered
            {
                e.Handled = true;

                ExecuteCommandLine();
                return;

#if false // experimental code that opens the currently selected item in the dropdown rather than doing a more-complete search
                int i1 = ListControl.SelectedIndex;

                if (ListControl.Visible &&
                    i1 >= 0 &&                        // something selected
                    i1 < MatchingContentsNodes.Count) // within list of nodes found in the latest quicksearch
                {
                    MetaTreeNode mtn = MatchingContentsNodes[i1];
                    QbUtil.CallCurrentProcessTreeItemOperationMethod("Open", mtn.Target);
                    HideQuickSearchPopup();
                }

                else
                {
                    ExecuteCommandLine();                  // just execute the command line
                }
                return;
#endif
            }
        }
Exemple #8
0
        /// <summary>
        /// Main tool entry point
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>

        public string Run(
            string args)
        {
            QbUtil.SetMode(QueryMode.Build);             // be sure in build mode

            //List<StructureDbInfo> dbInfo = StructureDbInfo.GetList(); // get list of root structure tables
            //MetaTable mt = MetaTableCollection.Get(dbInfo[0].StructureTable); // use first structure table

            if (DatabasesToSearch.Text == "")
            {                                                  // default to first structure table
                List <RootTable> dbInfo = RootTable.GetList(); // get list of root structure tables
                if (dbInfo != null && dbInfo.Count > 0)
                {
                    DatabasesToSearch.Text = dbInfo[0].Label;
                }
            }

            if (ServicesIniFile.Read("MultStructSearchHelpUrl") != "")
            {
                Help.Enabled = true;
            }

            DialogResult dr = ShowDialog(SessionManager.ActiveForm);

            return("");
        }
Exemple #9
0
        public void ExecuteCommandLine()
        {
            string s = CommandLineControl.Text;

            if (s == "")
            {
                return;
            }

            HideQuickSearchPopup();

            DevExpress.XtraEditors.Controls.MRUEditItemCollection items = CommandLineControl.Properties.Items;
            if (items.Count > 0 && Lex.Eq(items[0].ToString(), s))
            {
            }                                                                      // don't insert same item again
            else
            {
                CommandLineControl.Properties.Items.Insert(0, s);              // insert in list manually since we clear it here
            }
            CommandLineControl.Text = "";
            PreviousInput           = "";   // avoid any additional QuickDisplays

            QbUtil.CallCurrentProcessTreeItemOperationMethod("CommandLine", s);
            //CommandExec.Execute("CommandLine " + s);
        }
Exemple #10
0
/// <summary>
/// Build the query that is executed to retrieve the summarized target data and optional structure data
/// </summary>
/// <returns></returns>

        void BuildQuery(string title)
        {
            int qid = SS.I.ServicesIniFile.ReadInt("SpillTheBeansToolModelQuery", -1);

            if (qid < 0)
            {
                throw new Exception("SpillTheBeansToolModelQuery not defined");
            }

            Query q = QbUtil.ReadQuery(qid);

            if (q == null)
            {
                throw new Exception("Failed to read SpillTheBeansToolModelQuery: " + qid);
            }

            AssertMx.IsDefined(KeyQc?.Criteria, "KeyQc.Criteria");

            ParsedSingleCriteria psc = MqlUtil.ParseSingleCriteria(KeyQc?.Criteria);             // parse key criteria

            KeyQc.CopyCriteriaToQueryKeyCritera(q);
            Query = q;             // save for later use

            return;
        }
Exemple #11
0
        private void RunDatabaseQuery_Click(object sender, EventArgs e)
        {
            DataRow      dr;
            UcdbDatabase ucdb;
            UserObject   uo;
            int          ri;

            if (!GetFocusedUo(out ri, out dr, out ucdb, out uo))
            {
                return;
            }

            if (!UserData.BuildDatabaseQuery(uo))
            {
                return;                                               // some error
            }
            QbUtil.RenderQuery();

            QueryTable  qt = QbUtil.Query.Tables[0];            // root table
            QueryColumn qc = qt.GetQueryColumnByName("MolFormula");

            if (qc == null)
            {
                throw new Exception("MolFormula not found in root table");
            }
            MetaColumn mc = qc.MetaColumn;

            qc.CriteriaDisplay = "All Data Rows";             // do all data query on molformula
            qc.Criteria        = "(" + mc.Name + " IS NOT NULL OR " + mc.Name + " IS NULL)";
            QbUtil.RenderQuery(0);

            Response     = "Command RunQuery";
            DialogResult = DialogResult.OK;
        }
Exemple #12
0
/// <summary>
/// Add a query to the window list, make it current & render
/// </summary>
/// <param name="label"></param>
/// <param name="mql"></param>

        public static void AddQueryToWindowList(
            string label,
            string mql,
            bool convertToSimpleCriteria)
        {
            Query q = MqlUtil.ConvertMqlToQuery(mql);

            if (convertToSimpleCriteria)
            {
                MqlUtil.ConvertComplexCriteriaToQueryColumnCriteria(q, QueryLogicType.And);
            }
            q.UserObject.Name = label;

            int wi = QbUtil.GetQueryIndex(label);

            if (wi >= 0)             // replace existing query
            {
                Document mwt = (Document)QbUtil.DocumentList[wi];
                mwt.Type    = DocumentType.Query;
                mwt.Content = q;
                QbUtil.SelectQuery(wi);
            }

            else
            {
                QbUtil.AddQueryAndRender(q, false);              // new query
            }
        }
Exemple #13
0
        /// <summary>
        /// Build a basic database query for the user database
        /// </summary>
        /// <param name="uo"></param>
        /// <returns></returns>

        internal static bool BuildDatabaseQuery(
            UserObject uo)
        {
            List <UserObject> luo = UserDataEditor.GetUcdbUserObjects(uo.Id);

            if (luo == null || luo.Count == 0)
            {
                MessageBoxMx.ShowError("No tables found for database");
                return(false);
            }

            Query q = new Query();

            foreach (UserObject uo2 in luo)
            {
                if (!UserObject.IsMetaTableType(uo2.Type))
                {
                    continue;
                }

                string    mtName = uo2.Type.ToString() + "_" + uo2.Id;
                MetaTable mt     = MetaTableCollection.Get(mtName);
                if (mt == null)
                {
                    continue;
                }
                QueryTable qt = new QueryTable(mt);
                q.AddQueryTable(qt);
            }

            QbUtil.NewQuery(uo.Name);
            QbUtil.SetCurrentQueryInstance(q);
            return(true);
        }
Exemple #14
0
        /// <summary>
        /// Run query using supplied OutputDest displaying any error message
        /// </summary>
        /// <param name="query"></param>
        /// <param name="outputDest"></param>
        /// <returns></returns>

        public static string RunQuery(
            Query query,
            OutputDest outputDest)
        {
            try
            {
                bool browseExistingResults = QbUtil.BrowseExistingDataTable(query);
                return(RunQuery(query, outputDest, OutputFormContext.Session, null, browseExistingResults));
            }

            catch (UserQueryException ex)
            {             // just show message
                Progress.Hide();
                MessageBoxMx.ShowError(ex.Message);
                return("");
            }

            catch (Exception ex)
            {             // non-standard query exception, provide more detail
                Progress.Hide();
                string msg = DebugLog.FormatExceptionMessage(ex);

                if (!Lex.Contains(msg, "QueryLogged:"))                 // exception & query
                {
                    QueryEngine.LogExceptionAndSerializedQuery(msg, query);
                }
                else
                {
                    ServicesLog.Message(msg);                  // just log exception
                }
                MessageBoxMx.ShowError("Unexpected Exception\n\n" + msg);
                return("");
            }
        }
Exemple #15
0
        /// <summary>
        /// Setup the control for specified view
        /// </summary>
        /// <param name="view"></param>

        public void Setup(
            int selectedQueryId,
            string selectedQueryName,
            EventHandler callerEditValueChangedEventHandler = null)
        {
            DataRow    dr;
            DataColumn dc;
            string     queryName = "";

            InSetup = true;

            SelectedQueryId               = selectedQueryId;
            SelectedQueryName             = selectedQueryName;
            CallerEditValueChangedHandler = callerEditValueChangedEventHandler;

            if (SelectedQueryId < 0)
            {
                if (Lex.IsDefined(SelectedQueryName) && ShowCurrentQueryMenuItem)                 // if undefined use current query if available
                {
                    SelectedQueryId = 0;
                    queryName       = "Current Query";
                }

                else                 // start with no query
                {
                    SelectedQueryName = null;
                    queryName         = "";
                }
            }

            else if (SelectedQueryId == 0)
            {
                SelectedQueryName = SelectedQueryName;
                queryName         = "Current Query";
            }

            else
            {
                Query q = QbUtil.ReadQuery(SelectedQueryId);
                if (q != null)
                {
                    SelectedQueryName = q.Name;
                    SelectedQueryId   = q.UserObject.Id;
                }

                else
                {
                    SelectedQueryId   = -1;
                    SelectedQueryName = null;
                }
            }

            SourceQueryComboBox.Text = queryName;

            InSetup = false;

            return;
        }
Exemple #16
0
 private void Help_Click(object sender, EventArgs e)
 {
     if (UserDatabase)
     {
         QbUtil.ShowConfigParameterDocument("EditUserDatabaseHelpUrl", "Edit User Database Help");
     }
     else
     {
         QbUtil.ShowConfigParameterDocument("EditAnnotationTableHelpUrl", "Edit Annotation Table Help");
     }
 }
Exemple #17
0
        bool Cancelled = false;              // set to true if processing cancelled

/// <summary>
/// Main entrypoint for plugin
/// </summary>
/// <param name="args"></param>
/// <returns></returns>

        public string Run(
            string args)
        {
            DialogResult dr;

            try
            {
                Lex lex = new Lex();
                if (args == null)
                {
                    args = "";
                }
                lex.OpenString(args);
                string cmd   = lex.Get();
                string args2 = lex.GetRestOfLine().Trim();

                if (cmd == "" || Lex.Eq(cmd, "ShowDialog"))
                {
                    QbUtil.SetMode(QueryMode.Build);                     // be sure in build mode
                    dr = Instance.ShowDialog(args2);
                    if (dr == DialogResult.OK)
                    {
                        cmd = "Command RunQuery";                         // pass command back to main level
                        return(cmd);
                    }
                    else
                    {
                        return("");
                    }
                }

                else if (Lex.Eq(cmd, "ShowPopup"))
                {
                    if (Lex.IsUndefined(args2))
                    {
                        throw new Exception("Syntax: TargetResultsViewer ShowPopup <CorpId>");
                    }
                    ShowPopup(args2);
                    return("");
                }

                else
                {
                    throw new Exception("Invalid command: " + cmd);
                }
            }

            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
Exemple #18
0
        /// <summary>
        /// Main tool entry point
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>

        public string Run(
            string args)
        {
            QbUtil.SetMode(QueryMode.Build);             // be sure in build mode

            if (ServicesIniFile.Read("RgroupDecompositionHelpUrl") != "")
            {
                Help.Enabled = true;
            }

            this.ShowDialog();
            return("");
        }
Exemple #19
0
/// <summary>
/// ShowImmediate
/// </summary>
/// <param name="singleCorpId"></param>

        void ShowPopup(string singleCorpId)
        {
            KeyQc          = QueryTable.GetDefaultRootQueryTable()?.KeyQueryColumn;
            KeyQc.Criteria = KeyQc.MetaColumnName + " = " + singleCorpId;

            //Tso = new TargetSummaryOptions();
            //Tso.CidCriteria = "= " + singleCorpId;

            string title = "Spotfire View of Data for Compound Id " + CompoundId.Format(singleCorpId);

            BuildQuery(title);
            QbUtil.RunPopupQuery(Query, title, OutputDest.WinForms);
            return;
        }
Exemple #20
0
        /// <summary>
        /// Remove table from query
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void Tabs_CloseButtonClick(object sender, EventArgs e)
        {
            if (Tabs.SelectedTabPageIndex == 0 && ShowCriteriaTab)
            {
                MessageBoxMx.ShowError("The Criteria Summary tab cannot be removed.");
                return;
            }

            int qti = Tabs.SelectedTabPageIndex;

            if (ShowCriteriaTab)
            {
                qti--;
            }
            QbUtil.RemoveQueryTable(qti);
        }
Exemple #21
0
        void QueryChangedEventHandler(object sender, EventArgs e)
        {
            Query q = QbUtil.ReadQuery(QuerySelectorControl.SelectedQueryId);

            if (q == null)
            {
                throw new Exception("Query not found");
            }

            SelectedQuery = q;
            SetupViewSelector(q, "");

            ViewSelectorComboBox.ShowPopup();

            return;
        }
Exemple #22
0
        private void OpenQuery_Click(object sender, EventArgs e)
        {
            int row, queryId;

            row = V.GetFocusedDataSourceRowIndex();
            if (row < 0)
            {
                return;
            }
            queryId = (int)DataTable.Rows[row]["QueryId"];
            UserObject quo  = UserObjectDao.ReadHeader(queryId);
            string     path = quo.InternalName;

            QbUtil.OpenQuery(path, true, false, false);
            DialogResult = DialogResult.OK;             // close dialog
        }
Exemple #23
0
        /// <summary>
        /// Select a single item from the filtered types from the contents tree
        /// </summary>
        /// <param name="title"></param>
        /// <param name="prompt"></param>
        /// <param name="typeFilter"></param>
        /// <param name="initialSelection"></param>
        /// <param name="numberItems"></param>
        /// <returns></returns>

        public static MetaTreeNode SelectSingleItem(
            string title,
            string prompt,
            MetaTreeNodeType typeFilter,
            MetaTreeNode initialSelection,
            bool numberItems)
        {
            if (Instance == null)
            {
                Instance = new SelectFromContents();
            }
            Instance.Text        = title;
            Instance.Prompt.Text = prompt;

            string selectedNodeTarget = (initialSelection != null ? initialSelection.Target : null);
            string expandNodeTarget   = ContentsTreeControl.GetPreferredProjectNodeTarget();

            Instance.ContentsTree.FillTree(
                "root",
                typeFilter,
                selectedNodeTarget,
                expandNodeTarget,
                null,
                false,
                false);

            Instance.ContentsTreeWithSearch.CommandLineControl.Text = "";

            Instance.SelectionName.Text   = (initialSelection != null ? initialSelection.Label : null);
            Instance.SelectionTarget.Text = (initialSelection != null ? initialSelection.Target : null);
            Instance.TypeFilter           = typeFilter;

            QbUtil.SetProcessTreeItemOperationMethod(TreeItemOperation);

            DialogResult dr = Instance.ShowDialog(SessionManager.ActiveForm);

            QbUtil.RestoreProcessTreeItemOperationMethod();

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

            MetaTreeNode mtn = Instance.ContentsTree.FocusedMetaTreeNode;

            return(mtn);
        }
Exemple #24
0
        /// <summary>
        /// Open a new query with specified name
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>

        public Query NewQuery(
            string name)
        {
            int i1, i2;

            if (String.IsNullOrEmpty(name))             // create a name if not supplied
            {
                for (i1 = NewQueryCount + 1; ; i1++)
                {
                    name = "Query" + i1.ToString();
                    i2   = GetQueryIndex(name);
                    if (i2 < 0)
                    {
                        break;
                    }
                }

                NewQueryCount = i1;
            }

            else             // see if this query is already open
            {
                Query q2 = null;
                i1 = GetQueryIndex(name);
                if (i1 >= 0)                 // already open, just switch to it
                {
                    CurrentQueryIndex                     = i1;
                    CurrentQuery                          = (Query)DocumentList[CurrentQueryIndex].Content;
                    Tabs.SelectedTabPageIndex             = CurrentQueryIndex;
                    Tabs.TabPages[CurrentQueryIndex].Text = name;           // make sure tab title is correct
                    SessionManager.SetShellTitle(name);                     // set main window title
                    Qtc.Render(CurrentQuery);
                    return(CurrentQuery);
                }
            }

            Query newQuery = new Query();

            newQuery.Name = name;

            QbUtil.AddQueryAndRender(newQuery, false);

            //AddQuery(newQuery);
            //QbUtil.SetMode(QueryMode.Build); // be sure in build mode
            return(newQuery);
        }
Exemple #25
0
        /// <summary>
        /// Get the query that this secondary query view uses
        /// </summary>
        /// <returns></returns>

        public Query RealizeSubQuery()
        {
            if (SubQuery != null)
            {
                return(SubQuery);
            }

            else if (SubQueryId > 0)
            {
                SubQuery = QbUtil.ReadQuery(SubQueryId);
                return(SubQuery);
            }

            else
            {
                return(null);
            }
        }
Exemple #26
0
        private void BuildDatabaseQuery_Click(object sender, EventArgs e)
        {
            DataRow      dr;
            UcdbDatabase ucdb;
            UserObject   uo;
            int          ri;

            if (!GetFocusedUo(out ri, out dr, out ucdb, out uo))
            {
                return;
            }

            if (!UserData.BuildDatabaseQuery(uo))
            {
                return;                                               // some error
            }
            QbUtil.RenderQuery();
            DialogResult = DialogResult.OK;
        }
Exemple #27
0
        /// <summary>
        /// Select the specified tab (e.g. query)
        /// </summary>
        /// <param name="tabIndex"></param>

        public void SelectQuery(int queryIndex)
        {
            if (queryIndex >= DocumentList.Count)
            {
                return;                                               // shouldn't happen
            }
            SS.I.UISetupLevel++;

            CurrentQueryIndex = queryIndex;
            Document doc = DocumentList[queryIndex];

            CurrentQuery = (Query)doc.Content;             // restore query
            Query q = CurrentQuery;

            if (q.PresearchDerivedQuery != null)             // restore any browse query
            {
                CurrentBrowseQuery = q.PresearchDerivedQuery;
            }
            else
            {
                CurrentBrowseQuery = q;
            }

            Tabs.TabPages[CurrentQueryIndex].Text = q.UserObject.Name; // make sure tab title is correct
            SessionManager.SetShellTitle(q.UserObject.Name);           // set main window title
            Tabs.SelectedTabPageIndex = queryIndex;                    // select the tab if not done yet
            SS.I.UISetupLevel--;

            if (q.Mode == QueryMode.Unknown || q.Mode == QueryMode.Build)
            {
                QbUtil.SetMode(QueryMode.Build);                 // check & adjust build mode details
                Qtc.Render(q);
                SessionManager.DisplayCurrentCount();
            }

            else                                  // reenter browse mode
            {
                QbUtil.SetMode(QueryMode.Browse); // check & adjust build mode details
                QueryExec.RunQuery(q, OutputDest.WinForms, OutputFormContext.Session, browseExistingResults: true);
                SessionManager.DisplayFilterCountsAndString();
            }
        }
Exemple #28
0
/// <summary>
/// Setup the QueryManager members for the specified query
/// </summary>
/// <param name="qm"></param>
/// <param name="q"></param>
/// <param name="rf"></param>
/// <param name="qe"></param>
/// <param name="resultsKeys"></param>

        public static void InitializeQueryManager(
            QueryManager qm,
            Query q,
            ResultsFormat rf,
            QueryEngine qe,
            List <string> resultsKeys)
        {
            qm.Initialize(q, rf, qe, resultsKeys);

            if (q.InaccessableData != null)
            {
                if (SS.I.Attended)
                {
                    QbUtil.ShowUnavailableDataMessage(q);
                }
                q.InaccessableData = null;
            }

            return;
        }
Exemple #29
0
        public void DuplicateQuery()
        {
            Query q  = CurrentQuery;
            int   qi = GetQueryIndex(q);           // index of query to dup

            if (qi != CurrentQueryIndex)
            {
                qi = qi;                                      // debug
            }
            if (qi < 0 || qi >= DocumentList.Count)
            {
                return;
            }
            qi++;                                                 // where duplicate query will go

            Query q2 = q.Clone();                                 // make copy query

            q2.UserObject = new UserObject(UserObjectType.Query); // reset userobject info
            q2.Name       = q.Name;                               // set base name to build new name from
            AssignUniqueQueryName(q2);

            Document doc = new Document();

            doc.Type    = DocumentType.Query;
            doc.Content = q2;
            DocumentList.Insert(qi, doc);
            CurrentQuery      = q2;
            CurrentQueryIndex = qi;

            XtraTabPage tp = new XtraTabPage();

            tp.ImageIndex = 0;
            tp.Text       = q2.Name;
            Tabs.TabPages.Insert(qi, tp);
            Tabs.SelectedTabPageIndex = qi;

            QbUtil.SetMode(QueryMode.Build);
            //Qtc.Render(CurrentQuery);
            SessionManager.SetShellTitle(q2.Name);             // set main window title
            return;
        }
Exemple #30
0
/// <summary>
/// Open the specified query or copy the list
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

        private void GridView_RowCellClick(object sender, RowCellClickEventArgs e)
        {
            StreamReader sr;

            int         r  = e.RowHandle;
            int         c  = e.Column.AbsoluteIndex;
            HistoryItem hi = SS.I.History[r]; // get item allowing for header row

            if (c == 0)                       // open query
            {
                sr = new StreamReader(hi.QueryFileName);
                string queryText = sr.ReadToEnd();
                Query  q         = Query.Deserialize(queryText);
                q.UserObject.Name =                   // append time to name
                                    q.UserObject.Name + " - " + hi.DateTime.ToLongTimeString();
                q.Mode = QueryMode.Build;             // want to be in build mode
                q.UserObject.Content = q.Serialize(); // set content so not prompted for save when closed

                QbUtil.AddQueryAndRender(q, false);
            }

            // Copy list to current list

            sr = new StreamReader(hi.ListFileName);
            string  listText = sr.ReadToEnd();
            CidList cidList  = new CidList(listText);

            CidListCommand.WriteCurrentList(cidList);
            SessionManager.CurrentResultKeys = cidList.ToStringList();
            SessionManager.DisplayCurrentCount();

            if (c == 1)             // return message if just copying list to current
            {
                string msg = "The list has been copied to the current list (" + SessionManager.CurrentResultKeysCount + ")";
                MessageBoxMx.Show(msg);
            }

            HistoryList_Deactivate(null, null);
            return;
        }