示例#1
0
        private UPMCharacteristicsPage PageForOverview(Page page)
        {
            UPMCharacteristicsPage newPage = (UPMCharacteristicsPage)this.InstantiatePage();

            newPage.IsReadOnly = true;
            foreach (UPMCharacteristicsItemGroup group in page.Children)
            {
                UPMCharacteristicsItemGroup newGroup = new UPMCharacteristicsItemGroup(group.Identifier);
                newGroup.GroupNameField             = new UPMStringField(group.GroupNameField.Identifier);
                newGroup.GroupNameField.StringValue = group.GroupNameField.StringValue;
                newGroup.ShowExpanded = true;
                newGroup.GroupType    = group.GroupType;

                foreach (UPMCharacteristicsItem item in group.Children)
                {
                    if (item.SelectedField.BoolValue)
                    {
                        UPMCharacteristicsItem newItem = new UPMCharacteristicsItem(item.Identifier)
                        {
                            ItemNameField = new UPMStringField(item.ItemNameField.Identifier),
                            SelectedField = new UPMBooleanEditField(item.SelectedField.Identifier)
                        };
                        newItem.ItemNameField.StringValue = item.ItemNameField.StringValue;
                        newItem.SelectedField.BoolValue   = true;

                        List <UPMField> additionalFields = new List <UPMField>();
                        foreach (UPMEditField editField in item.EditFields)
                        {
                            UPMField newField = new UPMStringField(editField.Identifier);
                            newField.LabelText = editField.LabelText;
                            if (!editField.Empty)
                            {
                                newField.FieldValue = editField.StringDisplayValue;
                                additionalFields.Add(newField);
                            }
                        }

                        newItem.EditFields = additionalFields;
                        newGroup.AddChild(newItem);
                    }
                }

                if (newGroup.Children.Count > 0)
                {
                    newPage.AddChild(newGroup);
                }
            }

            return(newPage);
        }
        private UPMGroup CreateGroup(string _recordIdentification)
        {
            UPMCharacteristicsGroup charakteristicsGroup = new UPMCharacteristicsGroup(StringIdentifier.IdentifierWithStringId(this.Characteristics.RecordIdentification));

            charakteristicsGroup.LabelText = this.TabLabel;
            int groupId = 0;
            int itemId  = 0;

            if (this.Characteristics.Groups != null)
            {
                foreach (UPCharacteristicsGroup crmCharacteristicsGroup in this.Characteristics.Groups)
                {
                    FieldIdentifier             fieldIdentifier          = FieldIdentifier.IdentifierWithRecordIdentificationFieldId(_recordIdentification, this.Characteristics.DestinationGroupField.Identification);
                    UPMCharacteristicsItemGroup characteristicsItemGroup = new UPMCharacteristicsItemGroup(StringIdentifier.IdentifierWithStringId($"Group{groupId}_{itemId}"));
                    characteristicsItemGroup.GroupNameField = new UPMStringField(fieldIdentifier);
                    SetAttributesOnField(this.Characteristics.DestinationGroupField.Attributes, characteristicsItemGroup.GroupNameField);
                    characteristicsItemGroup.GroupNameField.StringValue = crmCharacteristicsGroup.Label;
                    charakteristicsGroup.AddChild(characteristicsItemGroup);
                    foreach (UPCharacteristicsItem crmCharacteristicsItem in crmCharacteristicsGroup.Items)
                    {
                        fieldIdentifier = FieldIdentifier.IdentifierWithRecordIdentificationFieldId(_recordIdentification, this.Characteristics.DestinationItemField.Identification);
                        UPMCharacteristicsItem characteristicsItem = new UPMCharacteristicsItem(StringIdentifier.IdentifierWithStringId($"Item{groupId}_{itemId}"));
                        characteristicsItem.ItemNameField = new UPMStringField(fieldIdentifier);
                        SetAttributesOnField(this.Characteristics.DestinationItemField.Attributes, characteristicsItem.ItemNameField);
                        characteristicsItem.ItemNameField.StringValue = crmCharacteristicsItem.Label;
                        characteristicsItemGroup.AddChild(characteristicsItem);
                        List <UPMField> additionalFields = new List <UPMField>();
                        if (crmCharacteristicsItem.ShowAdditionalFields)
                        {
                            int i = 0;
                            foreach (UPConfigFieldControlField crmAdditionalField in crmCharacteristicsItem.AdditionalFields)
                            {
                                fieldIdentifier = FieldIdentifier.IdentifierWithRecordIdentificationFieldId(_recordIdentification, crmAdditionalField.Identification);
                                UPMStringField additionalField = new UPMStringField(fieldIdentifier);
                                if (!string.IsNullOrEmpty(crmCharacteristicsItem.Values[i]))
                                {
                                    SetAttributesOnField(crmAdditionalField.Attributes, additionalField);
                                    FieldAttributes fieldAttributes = crmAdditionalField.Attributes;
                                    if (!fieldAttributes.NoLabel)
                                    {
                                        additionalField.LabelText = crmAdditionalField.Field.Label;
                                    }

                                    additionalField.StringValue = crmCharacteristicsItem.Values[i];
                                    if (!string.IsNullOrEmpty(additionalField.StringValue))
                                    {
                                        additionalFields.Add(additionalField);
                                    }
                                }

                                i++;
                            }
                        }

                        characteristicsItem.EditFields = additionalFields;
                        itemId++;
                    }

                    groupId++;
                }
            }

            return(charakteristicsGroup);
        }
示例#3
0
        private void FillPage()
        {
            UPMCharacteristicsPage newPage = (UPMCharacteristicsPage)this.InstantiatePage();

            newPage.IsReadOnly = this.IsReadOnly;
            foreach (UPCharacteristicsGroup crmGroup in this.Characteristics.Groups)
            {
                UPMCharacteristicsItemGroup group = new UPMCharacteristicsItemGroup(StringIdentifier.IdentifierWithStringId(crmGroup.CatalogValue))
                {
                    GroupNameField = new UPMStringField(StringIdentifier.IdentifierWithStringId(crmGroup.Label))
                    {
                        StringValue = crmGroup.Label
                    },
                    ShowExpanded = crmGroup.ShowExpanded,
                    GroupType    = crmGroup.SingleSelection ? UPMCharacteristicsItemGroupType.SingleSelect : UPMCharacteristicsItemGroupType.MultiSelect
                };

                foreach (UPCharacteristicsItem crmItem in crmGroup.Items)
                {
                    UPMCharacteristicsItem item = new UPMCharacteristicsItem(StringIdentifier.IdentifierWithStringId(crmItem.CatalogValue))
                    {
                        ItemNameField = new UPMStringField(StringIdentifier.IdentifierWithStringId(crmItem.Label))
                        {
                            StringValue = crmItem.Label
                        },
                        SelectedField = new UPMBooleanEditField(StringIdentifier.IdentifierWithStringId(crmItem.Label))
                        {
                            BoolValue = crmItem.Record != null
                        }
                    };
                    group.AddChild(item);

                    List <UPMField> additionalEditFields = new List <UPMField>();
                    if (crmItem.ShowAdditionalFields)
                    {
                        for (int additionalFieldIndex = 0; additionalFieldIndex < crmItem.AdditionalFields.Count; additionalFieldIndex++)
                        {
                            UPConfigFieldControlField configField     = crmItem.AdditionalFields[additionalFieldIndex];
                            FieldIdentifier           fieldIdentifier = FieldIdentifier.IdentifierWithRecordIdentificationFieldId(this.CharacteristicsRootRecordIdentification, configField.Identification);
                            UPEditFieldContext        fieldContext    = UPEditFieldContext.FieldContextFor(configField, fieldIdentifier, crmItem.Values[additionalFieldIndex], (List <UPEditFieldContext>)null);
                            if (fieldContext != null)
                            {
                                additionalEditFields.Add(fieldContext.EditField);
                                this.editPageContext.EditFields.SetObjectForKey(fieldContext, $"{configField.Identification}-{crmItem.CatalogValue}-{crmGroup.CatalogValue}");
                            }
                        }
                    }

                    item.EditFields = additionalEditFields;
                }

                if (group.Children.Count > 0)
                {
                    newPage.AddChild(group);
                }
            }

            if (this.IsReadOnly)
            {
                newPage = this.PageForOverview(newPage);
            }

            ITopLevelElement oldPage = this.TopLevelElement;

            this.TopLevelElement = newPage;
            newPage.Invalid      = false;
            this.InformAboutDidChangeTopLevelElement(oldPage, newPage, null, null);
        }