コード例 #1
0
        /// <summary>
        /// Returns changed records.
        /// </summary>
        /// <returns></returns>
        public override List <UPCRMRecord> ChangedRecords()
        {
            if (this.IsReadOnly)
            {
                return(null);
            }

            UPMCharacteristicsPage characteristicsPage = (UPMCharacteristicsPage)this.Page;

            foreach (UPMCharacteristicsItemGroup group in characteristicsPage.Children)
            {
                foreach (UPMCharacteristicsItem item in group.Children)
                {
                    UPCharacteristicsItem crmItem = this.FindCharacteristicItemWithGroupIdentifierItemIdentifier(group.Identifier, item.Identifier);
                    bool updateEditFields         = true;
                    if (item.SelectedField.Changed)
                    {
                        if (crmItem != null)
                        {
                            if (item.SelectedField.BoolValue)
                            {
                                crmItem.MarkItemAsSet();
                            }
                            else
                            {
                                crmItem.MarkItemAsUnset();
                                updateEditFields = false;
                            }
                        }
                    }

                    if (updateEditFields)
                    {
                        for (int editFieldIndex = 0; editFieldIndex < item.EditFields.Count; editFieldIndex++)
                        {
                            UPMEditField field = item.EditFields[editFieldIndex] as UPMEditField;
                            if (field != null && field.Changed)
                            {
                                List <UPEditFieldContext> fieldContextList = this.editPageContext.EditFields.Values.ToList();
                                foreach (UPEditFieldContext fieldContext in fieldContextList)
                                {
                                    if (fieldContext.EditField == field)
                                    {
                                        crmItem?.SetValueForAdditionalFieldPosition(fieldContext.Value, editFieldIndex);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(this.Characteristics?.ChangedRecords());
        }
コード例 #2
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);
        }
コード例 #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);
        }