Exemplo n.º 1
0
        public void onBeforeWriteDesignNode(CswNbtObjClassDesignNodeTypeProp DesignNTPNode)
        {
            // Copy value of 'Add To Template' to the Template
            CswNbtNodePropText         TemplateProp      = DesignNTPNode.AttributeProperty[AttributeName.Template].AsText;
            CswNbtNodePropRelationship AddToTemplateProp = DesignNTPNode.AttributeProperty[AttributeName.AddToTemplate].AsRelationship;

            if (CswTools.IsPrimaryKey(AddToTemplateProp.RelatedNodeId))
            {
                CswNbtObjClassDesignNodeTypeProp SelectedProp = _CswNbtFieldResources.CswNbtResources.Nodes[AddToTemplateProp.RelatedNodeId];
                if (null != SelectedProp)
                {
                    string newTemplate = TemplateProp.Text;
                    if (false == string.IsNullOrEmpty(newTemplate))
                    {
                        newTemplate += " ";
                    }
                    newTemplate      += CswNbtMetaData.MakeTemplateEntry(SelectedProp.RelationalNodeTypeProp.FirstPropVersionId.ToString());
                    TemplateProp.Text = newTemplate;

                    // Clear the selected value
                    AddToTemplateProp.RelatedNodeId  = null;
                    AddToTemplateProp.CachedNodeName = string.Empty;
                    AddToTemplateProp.PendingUpdate  = false;
                } // if( null != SelectedProp )
            }     // if( CswTools.IsPrimaryKey( AddToTemplateProp.RelatedNodeId ) )
        }
        public void onSetFk(CswNbtObjClassDesignNodeTypeProp DesignNTPNode)
        {
            Collection <CswNbtFieldTypeAttribute> Attributes = getAttributes();

            CswNbtFieldTypeAttribute FkTypeAttr        = Attributes.FirstOrDefault(a => a.Column == CswEnumNbtPropertyAttributeColumn.Fktype);
            CswNbtFieldTypeAttribute FkValueAttr       = Attributes.FirstOrDefault(a => a.Column == CswEnumNbtPropertyAttributeColumn.Fkvalue);
            CswNbtFieldTypeAttribute ValuePropTypeAttr = Attributes.FirstOrDefault(a => a.Column == CswEnumNbtPropertyAttributeColumn.Valueproptype);
            CswNbtFieldTypeAttribute ValuePropIdAttr   = Attributes.FirstOrDefault(a => a.Column == CswEnumNbtPropertyAttributeColumn.Valuepropid);

            if (DesignNTPNode.AttributeProperty.ContainsKey(FkTypeAttr.Name))
            {
                CswNbtNodePropText FkTypeProp        = DesignNTPNode.AttributeProperty[FkTypeAttr.Name].AsText;
                CswNbtNodePropList FkValueProp       = DesignNTPNode.AttributeProperty[FkValueAttr.Name].AsList;
                CswNbtNodePropText ValuePropTypeProp = DesignNTPNode.AttributeProperty[ValuePropTypeAttr.Name].AsText;
                CswNbtNodePropList ValuePropIdProp   = DesignNTPNode.AttributeProperty[ValuePropIdAttr.Name].AsList;

                if (FkTypeProp.wasSubFieldModified(CswNbtFieldTypeRuleList.SubFieldName.Value) ||
                    FkValueProp.wasSubFieldModified(CswNbtFieldTypeRuleRelationship.SubFieldName.NodeID) ||
                    ValuePropTypeProp.wasSubFieldModified(CswNbtFieldTypeRuleList.SubFieldName.Value) ||
                    ValuePropIdProp.wasSubFieldModified(CswNbtFieldTypeRuleRelationship.SubFieldName.NodeID))
                {
                    //We're changing the relationship
                    if (_isInvalidFkTarget(FkTypeProp.Text,
                                           CswConvert.ToInt32(FkValueProp.Value),
                                           ValuePropTypeProp.Text,
                                           CswConvert.ToInt32(ValuePropIdProp.Value)))
                    {
                        ValuePropTypeProp.Text = "";
                        ValuePropIdProp.Value  = "";
                    }
                }
            }
        }
        public void onBeforeWriteDesignNode(CswNbtObjClassDesignNodeTypeProp DesignNTPNode)
        {
            // Set values for FKType and RelatedPropType
            CswNbtNodePropText FKTypeWrapper       = DesignNTPNode.AttributeProperty[AttributeName.FKType].AsText;
            CswNbtNodePropList RelationshipWrapper = DesignNTPNode.AttributeProperty[AttributeName.Relationship].AsList;

            if (false == FKTypeWrapper.wasAnySubFieldModified(false))
            {
                if (false == RelationshipWrapper.Empty)
                {
                    if (RelationshipWrapper.Text.EndsWith(CswNbtObjClassDesignNodeTypeProp.PropRefValue_OCP_Suffix))
                    {
                        FKTypeWrapper.Text = CswEnumNbtViewPropIdType.ObjectClassPropId.ToString();
                    }
                    else
                    {
                        FKTypeWrapper.Text = CswEnumNbtViewPropIdType.NodeTypePropId.ToString();
                    }
                }
                else
                {
                    FKTypeWrapper.Text = string.Empty;
                }
            }
            CswNbtNodePropText RelatedPropTypeWrapper = DesignNTPNode.AttributeProperty[AttributeName.RelatedPropType].AsText;
            CswNbtNodePropList RelatedPropWrapper     = DesignNTPNode.AttributeProperty[AttributeName.RelatedProperty].AsList;

            if (false == RelatedPropTypeWrapper.wasAnySubFieldModified(false))
            {
                if (false == RelatedPropWrapper.Empty)
                {
                    if (RelatedPropWrapper.Text.EndsWith(CswNbtObjClassDesignNodeTypeProp.PropRefValue_OCP_Suffix))
                    {
                        RelatedPropTypeWrapper.Text = CswEnumNbtViewPropIdType.ObjectClassPropId.ToString();
                    }
                    else
                    {
                        RelatedPropTypeWrapper.Text = CswEnumNbtViewPropIdType.NodeTypePropId.ToString();
                    }
                }
                else
                {
                    RelatedPropTypeWrapper.Text = string.Empty;
                }
            }
        }
        public void onBeforeWriteDesignNode(CswNbtObjClassDesignNodeTypeProp DesignNTPNode)
        {
            CswNbtNodePropText OptionsProp = DesignNTPNode.AttributeProperty[AttributeName.Options].AsText;
            CswDelimitedString ListOptions = new CswDelimitedString(',');

            ListOptions.FromString(OptionsProp.Text.Trim());
            List <string> ValidOptions = new List <string>();

            for (int i = 0; i < ListOptions.Count; i++)
            {
                if (ValidOptions.Contains(ListOptions[i]))
                {
                    throw new CswDniException(CswEnumErrorType.Warning, "All options must be unique", "Duplicate option: " + ListOptions[i]);
                }
                else
                {
                    ValidOptions.Add(ListOptions[i]);
                }
            }
        }