private static string FormattedValueForResultRowFieldControlTabFieldIndex(UPCRMResultRow row, FieldControlTab tabConfig, int fieldIndex)
        {
            bool            found           = false;
            FieldAttributes attributes      = tabConfig.FieldAtIndex(fieldIndex).Attributes;
            List <string>   fieldValueArray = new List <string>(attributes.FieldCount);
            int             lastIndex       = fieldIndex + attributes.FieldCount;

            for (int i = fieldIndex; i < lastIndex; i++)
            {
                UPConfigFieldControlField field = tabConfig.FieldAtIndex(i);
                if (field != null)
                {
                    string v = row.ValueAtIndex(field.TabIndependentFieldIndex);
                    if (v != null)
                    {
                        fieldValueArray.Add(v);
                        if (v.Length > 1)
                        {
                            found = true;
                        }
                    }
                    else
                    {
                        fieldValueArray.Add(string.Empty);
                    }
                }
            }

            return(found ? attributes.FormatValues(fieldValueArray) : string.Empty);
        }
Exemplo n.º 2
0
        // functionName == nil => all Fields
        private static List <UPMStringField> FieldsForResultRow(UPCRMResultRow row, string functionName, int tabIndex, bool addHidden)
        {
            List <UPMStringField> fields             = new List <UPMStringField>();
            FieldControlTab       sourceFieldControl = row.Result.MetaInfo.SourceFieldControl.TabAtIndex(tabIndex);
            int offset     = tabIndex == 0 ? 0 : row.Result.MetaInfo.SourceFieldControl.TabAtIndex(0).Fields.Count;
            int fieldCount = tabIndex == 0 ? sourceFieldControl.Fields.Count : row.NumberOfColumns;

            for (int rowFieldIndex = 0; rowFieldIndex < fieldCount;)
            {
                string fieldFunctionNames = sourceFieldControl.FieldAtIndex(rowFieldIndex)?.Function ?? string.Empty;
                var    functionNames      = fieldFunctionNames.Split(',').ToList();
                functionNames = functionNames.Count == 0 ? new List <string> {
                    string.Empty
                } : functionNames;
                UPConfigFieldControlField configField = sourceFieldControl.FieldAtIndex(rowFieldIndex);
                FieldAttributes           attributes  = configField?.Attributes;
                bool found = false;
                foreach (string fieldFunctionName in functionNames)
                {
                    if (functionName == null || fieldFunctionName.StartsWith(functionName))
                    {
                        UPMStringField stringField = new UPMStringField(new FieldIdentifier(row.RecordIdentificationAtIndex(0), configField.Field.FieldIdentification));
                        stringField.Hidden = attributes.Hide;
                        if (attributes.FieldCount > 0)
                        {
                            List <string> combineFields = new List <string>();
                            for (int fieldIndex = 0; fieldIndex < attributes.FieldCount; fieldIndex++)
                            {
                                combineFields.Add(row.ValueAtIndex(rowFieldIndex + offset));
                                rowFieldIndex++;
                            }

                            stringField.StringValue = attributes.FormatValues(combineFields);
                        }
                        else
                        {
                            stringField.StringValue = row.ValueAtIndex(rowFieldIndex + offset);
                            rowFieldIndex++;
                        }

                        if (addHidden || !stringField.Hidden)
                        {
                            fields.Add(stringField);
                        }

                        found = true;
                    }
                }

                if (!found)
                {
                    rowFieldIndex++;
                }
            }

            return(fields);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UPSerialEntryParentInfoPanelCell"/> class.
        /// </summary>
        /// <param name="fieldControlTab">The field control tab.</param>
        /// <param name="resultRow">The result row.</param>
        public UPSerialEntryParentInfoPanelCell(FieldControlTab fieldControlTab, UPCRMResultRow resultRow)
        {
            int           numberOfFields = fieldControlTab.NumberOfFields;
            List <string> fields         = new List <string>();

            if (!string.IsNullOrEmpty(fieldControlTab.Label))
            {
                fields.Add(fieldControlTab.Label);
            }

            for (int index = 0; index < numberOfFields; index++)
            {
                UPConfigFieldControlField field = fieldControlTab.FieldAtIndex(index);
                if (index == 0)
                {
                    IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
                    this.ImageName = configStore.InfoAreaConfigById(field.InfoAreaId).ImageName;
                }

                int    offset = 0;
                string value  = resultRow.FormattedFieldValueAtIndex(index, offset, fieldControlTab);
                index += offset;
                if (!string.IsNullOrEmpty(value))
                {
                    fields.Add(value);
                }
            }

            this.FieldValues = fields;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="EditChildrenGroupModelController"/> class.
        /// </summary>
        /// <param name="fieldControl">The field control.</param>
        /// <param name="tabIndex">Index of the tab.</param>
        /// <param name="editPageContext">The edit page context.</param>
        /// <param name="theDelegate">The delegate.</param>
        /// <exception cref="Exception">
        /// TabConfig is null
        /// or
        /// ChildFieldControl is null
        /// </exception>
        public EditChildrenGroupModelController(FieldControl fieldControl, int tabIndex, UPEditPageContext editPageContext, IGroupModelControllerDelegate theDelegate)
            : base(fieldControl, tabIndex, editPageContext, theDelegate)
        {
            FieldControlTab tabConfig = fieldControl.TabAtIndex(tabIndex);

            if (tabConfig == null)
            {
                throw new Exception("TabConfig is null");
            }

            var typeParts = tabConfig.Type.Split('_');

            if (typeParts.Length > 1)
            {
                string detailsConfigurationName = (string)typeParts[1];
                var    configNameParts          = detailsConfigurationName.Split('#');
                if (configNameParts.Length > 1)
                {
                    this.LinkId = Convert.ToInt32(configNameParts[1]);
                    detailsConfigurationName = configNameParts[0];
                }

                IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
                this.ChildFieldControl = configStore.FieldControlByNameFromGroup("Edit", detailsConfigurationName);
                if (this.ChildFieldControl.NumberOfTabs > 1)
                {
                    this.ChildFieldControl = this.ChildFieldControl.FieldControlWithSingleTab(0);
                }

                this.ChildInfoAreaId = this.ChildFieldControl.InfoAreaId;
                if (typeParts.Length > 2)
                {
                    UPConfigFilter templateFilter = configStore.FilterByName((string)typeParts[2]);
                    if (templateFilter != null)
                    {
                        templateFilter     = templateFilter.FilterByApplyingReplacements(UPConditionValueReplacement.DefaultParameters);
                        this.initialValues = templateFilter.FieldsWithConditions(false);
                    }
                }
            }
            else if (tabConfig.NumberOfFields > 0)
            {
                UPConfigFieldControlField childField = tabConfig.FieldAtIndex(0);
                this.ChildInfoAreaId   = childField.InfoAreaId;
                this.LinkId            = childField.LinkId;
                this.ChildFieldControl = fieldControl.FieldControlWithSingleTabRootInfoAreaIdRootLinkId(tabIndex, this.ChildInfoAreaId, this.LinkId);
            }
            else
            {
                this.ChildFieldControl = null;
            }

            if (this.ChildFieldControl == null)
            {
                throw new Exception("ChildFieldControl is null");
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// The formatted field value at index.
        /// </summary>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <param name="offset">
        /// The offset.
        /// </param>
        /// <param name="tab">
        /// The tab.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public string FormattedFieldValueAtIndex(int index, int?offset, FieldControlTab tab)
        {
            UPConfigFieldControlField field = tab.FieldAtIndex(index);

            if (field != null)
            {
                return(this.FormattedFieldValueAtIndex(field.TabIndependentFieldIndex, offset, tab.FieldControl));
            }

            return(null);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Edits the contexts for result row.
        /// </summary>
        /// <param name="resultRow">The result row.</param>
        /// <param name="tabConfig">The tab configuration.</param>
        /// <param name="editFieldDictionary">The edit field dictionary.</param>
        /// <param name="initialValues">The initial values.</param>
        /// <param name="fieldPostfix">The field postfix.</param>
        /// <param name="initialRecords">The initial records.</param>
        /// <returns></returns>
        public List <object> EditContextsForResultRow(UPCRMResultRow resultRow, FieldControlTab tabConfig,
                                                      Dictionary <string, UPEditFieldContext> editFieldDictionary, Dictionary <string, object> initialValues, string fieldPostfix, List <UPCRMRecord> initialRecords)
        {
            var recordIdentification = resultRow?.RecordIdentificationAtIndex(0);

            var         fieldArray        = new List <object>();
            UPCRMRecord offlineRootRecord = null;

            if (initialRecords?.Count > 0)
            {
                offlineRootRecord = initialRecords.FirstOrDefault();
            }

            var identifierPrefix = recordIdentification;

            if (string.IsNullOrEmpty(identifierPrefix))
            {
                identifierPrefix = $"{this.TabConfig.FieldControl.UnitName}_{this.TabIndex}";
            }

            var fieldCount = tabConfig?.NumberOfFields ?? 0;

            for (var j = 0; j < fieldCount; j++)
            {
                var fieldConfig = tabConfig?.FieldAtIndex(j);
                if (fieldConfig == null)
                {
                    continue;
                }

                var        fieldAttributes   = fieldConfig.Attributes;
                var        currentInfoAreaId = fieldConfig.InfoAreaId;
                var        currentLinkId     = fieldConfig.LinkId;
                var        fieldIdentifier   = FieldIdentifier.IdentifierWithRecordIdentificationFieldId(identifierPrefix, fieldConfig.Identification);
                UPSelector selector          = null;
                var        selectorDef       = fieldConfig.Attributes?.Selector;
                if (selectorDef != null)
                {
                    var filterParameters = this.EditPageContext?.ViewReference?.ContextValueForKey("copyFields")?.JsonDictionaryFromString();
                    if (resultRow?.Result != null && resultRow.IsNewRow)
                    {
                        selector = UPSelector.SelectorFor(
                            resultRow.RootRecordIdentification?.InfoAreaId(),
                            resultRow.Result.ParentRecordIdentification,
                            resultRow.Result.LinkId,
                            selectorDef,
                            filterParameters,
                            fieldConfig);
                    }
                    else
                    {
                        selector = UPSelector.SelectorFor(resultRow?.RootRecordIdentification, selectorDef, filterParameters, fieldConfig);
                    }

                    selector.Build();
                    if (selector.OptionCount == 0 && selector.IsStaticSelector)
                    {
                        selector = null;
                    }
                }

                var isEditField = this.enableLinkedEditFields ||
                                  selector != null ||
                                  (tabConfig.FieldControl.InfoAreaId == currentInfoAreaId && currentLinkId <= 0);

                var isHidden       = fieldAttributes.Hide;
                var isReadOnly     = isEditField && fieldAttributes.ReadOnly;
                var rawFieldValue0 = resultRow?.RawValueAtIndex(fieldConfig.TabIndependentFieldIndex);
                var fieldInfo      = fieldConfig.Field.FieldInfo;
                if (isEditField && !isReadOnly && !(selector is UPRecordSelector && ((UPRecordSelector)selector).IgnoreFieldInfo))
                {
                    if (fieldInfo.IsReadOnly)
                    {
                        isReadOnly = true;
                    }
                    else if (resultRow?.IsNewRow == true || string.IsNullOrEmpty(rawFieldValue0))
                    {
                        if (fieldInfo.LockedOnNew)
                        {
                            isReadOnly = true;
                        }
                    }
                    else if (fieldInfo.LockedOnUpdate && !fieldInfo.IsEmptyValue(rawFieldValue0))
                    {
                        isReadOnly = true;
                    }
                }

                string             offlineValue = null;
                bool               offlineChanged;
                string             rawFieldValue;
                UPEditFieldContext editFieldContext;
                if (isEditField)
                {
                    List <UPEditFieldContext> childFields = null;
                    if (fieldAttributes.FieldCount > 1 && selector == null)
                    {
                        childFields = new List <UPEditFieldContext>();
                        for (var k = 1; k < fieldAttributes.FieldCount; k++)
                        {
                            var childFieldConfig = tabConfig.FieldAtIndex(++j);
                            if (childFieldConfig != null)
                            {
                                rawFieldValue = resultRow.RawValueAtIndex(childFieldConfig.TabIndependentFieldIndex);
                                if (initialValues != null)
                                {
                                    rawFieldValue = this.ValueByApplyingInitialValuesForField(rawFieldValue, childFieldConfig, initialValues);
                                }

                                offlineChanged = false;

                                if (offlineRootRecord != null)
                                {
                                    offlineValue = offlineRootRecord.StringFieldValueForFieldIndex(childFieldConfig.FieldId);
                                    if (offlineValue != null && !offlineValue.Equals(rawFieldValue))
                                    {
                                        offlineChanged = true;
                                    }
                                }

                                editFieldContext = UPEditFieldContext.ChildFieldContextForFieldConfigValue(childFieldConfig, rawFieldValue);
                                if (offlineChanged)
                                {
                                    editFieldContext.SetOfflineChangeValue(offlineValue);
                                }

                                childFields.Add(editFieldContext);
                            }
                        }
                    }

                    var markAsChanged = false;
                    rawFieldValue = rawFieldValue0;
                    if (initialValues != null)
                    {
                        string initialValue = this.ValueByApplyingInitialValuesForField(rawFieldValue, fieldConfig, initialValues);
                        if (!rawFieldValue.Equals(initialValue))
                        {
                            markAsChanged = true;
                            rawFieldValue = initialValue;
                        }
                    }

                    offlineChanged = false;
                    offlineValue   = null;
                    if (offlineRootRecord != null)
                    {
                        offlineValue = offlineRootRecord.StringFieldValueForFieldIndex(fieldConfig.FieldId);
                        if (offlineValue != null && !offlineValue.Equals(rawFieldValue))
                        {
                            offlineChanged = true;
                        }
                    }

                    if (selector != null)
                    {
                        // Sometimes it makes sense to add the Link field , so you have the link information on the EditPage , but the field is not displayed .
                        // Thus, the field is interpreted as EditField Selector must be set.
                        if (isHidden)
                        {
                            editFieldContext = UPEditFieldContext.HiddenFieldFor(fieldConfig, fieldIdentifier, rawFieldValue);
                        }
                        else if (isReadOnly && ConfigurationUnitStore.DefaultStore.ConfigValueIsSet("Disable.82213"))
                        {
                            editFieldContext = UPEditFieldContext.ReadonlyFieldFor(fieldConfig, fieldIdentifier, rawFieldValue);
                        }
                        else
                        {
                            editFieldContext = UPEditFieldContext.FieldContextFor(fieldConfig, fieldIdentifier, rawFieldValue, selector);
                        }
                    }
                    else
                    {
                        if (isHidden)
                        {
                            editFieldContext = UPEditFieldContext.HiddenFieldFor(fieldConfig, fieldIdentifier, rawFieldValue);
                        }
                        else if (isReadOnly)
                        {
                            editFieldContext = UPEditFieldContext.ReadonlyFieldFor(fieldConfig, fieldIdentifier, rawFieldValue);
                        }
                        else
                        {
                            editFieldContext = UPEditFieldContext.FieldContextFor(fieldConfig, fieldIdentifier, rawFieldValue, childFields as List <UPEditFieldContext>);
                        }
                    }

                    if (fieldInfo.DateFieldId >= 0 && tabConfig.FieldControl.InfoAreaId == currentInfoAreaId)
                    {
                        editFieldContext.DateOriginalValue = resultRow?.RawValueForFieldIdInfoAreaIdLinkId(fieldInfo.DateFieldId, currentInfoAreaId, -1);
                    }
                    else if (fieldInfo.TimeFieldId >= 0 && tabConfig.FieldControl.InfoAreaId == currentInfoAreaId)
                    {
                        editFieldContext.TimeOriginalValue = resultRow?.RawValueForFieldIdInfoAreaIdLinkId(fieldInfo.TimeFieldId, currentInfoAreaId, -1);
                    }

                    if (offlineChanged)
                    {
                        editFieldContext.SetOfflineChangeValue(offlineValue);
                    }
                    else if (markAsChanged)
                    {
                        editFieldContext.SetChanged(true);
                    }

                    if (editFieldContext != null)
                    {
                        if (!string.IsNullOrEmpty(fieldPostfix))
                        {
                            editFieldContext.FieldLabelPostfix = fieldPostfix;
                        }

                        if (editFieldDictionary != null)
                        {
                            editFieldDictionary.SetObjectForKey(editFieldContext, fieldConfig.Identification);
                            if (childFields != null)
                            {
                                foreach (var childFieldContext in childFields)
                                {
                                    editFieldDictionary.SetObjectForKey(childFieldContext, childFieldContext.FieldConfig.Identification);
                                }
                            }
                        }

                        fieldArray.Add(editFieldContext);
                    }
                }
                else
                {
                    string fieldValue;
                    if (fieldAttributes.FieldCount > 1)
                    {
                        fieldValue = resultRow?.ValueAtIndex(fieldConfig.TabIndependentFieldIndex);
                        if (string.IsNullOrEmpty(fieldValue))
                        {
                            fieldValue = this.ValueForLinkFieldFromInitialValues(fieldConfig, initialValues);
                        }

                        var values = !string.IsNullOrEmpty(fieldValue) ?
                                     new List <string> {
                            fieldValue
                        } :
                        new List <string>();

                        for (var k = 1; k < fieldAttributes.FieldCount; k++)
                        {
                            var childfieldConfig = tabConfig.FieldAtIndex(++j);
                            if (childfieldConfig == null)
                            {
                                continue;
                            }

                            fieldValue = resultRow?.ValueAtIndex(childfieldConfig.TabIndependentFieldIndex);
                            if (string.IsNullOrEmpty(fieldValue))
                            {
                                fieldValue = this.ValueForLinkFieldFromInitialValues(childfieldConfig, initialValues);
                            }

                            if (string.IsNullOrEmpty(fieldValue))
                            {
                                fieldValue = string.Empty;
                            }

                            values.Add(fieldValue);
                        }

                        fieldValue = fieldAttributes.FormatValues(values);
                    }
                    else
                    {
                        fieldValue = resultRow?.ValueAtIndex(fieldConfig.TabIndependentFieldIndex);
                        if (string.IsNullOrEmpty(fieldValue))
                        {
                            fieldValue = this.ValueForLinkFieldFromInitialValues(fieldConfig, initialValues);
                        }
                    }

                    UPMField field;
                    if (!isHidden && !string.IsNullOrEmpty(fieldValue))
                    {
                        field = new UPMStringField(fieldIdentifier);
                        ((UPMStringField)field).StringValue = fieldValue;
                    }
                    else
                    {
                        field = null;
                    }

                    if (field != null)
                    {
                        if (!fieldConfig.Attributes.NoLabel)
                        {
                            field.LabelText = fieldConfig.Label;
                        }

                        SetAttributesOnField(fieldAttributes, field);
                        fieldArray.Add(field);
                    }
                }
            }

            return(fieldArray);
        }
        /// <summary>
        /// The crm query for value.
        /// </summary>
        /// <param name="searchValue">
        /// The search value.
        /// </param>
        /// <param name="filters">
        /// The filters.
        /// </param>
        /// <param name="fullTextSearch">
        /// The full text search.
        /// </param>
        /// <returns>
        /// The <see cref="UPContainerMetaInfo"/>.
        /// </returns>
        public UPContainerMetaInfo CrmQueryForValue(
            string searchValue,
            List <UPConfigFilter> filters,
            bool fullTextSearch)
        {
            if (this.CombinedControl == null)
            {
                return(null);
            }

            if (this.SearchCRMFields == null && this.MultiSearchCRMFields == null &&
                this.SearchFieldControl?.Tabs?.Count > 0)
            {
                int tabCount = this.SearchFieldControl.Tabs.Count;

                List <UPCRMField> fieldArray      = null;
                List <UPCRMField> multiFieldArray = null;

                for (int i = 0; i < tabCount; i++)
                {
                    FieldControlTab tab = this.SearchFieldControl.TabAtIndex(i);
                    if (tab.Fields == null || tab.Fields.Count == 0)
                    {
                        continue;
                    }

                    if (string.Compare(tab.Type, @"MULTI", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        UPCRMField multiField = tab.FieldAtIndex(0).Field;

                        if (multiFieldArray == null)
                        {
                            multiFieldArray = new List <UPCRMField>();
                        }

                        multiFieldArray.Add(multiField);
                    }
                    else
                    {
                        if (fieldArray == null)
                        {
                            fieldArray = new List <UPCRMField>();
                        }

                        fieldArray.AddRange(tab.AllCRMFields());
                    }
                }

                this.SearchCRMFields      = fieldArray;
                this.MultiSearchCRMFields = multiFieldArray;
            }

            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
            UPContainerMetaInfo     container   = new UPContainerMetaInfo(this.CombinedControl);

            if (!string.IsNullOrEmpty(this.DetailActionSwitchFilterName))
            {
                this.DetailActionSwitchFilter = ConfigurationUnitStore.DefaultStore.FilterByName(this.DetailActionSwitchFilterName);

                if (this.DetailActionSwitchFilter != null)
                {
                    this.DetailActionSwitchFilter =
                        this.DetailActionSwitchFilter.FilterByApplyingValueDictionaryDefaults(
                            this.FilterParameter,
                            true);
                }

                if (this.DetailActionSwitchFilter != null)
                {
                    this.FilterBasedDecision = new UPCRMFilterBasedDecision(this.DetailActionSwitchFilter);
                }
            }

            container.ReplaceCaseSensitiveCharacters = this.ReplaceCaseSensitiveCharacters;

            List <UPCRMField> additionalFields = null;

            if (this.ExpandSettings != null)
            {
                Dictionary <string, UPCRMField> alternateExpandFields =
                    this.ExpandSettings.FieldsForAlternateExpands(true);
                List <UPCRMField> _additionalFields = this.AdditionalOutputFields != null
                                                         ? new List <UPCRMField>(this.AdditionalOutputFields)
                                                         : new List <UPCRMField>();

                if (alternateExpandFields != null)
                {
                    _additionalFields.AddRange(alternateExpandFields.Values.Where(field => container.ContainsField(field) == null));
                }

                additionalFields = _additionalFields;
            }
            else if (this.AdditionalOutputFields?.Count > 0)
            {
                additionalFields = this.AdditionalOutputFields;
            }

            if (additionalFields != null && additionalFields.Count > 0)
            {
                container.AddCrmFields(additionalFields);
            }

            var checkFilterFields = this.FilterBasedDecision?.FieldDictionary.Values.Select(x => x).ToList();

            if (checkFilterFields?.Count > 0)
            {
                container.AddCrmFields(checkFilterFields);
                this.FilterBasedDecision.UseCrmQuery(container);
            }

            if (this.ExpandSettings != null)
            {
                this.ExpandChecker = this.ExpandSettings.ExpandCheckerForCrmQuery(container);
            }

            if (!string.IsNullOrEmpty(this.LinkRecordIdentification))
            {
                container.SetLinkRecordIdentification(this.LinkRecordIdentification);
            }

            if (this.SearchFieldControl != null)
            {
                container.SetSearchConditionsFor(
                    searchValue,
                    this.SearchCRMFields,
                    this.MultiSearchCRMFields,
                    fullTextSearch);
            }
            else if (this.QuickSearchEntries != null)
            {
                if (!string.IsNullOrEmpty(searchValue))
                {
                    List <UPCRMField> crmFields = this.QuickSearchEntries.Select(entry => entry.CrmField).ToList();

                    container.SetSearchConditionsFor(searchValue, crmFields, fullTextSearch);
                }
            }

            if (!string.IsNullOrEmpty(this.SearchConfiguration?.FilterName))
            {
                UPConfigFilter filter = configStore.FilterByName(this.SearchConfiguration.FilterName);

                if (filter != null)
                {
                    filter = filter.FilterByApplyingDefaultReplacements();
                    filter = filter.FilterByApplyingValueDictionary(this.FilterParameter);
                    container.ApplyFilter(filter);
                }
            }

            if (this.FilterObject != null)
            {
                container.ApplyFilter(this.FilterObject);
            }
            else if (!string.IsNullOrEmpty(this.FilterName))
            {
                UPConfigFilter filter = configStore.FilterByName(this.FilterName);
                if (filter != null)
                {
                    filter = filter.FilterByApplyingDefaultReplacements();
                    filter = filter.FilterByApplyingValueDictionary(this.FilterParameter);
                    container.ApplyFilter(filter);
                }
            }

            if (filters != null)
            {
                foreach (UPConfigFilter filter in filters)
                {
                    if (this.FilterParameter != null)
                    {
                        container.ApplyFilterWithReplacementDictionary(filter, this.FilterParameter);
                    }
                    else
                    {
                        container.ApplyFilter(filter);
                    }
                }
            }

            return(container);
        }
        private void SetupSourceAndDestinationColumns(
            Dictionary <string, object> dict,
            IConfigurationUnitStore configStore,
            ref int nextColumn,
            UPSERowConfiguration defaultConfiguration,
            List <UPSEColumn> columnArray)
        {
            if (SerialEntry.ChildrenCount > 0)
            {
                var sourceChildFG = dict.ValueOrDefault("SourceChildFG") as string;
                var destChildFG   = dict.ValueOrDefault("DestChildFG") as string;
                if (!string.IsNullOrWhiteSpace(sourceChildFG) || !string.IsNullOrWhiteSpace(destChildFG))
                {
                    FieldControlTab sourceFieldTab = null, destFieldTab = null;
                    if (!string.IsNullOrWhiteSpace(sourceChildFG))
                    {
                        sourceFieldTab = configStore.FieldControlByNameFromGroup("List", sourceChildFG).TabAtIndex(0);
                    }

                    if (!string.IsNullOrWhiteSpace(destChildFG))
                    {
                        destFieldTab = configStore.FieldControlByNameFromGroup("Edit", destChildFG).TabAtIndex(0);
                    }

                    if (sourceFieldTab == null)
                    {
                        sourceFieldTab = SerialEntry.SourceChildFieldControl.TabAtIndex(0);
                    }

                    if (destFieldTab == null)
                    {
                        destFieldTab = SerialEntry.DestChildFieldControl.TabAtIndex(0);
                    }

                    var sourceChildFieldDictionary = new Dictionary <string, UPSEColumn>();
                    var destChildFieldDictionary   = new Dictionary <string, UPSEColumn>();
                    for (var i = nextColumn; i < defaultConfiguration.Columns.Count; i++)
                    {
                        var configurationColumn = defaultConfiguration.Columns[i];
                        if (configurationColumn is UPSESourceChildColumn column)
                        {
                            var colKey = $"{column.ChildIndex}_{column.CrmField.FieldIdentification}";
                            sourceChildFieldDictionary.SetObjectForKey(column, colKey);
                        }
                        else if (configurationColumn is UPSEDestinationChildColumn childColumn)
                        {
                            var colKey = $"{childColumn.ChildIndex}_{childColumn.CrmField.FieldIdentification}";
                            destChildFieldDictionary[colKey] = childColumn;
                        }
                        else
                        {
                            nextColumn = i;
                            break;
                        }
                    }

                    for (var j = 0; j < SerialEntry.ChildrenCount; j++)
                    {
                        var count = sourceFieldTab.NumberOfFields;
                        for (var i = 0; i < count; i++)
                        {
                            var configField = sourceFieldTab.FieldAtIndex(i);
                            var colKey      = $"{j}_{configField.Field.FieldIdentification}";
                            if (sourceChildFieldDictionary.ValueOrDefault(colKey) is UPSESourceChildColumn col)
                            {
                                columnArray.Add(new UPSESourceChildColumn(configField, col));
                            }
                        }

                        count = destFieldTab.NumberOfFields;
                        for (var i = 0; i < count; i++)
                        {
                            var configField = destFieldTab.FieldAtIndex(i);
                            var colKey      = $"{j}_{configField.Field.FieldIdentification}";
                            if (destChildFieldDictionary.ValueOrDefault(colKey) is UPSEDestinationChildColumn col)
                            {
                                columnArray.Add(new UPSEDestinationChildColumn(configField, col));
                            }
                        }
                    }
                }
                else
                {
                    for (var i = nextColumn; i < defaultConfiguration.Columns.Count; i++)
                    {
                        var column = defaultConfiguration.Columns[i];
                        if (!(column is UPSESourceChildColumn) && !(column is UPSEDestinationChildColumn))
                        {
                            nextColumn = i;
                            break;
                        }

                        columnArray.Add(column);
                    }
                }
            }
        }
        /// <summary>
        /// Creates the specified row.
        /// </summary>
        /// <param name="row">The row.</param>
        /// <param name="tabConfig">The tab configuration.</param>
        /// <returns></returns>
        public static UPGeoLocation Create(UPCRMResultRow row, FieldControlTab tabConfig)
        {
            try
            {
                string gpsXString = null, gpsYString = null, addressTitle = null;
                var    currentFieldIndex = 0;
                var    found             = false;
                var    numberOfFields    = tabConfig.NumberOfFields;
                var    address           = new StringBuilder();

                while (currentFieldIndex + 1 < numberOfFields)
                {
                    gpsXString = row.RawValueAtIndex(tabConfig.FieldAtIndex(currentFieldIndex++).TabIndependentFieldIndex);
                    gpsYString = row.RawValueAtIndex(tabConfig.FieldAtIndex(currentFieldIndex++).TabIndependentFieldIndex);

                    if (string.IsNullOrEmpty(gpsXString) || Convert.ToDecimal(gpsXString, System.Globalization.CultureInfo.InvariantCulture) == 0m || string.IsNullOrEmpty(gpsYString) || Convert.ToDecimal(gpsYString) == 0m)
                    {
                        gpsXString = gpsYString = string.Empty;
                    }
                    else
                    {
                        found = true;
                    }

                    if (currentFieldIndex < numberOfFields)
                    {
                        UPConfigFieldControlField addressNameField = tabConfig.FieldAtIndex(currentFieldIndex++);
                        int fieldCount = addressNameField.Attributes.FieldCount;
                        if (fieldCount <= 1)
                        {
                            addressTitle = row.ValueAtIndex(addressNameField.TabIndependentFieldIndex);
                        }
                        else
                        {
                            addressTitle       = FormattedValueForResultRowFieldControlTabFieldIndex(row, tabConfig, currentFieldIndex + 1);
                            currentFieldIndex += fieldCount - 1;
                        }
                    }

                    if (currentFieldIndex < numberOfFields)
                    {
                        UPConfigFieldControlField addressField = tabConfig.FieldAtIndex(currentFieldIndex++);
                        int fieldCount = addressField.Attributes.FieldCount;
                        if (fieldCount <= 1)
                        {
                            address.Append(row.ValueAtIndex(addressField.TabIndependentFieldIndex));
                        }
                        else
                        {
                            address.Append(FormattedValueForResultRowFieldControlTabFieldIndex(row, tabConfig, currentFieldIndex - 1));
                            currentFieldIndex += fieldCount - 1;
                        }

                        if (address.Length > 1)
                        {
                            found = true;
                            break;
                        }
                    }
                }

                if (found)
                {
                    while (currentFieldIndex + 1 < numberOfFields)
                    {
                        if (currentFieldIndex < numberOfFields)
                        {
                            UPConfigFieldControlField addressField = tabConfig.FieldAtIndex(currentFieldIndex++);
                            int fieldCount = addressField.Attributes.FieldCount;
                            if (fieldCount <= 1)
                            {
                                address.Append($" , {row.ValueAtIndex(addressField.TabIndependentFieldIndex)}");
                            }
                            else
                            {
                                address.Append($" , {FormattedValueForResultRowFieldControlTabFieldIndex(row, tabConfig, currentFieldIndex - 1)}");
                                currentFieldIndex += fieldCount - 1;
                            }
                        }
                    }

                    return(new UPGeoLocation(gpsXString, gpsYString, addressTitle, address.ToString()));
                }
            }
            catch (Exception error)
            {
                SimpleIoc.Default.GetInstance <ILogger>().LogError(error);
            }

            return(null);
        }