/// <summary> /// Get a MetaTreeNode from either MetaTree or UserObjectTree /// searching both by name and target /// </summary> /// <param name="name"></param> /// <returns></returns> public static MetaTreeNode GetNode( string name) { MetaTreeNode mtn = MetaTree.GetNode(name); // check main tree first if (mtn == null) // check UserObject tree if not in main tree { mtn = UserObjectTree.GetNodeByName(name); } if (mtn == null) // try by main tree target { mtn = MetaTree.GetNodeByTarget(name); } if (mtn == null) // try UserObject tree target { mtn = UserObjectTree.GetNodeByTarget(name); } if (mtn != null) { return(mtn); } else { return(null); } }
private void Setup() { InSetup = true; // Setup preferred project MetaTreeNode mtn = MetaTree.GetNode(SS.I.PreferredProjectId); // If not found create folder node // The following default folder node should exist in the MetaTree root node: // <child name = "default_folder" l = "Private Queries, Lists..." type = "project" item = "default_folder" /> if (mtn == null) { mtn = new MetaTreeNode(MetaTreeNodeType.Project); mtn.Name = mtn.Target = "DEFAULT_FOLDER"; mtn.Label = "Private Queries, Lists..."; } PreferredProject.Text = mtn.Label; PreferredProjectId = SS.I.PreferredProjectId; PreferredProjectChanged = false; // Setup default directory DefaultFolder.Text = ClientDirs.DefaultMobiusUserDocumentsFolder; // Setup zoom TableColumnZoom.ZoomPct = SS.I.TableColumnZoom; // Setup zoom controls GraphicsColumnZoom.ZoomPct = SS.I.GraphicsColumnZoom; ZoomChanged = false; ScrollGridByRow.Checked = !SS.I.ScrollGridByPixel; ScrollGridByPixel.Checked = SS.I.ScrollGridByPixel; InitialScrollGridByPixel = SS.I.ScrollGridByPixel; // Setup look and feel LookAndFeelOption.Properties.Items.Clear(); List <SkinInfoMx> skins = LookAndFeelMx.GetSkins(); foreach (SkinInfoMx si in skins) { LookAndFeelOption.Properties.Items.Add(new ImageComboBoxItem(si.ExternalName, si.ImageIndex)); } // Basic old styles (these cause dialog box to close for some reason) CurrentLookAndFeel = SS.I.UserIniFile.Read("LookAndFeel", "Blue"); LookAndFeelOption.Text = LookAndFeelMx.GetExternalSkinName(CurrentLookAndFeel); ChangingLookAndFeelModes = false; InSetup = false; FindRelatedCpdsInQuickSearch.Checked = SS.I.FindRelatedCpdsInQuickSearch; RestoreWindowsAtStartup.Checked = SS.I.RestoreWindowsAtStartup; return; }
public static void ShowProjectDescription( string projNodeName) { StreamWriter sw; string html, htmlFileName, flowScheme = "", flowSchemeFileName = ""; ProjectDescriptionDialog form = new ProjectDescriptionDialog(); MetaTreeNode mtn = MetaTree.GetNode(projNodeName); string title = (mtn != null ? mtn.Label : projNodeName); html = GetProjectHtmlDescription(projNodeName); if (Lex.IsNullOrEmpty(html)) { html = "Unable to retrieve project description"; } string[] sa = html.Split('\v'); if (sa.Length >= 2) // write flowscheme if exists { html = sa[0]; flowScheme = sa[1]; flowSchemeFileName = ClientDirs.TempDir + @"\FlowScheme" + UIMisc.PopupCount + ".xml"; sw = new StreamWriter(flowSchemeFileName); sw.Write(flowScheme); sw.Close(); } htmlFileName = ClientDirs.TempDir + @"\PopupHtml" + UIMisc.PopupCount + ".htm"; sw = new StreamWriter(htmlFileName); sw.Write(html); sw.Close(); UIMisc.PositionPopupForm(form); form.Text = title; form.Show(); form.WebBrowser.Navigate(htmlFileName); if (flowSchemeFileName != "") { form.OpenFlowSchemeDiagram(flowSchemeFileName); } form.Tabs.SelectedTabPageIndex = 0; UsageDao.LogEvent("ShowProject", projNodeName); return; }
/// <summary> /// Try to lookup a MetaTreeNode by the supplied token /// </summary> /// <param name="tok"></param> /// <returns></returns> static MetaTreeNode GetNode(string tok) { MetaTreeNode mtn; if (Lex.IsInteger(tok)) { tok = "ASSAY_" + tok; // if no prefix assume ASSAY for now } mtn = MetaTree.GetNode(tok); if (mtn != null) { return(mtn); } mtn = MetaTree.GetNodeByLabel(tok); if (mtn != null) { return(mtn); } return(null); }
private void BrowseProjects_Click(object sender, EventArgs e) { MetaTreeNode mtn = new MetaTreeNode(); mtn.Name = SS.I.PreferredProjectId; mtn = MetaTree.GetNode(SS.I.PreferredProjectId); mtn = SelectFromContents.SelectSingleItem( "Select Preferred Project", "Select your preferred project from the choices given below", MetaTreeNodeType.Project, // show project folders and above mtn, false); if (mtn == null) { return; } PreferredProject.Text = mtn.Label; PreferredProjectId = mtn.Target; PreferredProjectChanged = true; }
private void SaveButton_Click(object sender, EventArgs e) { if (ObjectName.Text.Trim() == "") { MessageBoxMx.ShowError("You must supply a name"); ObjectName.Focus(); return; } if (ProjectName.Text.Trim() == "") { ProjectTarget.Text = ""; if (Lex.Ne(ObjectName.Text.Trim(), "Current")) // blank project not allowed unless saving current { MessageBoxMx.ShowError("You must supply a folder name"); ProjectName.Focus(); return; } } string txt = ProjectTarget.Text; if (txt.ToLower().IndexOf("project ") == 0 && txt.Length > 8) { txt = txt.Substring(8); } else if (txt.ToLower().IndexOf("folder ") == 0 && txt.Length > 7) { txt = txt.Substring(7).ToUpper(); } else if (txt.ToLower().IndexOf("submenu ") == 0 && txt.Length > 8) { txt = txt.Substring(8).ToUpper(); } MetaTreeNode mtn = MetaTree.GetNode(txt); if (mtn == null && UserObjectTree.FolderNodes.ContainsKey(txt)) { mtn = UserObjectTree.FolderNodes[txt]; } UserObject uo2 = new UserObject(Uo.Type); uo2.Owner = SS.I.UserName; // we will be the new owner uo2.Description = Uo.Description; // copy any description uo2.Name = ObjectName.Text; uo2.AccessLevel = Uo.AccessLevel; uo2.ACL = Uo.ACL; //reassigning the folder id to the object type folder happens in the "Save" if (mtn != null) { uo2.ParentFolder = mtn.Target.ToUpper(); uo2.ParentFolderType = mtn.GetUserObjectFolderType(); } UserObject uo3 = UserObjectDao.ReadHeader(uo2); // see if already exists if (uo3 != null) { string objectTypeName = UserObject.GetTypeLabel(Uo.Type); DialogResult dr = MessageBoxMx.Show( objectTypeName + " " + uo2.Name + " already exists. Do you want to replace it?", UmlautMobius.String, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (dr == DialogResult.No) { return; } else if (dr == DialogResult.Cancel) { DialogResult = DialogResult.Cancel; return; } else { uo2.Id = uo3.Id; // keep the id when overwriting } } Uo = uo2; // info on object to save DialogResult = DialogResult.OK; return; }
/// <summary> /// See if a ClickFunction command & process if so /// </summary> /// <param name="command"></param> /// <param name="qm"></param> /// <param name="cInf"></param> public static void Process( string command, QueryManager qm, CellInfo cInf = null) { QueryTable rootQt, qt; QueryColumn qc; MetaTable mt; MetaColumn mc; Query q2; string dbName = "", mtName = "", mcName = ""; List <string> args0, args; string funcName, arg1, arg2, arg3, arg4, arg5; string value = "", keyValue = ""; int ai; try { // Parse click function arguments stripping all single quotes. // Arguments may be defined in the clickfunction definition including col values // indicated by field.Value in the metacolumn clickfunction definition. // If no args are defined in the clickfunction definition then a field value // argument will be added by default or the keyValue if [keyvalue] appears in the // ClickFunction definition CurrentClickQueryManager = qm; args0 = Lex.ParseAllExcludingDelimiters(command, "( , )", false); args = new List <string>(); for (ai = 0; ai < args0.Count; ai++) // strip all single quotes { string arg = args0[ai]; if (arg.StartsWith("'")) { arg = Lex.RemoveSingleQuotes(arg); } //if (Lex.Eq(arg, "[rowcol]") && cInf!= null) //{ // pass grid row & col // args.Add(cInf.GridRowHandle.ToString()); // args.Add(cInf.GridColAbsoluteIndex.ToString()); //} //else args.Add(arg); } funcName = args[0]; arg1 = (args.Count >= 2 ? args[1] : ""); // get other args arg2 = (args.Count >= 3 ? args[2] : ""); arg3 = (args.Count >= 4 ? args[3] : ""); arg4 = (args.Count >= 5 ? args[4] : ""); arg5 = (args.Count >= 6 ? args[5] : ""); if (Lex.Eq(funcName, "DisplayAllData")) { // do all data display for supplied root table and key, i.e. DisplayAllData(TableName, KeyColName, KeyValue) ParseMetaTableMetaColumn(arg1, out mt, arg2, out mc); string extKey = arg3; string intKey = CompoundId.Normalize(extKey, mt); Progress.Show("Building Query..."); _query = QueryEngine.GetSelectAllDataQuery(mt.Name, intKey); Progress.Show("Retrieving data..."); // put up progress dialog since this may take a while QbUtil.RunPopupQuery(_query, mt.KeyMetaColumn.Name + " " + extKey); Progress.Hide(); return; } else if (Lex.Eq(funcName, "DisplayAllDataUsingDbName")) { // display all data for supplied database synonym & key value, i.e. DisplayAllData2(DataBaseSynonym, KeyValue) mtName = null; dbName = arg1; RootTable rti = RootTable.GetFromTableLabel(dbName); if (rti != null) { mtName = rti.MetaTableName; } else // try synonyms { DictionaryMx dict = DictionaryMx.Get("Database_Synonyms"); if (dict != null) { mtName = dict.LookupDefinition(dbName); } } if (String.IsNullOrEmpty(mtName)) { MessageBoxMx.ShowError("Unrecognized database: " + dbName); return; } mt = MetaTableCollection.Get(mtName); if (mt == null) { MessageBoxMx.ShowError("Can't find key metatable " + mtName + " for database " + dbName); return; } string extKey = arg2; string intKey = CompoundId.Normalize(extKey, mt); Progress.Show("Building Query..."); _query = QueryEngine.GetSelectAllDataQuery(mt.Name, intKey); Progress.Show("Retrieving data..."); // put up progress dialog since this may take a while QbUtil.RunPopupQuery(_query, mt.KeyMetaColumn.Name + " " + extKey); return; } // Run a query displaying results to a grid or web page and substituting a parameter value else if (Lex.Eq(funcName, "RunHtmlQuery") || Lex.Eq(funcName, "RunGridQuery")) { // command to display to grid or html if (arg1.StartsWith("MetaTreeNode=", StringComparison.OrdinalIgnoreCase)) { // query based on metatables under a tree node string nodeName = arg1.Substring("MetaTreeNode=".Length).Trim(); _cid = arg2; MetaTreeNode mtn = MetaTree.GetNode(nodeName); if (mtn == null) { MessageBoxMx.ShowError("Can't find tree node referenced in ClickFunction: " + nodeName); return; } _query = new Query(); MetaTable rootMt = null; foreach (MetaTreeNode mtn_ in mtn.Nodes) { if (!mtn_.IsDataTableType) { continue; } mt = MetaTableCollection.Get(mtn_.Target); if (mt == null) { continue; } if (rootMt == null) { rootMt = mt.Root; rootQt = new QueryTable(_query, rootMt); } if (mt == rootMt) { continue; } qt = new QueryTable(_query, mt); } if (_query.Tables.Count == 0) { MessageBoxMx.ShowError("No valid data tables found: " + nodeName); return; } _query.KeyCriteria = "= " + _cid; _title = mtn.Label + " for " + _query.Tables[0].MetaTable.MetaColumns[0].Label + " " + CompoundId.Format(_cid); } else if (arg1.StartsWith("Query=", StringComparison.OrdinalIgnoreCase)) { // query based on saved query string qIdString = arg1.Substring("Query=".Length).Trim(); if (qIdString.StartsWith("Query_", StringComparison.OrdinalIgnoreCase)) { qIdString = qIdString.Substring("Query_".Length).Trim(); } int qId = int.Parse(qIdString); _query = QbUtil.ReadQuery(qId); _cid = arg2; _query.KeyCriteria = "= " + _cid; _title = _query.UserObject.Name + " for " + _query.Tables[0].MetaTable.MetaColumns[0].Label + " " + CompoundId.Format(_cid); } else // explicit mql string to execute { _mql = arg1; // mql to execute if (Lex.IsUndefined(_mql)) { throw new Exception("Expected MQL query not found: " + command); } mt = null; mc = null; if (Lex.IsDefined(arg2) && Lex.IsDefined(arg3)) { mtName = arg2; mcName = arg3; value = arg4; // value to plug in to mql keyValue = value; ParseMetaTableMetaColumn(arg2, out mt, arg3, out mc); } else if (cInf != null) { mt = cInf.Mt; mc = cInf.Mc; value = cInf?.DataValue?.ToString(); keyValue = qm?.DataTableManager?.GetRowKey(cInf.DataRowIndex); } if (mt == null || mc == null) { throw new Exception("Invalid MetaTable or MetaColumn name(s): " + command); } if (!mc.IsNumeric) { value = Lex.AddSingleQuotes(value); // quote if not numeric } int i1 = _mql.ToLower().IndexOf("[value]"); // see if a value parameter if (i1 >= 0) { string value2 = value; _mql = _mql.Replace(_mql.Substring(i1, 7), value); _title = mc.Label + " " + value; } i1 = _mql.ToLower().IndexOf("[keyvalue]"); // see if a key value parameter if (i1 >= 0) { _mql = _mql.Replace(_mql.Substring(i1, 10), keyValue); _title = mt.KeyMetaColumn.Label + " " + keyValue; } try { _query = MqlUtil.ConvertMqlToQuery(_mql); } catch (Exception ex) { MessageBoxMx.ShowError("Error converting Mql to query: " + ex.Message); return; } } if (Lex.Eq(funcName, "RunHtmlQuery")) { QbUtil.RunPopupQuery(_query, _title, OutputDest.Html); } else // output to grid { QbUtil.RunPopupQuery(_query, _title, OutputDest.WinForms); } //else // create new grid query & run (will lose results for current query) //{ // QbUtil.NewQuery(_title); // show in query builder // QbUtil.SetCurrentQueryInstance(_query); // QbUtil.RenderQuery(); // string nextCommand = QueryExec.RunQuery(_query, OutputDest.Grid); //} return; } // Open a URL, normally substituting parameter value else if (Lex.Eq(funcName, "OpenUrl")) { string url = arg1; // url to execute value = arg2; // value to plug in to url int i1 = Lex.IndexOf(url, "[value]"); // fill in one of the value place holders if (i1 >= 0) { string value2 = value; url = url.Replace(url.Substring(i1, 7), value); } else // check to see if we are matching on key { i1 = Lex.IndexOf(url, "[keyvalue]"); if (i1 >= 0) { url = url.Replace(url.Substring(i1, 10), value); } } SystemUtil.StartProcess(url); return; } else if (Lex.Eq(funcName, "OpenUrlFromSmallWorldCid")) { SmallWorldDepictions.OpenUrlFromSmallWorldCid(arg1); return; } else if (Lex.Eq(funcName, "ShowProjectDescription")) { string projName = arg1; QbUtil.ShowProjectDescription(projName); return; } else if (Lex.Eq(funcName, "ShowTableDescription")) { mtName = arg1; QbUtil.ShowTableDescription(mtName); return; } else if (Lex.Eq(funcName, "DisplayDrilldownDetail")) { // drill down into a result value mtName = arg1; // table mcName = arg2; // column int level = Int32.Parse(arg3); string resultId = arg4; // quoted resultId to get q2 = QueryEngine.GetSummarizationDetailQuery(mtName, mcName, level, resultId); if (q2 == null) { throw new Exception("Unable to build drill-down query for: " + mtName + "." + mcName); } bool success = QbUtil.RunPopupQuery(q2, "Result Detail", OutputDest.WinForms); return; } //else if (Lex.Eq(funcName, "PopupSmilesStructure")) // display structure for a Smiles string (still needs some work...) //{ // string molString = arg1.ToString(); // ChemicalStructure cs = new ChemicalStructure(StructureFormat.Smiles, molString); // ToolHelper.DisplayStructureInPopupGrid("Title...", "Smiles", "Structure", cs); //} //else if (Lex.Eq(funcName, "PopupChimeStructure")) // display structure for a Chime string //{ // string molString = arg1.ToString(); // ChemicalStructure cs = new ChemicalStructure(StructureFormat.Smiles, molString); // ToolHelper.DisplayStructureInPopupGrid("Title...", "Smiles", "Structure", cs); //} else if (Lex.Eq(funcName, "DisplayWebPage")) { // substitute a field value into a url & display associated web page string url = arg1; ParseMetaTableMetaColumn(arg2, out mt, arg3, out mc); value = arg4; // value to plug in to mql // value = "{6E9C28EF-407E-44A0-9007-5FFB735A5C6C}"; // debug // value = "{0AC17903-E551-445E-BFAA-860023D2884F}"; // debug // value = "{63EE71F9-15BA-42FB-AFDC-C399103707B1}"; // debug // value = "{80591183-B7BA-4669-8C5F-7E7F53D981CE}"; //lex.OpenString(mc.ClickFunction); // reparse url to get proper case //funcName = lex.GetNonDelimiter(); //url = Lex.RemoveAllQuotes(lex.GetNonDelimiter()); _title = mc.Label + " " + value; int i1 = url.ToLower().IndexOf("[value]"); // fill in one of the value place holders if (i1 >= 0) { url = url.Replace(url.Substring(i1, 7), value); } else // check to see if we are matching on key { i1 = url.ToLower().IndexOf("[keyvalue]"); if (i1 >= 0) { url = url.Replace(url.Substring(i1, 10), value); _title = mt.KeyMetaColumn.Label + " " + value; } } UIMisc.ShowHtmlPopupFormDocument(url, _title); return; } else if (Lex.Eq(funcName, "DisplayOracleBlobDocument")) // display a document contained in an Oracle blob column { // Syntax: DisplayOracleBlobDocument(<table-to-lookup>, <value_match_column>, <file-name-or-type-col>, <content-column>) string table = arg1; string matchCol = arg2; string typeCol = arg3; string contentCol = arg4; string matchVal = arg5; // value to match try { string typeName; byte[] ba; UalUtil.SelectOracleBlob(table, matchCol, typeCol, contentCol, matchVal, out typeName, out ba); if (ba == null || ba.Length == 0) { return; } UIMisc.SaveAndOpenBinaryDocument(typeName, ba); } catch (Exception ex) { MessageBoxMx.ShowError("Error retrieving document: " + ex.Message); return; } return; } else if (Lex.Eq(funcName, "DisplayOracleClobDocument")) // display a document contained in an Oracle clob column { // Syntax: DisplayOracleBlobDocument(<table-to-lookup>, <value_match_column>, <file-name-or-type-col>, <content-column>) string table = arg1; string matchCol = arg2; string typeCol = arg3; string contentCol = arg4; string matchVal = arg5; // value to match try { string typeName, clobString; UalUtil.SelectOracleClob(table, matchCol, typeCol, contentCol, matchVal, out typeName, out clobString); if (Lex.IsUndefined(clobString)) { return; } UIMisc.SaveAndOpenBase64BinaryStringDocument(typeName, clobString); // assume clob string is a Base64Binary string } catch (Exception ex) { MessageBoxMx.ShowError("Error retrieving document: " + ex.Message); return; } return; } else if (Plugins.IsMethodExtensionPoint(funcName)) { List <object> objArgs = new List <object>(); for (ai = 1; ai < args.Count; ai++) // build list of object arguments { objArgs.Add(args[ai]); } Plugins.CallStringExtensionPointMethod(funcName, objArgs); } else if (Lex.Eq(funcName, "None")) // dummy click function { return; } else { MessageBoxMx.ShowError("Unrecogized click function: " + funcName); return; } } catch (Exception ex) { Exception ex2 = ex; if (ex.InnerException != null) { ex2 = ex.InnerException; } string msg = "Error executing ClickFunction: " + command + "\r\n" + DebugLog.FormatExceptionMessage(ex); MessageBoxMx.ShowError(msg); ServicesLog.Message(msg); } }
/// <summary> /// Fill the grid of col defs /// </summary> /// <param name="mt"></param> /// <returns></returns> void FillItemDataTable() { MetaTreeNode mtn; string txt = "", tok, name, label; ItemGridDataTable.Rows.Clear(); List <string> vList = new List <string>(); ParsedSingleCriteria psc = MqlUtil.ParseSingleCriteria(Qc.Criteria); if (psc != null) { if (psc.ValueList != null) { vList = psc.ValueList; } else if (!Lex.IsNullOrEmpty(psc.Value)) { vList.Add(psc.Value); } } MetaTable mt = Qc.MetaColumn.MetaTable; MetaColumn mc = Qc.MetaColumn; string mcDict = mc.Dictionary; bool searchId = Lex.EndsWith(mcDict, ".Id"); bool searchLabel = Lex.EndsWith(mcDict, ".Label"); for (int si = 0; si < vList.Count; si++) { string s = vList[si]; if (Lex.IsUndefined(s)) { continue; } name = label = ""; if (searchId) // assume numeric ASSAY code for metatable for now { name = "ASSAY_" + s; mtn = MetaTree.GetNode(name); // try to look up by internal name } else { label = s; mtn = MetaTree.GetNodeByLabel(label); } if (mtn != null) { name = mtn.Target; label = mtn.Label; } DataRow dr = ItemGridDataTable.NewRow(); dr["LabelColumn"] = label; dr["InternalNameColumn"] = name; ItemGridDataTable.Rows.Add(dr); } return; }
/// <summary> /// Transform basic query to select all data for a compound number /// </summary> /// <param name="keyMt">Key metatable. If null then try to determine from key value</param> /// <param name="cn"></param> /// <returns></returns> public static Query TransformSelectAllDataQuery( Query originalQuery, QueryTable qt0, Query newQuery) { Query q2 = null; MetaTable mt; MetaColumn mc; QueryTable qt; QueryColumn qc; MetaTreeNode mtn, tn; qc = qt0.GetQueryColumnByNameWithException("root_table"); ParsedSingleCriteria psc = MqlUtil.ParseQueryColumnCriteria(qc); if (psc == null || Lex.IsUndefined(psc.Value)) { throw new UserQueryException("Root table not defined"); } string keyMtName = psc.Value; psc = MqlUtil.ParseSingleCriteria("cid " + originalQuery.KeyCriteria); if (psc == null || Lex.IsUndefined(psc.Value)) { throw new UserQueryException("Compound Id not defined"); } string cn = psc.Value; MetaTable keyMt = null; if (Lex.IsDefined(keyMtName)) { keyMt = MetaTableCollection.Get(keyMtName); } if (keyMt != null && keyMt.Root.IsUserDatabaseStructureTable) // if root metatable is user database then normalize based on key { keyMt = keyMt.Root; // be sure we have root cn = CompoundId.Normalize(cn, keyMt); } else { cn = CompoundId.Normalize(cn); keyMt = CompoundId.GetRootMetaTableFromCid(cn, keyMt); keyMt = keyMt.Root; // be sure we have root (may not be structure table) } if (keyMt == null) { throw new Exception("Failed to identify key MetaTable"); } string allTableName = keyMt.Name + "_AllData"; // see if specific all-data tree node mtn = MetaTree.GetNode(allTableName); if (mtn == null) // no special "_AllData" node, lookup in menu { foreach (MetaTreeNode parent in MetaTree.Nodes.Values) { foreach (MetaTreeNode child in parent.Nodes) { if (Lex.Eq(child.Target, keyMt.Name)) { mtn = parent; break; } } } IUserObjectTree iuot = InterfaceRefs.IUserObjectTree; if (mtn == null && keyMt.IsUserDatabaseStructureTable && iuot != null) // see if user structure table & db { int userObjId = UserObject.ParseObjectIdFromInternalName(keyMt.Name); string nodeItemId = "ANNOTATION_" + userObjId; MetaTreeNode childMtn = iuot.GetUserObjectNodeBytarget(nodeItemId); if (childMtn != null && childMtn.Parent.Type == MetaTreeNodeType.Database) { mtn = childMtn.Parent; } } } if (mtn == null) { return(null); } Query q = newQuery; for (int i1 = 0; i1 < mtn.Nodes.Count; i1++) { tn = (MetaTreeNode)mtn.Nodes[i1]; if (!tn.IsDataTableType) { continue; } mt = MetaTableCollection.Get(tn.Target); if (mt == null) { continue; } if (mt.Root.Name != keyMt.Name) { continue; // must have same root } if (mt.MultiPivot && !mt.UseSummarizedData && mt.SummarizedExists) { MetaTable mt2 = MetaTableCollection.Get(mt.Name + MetaTable.SummarySuffix); if (mt2 != null) { mt = mt2; } } //if (mt.RemapForRetrieval && mt.SummarizedExists) mt.UseSummarizedData = true; // get summarized multipivot data (not good, permanently changes the metatable) qt = new QueryTable(mt); // if (Lex.Eq(mt.Name, "all_star_pivoted") || Lex.Eq(mt.Name, "all_annotation_pivoted")) mt = mt // debug; if (qt.SelectedCount > 0) // be sure something is selected { q.AddQueryTable(qt); } } // See if a model query exists & use it or append to what we have already string fileName = ServicesDirs.ModelQueriesDir + @"\" + allTableName + ".qry"; if (!ServerFile.GetLastWriteTime(fileName).Equals(DateTime.MinValue)) // model query file exist? { try { string query2String = FileUtil.ReadFile(fileName); q2 = Query.Deserialize(query2String); q.MergeSubqueries(q2); // just use subquery } catch (Exception ex) { ex = ex; } } q.SetupQueryPagesAndViews(ResultsViewType.HtmlTable); // be sure we have a default page & HTML view // Set key criteria q.KeyCriteria = " = " + cn; // Review tables (debug) //int tCnt = q.Tables.Count; //string tls = q.TableListString; //q.Tables.RemoveRange(23, 1); //q.Tables.RemoveRange(27, q.Tables.Count - 27); //q.Tables.RemoveRange(1, 25); // Get list of any inaccessible tables & remove from query q.InaccessableData = CheckDataSourceAccessibility(q); if (q.InaccessableData != null) { foreach (string schema in q.InaccessableData.Keys) { foreach (string tName in q.InaccessableData[schema]) { qt = q.GetQueryTableByName(tName); if (qt != null && !qt.MetaTable.IsRootTable && q.Tables.Contains(qt)) { q.RemoveQueryTable(qt); } } } //ShowUnavailableDataMessage(q); q.InaccessableData = null; } UsageDao.LogEvent("QueryAllData", ""); //string mql = MqlUtil.ConvertQueryToMql(q); // debug return(q); }