/// <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); }
private void ConfigForStepFromQueryTable(UPRecordCopyStep recordCopyStep, UPConfigQueryTable queryTable) { UPConfigQueryCondition sourceConfigNameCondition = queryTable.PropertyConditions.ValueOrDefault("SourceConfig"); string sourceConfigName = null; if (sourceConfigNameCondition != null && sourceConfigNameCondition.FieldValues.Count > 0) { sourceConfigName = sourceConfigNameCondition.FieldValues[0] as string; } bool skipSearchAndList = false; if (string.IsNullOrEmpty(sourceConfigName)) { sourceConfigName = queryTable.InfoAreaId; skipSearchAndList = true; } if (!skipSearchAndList) { recordCopyStep.SearchAndListConfiguration = this.configStore.SearchAndListByName(sourceConfigName); } if (recordCopyStep.SearchAndListConfiguration == null) { recordCopyStep.FieldControl = this.configStore.FieldControlByNameFromGroup("Edit", sourceConfigName) ?? this.configStore.FieldControlByNameFromGroup("List", sourceConfigName); } else { recordCopyStep.FieldControl = this.configStore.FieldControlByNameFromGroup("List", recordCopyStep.SearchAndListConfiguration.FieldGroupName); } }
/// <summary> /// Initializes a new instance of the <see cref="UPConfigFilterCheckResult"/> class. /// </summary> /// <param name="failingCondition"> /// The failing condition. /// </param> public UPConfigFilterCheckResult(UPConfigQueryCondition failingCondition) { this.FailingCondition = failingCondition; var errorCondition = this.FailingCondition.PropertyConditions.ValueOrDefault("Error"); this.ErrorKey = errorCondition?.FirstValue; }
/// <summary> /// Tables the by removing fixed conditions for unnamed parameters. /// </summary> /// <returns> /// The <see cref="UPConfigQueryTable"/>. /// </returns> public UPConfigQueryTable TableByRemovingFixedConditionsForUnnamedParameters() { var subTables = new List <UPConfigQueryTable>(); var hasChangedTable = false; if (this.SubTables?.Count > 0) { foreach (var subTable in this.SubTables) { var changedSubTable = subTable.TableByRemovingFixedConditionsForUnnamedParameters(); if (changedSubTable != subTable) { hasChangedTable = true; subTables.Add(changedSubTable); } else { subTables.Add(subTable); } } } var hasChangedCondition = false; UPConfigQueryCondition changedCondition = null; if (this.Condition != null) { changedCondition = this.Condition.ConditionByRemovingFixedConditionsForUnnamedParameters(); if (changedCondition != this.Condition) { hasChangedCondition = true; } } if (hasChangedTable) { return(new UPConfigQueryTable( this.InfoAreaId, this.LinkId, this.ParentRelation, subTables, changedCondition, this.PropertyConditions, this.Alias)); } if (hasChangedCondition) { return(new UPConfigQueryTable( this.InfoAreaId, this.LinkId, this.ParentRelation, this.SubTables, changedCondition, this.PropertyConditions, this.Alias)); } return(this); }
/// <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="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; }
/// <summary> /// Copies the with sub tables condition property conditions. /// </summary> /// <param name="newSubTables"> /// The new sub tables. /// </param> /// <param name="newCondition"> /// The new condition. /// </param> /// <param name="propertyConditions"> /// The property conditions. /// </param> /// <returns> /// The <see cref="UPConfigQueryTable"/>. /// </returns> public UPConfigQueryTable CopyWithSubTablesConditionPropertyConditions( List <UPConfigQueryTable> newSubTables, UPConfigQueryCondition newCondition, Dictionary <string, UPConfigQueryCondition> propertyConditions) { return(new UPConfigQueryTable( this.InfoAreaId, this.LinkId, this.ParentRelation, newSubTables, newCondition, propertyConditions, this.Alias)); }
/// <summary> /// Adds the flat conditions. /// </summary> /// <param name="condition"> /// The condition. /// </param> /// <param name="flatConditions"> /// The flat conditions. /// </param> public virtual void AddFlatConditions( UPConfigQueryCondition condition, List <UPConfigQueryCondition> flatConditions) { if (condition.SubConditions.Count == 0) { flatConditions.Add(condition); } else { foreach (UPConfigQueryCondition subCondition in condition.SubConditions) { this.AddFlatConditions(subCondition, flatConditions); } } }
/// <summary> /// Initializes a new instance of the <see cref="UPConfigQueryTable"/> class. /// </summary> /// <param name="infoAreaId"> /// The information area identifier. /// </param> /// <param name="linkId"> /// The link identifier. /// </param> /// <param name="parentRelation"> /// The parent relation. /// </param> /// <param name="subTables"> /// The sub tables. /// </param> /// <param name="condition"> /// The condition. /// </param> /// <param name="propertyConditions"> /// The property conditions. /// </param> /// <param name="alias"> /// The alias. /// </param> public UPConfigQueryTable( string infoAreaId, int linkId, string parentRelation, List <UPConfigQueryTable> subTables, UPConfigQueryCondition condition, Dictionary <string, UPConfigQueryCondition> propertyConditions, string alias) { this.InfoAreaId = infoAreaId; this.LinkId = linkId; this.ParentRelation = parentRelation; this.SubTables = subTables; this.Condition = condition; this.PropertyConditions = propertyConditions; this.Alias = alias; }
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); }
/// <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> /// Results the view reference. /// </summary> /// <returns></returns> public ViewReference ResultViewReference() { if (this.DecisionHandler != null && this.Result.RowCount > 0) { UPCRMResultRow resultRow = (UPCRMResultRow)this.Result.ResultRowAtIndex(0); UPConfigQueryTable resultQueryTable = this.DecisionHandler.QueryTableForResultRow(resultRow); if (resultQueryTable != null) { UPConfigQueryCondition propertyCondition = resultQueryTable.PropertyConditions["Action"]; if (!string.IsNullOrEmpty(propertyCondition.FirstValue)) { Menu menu = ConfigurationUnitStore.DefaultStore.MenuByName(propertyCondition.FirstValue); ViewReference returnViewReference = menu.ViewReference.ViewReferenceWith(this.RecordIdentification, resultRow.RootRecordIdentification); if (this.ViewReference.HasBackToPreviousFollowUpAction()) { this.followUpReplaceOrganizer = true; return(returnViewReference.ViewReferenceWithBackToPreviousFollowUpAction()); } return(returnViewReference); } propertyCondition = resultQueryTable.PropertyConditions["ButtonAction"]; if (!string.IsNullOrEmpty(propertyCondition.FirstValue)) { UPConfigButton button = ConfigurationUnitStore.DefaultStore.ButtonByName(propertyCondition.FirstValue); ViewReference returnViewReference = button.ViewReference.ViewReferenceWith(this.RecordIdentification, resultRow.RootRecordIdentification); if (this.ViewReference.HasBackToPreviousFollowUpAction()) { this.followUpReplaceOrganizer = true; return(returnViewReference.ViewReferenceWithBackToPreviousFollowUpAction()); } return(returnViewReference); } propertyCondition = resultQueryTable.PropertyConditions["DefaultAction"]; if (!string.IsNullOrEmpty(propertyCondition.FirstValue)) { Menu menu = ConfigurationUnitStore.DefaultStore.MenuByName(propertyCondition.FirstValue); ViewReference returnViewReference = menu.ViewReference.ViewReferenceWith(this.RecordIdentification, resultRow.RootRecordIdentification); if (this.ViewReference.HasBackToPreviousFollowUpAction()) { this.followUpReplaceOrganizer = true; return(returnViewReference.ViewReferenceWithBackToPreviousFollowUpAction()); } return(returnViewReference); } propertyCondition = resultQueryTable.PropertyConditions["DefaultButtonAction"]; if (!string.IsNullOrEmpty(propertyCondition.FirstValue)) { UPConfigButton button = ConfigurationUnitStore.DefaultStore.ButtonByName(propertyCondition.FirstValue); ViewReference returnViewReference = button.ViewReference.ViewReferenceWith(this.RecordIdentification, resultRow.RootRecordIdentification); if (this.ViewReference.HasBackToPreviousFollowUpAction()) { this.followUpReplaceOrganizer = true; return(returnViewReference.ViewReferenceWithBackToPreviousFollowUpAction()); } return(returnViewReference); } } } if (this.Result.RowCount > 0) { Menu menu = ConfigurationUnitStore.DefaultStore.MenuByName(this.ViewReference.ContextValueForKey("ExistsAction")); if (menu != null) { ViewReference returnViewReference = menu.ViewReference.ViewReferenceWith( ((UPCRMResultRow)this.Result.ResultRowAtIndex(0)).RootRecordIdentification, this.ViewReference.ContextValueForKey("RecordId")); return(this.ViewReference.HasBackToPreviousFollowUpAction() ? returnViewReference.ViewReferenceWithBackToPreviousFollowUpAction() : returnViewReference); } return(null); } else { Menu menu = ConfigurationUnitStore.DefaultStore.MenuByName(this.ViewReference.ContextValueForKey("NotExistsAction")); if (menu != null) { ViewReference returnViewReference = menu.ViewReference.ViewReferenceWith(this.ViewReference.ContextValueForKey("RecordId")); return(this.ViewReference.HasBackToPreviousFollowUpAction() ? returnViewReference.ViewReferenceWithBackToPreviousFollowUpAction() : returnViewReference); } return(null); } }
/// <summary> /// Queries the table by applying replacements. /// </summary> /// <param name="replacements"> /// The replacements. /// </param> /// <returns> /// The <see cref="UPConfigQueryTable"/>. /// </returns> public UPConfigQueryTable QueryTableByApplyingReplacements(UPConditionValueReplacement replacements) { List <UPConfigQueryTable> newSubTables = null; UPConfigQueryCondition newCondition = null; var changed = false; if (this.SubTables != null) { var count = this.SubTables.Count; newSubTables = new List <UPConfigQueryTable>(count); for (var i = 0; i < count; i++) { var oldSubTable = this.SubTables[i]; var newSubTable = oldSubTable.QueryTableByApplyingReplacements(replacements); if (newSubTable != null) { newSubTables.Add(newSubTable); if (newSubTable != oldSubTable) { changed = true; } } else { changed = true; } } if (!changed) { newSubTables = null; } } var propertyConditions = this.PropertyConditions; if (this.Condition != null) { newCondition = this.Condition.QueryConditionByApplyingReplacements(replacements); if (newCondition == null) { return(null); } if (newCondition.IsFixed) { newCondition = null; // TODO 20150126: result depending on fixedValue? } if (newCondition != null && newCondition != this.Condition) { if (newCondition.PropertyCondition) { propertyConditions = new Dictionary <string, UPConfigQueryCondition> { { newCondition.FunctionName, newCondition } }; newCondition = null; } else if (newCondition.PropertyConditions != null) { propertyConditions = newCondition.PropertyConditions; } changed = true; } if (newCondition?.RemoveTableCondition ?? false) { return(null); } } if (changed) { var temp = newSubTables ?? this.SubTables; return(this.CopyWithSubTablesConditionPropertyConditions(temp, newCondition, propertyConditions)); } return(this); }
/// <summary> /// Adds the fields. /// </summary> /// <param name="dictionary"> /// The dictionary. /// </param> /// <param name="recursive"> /// if set to <c>true</c> [recursive]. /// </param> /// <param name="flat"> /// if set to <c>true</c> [flat]. /// </param> /// <param name="executeJavascript"> /// if set to <c>true</c> [execute javascript]. /// </param> public void AddFields(Dictionary <string, object> dictionary, bool recursive, bool flat, bool executeJavascript) { if (executeJavascript) { UPConfigQueryCondition javascriptCondition = this.PropertyConditions.ValueOrDefault("Arguments"); if (javascriptCondition != null) { this.Condition.AddFieldsFromJavascriptIntoDictionary(dictionary, javascriptCondition.FieldValues); return; } } this.Condition?.AddFieldsWithValuesIntoDictionary(dictionary); if (this.PropertyConditions != null) { foreach (var key in this.PropertyConditions.Keys) { var _condition = this.PropertyConditions[key]; dictionary[$".{key}"] = _condition.FieldValues; } } if (recursive && this.SubTables != null) { foreach (var subTable in this.SubTables) { var subDictionary = new Dictionary <string, object>(); subTable.AddFields(subDictionary, true, flat, executeJavascript); if (subDictionary.Count > 0) { if (flat && subTable.ParentRelation != "WITHOUT") { if (subTable.LinkId > 0) { var keyPrefix = $"{subTable.InfoAreaId}."; var targetPrefix = $"{subTable.InfoAreaId}:{subTable.LinkId}."; foreach (var key in subDictionary.Keys) { if (key.StartsWith(keyPrefix)) { dictionary[$"{targetPrefix}{key.Substring(keyPrefix.Length)}"] = subDictionary[key]; } else { dictionary[key] = subDictionary[key]; } } } else { foreach (var key in subDictionary.Keys) { dictionary[key] = subDictionary[key]; } } } else { var linkIdTmp = subTable.LinkId <= 0 ? 0 : subTable.LinkId; if (linkIdTmp <= 0 && subTable.InfoAreaId == this.InfoAreaId) { dictionary = dictionary.Concat(subDictionary).ToDictionary(k => k.Key, k => k.Value); continue; } var key = subTable.ParentRelation == "WITHOUT" ? $"#{subTable.InfoAreaId}.{linkIdTmp}" : $".{subTable.InfoAreaId}.{linkIdTmp}"; var arr = dictionary.ValueOrDefault(key) as List <object>; if (arr != null) { arr.Add(subDictionary); } else { arr = new List <object> { subDictionary }; dictionary[key] = arr; } } } } } }
/// <summary> /// Initializes a new instance of the <see cref="UPConfigFilterCheckResult"/> class. /// </summary> /// <param name="checkResults"> /// The check results. /// </param> /// <param name="parentCondition"> /// The parent condition. /// </param> public UPConfigFilterCheckResult(List <UPConfigFilterCheckResult> checkResults, UPConfigQueryCondition parentCondition) : this(parentCondition) { this.ChildResults = checkResults; }
/// <summary> /// Initializes a new instance of the <see cref="UPConfigFilterCheckResult"/> class. /// </summary> /// <param name="filterCheckResult"> /// The filter check result. /// </param> /// <param name="parentCondition"> /// The parent condition. /// </param> public UPConfigFilterCheckResult(UPConfigFilterCheckResult filterCheckResult, UPConfigQueryCondition parentCondition) { this.FailingCondition = filterCheckResult.FailingCondition; this.ErrorKey = filterCheckResult.ErrorKey; this.ChildResults = filterCheckResult.ChildResults; if (string.IsNullOrEmpty(this.ErrorKey)) { var errorCondition = parentCondition.PropertyConditions.ValueOrDefault("Error"); this.ErrorKey = errorCondition?.FirstValue; } }