/// <summary> /// The query table for result row. /// </summary> /// <param name="row"> /// The row. /// </param> /// <returns> /// The <see cref="UPConfigQueryTable"/>. /// </returns> public UPConfigQueryTable QueryTableForResultRow(UPCRMResultRow row) { var resultFieldMap = this.ResultFieldMap ?? this.ResultFeldMapFromCrmQuery(row.Result.MetaInfo); if (resultFieldMap == null) { return(null); } Dictionary <string, object> valueDictionary = new Dictionary <string, object>(resultFieldMap.Count); foreach (string key in resultFieldMap.Keys) { int position = resultFieldMap[key]; var value = position < 0 ? string.Empty : row.RawValueAtIndex(position); valueDictionary.Add(key, value); } UPConfigQueryTable foundTable = this.Filter.RootTable.QueryTableForValueDictionaryWithSubInfoAreas(valueDictionary, true); if (foundTable == null) { return(this.Filter.RootTable); } return(foundTable); }
/// <summary> /// The properties for query table. /// </summary> /// <param name="queryTable"> /// The query table. /// </param> /// <param name="multiValue"> /// The multi value. /// </param> /// <returns> /// Dictionary /// </returns> public Dictionary <string, object> PropertiesForQueryTable(UPConfigQueryTable queryTable, bool multiValue) { if (queryTable != null && queryTable.PropertyConditions.Count > 0) { Dictionary <string, object> dict = new Dictionary <string, object>(queryTable.PropertyConditions.Count); if (multiValue) { foreach (string condKey in queryTable.PropertyConditions.Keys) { UPConfigQueryCondition cond = queryTable.PropertyConditions[condKey]; dict.Add(condKey, cond); } } else { foreach (string condKey in queryTable.PropertyConditions.Keys) { UPConfigQueryCondition cond = queryTable.PropertyConditions[condKey]; if (cond.FieldValues.Count == 1) { dict.Add(condKey, cond.FieldValues[0]); } } } return(dict); } return(null); }
/// <summary> /// The buttons for result row. /// </summary> /// <param name="row"> /// The row. /// </param> /// <returns> /// The <see cref="IList"/>. /// </returns> public List <UPConfigButton> ButtonsForResultRow(UPCRMResultRow row) { UPConfigQueryTable matchingTable = this.QueryTableForResultRow(row); if (matchingTable != null) { List <UPConfigButton> matchingButtons = new List <UPConfigButton>(); UPConfigQueryCondition propertyCondition = matchingTable.PropertyConditions[@"Action"]; if (propertyCondition != null) { IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; foreach (string menuName in propertyCondition.FieldValues) { Menu menu = configStore.MenuByName(menuName); if (menu != null) { UPConfigButton button = new UPConfigButton( menu.DisplayName, menu.ImageName, menu.ViewReference); matchingButtons.Add(button); } else if (menuName.StartsWith(@"Button:")) { UPConfigButton button = configStore.ButtonByName(menuName.Substring(7)); if (button != null) { matchingButtons.Add(button); } } } } propertyCondition = matchingTable.PropertyConditions.ValueOrDefault("ButtonAction"); if (propertyCondition != null) { foreach (string buttonName in propertyCondition.FieldValues) { UPConfigButton button = ConfigurationUnitStore.DefaultStore.ButtonByName(buttonName); if (button != null) { matchingButtons.Add(button); } } } return(matchingButtons.Count > 0 ? matchingButtons : null); } return(null); }
/// <summary> /// Initializes a new instance of the <see cref="UPConfigQuery"/> class. /// </summary> /// <param name="name"> /// The name. /// </param> /// <param name="rootTable"> /// The root table. /// </param> /// <param name="queryFields"> /// The query fields. /// </param> /// <param name="sortFields"> /// The sort fields. /// </param> public UPConfigQuery( string name, UPConfigQueryTable rootTable, List <UPConfigQueryField> queryFields, List <UPConfigQuerySortField> sortFields) : base(name, rootTable) { this.QueryFields = queryFields; this.SortFields = sortFields; }
/// <summary> /// Initializes a new instance of the <see cref="UPConfigFilterParameter"/> class. /// </summary> /// <param name="name"> /// The name. /// </param> /// <param name="table"> /// The table. /// </param> /// <param name="condition"> /// The condition. /// </param> /// <param name="valueIndex"> /// Index of the value. /// </param> public UPConfigFilterParameter( string name, UPConfigQueryTable table, UPConfigQueryCondition condition, int valueIndex) { this.ParameterName = name; this.Table = table; this.Condition = condition; this.ValueIndex = valueIndex; this.Values = null; }
private UPConfigQueryTable CreateTable(bool mergeTablePossible, UPConfigQueryTable mergeTable, bool mergedTableFound, bool orRelation, List <UPConfigQueryTable> mergedTables) { UPConfigQueryCondition mergedCondition = null; if (this.Condition != null || mergeTable.Condition != null) { if (this.Condition == null || mergeTable.Condition == null) { if (mergedTableFound) { mergeTablePossible = false; } } else { mergedCondition = this.Condition.ConditionByAppendingConditionOrRelation( mergeTable.Condition, orRelation); if (mergedCondition != this.Condition && mergedTableFound) { mergeTablePossible = false; } } } if (mergeTablePossible) { if (this.Condition == mergedCondition && !mergedTableFound) { return(this); } return(new UPConfigQueryTable( this.InfoAreaId, this.LinkId, this.ParentRelation, mergedTables, mergedCondition, this.PropertyConditions, this.Alias)); } return(null); }
private UPConfigQueryTable CreateTable(bool orRelation, UPConfigQueryTable mergeTable) { string subTableAlias = null; string otherTableAlias = null; if (!string.IsNullOrWhiteSpace(this.Alias)) { subTableAlias = $"{this.Alias}_{this.InfoAreaId}m1"; otherTableAlias = $"{this.Alias}_{this.InfoAreaId}m2"; } var newSubTable = new UPConfigQueryTable( this.InfoAreaId, this.LinkId, orRelation ? "HAVINGOPTIONAL" : "HAVING", this.SubTables, this.Condition, this.PropertyConditions, subTableAlias); var otherTable = new UPConfigQueryTable( this.InfoAreaId, this.LinkId, newSubTable.ParentRelation, mergeTable.SubTables, mergeTable.Condition, mergeTable.PropertyConditions, otherTableAlias); return(new UPConfigQueryTable( this.InfoAreaId, this.LinkId, this.ParentRelation, new List <UPConfigQueryTable> { newSubTable, otherTable }, null, this.PropertyConditions, this.Alias)); }
/// <summary> /// Tables the by appending table or relation. /// </summary> /// <param name="mergeTable"> /// The merge table. /// </param> /// <param name="orRelation"> /// if set to <c>true</c> [or relation]. /// </param> /// <returns> /// The <see cref="UPConfigQueryTable"/>. /// </returns> public UPConfigQueryTable TableByAppendingTableOrRelation(UPConfigQueryTable mergeTable, bool orRelation) { var mergeSubTableDictionary = new Dictionary <string, UPConfigQueryTable>(mergeTable.SubTableDictionary()); bool mergeTablePossible; bool mergedTableFound; var isWithout = this.ParentRelation.StartsWith("WITHOUT"); if (isWithout) { orRelation = !orRelation; } var mergedTables = this.GetMergedTables(orRelation, mergeSubTableDictionary, out mergeTablePossible, out mergedTableFound); if (mergeSubTableDictionary.Count > 0) { mergeTablePossible = false; } var table = this.CreateTable(mergeTablePossible, mergeTable, mergedTableFound, orRelation, mergedTables); return(table ?? this.CreateTable(orRelation, mergeTable)); }
/// <summary> /// Checks the value information area identifier field identifier. /// </summary> /// <param name="value"> /// The value. /// </param> /// <param name="infoAreaId"> /// The information area identifier. /// </param> /// <param name="fieldId"> /// The field identifier. /// </param> /// <returns> /// The <see cref="UPConfigFilterCheckResult"/>. /// </returns> public UPConfigFilterCheckResult CheckValueInfoAreaIdFieldId(string value, string infoAreaId, int fieldId) { UPConfigQueryTable table = null; if (this.InfoAreaId == null || this.RootTable.InfoAreaId == infoAreaId) { table = this.RootTable; } else { var count = this.RootTable.NumberOfSubTables; for (var i = 0; i < count; i++) { var subTable = this.RootTable.SubTableAtIndex(i); if (subTable.InfoAreaId == infoAreaId) { table = subTable; break; } } } return(table?.CheckValueFieldId(value, fieldId)); }
/// <summary> /// The button for result row. /// </summary> /// <param name="row"> /// The row. /// </param> /// <returns> /// The <see cref="UPConfigButton"/>. /// </returns> public UPConfigButton ButtonForResultRow(UPCRMResultRow row) { UPConfigQueryTable matchingTable = this.QueryTableForResultRow(row); if (matchingTable != null) { UPConfigQueryCondition propertyCondition = matchingTable.PropertyConditions.ValueOrDefault("DefaultAction"); if (!string.IsNullOrEmpty(propertyCondition?.FirstValue)) { Menu menu = ConfigurationUnitStore.DefaultStore.MenuByName(propertyCondition.FirstValue); return(new UPConfigButton(menu.DisplayName, menu.ImageName, menu.ViewReference)); } propertyCondition = matchingTable.PropertyConditions.ValueOrDefault("DefaultButtonAction"); if (!string.IsNullOrEmpty(propertyCondition?.FirstValue)) { return(ConfigurationUnitStore.DefaultStore.ButtonByName(propertyCondition.FirstValue)); } } return(null); }
/// <summary> /// Copies the with root. /// </summary> /// <param name="newRoot"> /// The new root. /// </param> /// <returns> /// The <see cref="UPConfigQueryFilterBase"/>. /// </returns> public override UPConfigQueryFilterBase CopyWithRoot(UPConfigQueryTable newRoot) { return(new UPConfigQuery(this.UnitName, newRoot, this.QueryFields, this.SortFields)); }
/// <summary> /// Initializes a new instance of the <see cref="UPConfigFilter"/> class. /// </summary> /// <param name="name"> /// The name. /// </param> /// <param name="rootTable"> /// The root table. /// </param> /// <param name="infoAreaId"> /// The information area identifier. /// </param> /// <param name="displayName"> /// The display name. /// </param> public UPConfigFilter(string name, UPConfigQueryTable rootTable, string infoAreaId, string displayName) : base(name, rootTable) { this.InfoAreaId = infoAreaId; this.DisplayName = displayName; }
/// <summary> /// Initializes a new instance of the <see cref="UPConfigQueryFilterBase"/> class. /// </summary> /// <param name="name"> /// The name. /// </param> /// <param name="rootTable"> /// The root table. /// </param> public UPConfigQueryFilterBase(string name, UPConfigQueryTable rootTable) { this.UnitName = name; this.RootTable = rootTable; }
/// <summary> /// Copies the with root. /// </summary> /// <param name="newRoot"> /// The new root. /// </param> /// <returns> /// The <see cref="UPConfigQueryFilterBase"/>. /// </returns> public virtual UPConfigQueryFilterBase CopyWithRoot(UPConfigQueryTable newRoot) { return(new UPConfigQueryFilterBase(this.UnitName, this.RootTable)); }
/// <summary> /// Initializes a new instance of the <see cref="UPConfigFilter"/> class. /// </summary> /// <param name="name"> /// The name. /// </param> /// <param name="rootTable"> /// The root table. /// </param> public UPConfigFilter(string name, UPConfigQueryTable rootTable) : base(name, rootTable) { }
/// <summary> /// The properties for result row. /// </summary> /// <param name="row"> /// The row. /// </param> /// <param name="multiValue"> /// The multi value. /// </param> /// <returns> /// The <see cref="Dictionary"/>. /// </returns> public Dictionary <string, object> PropertiesForResultRow(UPCRMResultRow row, bool multiValue) { UPConfigQueryTable matchingTable = this.QueryTableForResultRow(row); return(this.PropertiesForQueryTable(matchingTable, multiValue)); }
/// <summary> /// Copies the with root. /// </summary> /// <param name="newRoot"> /// The new root. /// </param> /// <returns> /// filter configurations /// </returns> public override UPConfigQueryFilterBase CopyWithRoot(UPConfigQueryTable newRoot) { return(new UPConfigFilter(this.UnitName, newRoot, this.InfoAreaId, this.DisplayName)); }