/// <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); }
/// <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; }