/// <summary> /// Update the secondary criteria to match the slider /// </summary> void UpdateSecondaryCriteria() { QueryColumn qc = ColInfo.Qc; if (ItemFilter.Value == 0) { ValueLabel.Text = "(All)"; qc.SecondaryCriteria = qc.SecondaryCriteriaDisplay = ""; } else if (ItemFilter.Value == Stats.DistinctValueList.Count + 1) { ValueLabel.Text = "(Blanks)"; qc.SecondaryCriteria = qc.MetaColumn.Name + " is null"; qc.SecondaryCriteriaDisplay = qc.ActiveLabel + " is null"; } else { MobiusDataType mdt = Stats.DistinctValueList[ItemFilter.Value - 1]; ValueLabel.Text = mdt.FormattedText; string normalizedString = mdt.FormatForCriteria(); qc.SecondaryCriteria = qc.MetaColumn.Name + " = " + Lex.AddSingleQuotes(normalizedString); qc.SecondaryCriteriaDisplay = qc.ActiveLabel + " = " + Lex.AddSingleQuotes(ValueLabel.Text); } qc.SecondaryFilterType = FilterType.ItemSlider; FilterBasicCriteriaControl.SyncBaseQuerySecondaryCriteria(qc); // sync any base query }
/// <summary> /// Initialize marker shape rules for newly selected QueryColumn /// </summary> internal void InitializeShapeRules() { CondFormatRule r; ShapeBy.Rules = new CondFormatRules(); if (ShapeBy.QueryColumn == null) { return; } QueryColumn qc = ShapeBy.QueryColumn; ColumnStatistics stats = View.GetStats(qc); for (int i1 = 0; i1 < stats.DistinctValueList.Count; i1++) { MobiusDataType mdt = stats.DistinctValueList[i1]; r = new CondFormatRule(); r.Value = View.GetFormattedText(qc, mdt); AddRule(r); if (i1 + 1 >= 25) { break; // limit number of items } } if (stats.NullsExist) { r = new CondFormatRule(); r.Value = "(Blank)"; AddRule(r); } return; }
/// <summary> /// Select a MoleculeMx object for a compound id /// </summary> /// <param name="cid"></param> /// <param name="mt"></param> /// <returns></returns> public static MoleculeMx SelectMoleculeForCid( string cid, MetaTable mt = null) { MoleculeMx mol = null; Stopwatch sw = Stopwatch.StartNew(); mol = MoleculeCache.Get(cid); // see if molecule in cache if (mol != null) { return(mol); } if (ServiceFacade.UseRemoteServices) { string mtName = mt?.Name; Mobius.Services.Native.INativeSession nativeClient = ServiceFacade.CreateNativeSessionProxy(); Services.Native.NativeMethodTransportObject resultObject = ServiceFacade.InvokeNativeMethod(nativeClient, (int)Services.Native.ServiceCodes.MobiusCompoundUtilService, (int)Services.Native.ServiceOpCodes.MobiusCompoundUtilService.SelectMoleculeFromCid, new Services.Native.NativeMethodTransportObject(new object[] { cid, mtName })); // , setStereoChemistryComments ((System.ServiceModel.IClientChannel)nativeClient).Close(); if (resultObject == null) { return(null); } byte[] ba = resultObject.Value as byte[]; if (ba != null && ba.Length > 0) { MobiusDataType mdt = MobiusDataType.DeserializeBinarySingle(ba); mol = mdt as MoleculeMx; } } else { mol = QEL.MoleculeUtil.SelectMoleculeForCid(cid, mt); } if (MoleculeMx.IsDefined(mol)) { bool isUcdb = (mt != null && mt.Root.IsUserDatabaseStructureTable); // user compound database if (!isUcdb) { MoleculeCache.AddMolecule(cid, mol); // add to cache } } long ms = sw.ElapsedMilliseconds; return(mol); }
public void Setup(ColumnInfo colInfo) { MobiusDataType mdtLow, mdtHigh; InSetup = true; ColInfo = colInfo; // save ref to colInfo Stats = colInfo.Rfld.GetStats(); ItemFilter.Properties.Minimum = 0; ItemFilter.Properties.Maximum = Stats.DistinctValueList.Count + 2 - 1; // (All) on left, (Blanks) on right ParsedSingleCriteria psc = MqlUtil.ParseSingleCriteria(ColInfo.Qc.SecondaryCriteria); // parse criteria ItemFilter.Value = 0; ValueLabel.Text = "(All)"; if (psc != null && psc.OpEnum == CompareOp.Eq && Stats.DistinctValueList.Count > 0) { MetaColumnType type = ColInfo.Mc.DataType; MobiusDataType lowVal = MobiusDataType.New(type, psc.Value); MobiusDataType highVal = MobiusDataType.New(type, psc.Value); if (MetaColumn.IsDecimalMetaColumnType(type)) { // adjust decimal comparison values by an epsilon double e = MobiusDataType.GetEpsilon(Stats.MaxValue.FormattedText); lowVal.NumericValue -= e; highVal.NumericValue += e; } for (int i1 = 0; i1 < Stats.DistinctValueList.Count; i1++) { MobiusDataType mdt = Stats.DistinctValueList[i1]; string fTxt = mdt.FormattedText; if (Lex.Eq(psc.Value, fTxt) || (mdt.CompareTo(lowVal) >= 0 && mdt.CompareTo(highVal) <= 0)) { ItemFilter.Value = i1 + 1; ValueLabel.Text = Stats.DistinctValueList[i1].FormattedText; break; } } } else if (psc != null && psc.OpEnum == CompareOp.IsNull) // (Blanks) { ItemFilter.Value = Stats.DistinctValueList.Count + 1; ValueLabel.Text = "(Blanks)"; } ItemFilter.Focus(); InSetup = false; return; }
/// <summary> /// Get unbound data /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PivotGridControl_CustomUnboundFieldData(object sender, DevExpress.XtraPivotGrid.CustomFieldDataEventArgs e) { MobiusDataType mdt = null; NumberMx nex; StringMx sex; DateTimeMx dex; QualifiedNumber qn; double dVal; string cid; int iVal, rti, dri, dri2; //int t0 = TimeOfDay.Milliseconds(); if (PivotGrid.DataSource == null) { return; } PivotGridFieldContext fc = GetPivotGridFieldContext(e.Field); dri = e.ListSourceRowIndex; object vo = Dtm.GetColumnValueWithRowDuplication(fc.ResultsField, dri); if (vo != null) { Type voType = vo.GetType(); if (MobiusDataType.IsMobiusDataType(vo)) { if (vo is QualifiedNumber) { qn = vo as QualifiedNumber; if (!Lex.IsDefined(qn.Qualifier)) // if no qualifier then just use double NumberValue { vo = qn.NumberValue; } } else // otherwise convert to a primitive { vo = MobiusDataType.ConvertToPrimitiveValue(vo); } } if (vo is DateTime) { vo = ((DateTime)vo).ToBinary(); // handle DateTimes as int64 (longs) to avoid performance hit in Dx code } } e.Value = vo; return; }
/// <summary> /// Update the labels to reflect the current selected range of the control /// </summary> /// <param name="lowCriteriaDisplayText"></param> /// <param name="lowCriteriaText"></param> /// <param name="highCriteriaDisplayText"></param> /// <param name="highCriteriaText"></param> void UpdateLabels( out string lowCriteriaDisplayText, out string lowCriteriaText, out string highCriteriaDisplayText, out string highCriteriaText) { QualifiedNumber qn; lowCriteriaDisplayText = lowCriteriaText = highCriteriaDisplayText = highCriteriaText = ""; if (ColInfo == null || Stats == null) { return; } QueryColumn qc = ColInfo.Qc; if (Stats.DistinctValueList.Count > 0) { MobiusDataType mdtLow = Stats.DistinctValueList[RangeFilter.Value.Minimum]; MobiusDataType mdtHigh = Stats.DistinctValueList[RangeFilter.Value.Maximum]; lowCriteriaDisplayText = LowValueLabel.Text = mdtLow.FormattedText; lowCriteriaText = mdtLow.FormatForCriteria(); highCriteriaDisplayText = HighValueLabel.Text = mdtHigh.FormattedText; highCriteriaText = mdtHigh.FormatForCriteria(); if (qc.MetaColumn.DataType == MetaColumnType.QualifiedNo) { qn = (QualifiedNumber)mdtLow; lowCriteriaDisplayText = QualifiedNumber.FormatNumber(qn.NumberValue, qc.ActiveDisplayFormat, qc.ActiveDecimals); // get basic QN textstats qn = (QualifiedNumber)mdtHigh; highCriteriaDisplayText = QualifiedNumber.FormatNumber(qn.NumberValue, qc.ActiveDisplayFormat, qc.ActiveDecimals); } } else { lowCriteriaDisplayText = highCriteriaDisplayText = ""; // no values } LowValueLabel.Text = lowCriteriaDisplayText; HighValueLabel.Text = highCriteriaDisplayText; // Update label position and size int width = RangeFilter.Width - 10; // decrease for overhangs Size labelSize = new Size(width / 2, LowValueLabel.Height); LowValueLabel.Size = labelSize; HighValueLabel.Left = RangeFilter.Left + RangeFilter.Width / 2; HighValueLabel.Size = labelSize; return; }
/// <summary> /// Format a criteria value for display /// </summary> /// <param name="comOp"></param> /// <param name="value"></param> /// <returns></returns> string FormatCriteriaForDisplay(CompareOp comOp, string value) { if (CompOp == CompareOp.Like) { return(value); } if (String.IsNullOrEmpty(value)) { return(""); } MobiusDataType mdt = MobiusDataType.New(ColInfo.Mc.DataType, value); string formattedValue = mdt.FormatCriteriaForDisplay(); return(formattedValue); }
/// <summary> /// Format the hyperlink for a MobiusDataType object /// </summary> /// <param name="qc"></param> /// <param name="mdt"></param> /// <returns></returns> public string FormatHyperlink( CellInfo ci) { MobiusDataType mdt = ci.DataValue as MobiusDataType; int dri = ci.DataRowIndex; DataTableMx dt = Qm.DataTable; DataRowMx dr = null; if (dri >= 0 && dri < dt.Rows.Count) { dr = dt.Rows[dri]; } FormattedFieldInfo ffi = FormatField(ci.Rt, ci.TableIndex, ci.Rfld, ci.FieldIndex, dr, dri, mdt, -1, false); string hyperlink = ffi.Hyperlink; return(hyperlink); }
/// <summary> /// Get formatted text value for field /// </summary> /// <param name="qc"></param> /// <param name="mdt"></param> /// <returns></returns> internal string GetFormattedText(QueryColumn qc, MobiusDataType mdt) { if (qc == null || mdt == null) { return(""); } else if (mdt.FormattedText != null) { return(mdt.FormattedText); } ResultsFormatter fmtr = Qm.ResultsFormatter; FormattedFieldInfo ffi = fmtr.FormatField(qc, mdt); if (ffi.FormattedText == null) { ffi.FormattedText = ""; } mdt.FormattedText = ffi.FormattedText; // store back in the field return(mdt.FormattedText); }
/// <summary> /// Store selected formatting information for possible use later needed later /// </summary> /// <param name="ffi"></param> /// <param name="fieldValue"></param> /// <param name="dr"></param> /// <param name="ci"></param> /// <param name="mdt"></param> void StoreFormattingInformationInMdt(FormattedFieldInfo ffi, object fieldValue, DataRowMx dr, CellInfo ci, MobiusDataType mdt) { bool hyperLinked = !String.IsNullOrEmpty(ffi.Hyperlink); if (ffi.ForeColor != Color.Black || ffi.BackColor != Color.Empty || hyperLinked) { // store any formatting info in a MDT so that it's available for the later display RowCellStyle event if (mdt == null && !NullValue.IsNull(fieldValue)) // need to create MDT? { //if (ci.Mc.DataType == MetaColumnType.Structure) ci = ci; // debug mdt = MobiusDataType.New(ci.Mc.DataType, fieldValue); dr.ItemArrayRef[ci.DataColIndex] = mdt; // store new value without firing event } if (mdt.BackColor != ffi.BackColor) { mdt.BackColor = ffi.BackColor; // set in DataTable only if changed to avoid repaints } if (mdt.ForeColor != ffi.ForeColor) { mdt.ForeColor = ffi.ForeColor; } if (mdt.Hyperlink != ffi.Hyperlink) { mdt.Hyperlink = ffi.Hyperlink; } if (mdt.Hyperlinked != hyperLinked) { mdt.Hyperlinked = hyperLinked; } if (ffi.FormattedBitmap != null) { mdt.FormattedBitmap = ffi.FormattedBitmap; } if (ffi.FormattedText != null) { mdt.FormattedText = ffi.FormattedText; } } }
public DataTableMx _table; // associated DataTableMx /// <summary> /// Get/set a single element in the ItemArray object array /// </summary> /// <param name="columnIndex"></param> /// <returns></returns> public object this[int columnIndex] { get { if (_itemArray == null) { DebugMx.InvalidConditionException("_itemArray == null"); } if (columnIndex < 0 || columnIndex >= _itemArray.Length) { DebugMx.InvalidConditionException("columnIndex = " + columnIndex + " out of range for DataRow of size = " + _itemArray.Length); } object o = _itemArray[columnIndex]; if (o == null || o is DBNull) { return(o); } else if (Table == null || Table.UseNativeDataTypes) { return(o); } else { return(MobiusDataType.ConvertToPrimitiveValue(o)); } } set { _itemArray[columnIndex] = value; RowState = DataRowState.Modified; // say the row is now modified _table.CallDataChangedEventHandlers(ListChangedType.ItemChanged, this); } }
internal DataTableMx _nativeDataTableMx; // native verion of table /// <summary> /// CreateCompatiblePrimitiveDataTable /// </summary> void CreateCompatiblePrimitiveDataTableMx() { DataTableMx pt = new DataTableMx(); // create primitive table pt.UsePrimitiveDataTypes = true; this._primitiveDataTableMx = pt; // link this native table to the primitive table pt._nativeDataTableMx = this; // link primitive table to native foreach (DataColumn c0 in Columns) // create set of columns with "primitive" types { DataColumn dc = new DataColumn(); dc.ColumnName = c0.ColumnName; dc.Caption = c0.Caption; foreach (string key in dc.ExtendedProperties.Keys) { c0.ExtendedProperties.Add(key, dc.ExtendedProperties[key]); } dc.DataType = c0.DataType; if (c0.ExtendedProperties.ContainsKey("MobiusDataType")) { // if MobiusDataType specified then map to primitive type Type type = c0.ExtendedProperties["MobiusDataType"] as Type; if (type != null) { dc.DataType = MobiusDataType.ConvertToPrimitiveType(type); } } pt.Columns.Add(dc); } pt._rows = _rows; // share the same set of rows return; }
/// <summary> /// Format a hyperlink for a metacolumn where details are available /// </summary> /// <param name="qc"></param> /// <param name="mdt"></param> /// <returns></returns> public static string FormatDetailsAvailableHyperlink( QueryColumn qc, MobiusDataType mdt) { string hyperlink, uri = ""; int drilldownLevel = 1; if (qc == null || qc.MetaColumn == null || qc.MetaColumn.MetaTable == null) { return(""); } MetaColumn mc = qc.MetaColumn; MetaTable mt = mc.MetaTable; MetaColumnType mcType = mc.DataType; MetaBrokerType mbt = qc.MetaColumn.MetaTable.MetaBrokerType; // Annotation table broker if (mbt == MetaBrokerType.Annotation) { return(mdt.Hyperlink); // just return already formatted hyperlink value } // Target-Assay broker else if (mbt == MetaBrokerType.TargetAssay) { if (Lex.Eq(qc.MetaColumn.Name, "assy_nm")) { if (mdt.DbLink != "") { string[] sa = mdt.DbLink.Split(','); string mtName = sa[0].Trim() + "_" + sa[1].Trim(); uri = "http://Mobius/command?" + "ClickFunction ShowTableDescription " + mtName; } } else if (qc.MetaColumn.DetailsAvailable) { if (Lex.Eq(qc.MetaColumn.MetaTable.Name, MultiDbAssayDataNames.CombinedNonSumTableName)) { drilldownLevel = 2; // level 2 goes from unsummarized unpivoted to warehouse details } else { drilldownLevel = 1; // level 1 goes from summarized to unsummarized (UNPIVOTED_ASSAY_RESULTS) } uri = "http://Mobius/command?" + "ClickFunction DisplayDrilldownDetail " + qc.MetaColumn.MetaTable.Name + " " + qc.MetaColumn.Name + " " + drilldownLevel + " " + Lex.AddSingleQuotes(mdt.DbLink); } } // Pivot broker else if (mbt == MetaBrokerType.Pivot) { string[] sa = mdt.DbLink.Split(','); if (sa.Length < 2 || sa[1] == "") { return(""); } uri = sa[1]; if (uri.ToLower().StartsWith("www.")) { uri = "http://" + uri; // fix shortcut for proper linking } } // All other broker types else { int nValue = -1; if (mdt is QualifiedNumber) { nValue = ((QualifiedNumber)mdt).NValue; } if ((qc.QueryTable.MetaTable.UseSummarizedData && nValue >= 0) || // link if there is a non-null n-value associated with number qc.MetaColumn.DetailsAvailable) // or we explicitly know that details are available { uri = "http://Mobius/command?" + "ClickFunction DisplayDrilldownDetail " + qc.QueryTable.MetaTable.Name + " " + qc.MetaColumn.Name + (qc.QueryTable.MetaTable.UseSummarizedData ? " 1 " : " 2 ") + Lex.AddSingleQuotes(mdt.DbLink); } } return(uri); }
/// <summary> /// Initialize coloring rules for newly selected QueryColumn /// </summary> #if false internal CondFormatRules InitializeRulesBasedOnDataValues() { CondFormatRule r; Color[] colors = GetColors(); CondFormatRules rules = new CondFormatRules(); if (ResultsField == null) { return(rules); } QueryColumn qc = ResultsField.QueryColumn; ColumnStatistics stats = ResultsField.GetStats(); if (qc.MetaColumn.DataType == MetaColumnType.Structure) { // setup substructure search rules if structures for (int i1 = 0; i1 < stats.DistinctValueList.Count; i1++) { MobiusDataType mdt = stats.DistinctValueList[i1]; r = new CondFormatRule(); r.Op = "SSS"; r.OpCode = CondFormatOpCode.SSS; ChemicalStructureMx cs = mdt as ChemicalStructureMx; if (cs != null) { r.Value = cs.ChimeString; } r.BackColor1 = colors[i1 % colors.Length]; rules.Add(r); } } else // setup equality rules for other types { for (int i1 = 0; i1 < stats.DistinctValueList.Count; i1++) { MobiusDataType mdt = stats.DistinctValueList[i1]; r = new CondFormatRule(); r.Op = "Equal to"; r.OpCode = CondFormatOpCode.Eq; r.Value = mdt.FormattedText; r.BackColor1 = colors[i1 % colors.Length]; rules.Add(r); // if (i1 + 1 >= 25) break; // limit number of items } } if (stats.NullsExist) { r = new CondFormatRule(); r.Name = "Missing Data"; r.Op = "Missing"; r.OpCode = CondFormatOpCode.NotExists; r.BackColor1 = CondFormatMatcher.DefaultMissingValueColor; rules.Add(r); } SetRules(ResultsField, rules); // put into the grid return(rules); }
public void Setup(ColumnInfo colInfo) { InSetup = true; ColInfo = colInfo; // save ref to colInfo QueryColumn qc = colInfo.Qc; Stats = colInfo.Rfld.GetStats(); RangeFilter.Properties.Minimum = 0; RangeFilter.Properties.Maximum = Stats.DistinctValueList.Count - 1; ParsedSingleCriteria psc = MqlUtil.ParseSingleCriteria(ColInfo.Qc.SecondaryCriteria); // parse criteria TrackBarRange tbr = new TrackBarRange(0, Stats.DistinctValueList.Count - 1); RangeFilter.Value = tbr; if (psc != null && psc.OpEnum == CompareOp.Between && Stats.DistinctValueList.Count > 0) // setup prev value { MetaColumnType type = ColInfo.Mc.DataType; MobiusDataType lowVal = MobiusDataType.New(type, psc.Value); MobiusDataType highVal = MobiusDataType.New(type, psc.Value2); if (MetaColumn.IsDecimalMetaColumnType(type)) { // adjust decimal comparison values by an epsilon double e = MobiusDataType.GetEpsilon(Stats.MaxValue.FormattedText); lowVal.NumericValue += e; highVal.NumericValue -= e; } int lowPos = -1; for (int i1 = 0; i1 < Stats.DistinctValueList.Count; i1++) { MobiusDataType mdt = Stats.DistinctValueList[i1]; string fTxt = mdt.FormattedText; if (mdt.CompareTo(lowVal) <= 0 || Lex.Eq(fTxt, psc.Value)) { lowPos = i1; } else { break; } } int highPos = -1; for (int i1 = Stats.DistinctValueList.Count - 1; i1 >= 0; i1--) { MobiusDataType mdt = Stats.DistinctValueList[i1]; string fTxt = mdt.FormattedText; if (mdt.CompareTo(highVal) >= 0 || Lex.Eq(fTxt, psc.Value2)) { highPos = i1; } else { break; } } if (lowPos >= 0 && highPos >= 0) { tbr = new TrackBarRange(lowPos, highPos); RangeFilter.Value = tbr; } } UpdateLabels(); RangeFilter.Focus(); InSetup = false; return; }
/// <summary> /// Delegate instance for formatting hyperlink /// </summary> /// <param name="qc"></param> /// <param name="mdt"></param> /// <returns></returns> public string FormatHyperlink( QueryColumn qc, MobiusDataType mdt) { return(FormatDetailsAvailableHyperlink(qc, mdt)); }
/// <summary> /// When check state changes update the display to reflect /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ItemList_ItemCheck(object sender, DevExpress.XtraEditors.Controls.ItemCheckEventArgs e) { if (InSetup) { return; } InSetup = true; ItemList.BeginUpdate(); CheckedListBoxItemCollection items = ItemList.Items; string txt = items[e.Index].Description; bool isChecked = (e.State == CheckState.Checked); if (txt == "(All)") // check/uncheck everything { foreach (CheckedListBoxItem i in items) { i.CheckState = e.State; } } else if (txt == "(Non blanks)") { foreach (CheckedListBoxItem i in items) { if (i.Description == "(All)" || i.Description == "(Blanks)") { continue; } i.CheckState = e.State; } } else if (e.State == CheckState.Unchecked) // turned item off; turn off All & Non blanks as well { items[AllPos].CheckState = CheckState.Unchecked; if (NonBlanksPos >= 0 && txt != "(Blanks)") { items[NonBlanksPos].CheckState = CheckState.Unchecked; } } if (BlanksPos >= 0) // if blanks allowed set (All) based on Blanks/Non blanks settings { if (items[BlanksPos].CheckState == CheckState.Checked && items[NonBlanksPos].CheckState == CheckState.Checked) { items[AllPos].CheckState = CheckState.Checked; } else { items[AllPos].CheckState = CheckState.Unchecked; } } ItemList.EndUpdate(); InSetup = false; // Generate new criteria from set of checks QueryColumn qc = ColInfo.Qc; if (items[AllPos].CheckState == CheckState.Checked) // everything { qc.SecondaryCriteria = qc.MetaColumn.Name + " in ('(All)')"; qc.SecondaryCriteriaDisplay = qc.ActiveLabel + " in list (All)"; } //else if (NonBlanksPos >= 0 && items[NonBlanksPos].CheckState == CheckState.Checked) //{ // just non-null // qc.SecondaryCriteria = qc.MetaColumn.Name + " is not null"; // qc.SecondaryCriteriaDisplay = qc.ActiveLabel + " is not null"; //} else // build list of checked items possibly including "(Blanks)" and "(Non blanks)" { int itemsChecked = 0; qc.SecondaryCriteria = qc.MetaColumn.Name + " in ("; foreach (CheckedListBoxItem i in items) { string normalizedString; if (i.CheckState != CheckState.Checked) { continue; } if (itemsChecked > 0) { qc.SecondaryCriteria += ", "; } normalizedString = i.Description; if (i.Description == "(All)" || i.Description == "(Blanks)" || i.Description == "(Non blanks)") { } // these are always ok as is else if (qc.MetaColumn.DataType == MetaColumnType.CompoundId || qc.MetaColumn.DataType == MetaColumnType.Date) { // store these in internal format MobiusDataType mdt = MobiusDataType.New(qc.MetaColumn.DataType, i.Description); normalizedString = mdt.FormatForCriteria(); } qc.SecondaryCriteria += Lex.AddSingleQuotes(normalizedString); itemsChecked++; } qc.SecondaryCriteria += ")"; qc.SecondaryCriteriaDisplay = qc.ActiveLabel + " in list"; } qc.SecondaryFilterType = FilterType.CheckBoxList; QueryManager.QueryResultsControl.UpdateFiltering(ColInfo); FilterBasicCriteriaControl.SyncBaseQuerySecondaryCriteria(qc); // sync any base query return; }
/// <summary> /// Build click function and field value text string for output /// ClickFunction arguments may be defined in the clickfunction definition including col values /// indicated by fieldName.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, the keyValue if [keyvalue] or /// [rowcol] as a grid row and column to be returned if these appear in the /// ClickFunction definition. /// </summary> /// <param name="rf">Results field to display link for</param> /// <param name="vo">Vo contain tuple values</param> /// <param name="displayValue">Formatted display value for field</param> /// <returns></returns> public static string BuildClickFunctionText( ResultsField rf, DataRowMx dr, int dri, string displayValue) { ResultsTable rt; MetaColumn mc, mc2; MetaTable mt; string arg, arg2, argsString; int ai, rfi, voi; if (rf == null || dr == null || dri < 0) { return(""); } rt = rf.ResultsTable; mc = rf.MetaColumn; mt = mc.MetaTable; object[] vo = dr.ItemArray; if (String.IsNullOrEmpty(mc.ClickFunction)) { return(""); } List <string> args = Lex.ParseAllExcludingDelimiters(mc.ClickFunction, "( , )", false); string funcName = args[0]; // click function name int fieldRefs = 0; for (ai = 1; ai < args.Count; ai++) { // see how many mcName.Value references there are arg = args[ai]; string suffix = ".Value"; if (!Lex.EndsWith(arg, suffix)) { continue; } arg = arg.Substring(0, arg.Length - suffix.Length); if (mt.GetMetaColumnByName(arg) != null) { fieldRefs++; } } if (fieldRefs == 0) // if no field references add either the field value, key value or grid row and column { if (Lex.Eq(funcName, "RunHtmlQuery") || Lex.Eq(funcName, "RunGridQuery") || Lex.Eq(funcName, "DisplayWebPage")) // fixups for old functions { args.Add(Lex.AddSingleQuotes(mt.Name)); // add metatable name args.Add(Lex.AddSingleQuotes(mc.Name)); // add metacolumn name } if (Lex.Contains(mc.ClickFunction, "[TableColumnValue]")) // convert to metatable, metacolumns, &value refDataTable row & col { args.RemoveAt(1); // remove [TableColumnValue] arg args.Add(Lex.AddSingleQuotes(mt.Name)); args.Add(Lex.AddSingleQuotes(mc.Name)); args.Add(mc.Name + ".Value"); } else if (Lex.Contains(mc.ClickFunction, "[keyvalue]")) { args.Add(mt.KeyMetaColumn.Name + ".value"); // pass key value rather than this col value } else { args.Add(mc.Name + ".value"); // pass column value } } argsString = ""; for (ai = 1; ai < args.Count; ai++) { arg = args[ai]; string suffix = ".Value"; if (!arg.EndsWith(suffix, StringComparison.OrdinalIgnoreCase)) { continue; } arg2 = arg.Substring(0, arg.Length - suffix.Length); mc2 = mt.GetMetaColumnByName(arg2); if (mc2 == null) { continue; // assume unquoted string constant & pass as is } else if (mc2.IsKey && rt.Fields[0].MetaColumn.Name != mc2.Name) { // see if undisplayed key value voi = rt.Fields[0].VoPosition - 1; // position in vo } else // find the field name in the list of report fields { for (rfi = 0; rfi < rt.Fields.Count; rfi++) { if (Lex.Eq(mc2.Name, rt.Fields[rfi].MetaColumn.Name)) { break; } } if (rfi >= rt.Fields.Count) { throw new Exception("Column name not selected in query: " + mc2.Name); } voi = rt.Fields[rfi].VoPosition; } if (vo[voi] == null) { args[ai] = ""; } else { arg = vo[voi].ToString(); if (vo[voi] is MobiusDataType) { // use dblink if defined MobiusDataType mdt = vo[voi] as MobiusDataType; if (!String.IsNullOrEmpty(mdt.DbLink)) { arg = mdt.DbLink; } } args[ai] = arg; } } for (ai = 1; ai < args.Count; ai++) { arg = args[ai]; if (!Lex.IsDouble(arg) && !arg.StartsWith("'") && !arg.StartsWith("[")) // quote if string { arg = Lex.AddSingleQuotes(arg); } if (argsString != "") { argsString += ","; } argsString += arg; } string txt = // build full string including link & display value "<a href=\"http:////Mobius/command?ClickFunction " + funcName + "(" + argsString + ")\">" + displayValue + "</a>"; return(txt); }
/// <summary> /// Handle conversion of Mobius custom data types between the grid and the underlying DataSet /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void ProcessCustomUnboundColumnDataEvent(object sender, CustomColumnDataEventArgs e) { MobiusDataType mdt = null; FormattedFieldInfo ffi = null; bool formatted = false; NumberMx numberEx; StringMx stringEx; ImageMx imageMx; DateTimeMx dateTimeEx; DataRowMx dr = null; BandedGridView mbgv; int nonNullDri; string debugMsg; if (DebugMx.False) // fillValuesImmediately debug test { e.Value = "XXX"; return; } DateTime t0 = DateTime.Now; int callId = ++UnboundCalls; // get id for this call if (sender is BandedGridView) { mbgv = sender as BandedGridView; } if (Grid.DataSource == null) { return; } CellInfo ci = Grid.GetDataTableCellInfo(e.ListSourceRowIndex, e.Column); //if (e.ListSourceRowIndex == 2 && ci.DataRowIndex == 1) e = e; // debug //if (ci.Mc.DataType == MetaColumnType.CompoundId && ci.DataRowIndex > 0) ci = ci; // debug //DebugLog.Message("CustomUnboundColumnData " + ci.DataRowIndex + ", " + ci.DataColIndex + ", " + ci.DataValue.ToString()); if (ci.Rfld == null) { return; } QueryManager qm = Grid.QueryManager; ResultsFormatter fmtr = qm.ResultsFormatter; ResultsFormat rf = qm.ResultsFormat; if (e.ListSourceRowIndex == GridControl.NewItemRowHandle || e.ListSourceRowIndex >= Qm.DataTable.Rows.Count) // new row being created { if (NewRow == null) { NewRow = Qm.DataTable.NewRow(); } dr = NewRow; } else if (e.ListSourceRowIndex >= 0 && ci.DataRowIndex >= 0) // row exist in DataTable (i.e. not new row) { AdjustDataRowToRender(ci); if (ci.DataRowIndex >= 0) { dr = DataTable.Rows[ci.DataRowIndex]; if (ci.DataRowIndex == 0) { } } } else { if (DebugDetails) { ClientLog.Message("Fail 1"); } return; // something else, ignore } // Store edited data for unbound column in DataTable if (e.IsSetData) { SetGridData(e, ci); return; } else if (!e.IsGetData) { return; // just return if not GetData as expected } // Get data from underlying unbound dataset & return in format for grid //if (ci.Mc.DataType == MetaColumnType.Structure) ci = ci; // debug //if (ci.Mc.DataType == MetaColumnType.String) ci = ci; // debug //if (ci.DataValue is StringEx && ((StringEx)ci.DataValue).Value == " ") ci = ci; // debug UnboundGets++; if (dr == null) { e.Value = null; if (DebugDetails) { ClientLog.Message("Fail 2"); // debug } return; } if (Dtm.IsRetrievingDataMessageRow(dr) && ci.Mc != null && !ci.Mc.IsGraphical) { //if (ci.Mc.IsKey) // show retrieving data message for key field e.Value = "Retrieving data..."; return; } object fieldValue = dr[ci.DataColIndex]; if (DebugDetails && fieldValue is MoleculeMx) // debug { MoleculeMx cs = fieldValue as MoleculeMx; MoleculeFormat csType = cs.PrimaryFormat; string csValue = cs.PrimaryValue; int csLen = cs.PrimaryValue.Length; string molfile = cs.GetMolfileString(); molfile = molfile; } try { // If already formatted use existing formatting info ffi = null; if (fieldValue is MobiusDataType) { mdt = (MobiusDataType)fieldValue; if (mdt.FormattedBitmap != null) { ffi = new FormattedFieldInfo(); ffi.FormattedBitmap = mdt.FormattedBitmap; } else if (mdt.FormattedText != null) { ffi = new FormattedFieldInfo(); ffi.FormattedText = mdt.FormattedText; } if (ffi != null) // if formatted then copy other format attributes as well { ffi.BackColor = mdt.BackColor; ffi.ForeColor = mdt.ForeColor; ffi.Hyperlink = mdt.Hyperlink; } } // If not formatted then format if (ffi == null) // need to format? { // Format non-image field (including structures) if (ci.Mc.DataType != MetaColumnType.Image) // format other than image immediately { //if (ci.Mc.DataType == MetaColumnType.Structure) // debug //{ // DebugLog.Message(fieldValue.ToString()); // UIMisc.Beep(); //} ffi = fmtr.FormatField(ci.Rt, ci.TableIndex, ci.Rfld, ci.FieldIndex, dr, e.ListSourceRowIndex, fieldValue, ci.DataRowIndex, false); FormatFieldCalls++; if (ci.Mc.DataType == MetaColumnType.Structure) { FormatStructureFieldCalls++; } StoreFormattingInformationInMdt(ffi, fieldValue, dr, ci, mdt); formatted = true; } // Image: start asynch call to get image in background as necessary since it is too slow to wait for it here else { if (fieldValue is ImageMx) { imageMx = fieldValue as ImageMx; } else { imageMx = new ImageMx(); if (fieldValue != null) { if (fieldValue is MobiusDataType) { imageMx.DbLink = (fieldValue as MobiusDataType).DbLink; } else { imageMx.DbLink = fieldValue.ToString(); // store field value as dblink } } dr.ItemArrayRef[ci.DataColIndex] = imageMx; // store new image object without firing event } mdt = imageMx; // copy image object to general MobiusDataType ffi = new FormattedFieldInfo(); if (imageMx.FormattedBitmap != null) // already have bitmap? { ffi.FormattedBitmap = imageMx.FormattedBitmap; } else if (imageMx.Value != null) // have the bitmap, just need to scale it { int fieldWidth = ci.Rfld.FieldWidth; // current field width in milliinches int desiredWidth = (int)((fieldWidth / 1000.0) * GraphicsMx.LogicalPixelsX * 1.0); // width in pixels imageMx.FormattedBitmap = BitmapUtil.ScaleBitmap(imageMx.Value, desiredWidth); ffi.FormattedBitmap = imageMx.FormattedBitmap; } else if (imageMx.IsRetrievingValue) // already retrieving? { ffi.FormattedBitmap = (Bitmap)RetrievingImageMsg.Image; // put up the processing image } else if (SS.I.AsyncImageRetrieval) // start async image retrieval { FormatImageFieldCalls++; GetImageBitmapAsync(ci, dr, e.ListSourceRowIndex, fieldValue, imageMx, callId); ffi.FormattedBitmap = (Bitmap)RetrievingImageMsg.Image; // put up the processing image } else // do synchronous image retrieval { GetImageBitmap(ci, dr, e.ListSourceRowIndex, fieldValue, imageMx, callId); ffi.FormattedBitmap = imageMx.FormattedBitmap; formatted = true; } } } //if (ci.Mc.DataType == MetaColumnType.CompoundId && String.IsNullOrEmpty(fmtdFld.Hyperlink)) ci = ci; // debug //if (mdt is CompoundId) mdt = mdt; // debug if (e.Column.ColumnEdit is RepositoryItemPictureEdit) { if (ffi != null && ffi.FormattedBitmap != null) { e.Value = ffi.FormattedBitmap; } else { e.Value = new Bitmap(1, 1); // avoid no-image data message } //ffi.FormattedBitmap.Save(@"c:\download\test.bmp"); // debug } else { e.Value = ffi.FormattedText; // non-picture column } if (ci.DataRowIndex == DataTable.Rows.Count - 1 && // if at end of DataTable && more rows available, request them !Dtm.RowRetrievalComplete) { //Progress.Show("Retrieving data..."); // put up progress dialog if not already up //if (WaitForMoreDataStartTime.Equals(DateTime.MinValue)) // say we've started waiting for data //{ // WaitForMoreDataStartTime = DateTime.Now; // ClientLog.Message("Set WaitForMoreDataStartTime: " + WaitForMoreDataStartTime.ToLongTimeString()); //} if (Dtm.RowRetrievalState == RowRetrievalState.Paused) { Dtm.StartRowRetrieval(); // .ReadNextRowsFromQueryEngine(); // restart retrieval } } else if (Lex.StartsWith(Progress.GetCaption(), "Retrieving data...") || Lex.IsUndefined(Progress.GetCaption())) { // hide any "Retrieving data..." message Progress.Hide(); //SystemUtil.Beep(); } Grid.LastRowRendered = e.ListSourceRowIndex; if (DebugDetails) { debugMsg = "Grid.GetData: " + callId + ", e.Row = " + e.ListSourceRowIndex + ", e.Col = " + e.Column.AbsoluteIndex + ", Formatted = " + (formatted ? "T" : "F") + ", Time(ms) = " + TimeOfDay.Delta(t0) + ", ColLabel = " + ci.Qc.ActiveLabel; debugMsg += ", FieldValue = "; if (fieldValue != null) { debugMsg += fieldValue.ToString(); } debugMsg += ", e.Value = "; if (e.Value != null) { debugMsg += e.Value.ToString(); } else { debugMsg += "null"; } ClientLog.Message(debugMsg); } // TODO: This does a some unnecessary hides which cause flashing of the window frame // This happens when we are not at the end of the DataTable but don't know if any additional requests // for rendering will occur. May be better to move this to DataTableManger when we detect // that we have retrieved a row that is below the level of those displayed in the grid or all rows have been retrieved. // Also maybe in MoleculeGridControl.RetrievalMonitorTimer_Tick } catch (Exception ex) { if (e.Column.ColumnEdit is RepositoryItemPictureEdit) { e.Value = new Bitmap(1, 1); // avoid no-image data message } else { e.Value = ex.Message; } string msg = "ColumnView_CustomUnboundColumnData Exception"; if (ci.Rfld != null) { msg += ", MetaColumn: " + ci.Rfld.MetaColumn.MetaTable.Name + "." + ci.Rfld.MetaColumn.Name; } msg += ", DataColIndex: " + ci.DataColIndex + ", DataRowIndex: " + ci.DataRowIndex; if (fieldValue != null) { msg += ", Value: " + fieldValue.ToString(); } ClientLog.Message(msg); } // t0 = TimeOfDay.Milliseconds() - t0; // ClientLog.Message("CustomUnboundColumnData event time: " + t0); }
/// <summary> /// Build tooltip for data row /// </summary> /// <param name="dri">Data row index</param> /// <returns></returns> internal SuperToolTip BuildDataRowTooltip( TooltipDimensionDef ttDim, int dri) { ColumnMapMsx cm; QueryTable qt; QueryColumn qc; MetaTable mt; MetaColumn mc; int i1, i2; if (BaseQuery == null || BaseQuery.Tables.Count == 0 || Dtm == null) { return(null); } qt = BaseQuery.Tables[0]; SuperToolTip s = new SuperToolTip(); s.MaxWidth = 200; s.AllowHtmlText = DefaultBoolean.True; ToolTipItem i = new ToolTipItem(); i.AllowHtmlText = DefaultBoolean.True; i.Appearance.TextOptions.WordWrap = WordWrap.Wrap; ColumnMapCollection cml2 = new ColumnMapCollection(); // list of fields we'll actually display int strPos = -1; ColumnMapCollection cml = ttDim.Fields; if (cml.Count == 0) { return(s); } for (i1 = 0; i1 < cml.Count; i1++) { cm = cml[i1]; qc = cm.QueryColumn; if (qc == null || !cm.Selected) { continue; } //if (qc.IsKey) continue; if (qc.MetaColumn.DataType == MetaColumnType.Structure) { strPos = i1; } for (i2 = 0; i2 < cml2.Count; i2++) // see if already have the column { if (qc == cml2[i2].QueryColumn) { break; } } if (i2 < cml2.Count) { continue; } cml2.Add(cm); } if (cml2.Count == 0) { return(null); // no fields } if (strPos < 0 && ttDim.IncludeStructure) { // include str if requested & not already included qc = qt.FirstStructureQueryColumn; strPos = cml2.Count; // put str at end //strPos = keyPos + 1; // place str after key if (qc != null && qc.Selected) // regular selected Qc? { cml2.ColumnMapList.Insert(strPos, ColumnMapMsx.BuildFromQueryColumn(qc)); } else // look in root table for a structure { mt = qt.MetaTable.Root; if (mt.FirstStructureMetaColumn != null) { qt = new QueryTable(mt); qc = new QueryColumn(); // add qc with no vo pos as indicator that must be selected qc.MetaColumn = mt.FirstStructureMetaColumn; qc.Selected = true; qt.AddQueryColumn(qc); cml2.ColumnMapList.Insert(strPos, ColumnMapMsx.BuildFromQueryColumn(qc)); } } } string keyVal = ""; foreach (ColumnMapMsx fli0 in cml2.ColumnMapList) // format each field { qc = fli0.QueryColumn; mc = qc.MetaColumn; i.Text += "<b>"; // build label if (!Lex.IsNullOrEmpty(fli0.ParameterName)) { i.Text += fli0.ParameterName; } else { i.Text += fli0.QueryColumn.ActiveLabel; } i.Text += ": </b>"; if (qc.VoPosition >= 0) { int ti = qc.QueryTable.TableIndex; int dri2 = Dtm.AdjustDataRowToCurrentDataForTable(dri, ti, true); DataRowMx dr = Qm.DataTable.Rows[dri2]; if (dr == null) { continue; } ResultsTable rt = Rf.Tables[ti]; object fieldValue = dr[qc.VoPosition]; if (!NullValue.IsNull(fieldValue)) { if (qc.IsKey) { keyVal = fieldValue.ToString(); } MobiusDataType mdt = MobiusDataType.ConvertToMobiusDataType(qc.MetaColumn.DataType, fieldValue); FormattedFieldInfo ffi = Qm.ResultsFormatter.FormatField(qc, mdt); if (mc.DataType != MetaColumnType.Structure) { i.Text += ffi.FormattedText; i.Text += "<br>"; } else { i = ToolTipUtil.AppendBitmapToToolTip(s, i, ffi.FormattedBitmap); } } else { i.Text += "<br>"; // no data } } else if (!Lex.IsNullOrEmpty(keyVal)) // select structure from db (may already have) { MoleculeMx cs = MoleculeUtil.SelectMoleculeForCid(keyVal, qc.MetaColumn.MetaTable); if (cs != null) { int width = ResultsFormatFactory.QcWidthInCharsToDisplayColWidthInMilliinches(mc.Width, ResultsFormat); FormattedFieldInfo ffi = Qm.ResultsFormatter.FormatStructure(cs, new CellStyleMx(), 's', 0, width, -1); i = ToolTipUtil.AppendBitmapToToolTip(s, i, ffi.FormattedBitmap); } } } if (i.Text.Length > 0) { s.Items.Add(i); } if (s.Items.Count == 0) { // show something by default i = new ToolTipItem(); i.Text = "No fields selected"; i.LeftIndent = 6; i.Appearance.TextOptions.WordWrap = WordWrap.Wrap; s.Items.Add(i); } //ToolTipTitleItem ti = new ToolTipTitleItem(); //ti.Text = "Dude"; //s.Items.Add(ti); //ToolTipItem i = new ToolTipItem(); //i.Text = "Subtext that is fairly long longer longest"; //i.LeftIndent = 6; //i.Appearance.TextOptions.WordWrap = WordWrap.Wrap; //s.Items.Add(i); //i = new ToolTipItem(); //Image img = Bitmap.FromFile(@"C:\Mobius_OpenSource\Mobius-3.0\ClientComponents\Resources\Mobius76x76DkBlueBack.bmp"); //i.Image = img; //s.Items.Add(i); //ToolTipSeparatorItem si = new ToolTipSeparatorItem(); return(s); //ChartPanel.ToolTipController.ToolTipLocation = ToolTipLocation.TopCenter; //ChartPanel.ToolTipController.AllowHtmlText = true; //string s = point.SeriesPointID.ToString(); //s = "This <b>SuperToolTip</b> supports <i>HTML formatting</i>"; }
object IInvokeServiceOps.InvokeServiceOperation(int opCode, object[] args) { MobiusCompoundUtilService op = (MobiusCompoundUtilService)opCode; switch (op) { case MobiusCompoundUtilService.DoesCidExist: { string cid = (string)args[0]; string mtName = (string)args[1]; Mobius.Data.MetaTable mt = (mtName == null) ? null : Mobius.Data.MetaTableCollection.Get(mtName); bool cidExists = Qel.CompoundIdUtil.Exists(cid, mt); return(cidExists); } case MobiusCompoundUtilService.SelectMoleculeFromCid: { string cid = (string)args[0]; string mtName = (string)args[1]; Mobius.Data.MetaTable mt = (mtName == null) ? null : Mobius.Data.MetaTableCollection.Get(mtName); Data.MoleculeMx nativeMolecule = Qel.MoleculeUtil.SelectMoleculeForCid(cid, mt); if (ClientState.MobiusClientVersionIsAtLeast(6, 0)) // Helm version or newer { byte[] ba = MobiusDataType.SerializeBinarySingle(nativeMolecule); return(ba); } else { ChemicalStructure transferMolecule = _transHelper.Convert <Mobius.Data.MoleculeMx, ChemicalStructure>(nativeMolecule); return(transferMolecule); } } case MobiusCompoundUtilService.SelectMoleculesForCidList: { List <string> cidList = (List <string>)args[0]; string mtName = (string)args[1]; Mobius.Data.MetaTable mt = (mtName == null) ? null : Mobius.Data.MetaTableCollection.Get(mtName); Dictionary <string, Data.MoleculeMx> csDict = Qel.MoleculeUtil.SelectMoleculesForCidList(cidList, mt); return(csDict); } case MobiusCompoundUtilService.GetAllSaltForms: { string cid = (string)args[0]; string normalizedCid = Data.CompoundId.Normalize(cid); List <string> cidList = new List <string>(new string[] { normalizedCid }); Dictionary <string, List <string> > cidDict = Qel.MoleculeUtil.GetAllSaltForms(cidList); List <string> results = null; if (cidDict.ContainsKey(cid)) { results = cidDict[cid] as List <string>; } return(results); } case MobiusCompoundUtilService.GetAllSaltFormsForList: { List <string> cidList = (List <string>)args[0]; Dictionary <string, List <string> > allSaltIds = Qel.MoleculeUtil.GetAllSaltForms(cidList); return(allSaltIds); } case MobiusCompoundUtilService.InsertSalts: { List <string> cidList = (List <string>)args[0]; List <string> result = Qel.MoleculeUtil.InsertSalts(cidList); return(result); } case MobiusCompoundUtilService.GroupSalts: { List <string> cidList = (List <string>)args[0]; List <string> result = Qel.MoleculeUtil.GroupSalts(cidList); return(result); } case MobiusCompoundUtilService.ValidateList: { string listText = (string)args[0]; string rootTableName = (string)args[1]; string result = Qel.CompoundIdUtil.ValidateList(listText, rootTableName); return(result); } case MobiusCompoundUtilService.GetRelatedCompoundIds: { StructureSearchType searchTypes = // default for old client that doesn't supply this parm StructureSearchType.FullStructure | StructureSearchType.MolSim | StructureSearchType.MatchedPairs | StructureSearchType.SmallWorld; int argIdx = 0; string cid = (string)args[argIdx++]; string mtName = (string)args[argIdx++]; string chime = (string)args[argIdx++]; if (args.Length > 4) { searchTypes = (StructureSearchType)args[argIdx++]; } int searchId = (int)args[argIdx++]; string result = Qel.MoleculeUtil.GetRelatedMatchCounts(cid, mtName, chime, searchTypes, searchId); return(result); } case MobiusCompoundUtilService.GetRelatedStructures: { string cid = (string)args[0]; string mtName = (string)args[1]; string result = Qel.MoleculeUtil.GetRelatedMatchRowsSerialized(cid, mtName); return(result); } case MobiusCompoundUtilService.ExecuteSmallWorldPreviewQuery: { string serializedQuery = (string)args[0]; object[] oa = Qel.MoleculeUtil.ExecuteSmallWorldPreviewQuerySerialized(serializedQuery); return(oa); } } return(null); }
/// <summary> /// Text changed, update filter flags accordingly /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Value_TextChanged(object sender, EventArgs e) { MobiusDataType mdt = null, mdt2 = null; string criteriaString = null, criteriaDisplayString = null, criteriaString2 = null, criteriaDisplayString2 = null; if (InSetup) { return; } QueryColumn qc = ColInfo.Qc; qc.SecondaryFilterType = FilterType.BasicCriteria; qc.SecondaryCriteria = qc.SecondaryCriteriaDisplay = ""; bool validInput = true; if (Value.Visible && Value.Text.Trim() == "") // no filter if nothing entered { qc.SecondaryCriteria = qc.SecondaryCriteriaDisplay = ""; } else if (CompOp == CompareOp.Like) // keep criteria in literal text form for like { qc.SecondaryCriteria = qc.MetaColumn.Name + " like " + Lex.AddSingleQuotes(Value.Text.Trim()); qc.SecondaryCriteriaDisplay = qc.ActiveLabel + " contains " + Lex.AddSingleQuotes(Value.Text.Trim()); } else // normalize for comparison for other filter types { string op = CompareOpString.Values[(int)CompOp]; string opd = CompareOpDisplayString.Values[(int)CompOp]; if (Value.Visible) // get first value { if (MobiusDataType.TryParse(qc.MetaColumn.DataType, Value.Text, out mdt)) { criteriaString = mdt.FormatForCriteria(); criteriaDisplayString = mdt.FormatCriteriaForDisplay(); } else { validInput = false; } } if (CompOp == CompareOp.Between) // get 2nd value { if (MobiusDataType.TryParse(qc.MetaColumn.DataType, Value2.Text, out mdt2)) { criteriaString2 = mdt2.FormatForCriteria(); criteriaDisplayString2 = mdt2.FormatCriteriaForDisplay(); } else { validInput = false; } } if (validInput) { qc.SecondaryCriteria = qc.MetaColumn.Name + " " + op; qc.SecondaryCriteriaDisplay = qc.ActiveLabel + " " + opd; if (mdt != null) { qc.SecondaryCriteria += " " + Lex.AddSingleQuotes(criteriaString); qc.SecondaryCriteriaDisplay += " " + Lex.AddSingleQuotes(criteriaDisplayString); } if (mdt2 != null) { qc.SecondaryCriteria += " and " + Lex.AddSingleQuotes(criteriaString2); qc.SecondaryCriteriaDisplay += " and " + Lex.AddSingleQuotes(criteriaDisplayString2); } } else { qc.SecondaryCriteria = qc.MetaColumn.Name + " like 'No-Match-String'"; // assure no matches qc.SecondaryCriteriaDisplay = qc.ActiveLabel + " " + opd + " invalid value"; } } QueryManager.QueryResultsControl.UpdateFiltering(ColInfo); // Update the filters and the associated view SyncBaseQuerySecondaryCriteria(qc); // sync any base query return; }
/// <summary> /// Summarize pivoted data /// </summary> /// <param name="sumLevel"></param> /// <param name="sumMethod"></param> /// <returns></returns> public QueryManager SummarizePivoted( TargetAssaySummarizationLevel sumLevel, SummarizationType sumMethod, ColumnsToTransform colsToSumm, OutputDest outputDest, TargetMap targetMap) { QueryManager qm2; QueryTable qt; DataRow dr, dr2; DataRowAttributes dra; string cid = "", currentCid; int rti, rfi; qm2 = InitializeSubqueryQm(MultiDbAssayDataNames.CombinedNonSumTableName); #if false // Get the data for a compound, summarize & add results to data for charting DataTableManager dtm = Qm0.DataTableManager; for (int dri = 0; dri < dtm.DataTable.Rows.Count; dri++) { DataRow dr = dtm.DataTable.Rows[dri]; DataRowAttributes dra = GetRowAttributes(dr); string keyVal = dr[KeyValueVoPos] as string; if (keyVal != curKeyVal || Rf.Tables.Count <= 1) // going to new key { curKeyVal = keyVal; curKeyRow = dri; rowsForKey = 0; } rowsForKey++; object o = dr[dci]; // if (o is string && ((string)o) == "") o = o; // debug if (NullValue.IsNull(o)) { if (rowsForKey == 0 || // count as null if first row for key dra.TableRowState[colInfo.TableIndex] != RowStateEnum.Undefined) // or real row data but col is null { stats.NullsExist = true; } continue; } else if (o is MobiusDataType) { // create a MobiusDataType that we can point to o = MobiusDataType.New(o); dr[dci] = o; } MobiusDataType val = o as MobiusDataType; try { if (val.FormattedText == null) // get formatted text if not done yet { val = QueryManager.ResultsFormatter.FormatField(rt, ti, rfld, fi, dr, dri, val, -1, false); } dictKey = val.FormattedText.ToUpper(); if (!stats.DistinctValueDict.ContainsKey(dictKey)) { DistinctValueAndPosition dvp = new DistinctValueAndPosition(); dvp.Value = val; stats.DistinctValueDict[dictKey] = dvp; } } catch (Exception ex) { val = val; } } // row loop dtm.n #endif return(qm2); }