コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UPSerialEntryParentInfoPanel"/> class.
        /// </summary>
        /// <param name="fieldControl">The field control.</param>
        /// <param name="resultRow">The result row.</param>
        public UPSerialEntryParentInfoPanel(FieldControl fieldControl, UPCRMResultRow resultRow)
        {
            int tabs = fieldControl.NumberOfTabs;
            List <UPSerialEntryParentInfoPanelCell> cells = new List <UPSerialEntryParentInfoPanelCell>();

            for (int index = 0; index < tabs; index++)
            {
                FieldControlTab tabControl = fieldControl.TabAtIndex(index);
                if (tabControl.NumberOfFields > 0 && string.IsNullOrEmpty(tabControl.Type))
                {
                    UPSerialEntryParentInfoPanelCell cell = new UPSerialEntryParentInfoPanelCell(tabControl, resultRow);
                    string ownImageName = fieldControl.ValueForAttribute($"ParentInfoImage{index}") ??
                                          tabControl.ValueForAttribute("ParentInfoImage");

                    if (!string.IsNullOrEmpty(ownImageName))
                    {
                        cell.ImageName = ownImageName;
                    }

                    int minFields = !string.IsNullOrEmpty(tabControl.Label) ? 1 : 0;
                    if (cell.FieldValues.Count > minFields)
                    {
                        cells.Add(cell);
                    }
                }
            }

            this.Cells = cells;
        }
        /// <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");
            }
        }
コード例 #4
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);
        }
コード例 #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);
        }
コード例 #6
0
        /// <summary>
        /// Loads the element for calendar group field control.
        /// </summary>
        /// <param name="_origDetailGroup">The original detail group.</param>
        /// <param name="_sourceFieldControl">The source field control.</param>
        public void LoadElementForCalendarGroupFieldControl(UPMCalendarPopoverGroup _origDetailGroup, FieldControl _sourceFieldControl)
        {
            this.sourceFieldControl = _sourceFieldControl;
            FieldControlTab tabConfig = _sourceFieldControl.TabAtIndex(0);

            this.origDetailGroup           = _origDetailGroup;
            this.origDetailGroup.LabelText = tabConfig.Label;

            if (this.sourceFieldControl != null)
            {
                this.LoadSourceRecordRecordId(this.sourceFieldControl, ((RecordIdentifier)this.origDetailGroup.Identifier).RecordIdentification);
            }
        }
        private void AddRecordsToGroup(
            UPMRepeatableEditGroup repeatableEditGroup,
            int count,
            UPCRMResult childResult,
            Dictionary <string, UPCRMRecord> changedRecords,
            FieldControlTab childFieldControlTab)
        {
            for (var i = 0; i < count; i++)
            {
                var childRow         = (UPCRMResultRow)childResult.ResultRowAtIndex(i);
                var childEditContext = new UPChildEditContext(childRow, this.NextPostfix);
                var changedRecord    = changedRecords.ValueOrDefault(childRow.RootRecordId);
                var initialRecords   = changedRecord != null ? new List <UPCRMRecord> {
                    changedRecord
                } : null;

                var editFieldContextArray = this.EditContextsForResultRow(childRow, childFieldControlTab, childEditContext.EditFieldContext, null, childEditContext.FieldLabelPostfix, initialRecords);
                var editFieldCount        = editFieldContextArray.Count;
                if (editFieldCount > 0)
                {
                    var standardGroup = new UPMStandardGroup(new RecordIdentifier(childRow.RootRecordIdentification))
                    {
                        Deletable = this.DeleteRecordEnabled
                    };
                    childEditContext.Group = standardGroup;
                    this.AddChildRecordContext(childEditContext);
                    for (var j = 0; j < editFieldCount; j++)
                    {
                        var field = editFieldContextArray[j];
                        AddFieldToGroup(standardGroup, field, childEditContext);
                    }

                    childEditContext.HandleDependentFields();
                    repeatableEditGroup.AddChild(standardGroup);
                }
            }
        }
        /// <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);
        }
コード例 #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UPCRMListFormatter"/> class.
        /// </summary>
        /// <param name="fieldControlTab">
        /// The field control tab.
        /// </param>
        /// <param name="fieldCount">
        /// The field count.
        /// </param>
        public UPCRMListFormatter(FieldControlTab fieldControlTab, int fieldCount)
        {
            List <UPCRMListFormatterPosition> positionArray = null;
            var childFieldCount = 0;
            UPCRMListFormatterPosition currentPosition = null;

            this.DisplayNo = ServerSession.CurrentSession.UpTextForNO();

            foreach (var field in fieldControlTab.Fields ?? new List <UPConfigFieldControlField>())
            {
                if (fieldCount-- == 0)
                {
                    break;
                }

                if (childFieldCount > 0)
                {
                    currentPosition?.AddField(field);
                    --childFieldCount;

                    // PVCS 87654 Kombinierte Personendarstellung (3 Felder) in GRID View
                    // wenn das letzte Feld einen colSpan hat, so erhöht sich der childFieldCount
                    if (childFieldCount == 0)
                    {
                        childFieldCount = field.Attributes.FieldCount - 1;
                    }
                }
                else
                {
                    if (field.TargetFieldNumber > 0 && field.TargetFieldNumber < 7)
                    {
                        if (positionArray == null)
                        {
                            positionArray = new List <UPCRMListFormatterPosition>();
                        }

                        int positionIndex = field.TargetFieldNumber - 1;
                        if (positionArray.Count <= positionIndex)
                        {
                            while (positionArray.Count < positionIndex)
                            {
                                positionArray.Add(null);
                            }

                            currentPosition = new UPCRMListFormatterPosition {
                                ListFormatter = this
                            };
                            positionArray.Add(currentPosition);
                        }
                        else if (positionArray[positionIndex] == null)
                        {
                            currentPosition = new UPCRMListFormatterPosition {
                                ListFormatter = this
                            };
                            positionArray[positionIndex] = currentPosition;
                        }
                        else
                        {
                            currentPosition = positionArray[positionIndex];
                        }
                    }
                    else
                    {
                        currentPosition = new UPCRMListFormatterPosition {
                            ListFormatter = this
                        };
                        if (positionArray == null)
                        {
                            positionArray = new List <UPCRMListFormatterPosition> {
                                currentPosition
                            };
                        }
                        else
                        {
                            positionArray.Add(currentPosition);
                        }
                    }

                    childFieldCount = field.Attributes.FieldCount - 1;
                    currentPosition.AddField(field);
                }
            }

            this._positions = positionArray;
            var configStore = ConfigurationUnitStore.DefaultStore;
            var show0       = configStore.ConfigValueIsSet("Format.Show0InLists");
            var show0Float  =
                configStore.ConfigValueIsSet(
                    configStore.WebConfigValueByName("Format.Show0InListsForFloat") != null
                        ? "Format.Show0InListsForFloat"
                        : "Format:Show0InListsForFloat");

            if (show0)
            {
                this._formatOptions |= UPFormatOption.Show0;
            }

            if (show0Float)
            {
                this._formatOptions |= UPFormatOption.Show0Float;
            }

            if (this._removeLineBreaks)
            {
                this._formatOptions |= UPFormatOption.DontRemoveLineBreak;
            }
        }
コード例 #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UPCRMListFormatter"/> class.
 /// </summary>
 /// <param name="fieldControlTab">
 /// The field control tab.
 /// </param>
 public UPCRMListFormatter(FieldControlTab fieldControlTab)
     : this(fieldControlTab, fieldControlTab?.Fields?.Count ?? 0)
 {
 }
コード例 #11
0
        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);
        }
コード例 #12
0
        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>
        /// Initializes a new instance of the <see cref="ChildListGroupModelController"/> class.
        /// </summary>
        /// <param name="fieldControl">The field control.</param>
        /// <param name="tabIndex">Index of the tab.</param>
        /// <param name="theDelegate">The delegate.</param>
        public ChildListGroupModelController(FieldControl fieldControl, int tabIndex, IGroupModelControllerDelegate theDelegate)
            : base(fieldControl, tabIndex, theDelegate)
        {
            string[] typeParts = this.TabConfig.Type.Split('_');
            string   searchAndListConfigurationName;
            int      linkId = -1;

            this.MaxResults = 0;
            bool swipeDetailRecords = ConfigurationUnitStore.DefaultStore.ConfigValueIsSetDefaultValue("View.RecordSwipeEnabledDefault", true);

            if (typeParts.Length > 1)
            {
                searchAndListConfigurationName = typeParts[1];
                string[] configParts = searchAndListConfigurationName.Split('#');
                if (configParts.Length > 1)
                {
                    searchAndListConfigurationName = configParts[0];
                    linkId = configParts[1].ToInt();
                }

                if (typeParts.Length > 2)
                {
                    this.MaxResults = typeParts[2].ToInt();
                }

                if (typeParts.Length > 3)
                {
                    if (swipeDetailRecords)
                    {
                        swipeDetailRecords = typeParts[3] != "NoSwipe";
                    }
                    else
                    {
                        swipeDetailRecords = typeParts[3] == "Swipe";
                    }
                }
            }
            else if (this.TabConfig.NumberOfFields > 0)
            {
                UPConfigFieldControlField field = this.TabConfig.FieldAtIndex(0);
                searchAndListConfigurationName = field.InfoAreaId;
                linkId = field.LinkId;
            }
            else
            {
                return;
            }

            FieldControlTab tabConfig = fieldControl.TabAtIndex(tabIndex);

            this.ListStyle = tabConfig.ValueForAttribute("listStyle");
            if (string.IsNullOrEmpty(this.ListStyle))
            {
                this.ListStyle = fieldControl.ValueForAttribute($"listStyle{tabIndex + 1}");
            }

            string disablePagingString = tabConfig.ValueForAttribute("disablePaging");

            if (string.IsNullOrEmpty(disablePagingString))
            {
                disablePagingString = fieldControl.ValueForAttribute($"disablePaging{tabIndex + 1}");
            }

            if (!string.IsNullOrEmpty(disablePagingString))
            {
                this.DisablePaging = disablePagingString.CompareWithOptions("true") || disablePagingString.CompareWithOptions("1");
            }
            else
            {
                this.DisablePaging = false;
            }

            this.ChildController = this.CreateChildControllerLinkIdSearchAndListConfigurationName(swipeDetailRecords, linkId, searchAndListConfigurationName);
            this.ChildController.ExplicitLabel = this.TabLabel;
            this.ChildController.RootTabIndex  = this.RootTabIndex;
            if (this.MaxResults > 0)
            {
                this.ChildController.MaxResults = this.MaxResults;
            }
        }
        private UPMStandardGroup CreateNewGroupRecordAsNew(Dictionary <string, object> parentInitialValues, UPCRMRecord record, bool asNew)
        {
            UPContainerMetaInfo metaInfo = new UPContainerMetaInfo(this.ChildFieldControl);
            UPCRMResult         result   = !string.IsNullOrEmpty(record?.RecordId) ? metaInfo.NewRecordWithRecordId(record.RecordId) : metaInfo.NewRecord();

            UPCRMResultRow     childRow         = (UPCRMResultRow)result.ResultRowAtIndex(0);
            UPChildEditContext childEditContext = new UPChildEditContext(childRow, this.NextPostfix);

            if (asNew)
            {
                childEditContext.SetAsNew();
            }

            if (record != null)
            {
                childEditContext.AddChangedLinksFromRecordParentLink(record, null);
            }

            FieldControlTab childFieldControlTab = this.ChildFieldControl.TabAtIndex(0);

            this.combinedInitialValues = null;
            if (this.initialValues != null)
            {
                if (parentInitialValues != null)
                {
                    Dictionary <string, object> combined = new Dictionary <string, object>(this.initialValues);
                    foreach (var item in parentInitialValues)
                    {
                        combined[item.Key] = item.Value;
                    }

                    this.combinedInitialValues = combined;
                }
                else
                {
                    this.combinedInitialValues = this.initialValues;
                }
            }
            else
            {
                this.combinedInitialValues = parentInitialValues;
            }

            List <UPCRMRecord> initialRecords = record != null ? new List <UPCRMRecord> {
                record
            } : null;

            List <object> editFieldContextArray = this.EditContextsFor(childRow, childFieldControlTab,
                                                                       childEditContext.EditFieldContext, this.combinedInitialValues, initialRecords);
            int editFieldCount = editFieldContextArray.Count;

            if (editFieldCount > 0)
            {
                UPMStandardGroup group = new UPMStandardGroup(new RecordIdentifier(childRow.RootRecordIdentification));
                group.Deletable        = true;
                childEditContext.Group = group;
                this.AddChildRecordContext(childEditContext);
                for (int j = 0; j < editFieldCount; j++)
                {
                    UPEditFieldContext editFieldContext = editFieldContextArray[j] as UPEditFieldContext;
                    if (editFieldContext != null)
                    {
                        editFieldContext.ChildEditContext  = childEditContext;
                        editFieldContext.FieldLabelPostfix = childEditContext.FieldLabelPostfix;
                        List <UPMEditField> editFields = editFieldContext.EditFields;
                        if (editFields.Count > 0)
                        {
                            foreach (UPMEditField editField in editFields)
                            {
                                editField.EditFieldsContext = childEditContext;
                                group.AddField(editField);
                            }
                        }
                        else
                        {
                            UPMField field = editFieldContext.Field;
                            if (field != null)
                            {
                                group.AddField(field);
                            }
                        }
                    }
                    else
                    {
                        group.AddField((UPMField)editFieldContextArray[j]);
                    }
                }

                childEditContext.HandleDependentFields();
                return(group);
            }

            return(null);
        }
コード例 #15
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);
        }
コード例 #16
0
 /// <summary>
 /// Edits the contexts for.
 /// </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="initialRecords">The initial records.</param>
 /// <returns></returns>
 public List <object> EditContextsFor(UPCRMResultRow resultRow, FieldControlTab tabConfig,
                                      Dictionary <string, UPEditFieldContext> editFieldDictionary, Dictionary <string, object> initialValues, List <UPCRMRecord> initialRecords)
 {
     return(this.EditContextsForResultRow(resultRow, tabConfig, editFieldDictionary, initialValues, null, initialRecords));
 }
コード例 #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UPCRMListFormatter"/> class.
 /// </summary>
 /// <param name="fieldControlTab">
 /// The field control tab.
 /// </param>
 /// <param name="fieldCount">
 /// The field count.
 /// </param>
 /// <param name="removeLineBreaks">
 /// if set to <c>true</c> [_remove line breaks].
 /// </param>
 public UPCRMListFormatter(FieldControlTab fieldControlTab, int fieldCount, bool removeLineBreaks)
     : this(fieldControlTab, fieldCount)
 {
     this._removeLineBreaks = removeLineBreaks;
 }
コード例 #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UPCRMListFormatter"/> class.
 /// </summary>
 /// <param name="fieldControlTab">
 /// The field control tab.
 /// </param>
 /// <param name="removeLineBreaks">
 /// The remove Line Breaks.
 /// </param>
 public UPCRMListFormatter(FieldControlTab fieldControlTab, bool removeLineBreaks)
     : this(fieldControlTab, fieldControlTab?.Fields?.Count ?? 0, removeLineBreaks)
 {
 }
コード例 #19
0
        /// <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);
        }