private static UPConfigFilter QueryForDate(UPConfigFilter configFilter, UPConfigFilterParameters parameters, UPMFilter upmFilter) { if (!(parameters?.NumberOfParameters > 0)) { return(configFilter); } if (parameters.NumberOfParameters == parameters.NumberOfUnnamedParameters) { var unnmaedParameters = parameters.UnnamedParameters; var rawValues = upmFilter.RawValues; var valueCount = rawValues.Count; for (var i = 0; i < parameters.NumberOfUnnamedParameters; i++) { var param = unnmaedParameters[i]; if (valueCount > i) { param.Value = rawValues[i]; } } return((UPConfigFilter)configFilter.QueryByApplyingFilterParameters(parameters)); } var firstParameter = parameters.FirstParameter(); firstParameter.Values = upmFilter.RawValues; return((UPConfigFilter)configFilter.QueryByApplyingFilterParameter(firstParameter)); }
/// <summary> /// Initializes a new instance of the <see cref="UPConditionValueReplacement"/> class. /// </summary> /// <param name="_parameters"> /// The _parameters. /// </param> public UPConditionValueReplacement(UPConfigFilterParameters _parameters) { var unnamedSource = _parameters.UnnamedParameters; var count = unnamedSource?.Count ?? 0; if (count > 0) { this.nextUnnamedParameter = 0; this.unnamedParameters = new List <List <string> >(count); for (var i = 0; i < count; i++) { this.unnamedParameters.Add(unnamedSource[i].Values); } } count = _parameters.NumberOfNamedParameters; if (count <= 0) { return; } this.replaceDictionary = new Dictionary <string, List <string> >(count); this.replaceParameters = new Dictionary <string, object>(count); foreach (var parameter in _parameters.namedParameters.Select(parameters => parameters.Value[0])) { this.replaceDictionary[parameter.ParameterName] = parameter.Values; this.replaceParameters[parameter.ParameterName] = parameter; } }
private static UPMFilter GetDateFilter(UPConfigFilterParameters parameters, FieldIdentifier identifier, UPCRMFieldInfo fieldInfo) { var dateFilter = new UPMDateFilter(identifier) { ParameterName = fieldInfo.Label }; if (parameters.NumberOfParameters > 1) { dateFilter.ParameterName = LocalizedString.TextFrom; dateFilter.SecondParameterName = LocalizedString.TextTo; } return(dateFilter); }
private static UPConfigFilter QueryForDistance(UPConfigFilter configFilter, UPConfigFilterParameters parameters, UPMFilter upmFilter) { var distanceFilter = (UPMDistanceFilter)upmFilter; parameters.SetValuesName(new List <string> { distanceFilter.GetGPSXMin.ToString() }, "$parGPSXmin"); parameters.SetValuesName(new List <string> { distanceFilter.GetGPSXMax.ToString() }, "$parGPSXmax"); parameters.SetValuesName(new List <string> { distanceFilter.GetGPSYMin.ToString() }, "$parGPSYmin"); parameters.SetValuesName(new List <string> { distanceFilter.GetGPSYMax.ToString() }, "$parGPSYmax"); return((UPConfigFilter)configFilter.QueryByApplyingFilterParameters(parameters)); }
private static UPMFilter GetFilter(string filtername, UPConfigFilterParameters parameters) { UPMFilter filter = null; var parameter = parameters.FirstParameter(); var fieldInfo = parameter.CrmFieldInfo; var type = fieldInfo.FieldType; var identifier = FieldIdentifier.IdentifierWithInfoAreaIdRecordIdFieldId(fieldInfo.InfoAreaId, filtername, fieldInfo.FieldId.ToString()); if (type == CatalogFilterK || type == CatalogFilterX) { filter = GetCatalogFilter(parameter, identifier, fieldInfo); } else if (type == DateFilter) { filter = GetDateFilter(parameters, identifier, fieldInfo); } else if (parameters.AllParameterNames != null && (parameters.AllParameterNames.Contains("$parGPSXmin") || parameters.AllParameterNames.Contains("$parGPSXmax") || parameters.AllParameterNames.Contains("$parGPSYmin") || parameters.AllParameterNames.Contains("$parGPSYmax"))) { filter = GetUPMDistanceFilter(identifier, fieldInfo); } else if (!string.IsNullOrEmpty(fieldInfo.RepType)) { filter = GetRepFilter(identifier, fieldInfo); } else if (type == EditFieldF || type == EditFieldS || type == EditFieldL || type == EditFieldC || type == EditFieldB) { filter = GetEditFieldFilter(parameters, identifier, fieldInfo, type); } if (filter != null) { var fieldValueArray = parameter.Condition.FieldValues; if (fieldValueArray.Count > 1 && (string)fieldValueArray[0] == "$parValue") { var defaultValueArray = new List <object>(fieldValueArray); defaultValueArray.RemoveAt(0); filter.SetDefaultRawValues(defaultValueArray); } } return(filter); }
private static UPMFilter GetEditFieldFilter(UPConfigFilterParameters parameters, FieldIdentifier identifier, UPCRMFieldInfo fieldInfo, string type) { var editFieldFilter = new UPMEditFieldFilter(identifier); var rangFilter = parameters.NumberOfParameters > 1; if (rangFilter) { editFieldFilter.ParameterName = LocalizedString.TextFrom; editFieldFilter.SecondParameterName = LocalizedString.TextTo; } CreateEditFields(fieldInfo, rangFilter, type, out var editField, out var secondEditField); if (!rangFilter) { editField.LabelText = fieldInfo.Label; } editFieldFilter.Editfield = editField; editFieldFilter.SecondEditfield = secondEditField; return(editFieldFilter); }
private static UPConfigFilter QueryForDefault(UPConfigFilter configFilter, UPConfigFilterParameters parameters, UPMFilter upmFilter) { if (!(parameters?.NumberOfParameters > 0)) { return(configFilter); } if (parameters.NumberOfParameters > 1 && parameters.NumberOfParameters == parameters.NumberOfUnnamedParameters) { var unnmaedParameters = parameters.UnnamedParameters; var rawValues = upmFilter.RawValues; var valueCount = rawValues.Count; if (valueCount == unnmaedParameters.Count) { for (var i = 0; i < valueCount; i++) { parameters.SetUnnamedValueForIndex(rawValues[i], i); } return((UPConfigFilter)configFilter.QueryByApplyingFilterParameters(parameters)); } return(configFilter); } else { var rawValues = upmFilter.RawValues; if (rawValues?.Count == 0) { return(configFilter); } var firstParameter = parameters.FirstParameter(); firstParameter.Values = rawValues; return((UPConfigFilter)configFilter.QueryByApplyingFilterParameter(firstParameter)); } }
private static UPConfigFilter QueryForCatalog(UPConfigFilter configFilter, UPConfigFilterParameters parameters, UPMFilter upmFilter) { if (!(parameters?.NumberOfParameters > 0)) { return(configFilter); } var firstParameter = parameters.FirstParameter(); var rawValues = upmFilter.RawValues; firstParameter.Values = rawValues; if (firstParameter.ValueIndex == 1 && upmFilter.FilterType == UPMFilterType.Catalog) { firstParameter.RemoveFirstValuesFromValueSet = true; return((UPConfigFilter)configFilter.QueryByApplyingFilterParameter(firstParameter)); } if (upmFilter.FilterType == UPMFilterType.DependentCatalog && rawValues.Count > 1) { return((UPConfigFilter)configFilter.QueryByApplyingFilterParameter(firstParameter)); } return((UPConfigFilter)configFilter.QueryByApplyingFilterParameter(firstParameter)); }
private static UPConfigFilter QueryForCatalogFilter(UPConfigFilter configFilter, UPConfigFilterParameters parameters, UPMFilter upmFilter) { var selectCatalogFilter = (UPMSelectCatalogFilter)upmFilter; var rawValues = upmFilter.RawValues; var selectedValueDictionaries = new List <Dictionary <string, object> >(rawValues.Count); foreach (var recordIdentification in rawValues) { var row = selectCatalogFilter.ResultRowDictionary[recordIdentification]; var rowFunctionNames = row.ValuesWithFunctions(); if (rowFunctionNames != null) { selectedValueDictionaries.Add(rowFunctionNames); } } return(configFilter .FilterByApplyingArrayOfValueDictionariesParameters( selectedValueDictionaries, selectCatalogFilter.FilterParameters)); }