Esempio 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);

            if (DesignNTPNode.AttributeProperty.ContainsKey(FkTypeAttr.Name))
            {
                CswNbtNodePropWrapper FkTypeProp = DesignNTPNode.AttributeProperty[FkTypeAttr.Name];
                if (null != FkTypeProp && FkTypeProp.wasAnySubFieldModified(false))
                {
                    CswNbtNodePropMetaDataList FkProp = FkTypeProp.AsMetaDataList;
                    CswNbtViewId ViewId = DesignNTPNode.AttributeProperty[AttributeName.UnitView].AsViewReference.ViewId;
                    CswNbtView   View   = _CswNbtFieldResources.CswNbtResources.ViewSelect.restoreView(ViewId);
                    if (CswEnumNbtViewRelatedIdType.Unknown != FkProp.Type && Int32.MinValue != FkProp.Id)
                    {
                        //We have valid values that are different that what is currently set
                        CswNbtFieldTypeRuleDefaultImpl.setDefaultView(_CswNbtFieldResources.CswNbtResources.MetaData, DesignNTPNode, View, FkProp.Type, FkProp.Id, false);
                    }
                    else
                    {
                        //Make sure a default view is set
                        CswEnumNbtViewRelatedIdType TargetType = DesignNTPNode.AttributeProperty[AttributeName.UnitTarget].AsMetaDataList.Type;
                        Int32 TargetId = DesignNTPNode.AttributeProperty[AttributeName.UnitTarget].AsMetaDataList.Id;
                        if (CswEnumNbtViewRelatedIdType.Unknown != TargetType && Int32.MinValue != TargetId)
                        {
                            CswNbtFieldTypeRuleDefaultImpl.setDefaultView(_CswNbtFieldResources.CswNbtResources.MetaData, DesignNTPNode, View, TargetType, TargetId, true);
                        }
                    }
                }
            } // if( DesignNTPNode.AttributeProperty.ContainsKey( FkTypeAttr.Name ) )
        }     // onSetFk()
        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  = "";
                    }
                }
            }
        }
        } // getPropsNotInLayout()

        public Collection <CswNbtObjClassDesignNodeTypeProp> getPropNodesInLayout(Int32 NodeTypeId, Int32 TabId, CswEnumNbtLayoutType LayoutType, bool NumberedOnly = false, CswDateTime Date = null)
        {
            Collection <CswNbtObjClassDesignNodeTypeProp> ret = new Collection <CswNbtObjClassDesignNodeTypeProp>();
            CswTableSelect LayoutSelect = _CswNbtMetaDataResources.CswNbtResources.makeCswTableSelect("getPropNodesInLayout_select", "nodetype_layout");
            string         WhereClause  = "where nodetypeid = " + NodeTypeId.ToString() +
                                          "  and nodetypetabsetid = " + TabId.ToString() +
                                          "  and layouttype = '" + LayoutType.ToString() + "'";

            if (NumberedOnly)
            {
                WhereClause += " and nodetypepropid in (select nodetypepropid " +
                               "                          from nodetype_props " +
                               "                         where " + CswEnumNbtNodeTypePropAttributes.usenumbering + " = '" + CswConvert.ToDbVal(true) + "')";
            }
            Collection <OrderByClause> orderBy = new Collection <OrderByClause>()
            {
                new OrderByClause("display_row", CswEnumOrderByType.Ascending),
                new OrderByClause("display_column", CswEnumOrderByType.Descending)
            };
            DataTable LayoutTable = LayoutSelect.getTable(WhereClause, orderBy);

            foreach (DataRow Row in LayoutTable.Rows)
            {
                Int32 PropId = CswConvert.ToInt32(Row["nodetypepropid"]);
                CswNbtObjClassDesignNodeTypeProp PropNode = _CswNbtMetaDataResources.CswNbtResources.Nodes.getNodeByRelationalId(new CswPrimaryKey("nodetype_props", PropId));
                ret.Add(PropNode);
            }
            return(ret);
        } // getPropNodesInLayout()
Esempio n. 5
0
        } // getAttributes()

        public static CswNbtView setDefaultView(CswNbtMetaData MetaData, CswNbtObjClassDesignNodeTypeProp DesignNTPNode, CswNbtView View, CswEnumNbtViewRelatedIdType RelatedIdType, Int32 inFKValue, bool OnlyCreateIfNull)
        {
            if (RelatedIdType != CswEnumNbtViewRelatedIdType.Unknown &&
                (null == View ||
                 View.Root.ChildRelationships.Count == 0 ||
                 false == OnlyCreateIfNull))
            {
                if (null != View)
                {
                    View.Root.ChildRelationships.Clear();
                }

                ICswNbtMetaDataDefinitionObject targetObj = MetaData.getDefinitionObject(RelatedIdType, inFKValue);
                if (null != targetObj)
                {
                    CswNbtViewId OldViewId = View.ViewId;
                    View        = targetObj.CreateDefaultView();
                    View.ViewId = OldViewId;
                }
                else
                {
                    throw new CswDniException(CswEnumErrorType.Error, "Cannot create a relationship without a valid target.", "setDefaultView() got an invalid RelatedIdType: " + RelatedIdType + " or value: " + inFKValue);
                }

                View.Visibility = CswEnumNbtViewVisibility.Property;
                View.ViewMode   = CswEnumNbtViewRenderingMode.Tree;
                View.ViewName   = DesignNTPNode.PropName.Text;
                View.save();
            }
            return(View);
        }
Esempio n. 6
0
        public override void update()
        {

            CswNbtMetaDataObjectClass RequestItemOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.RequestItemClass );
            CswNbtMetaDataObjectClassProp ItemNoOCP = RequestItemOC.getObjectClassProp( CswNbtObjClassRequestItem.PropertyName.ItemNumber );

            //First verify there is no sequence for any ItemNo NTPs
            Collection<CswNbtMetaDataNodeTypeProp> PropsWithNoSequences = new Collection<CswNbtMetaDataNodeTypeProp>();
            foreach( CswNbtMetaDataNodeTypeProp ItemNoNTP in ItemNoOCP.getNodeTypeProps() )
            {
                if( null == ItemNoNTP.Sequence )
                {
                    PropsWithNoSequences.Add( ItemNoNTP );
                }
            }

            if( PropsWithNoSequences.Any() )
            {
                CswNbtMetaDataObjectClass DesignSequenceOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.DesignSequenceClass );
                CswNbtMetaDataNodeType DesignSequenceNT = DesignSequenceOC.getNodeTypes().FirstOrDefault();
                if( null == DesignSequenceNT )
                {
                    throw new CswDniException( CswEnumErrorType.Error, "Error creating new Sequence for Item Number property", "Cannot create a new sequence because there is no DesignSequence NodeType" );
                }

                CswNbtObjClassDesignSequence ItemNoSequence = _CswNbtSchemaModTrnsctn.Nodes.makeNodeFromNodeTypeId( DesignSequenceNT.NodeTypeId, OnAfterMakeNode : delegate( CswNbtNode NewNode )
                    {
                        CswNbtObjClassDesignSequence AsSequence = NewNode;
                        AsSequence.Name.Text = "RequestItem_ItemNumber";
                        AsSequence.Pre.Text = "RI";
                        AsSequence.Pad.Value = 6;
                    } );

                foreach( CswNbtMetaDataNodeTypeProp SequenceslessProp in PropsWithNoSequences )
                {
                    //Update the NTP to have a sequence
                    CswNbtObjClassDesignNodeTypeProp DesignNodeProp = SequenceslessProp.DesignNode;
                    CswNbtMetaDataNodeTypeProp SequenceNTP = DesignNodeProp.NodeType.getNodeTypeProp( "Sequence" );
                    if( null == SequenceNTP )
                    {
                        throw new CswDniException(CswEnumErrorType.Error, "Error assigning sequence to Item Number property", "Cannot assign a sequence to the Item Number property because there is no Sequence relationship property to assign a value to");
                    }
                    DesignNodeProp.Node.Properties[SequenceNTP].AsRelationship.RelatedNodeId = ItemNoSequence.NodeId;
                    DesignNodeProp.postChanges( false );

                    //Update existing Request Items Item No prop to have a value
                    _updateRequestItems(SequenceslessProp.getNodeType(), SequenceslessProp);
                }
            }

        } // update()
        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;
                }
            }
        }
        } // getPropNodesInLayout()

        public IEnumerable <CswNbtObjClassDesignNodeTypeProp> getPropNodesNotInLayout(CswNbtMetaDataNodeType NodeType, Int32 TabId, CswEnumNbtLayoutType LayoutType, CswDateTime Date = null)
        {
            Collection <CswNbtObjClassDesignNodeTypeProp> ret = new Collection <CswNbtObjClassDesignNodeTypeProp>();
            CswTableSelect PropsSelect = _CswNbtMetaDataResources.CswNbtResources.makeCswTableSelect("getPropNodesNotInLayout_select", "nodetype_props");
            string         WhereClause = "where nodetypepropid not in (select nodetypepropid " +
                                         "                               from nodetype_layout " +
                                         "                              where nodetypeid = " + NodeType.NodeTypeId.ToString() +
                                         "                                and nodetypetabsetid = " + TabId.ToString() +
                                         "                                and layouttype = '" + LayoutType.ToString() + "')";
            DataTable LayoutTable = PropsSelect.getTable(WhereClause);

            foreach (DataRow Row in LayoutTable.Rows)
            {
                Int32 PropId = CswConvert.ToInt32(Row["nodetypepropid"]);
                CswNbtObjClassDesignNodeTypeProp PropNode = _CswNbtMetaDataResources.CswNbtResources.Nodes.getNodeByRelationalId(new CswPrimaryKey("nodetype_props", PropId));
                ret.Add(PropNode);
            }
            return(ret);
        } // getPropNodesNotInLayout()
Esempio n. 9
0
        public void onBeforeWriteDesignNode(CswNbtObjClassDesignNodeTypeProp DesignNTPNode)
        {
            CswNbtNodePropRelationship SequenceProp = DesignNTPNode.AttributeProperty[CswEnumNbtPropertyAttributeName.Sequence].AsRelationship;

            if (SequenceProp.wasSubFieldModified(CswNbtFieldTypeRuleRelationship.SubFieldName.NodeID))
            {
                if (null != DesignNTPNode.RelationalNodeTypeProp && null != DesignNTPNode.RelationalNodeType)
                {
                    // Update nodes
                    foreach (CswNbtNode CurrentNode in DesignNTPNode.RelationalNodeType.getNodes(false, false))
                    {
                        CswNbtNodePropWrapper CurrentProp = CurrentNode.Properties[DesignNTPNode.RelationalNodeTypeProp];
                        if (CurrentProp.AsSequence.Empty)
                        {
                            CurrentProp.AsSequence.setSequenceValue();
                        }
                    }
                } // if prop is sequence or barcode
            }     // if(SequenceProp.wasSubFieldModified( CswNbtFieldTypeRuleRelationship.SubFieldName.NodeID ) )
        }         // onBeforeWriteDesignNode()
Esempio n. 10
0
        public override void update()
        {
            CswNbtMetaDataObjectClass MailReportOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.MailReportClass );
            CswNbtMetaDataObjectClassProp NameOCP = MailReportOC.getObjectClassProp( CswNbtObjClassMailReport.PropertyName.Name );

            //Make sure all Mail reports have unique names
            foreach( CswNbtObjClassMailReport MailReport in MailReportOC.getNodes( false, true, false, true ) )
            {
                _makeNameUnique( MailReportOC, NameOCP, MailReport, MailReport.Name.Text, 0 );
            }

            //Make the Name property unique
            foreach( CswNbtMetaDataNodeTypeProp NameNTP in NameOCP.getNodeTypeProps() )
            {
                CswNbtObjClassDesignNodeTypeProp NamePropertyNode = NameNTP.DesignNode;
                NamePropertyNode.Unique.Checked = CswEnumTristate.True;
                NamePropertyNode.postChanges( false );
            }

        } // update()
        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]);
                }
            }
        }
        public void onBeforeWriteDesignNode(CswNbtObjClassDesignNodeTypeProp DesignNTPNode)
        {
            CswNbtMetaDataNodeTypeProp PossibleAnswersNTP  = DesignNTPNode.NodeType.getNodeTypeProp(CswEnumNbtPropertyAttributeName.PossibleAnswers.ToString());
            CswNbtMetaDataNodeTypeProp CompliantAnswersNTP = DesignNTPNode.NodeType.getNodeTypeProp(CswEnumNbtPropertyAttributeName.CompliantAnswers.ToString());

            if (null != PossibleAnswersNTP && null != CompliantAnswersNTP)
            {
                CswNbtNodePropWrapper PossibleAnswersProp  = DesignNTPNode.Node.Properties[PossibleAnswersNTP];
                CswNbtNodePropWrapper CompliantAnswersProp = DesignNTPNode.Node.Properties[CompliantAnswersNTP];
                if (null != PossibleAnswersProp && null != CompliantAnswersProp)
                {
                    // Guarantee a Compliant Answer for Question
                    if (CompliantAnswersProp.AsMultiList.Empty &&
                        CompliantAnswersProp.AsMultiList.Options.Count > 0)
                    {
                        //throw new CswDniException( CswEnumErrorType.Warning, "Compliant Answer is a required field", "Compliant Answer is a required field" );
                        CompliantAnswersProp.AsMultiList.AddValue(CompliantAnswersProp.AsMultiList.Options.First().Value);
                    }
                }
            }
        }
Esempio n. 13
0
        public void onSetFk(CswNbtObjClassDesignNodeTypeProp DesignNTPNode)
        {
            CswNbtNodePropMetaDataList  FkProp   = DesignNTPNode.AttributeProperty[AttributeName.Target].AsMetaDataList;
            CswNbtNodePropViewReference ViewProp = DesignNTPNode.AttributeProperty[AttributeName.View].AsViewReference;

            if (null != FkProp &&
                null != ViewProp &&
                (FkProp.wasSubFieldModified(CswNbtFieldTypeRuleMetaDataList.SubFieldName.Type) ||
                 FkProp.wasSubFieldModified(CswNbtFieldTypeRuleMetaDataList.SubFieldName.Id)) &&
                CswEnumNbtViewRelatedIdType.Unknown != FkProp.Type &&
                Int32.MinValue != FkProp.Id)
            {
                CswNbtView View = _CswNbtFieldResources.CswNbtResources.ViewSelect.restoreView(ViewProp.ViewId);
                // don't override if view was also modified (case 31812)
                // but still override if the view is empty, to handle brand new properties (case 31858)
                if (View.IsEmpty() || false == ViewProp.wasSubFieldModified(CswNbtFieldTypeRuleViewReference.SubFieldName.ViewID))
                {
                    //We have valid values that are different that what is currently set
                    CswNbtFieldTypeRuleDefaultImpl.setDefaultView(_CswNbtFieldResources.CswNbtResources.MetaData, DesignNTPNode, View, FkProp.Type, FkProp.Id, false);
                }
            }
        } // onSetFk()
Esempio n. 14
0
        private void _NameTemplateAdd_Change(CswNbtNodeProp Prop, bool Creating)
        {
            // Add the selected value to the name template
            CswNbtObjClassDesignNodeTypeProp SelectedProp = _CswNbtResources.Nodes[NameTemplateAdd.RelatedNodeId];

            if (null != SelectedProp)
            {
                string newTemplate = NameTemplateText.Text;
                if (false == string.IsNullOrEmpty(newTemplate))
                {
                    newTemplate += " ";
                }
                newTemplate          += CswNbtMetaData.MakeTemplateEntry(SelectedProp.PropName.Text);
                NameTemplateText.Text = newTemplate;
                _syncNameTemplate();

                // Clear the selected value
                NameTemplateAdd.RelatedNodeId  = null;
                NameTemplateAdd.CachedNodeName = string.Empty;
                NameTemplateAdd.PendingUpdate  = false;
            } // if( null != SelectedProp )
        }     // _NameTemplateAdd_Change()
Esempio n. 15
0
        public void onBeforeWriteDesignNode(CswNbtObjClassDesignNodeTypeProp DesignNTPNode)
        {
            CswNbtNodePropMemo NameOptionsProp = DesignNTPNode.AttributeProperty[AttributeName.ImageNames].AsMemo;
            CswNbtNodePropMemo UrlOptionsProp  = DesignNTPNode.AttributeProperty[AttributeName.ImageUrls].AsMemo;
            CswDelimitedString ListOptions     = new CswDelimitedString('\n');

            ListOptions.FromString(NameOptionsProp.Text.Trim());
            CswDelimitedString ValueOptions = new CswDelimitedString('\n');

            ValueOptions.FromString(UrlOptionsProp.Text.Trim());
            Dictionary <string, string> ValidOptions = new Dictionary <string, string>();

            for (int i = 0; i < ValueOptions.Count; i++)
            {
                if (ValidOptions.Keys.Contains(ListOptions[i]) || ValidOptions.Values.Contains(ValueOptions[i]))
                {
                    throw new CswDniException(CswEnumErrorType.Warning, "Image Names and URLs must be unique", "");
                }
                else
                {
                    ValidOptions.Add(ListOptions[i], ValueOptions[i]);
                }
            }
        }
Esempio n. 16
0
 public void onBeforeWriteDesignNode(CswNbtObjClassDesignNodeTypeProp DesignNTPNode)
 {
 }
Esempio n. 17
0
        /// <summary>
        /// Create properties based from the object class
        /// </summary>
        private void _setPropertyValuesFromObjectClass()
        {
            Dictionary <Int32, CswNbtObjClassDesignNodeTypeProp> NewNTPropsByOCPId = new Dictionary <Int32, CswNbtObjClassDesignNodeTypeProp>();

            //int DisplayRow = 1;

            // Create/convert object class props
            foreach (CswNbtMetaDataObjectClassProp OCProp in ObjectClassPropertyValue.getObjectClassProps())
            {
                CswNbtObjClassDesignNodeTypeProp PropNode = null;
                if (null != RelationalNodeType)
                {
                    PropNode = (from Prop in RelationalNodeType.getNodeTypeProps()
                                where (Prop.PropName == OCProp.PropName || Prop.getObjectClassPropName() == OCProp.PropName) && Prop.FieldTypeId == OCProp.FieldTypeId
                                select Prop.DesignNode
                                ).FirstOrDefault();
                }
                // If converting, need to detect existing properties
                if (null != PropNode)
                {
                    PropNode.ObjectClassPropName.Value = OCProp.PropId.ToString();
                    NewNTPropsByOCPId.Add(OCProp.PropId, PropNode);
                }
                else
                {
                    string NewPropName = OCProp.PropName;
                    while (null != RelationalNodeType &&
                           null != RelationalNodeType.getNodeTypeProp(NewPropName))
                    {
                        NewPropName = NewPropName + " (new)";
                    }

                    CswNbtMetaDataNodeType DesignNodeTypePropNT = _CswNbtResources.MetaData.getNodeType(CswNbtObjClassDesignNodeTypeProp.getNodeTypeName(OCProp.getFieldTypeValue()));
                    PropNode = _CswNbtResources.Nodes.makeNodeFromNodeTypeId(DesignNodeTypePropNT.NodeTypeId, delegate(CswNbtNode NewNode)
                    {
                        ((CswNbtObjClassDesignNodeTypeProp)NewNode).NodeTypeValue.RelatedNodeId = this.NodeId;
                        ((CswNbtObjClassDesignNodeTypeProp)NewNode).ObjectClassPropName.Value   = OCProp.PropId.ToString();
                        ((CswNbtObjClassDesignNodeTypeProp)NewNode).FieldType.Value             = OCProp.FieldTypeId.ToString();
                        ((CswNbtObjClassDesignNodeTypeProp)NewNode).PropName.Text = NewPropName;
                    });

                    NewNTPropsByOCPId.Add(OCProp.ObjectClassPropId, PropNode);
                } // if-else( null != PropNode )

                //only update the layout when we're not overriding an existing nodetype
                PropNode.syncFromObjectClassProp(false == _overrideNodeConversionCheck);
            } // foreach( CswNbtMetaDataObjectClassProp OCProp in ObjectClassPropertyValue.getObjectClassProps() )

            // Now that we're done with all object class props, we can handle filters
            foreach (CswNbtMetaDataObjectClassProp OCProp in ObjectClassPropertyValue.getObjectClassProps())
            {
                if (OCProp.hasFilter())
                {
                    CswNbtObjClassDesignNodeTypeProp NTProp = NewNTPropsByOCPId[OCProp.ObjectClassPropId];
                    if (null != NTProp)
                    {
                        CswNbtObjClassDesignNodeTypeProp TargetOfFilter = NewNTPropsByOCPId[OCProp.FilterObjectClassPropId];
                        if (TargetOfFilter != null)
                        {
                            CswNbtSubField       SubField   = null;
                            CswEnumNbtFilterMode FilterMode = CswEnumNbtFilterMode.Unknown;
                            string FilterValue = string.Empty;
                            OCProp.getFilter(ref SubField, ref FilterMode, ref FilterValue);

                            // We don't have to worry about versioning in this function
                            NTProp.DisplayConditionProperty.RelatedNodeId = TargetOfFilter.NodeId;
                            NTProp.DisplayConditionSubfield.Value         = SubField.Name.ToString();
                            NTProp.DisplayConditionFilterMode.Value       = FilterMode.ToString();
                            NTProp.DisplayConditionValue.Text             = FilterValue;
                            NTProp.postChanges(false);
                        } // if( TargetOfFilter != null )
                    }     // if( null != NTProp )
                }         // if( OCProp.hasFilter() )
            }             // foreach( CswNbtMetaDataObjectClassProp OCProp in ObjectClassProps )


            // Handle search defer inheritance from object classes
            if (Int32.MinValue != ObjectClassPropertyValue.SearchDeferPropId)
            {
                //if( CswNbtMetaDataObjectClass.NotSearchableValue != ObjectClassPropertyValue.SearchDeferPropId )
                //{
                CswNbtObjClassDesignNodeTypeProp SearchDeferProp = NewNTPropsByOCPId[ObjectClassPropertyValue.SearchDeferPropId];
                this.DeferSearchTo.RelatedNodeId = SearchDeferProp.NodeId;
                //}
                //else
                //{
                //    this.DeferSearchTo.RelatedNodeId = null;
                //}
            }
        } // _setPropertyValuesFromObjectClass()
Esempio n. 18
0
        public override CswNbtNode CopyNode(bool IsNodeTemp = false, Action <CswNbtNode> OnCopy = null)
        {
            // Copy NodeType
            string NewNodeTypeName = "Copy Of " + NodeTypeName.Text;
            Int32  CopyInt         = 1;

            while (null != _CswNbtResources.MetaData.getNodeType(NewNodeTypeName))
            {
                CopyInt++;
                NewNodeTypeName = "Copy " + CopyInt.ToString() + " Of " + NodeTypeName.Text;
            }

            CswNbtObjClassDesignNodeType NodeTypeCopy = base.CopyNodeImpl(IsNodeTemp, delegate(CswNbtNode NewNode)
            {
                ((CswNbtObjClassDesignNodeType)NewNode).InternalCreate    = true;
                ((CswNbtObjClassDesignNodeType)NewNode).NodeTypeName.Text = NewNodeTypeName;
                if (null != OnCopy)
                {
                    OnCopy(NewNode);
                }
            });

            // Copy Tabs
            Dictionary <Int32, CswNbtObjClassDesignNodeTypeTab> TabMap = new Dictionary <Int32, CswNbtObjClassDesignNodeTypeTab>();

            foreach (CswNbtObjClassDesignNodeTypeTab TabNode in getTabNodes())
            {
                CswNbtObjClassDesignNodeTypeTab TabCopy = TabNode.CopyNode(IsNodeTemp, delegate(CswNbtNode CopiedNode)
                {
                    ((CswNbtObjClassDesignNodeTypeTab)CopiedNode).NodeTypeValue.RelatedNodeId = NodeTypeCopy.NodeId;
                    ((CswNbtObjClassDesignNodeTypeTab)CopiedNode).TabName.Text = TabNode.TabName.Text;
                });

                TabMap.Add(TabNode.RelationalId.PrimaryKey, TabCopy);
            }

            // case 31518 - props won't be able to see the tab if we don't do this
            _CswNbtResources.MetaData.refreshAll();

            // Copy Props
            Collection <CswNbtObjClassDesignNodeTypeProp>        PropNodes = getPropNodes();
            Dictionary <Int32, CswNbtObjClassDesignNodeTypeProp> PropMap   = new Dictionary <Int32, CswNbtObjClassDesignNodeTypeProp>();

            foreach (CswNbtObjClassDesignNodeTypeProp PropNode in PropNodes)
            {
                CswNbtObjClassDesignNodeTypeProp PropCopy = PropNode.CopyNode(IsNodeTemp, delegate(CswNbtNode CopiedNode)
                {
                    ((CswNbtObjClassDesignNodeTypeProp)CopiedNode).NodeTypeValue.RelatedNodeId = NodeTypeCopy.NodeId;
                    ((CswNbtObjClassDesignNodeTypeProp)CopiedNode).PropName.Text = PropNode.PropName.Text;
                });
                PropMap.Add(PropNode.RelationalId.PrimaryKey, PropCopy);

                // Fix layout
                if (PropCopy.PropName.Text.Equals(CswNbtObjClass.PropertyName.Save))
                {
                    foreach (CswNbtObjClassDesignNodeTypeTab NewTab in TabMap.Values)
                    {
                        //Case 29181 - Save prop on all tabs except identity
                        if (NewTab.RelationalId.PrimaryKey != NodeTypeCopy.RelationalNodeType.getIdentityTab().TabId)
                        {
                            _CswNbtResources.MetaData.NodeTypeLayout.updatePropLayout(CswEnumNbtLayoutType.Edit, NodeTypeCopy.RelationalId.PrimaryKey, PropCopy.RelationalNodeTypeProp, false, NewTab.RelationalId.PrimaryKey, Int32.MaxValue, 1);
                        }
                    }
                }
                else
                {
                    foreach (CswEnumNbtLayoutType LayoutType in CswEnumNbtLayoutType._All)
                    {
                        Dictionary <Int32, CswNbtMetaDataNodeTypeLayoutMgr.NodeTypeLayout> OriginalLayouts = _CswNbtResources.MetaData.NodeTypeLayout.getLayout(LayoutType, PropNode.RelationalNodeTypeProp, null);
                        foreach (CswNbtMetaDataNodeTypeLayoutMgr.NodeTypeLayout OriginalLayout in OriginalLayouts.Values)
                        {
                            if (OriginalLayout != null)
                            {
                                Int32 NewTabId = Int32.MinValue;
                                if (LayoutType == CswEnumNbtLayoutType.Edit)
                                {
                                    NewTabId = TabMap[OriginalLayout.TabId].RelationalId.PrimaryKey;
                                }
                                _CswNbtResources.MetaData.NodeTypeLayout.updatePropLayout(LayoutType, NodeTypeCopy.RelationalId.PrimaryKey, PropCopy.RelationalNodeTypeProp, true, NewTabId, OriginalLayout.DisplayRow, OriginalLayout.DisplayColumn);
                            }
                        }
                    } // foreach( CswEnumNbtLayoutType LayoutType in CswEnumNbtLayoutType._All )
                }
            }         // foreach( CswNbtObjClassDesignNodeTypeProp PropNode in getPropNodes() )


            // Fix Conditional Props (case 22328)
            foreach (CswNbtObjClassDesignNodeTypeProp PropNode in PropNodes)
            {
                if (CswTools.IsPrimaryKey(PropNode.DisplayConditionProperty.RelatedNodeId))
                {
                    CswNbtObjClassDesignNodeTypeProp PropCopy             = PropMap[PropNode.RelationalId.PrimaryKey];
                    CswNbtObjClassDesignNodeTypeProp DisplayConditionProp = PropNodes.FirstOrDefault(p => p.NodeId == PropNode.DisplayConditionProperty.RelatedNodeId);
                    if (null != DisplayConditionProp)
                    {
                        CswNbtObjClassDesignNodeTypeProp DisplayConditionPropCopy = PropMap[DisplayConditionProp.RelationalId.PrimaryKey];
                        PropCopy.DisplayConditionProperty.RelatedNodeId = DisplayConditionPropCopy.NodeId;
                    }
                }
            }

            // Fix the name template, now that properties are in place
            NodeTypeCopy.postChanges(true);

            //if( OnCopyNodeType != null )
            //    OnCopyNodeType( OldNodeType, NewNodeType );

            return(NodeTypeCopy.Node);
        } // CopyNode()
Esempio n. 19
0
        /// <summary>
        /// Create an ObjClass instance for given ObjectClass and Node
        /// </summary>
        public static CswNbtObjClass makeObjClass(CswNbtResources CswNbtResources, CswNbtMetaDataObjectClass ObjectClass, CswNbtNode Node = null)
        {
            CswNbtObjClass ReturnVal = null;

            switch (ObjectClass.ObjectClass)
            {
            case CswEnumNbtObjectClass.BalanceClass:
                ReturnVal = new CswNbtObjClassBalance(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.BalanceConfigurationClass:
                ReturnVal = new CswNbtObjClassBalanceConfiguration(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.BatchOpClass:
                ReturnVal = new CswNbtObjClassBatchOp(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.BiologicalClass:
                ReturnVal = new CswNbtObjClassBiological(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.CertDefCharacteristicLimitClass:
                ReturnVal = new CswNbtObjClassCertDefCharacteristicLimit(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.CertDefSpecClass:
                ReturnVal = new CswNbtObjClassCertDefSpec(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.CertificateDefinitionClass:
                ReturnVal = new CswNbtObjClassCertificateDefinition(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.CertDefConditionClass:
                ReturnVal = new CswNbtObjClassCertDefCondition(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.CertDefSpecLevelClass:
                ReturnVal = new CswNbtObjClassCertDefSpecLevel(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.CofADocumentClass:
                ReturnVal = new CswNbtObjClassCofADocument(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.CofAMethodClass:
                ReturnVal = new CswNbtObjClassCofAMethod(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.CofAMethodTemplateClass:
                ReturnVal = new CswNbtObjClassCofAMethodTemplate(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.ContainerClass:
                ReturnVal = new CswNbtObjClassContainer(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.ContainerDispenseTransactionClass:
                ReturnVal = new CswNbtObjClassContainerDispenseTransaction(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.ContainerGroupClass:
                ReturnVal = new CswNbtObjClassContainerGroup(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.ContainerLocationClass:
                ReturnVal = new CswNbtObjClassContainerLocation(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.ControlZoneClass:
                ReturnVal = new CswNbtObjClassControlZone(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.CustomerClass:
                ReturnVal = new CswNbtObjClassCustomer(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.DepartmentClass:
                ReturnVal = new CswNbtObjClassDepartment(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.DesignNodeTypeClass:
                ReturnVal = new CswNbtObjClassDesignNodeType(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.DesignNodeTypePropClass:
                ReturnVal = new CswNbtObjClassDesignNodeTypeProp(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.DesignNodeTypeTabClass:
                ReturnVal = new CswNbtObjClassDesignNodeTypeTab(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.DesignSequenceClass:
                ReturnVal = new CswNbtObjClassDesignSequence(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.DocumentClass:
                ReturnVal = new CswNbtObjClassDocument(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.DSDPhraseClass:
                ReturnVal = new CswNbtObjClassDSDPhrase(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.EnterprisePartClass:
                ReturnVal = new CswNbtObjClassEnterprisePart(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.EquipmentAssemblyClass:
                ReturnVal = new CswNbtObjClassEquipmentAssembly(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.EquipmentClass:
                ReturnVal = new CswNbtObjClassEquipment(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.EquipmentTypeClass:
                ReturnVal = new CswNbtObjClassEquipmentType(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.FeedbackClass:
                ReturnVal = new CswNbtObjClassFeedback(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.FireClassExemptAmountClass:
                ReturnVal = new CswNbtObjClassFireClassExemptAmount(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.FireClassExemptAmountSetClass:
                ReturnVal = new CswNbtObjClassFireClassExemptAmountSet(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.GenericClass:
                ReturnVal = new CswNbtObjClassGeneric(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.GHSClass:
                ReturnVal = new CswNbtObjClassGHS(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.GHSClassificationClass:
                ReturnVal = new CswNbtObjClassGHSClassification(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.GHSPhraseClass:
                ReturnVal = new CswNbtObjClassGHSPhrase(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.GHSSignalWordClass:
                ReturnVal = new CswNbtObjClassGHSSignalWord(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.InspectionDesignClass:
                ReturnVal = new CswNbtObjClassInspectionDesign(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.InspectionRouteClass:
                ReturnVal = new CswNbtObjClassInspectionRoute(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.InspectionTargetClass:
                ReturnVal = new CswNbtObjClassInspectionTarget(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.InspectionTargetGroupClass:
                ReturnVal = new CswNbtObjClassInspectionTargetGroup(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.InventoryGroupClass:
                ReturnVal = new CswNbtObjClassInventoryGroup(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.InventoryGroupPermissionClass:
                ReturnVal = new CswNbtObjClassInventoryGroupPermission(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.InventoryLevelClass:
                ReturnVal = new CswNbtObjClassInventoryLevel(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.JurisdictionClass:
                ReturnVal = new CswNbtObjClassJurisdiction(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.Level:
                ReturnVal = new CswNbtObjClassLevel(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.LocationClass:
                ReturnVal = new CswNbtObjClassLocation(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.LQNoClass:
                ReturnVal = new CswNbtObjClassLQNo(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.ManufacturerClass:
                ReturnVal = new CswNbtObjClassManufacturer(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.ManufacturerEquivalentPartClass:
                ReturnVal = new CswNbtObjClassManufacturerEquivalentPart(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.ChemicalClass:
                ReturnVal = new CswNbtObjClassChemical(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.MaterialComponentClass:
                ReturnVal = new CswNbtObjClassMaterialComponent(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.MaterialSynonymClass:
                ReturnVal = new CswNbtObjClassMaterialSynonym(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.MailReportClass:
                ReturnVal = new CswNbtObjClassMailReport(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.MailReportGroupClass:
                ReturnVal = new CswNbtObjClassMailReportGroup(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.MailReportGroupPermissionClass:
                ReturnVal = new CswNbtObjClassMailReportGroupPermission(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.MethodClass:
                ReturnVal = new CswNbtObjClassMethod(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.MethodCharacteristicClass:
                ReturnVal = new CswNbtObjClassMethodCharacteristic(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.MethodConditionClass:
                ReturnVal = new CswNbtObjClassMethodCondition(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.NonChemicalClass:
                ReturnVal = new CswNbtObjClassNonChemical(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.PrinterClass:
                ReturnVal = new CswNbtObjClassPrinter(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.PrintJobClass:
                ReturnVal = new CswNbtObjClassPrintJob(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.PrintLabelClass:
                ReturnVal = new CswNbtObjClassPrintLabel(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.ProblemClass:
                ReturnVal = new CswNbtObjClassProblem(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.ReceiptLotClass:
                ReturnVal = new CswNbtObjClassReceiptLot(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.RegulatoryListClass:
                ReturnVal = new CswNbtObjClassRegulatoryList(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.RegulatoryListCasNoClass:
                ReturnVal = new CswNbtObjClassRegulatoryListCasNo(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.RegulatoryListMemberClass:
                ReturnVal = new CswNbtObjClassRegulatoryListMember(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.RegulatoryListListCodeClass:
                ReturnVal = new CswNbtObjClassRegulatoryListListCode(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.ReportClass:
                ReturnVal = new CswNbtObjClassReport(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.ReportGroupClass:
                ReturnVal = new CswNbtObjClassReportGroup(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.ReportGroupPermissionClass:
                ReturnVal = new CswNbtObjClassReportGroupPermission(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.RequestClass:
                ReturnVal = new CswNbtObjClassRequest(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.RequestItemClass:
                ReturnVal = new CswNbtObjClassRequestItem(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.RoleClass:
                ReturnVal = new CswNbtObjClassRole(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.SDSDocumentClass:
                ReturnVal = new CswNbtObjClassSDSDocument(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.TestingLabClass:
                ReturnVal = new CswNbtObjClassTestingLab(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.GeneratorClass:
                ReturnVal = new CswNbtObjClassGenerator(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.SizeClass:
                ReturnVal = new CswNbtObjClassSize(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.TaskClass:
                ReturnVal = new CswNbtObjClassTask(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.TestingLabUserAssignmentClass:
                ReturnVal = new CswNbtObjClassTestingLabUserAssignment(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.TestingLabMethodAssignmentClass:
                ReturnVal = new CswNbtObjClassTestingLabMethodAssignment(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.UnitOfMeasureClass:
                ReturnVal = new CswNbtObjClassUnitOfMeasure(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.UserClass:
                ReturnVal = new CswNbtObjClassUser(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.VendorClass:
                ReturnVal = new CswNbtObjClassVendor(CswNbtResources, Node);
                break;

            case CswEnumNbtObjectClass.WorkUnitClass:
                ReturnVal = new CswNbtObjClassWorkUnit(CswNbtResources, Node);
                break;

            default:
                //ReturnVal = new CswNbtObjClassDefault( CswNbtResources, _CswNbtNode );
                throw (new CswDniException("There is no NbtObjClass derivative for object class " + ObjectClass.ObjectClass.ToString()));
            }//switch


            return(ReturnVal);
        } //makeObjClass()
Esempio n. 20
0
 public void onSetFk(CswNbtObjClassDesignNodeTypeProp DesignNTPNode)
 {
     _CswNbtFieldTypeRuleDefault.onSetFk(DesignNTPNode);
 }
        public override void update()
        {
            CswTableUpdate jctUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "29311_jctddntp_update", "jct_dd_ntp" );
            DataTable jctTable = jctUpdate.getEmptyTable();

            // Set up Sequence Nodetype
            CswNbtMetaDataObjectClass SequenceOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.DesignSequenceClass );
            CswNbtMetaDataNodeType SequenceNT = _CswNbtSchemaModTrnsctn.MetaData.makeNewNodeTypeNew( new CswNbtWcfMetaDataModel.NodeType( SequenceOC )
                {
                    NodeTypeName = "Design Sequence",
                    Category = "Design",
                    IconFileName = "wrench.png"
                } );
            //SequenceNT.addNameTemplateText( CswNbtObjClassDesignSequence.PropertyName.Name );
            SequenceNT._DataRow["nametemplate"] = CswNbtMetaData.TemplateTextToTemplateValue( SequenceNT.getNodeTypeProps(), CswNbtMetaData.MakeTemplateEntry( CswNbtObjClassDesignSequence.PropertyName.Name ) );

            Int32 TabId = SequenceNT.getFirstNodeTypeTab().TabId;

            CswNbtMetaDataNodeTypeProp SeqNameNTP = SequenceNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDesignSequence.PropertyName.Name );
            CswNbtMetaDataNodeTypeProp SeqNextValueNTP = SequenceNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDesignSequence.PropertyName.NextValue );
            CswNbtMetaDataNodeTypeProp SeqPadNTP = SequenceNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDesignSequence.PropertyName.Pad );
            CswNbtMetaDataNodeTypeProp SeqPostNTP = SequenceNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDesignSequence.PropertyName.Post );
            CswNbtMetaDataNodeTypeProp SeqPreNTP = SequenceNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDesignSequence.PropertyName.Pre );

            // Edit Layout
            SeqNameNTP.updateLayout( CswEnumNbtLayoutType.Edit, true, TabId, DisplayRow: 1, DisplayColumn: 1 );
            SeqPreNTP.updateLayout( CswEnumNbtLayoutType.Edit, true, TabId, DisplayRow: 2, DisplayColumn: 1 );
            SeqPostNTP.updateLayout( CswEnumNbtLayoutType.Edit, true, TabId, DisplayRow: 3, DisplayColumn: 1 );
            SeqPadNTP.updateLayout( CswEnumNbtLayoutType.Edit, true, TabId, DisplayRow: 4, DisplayColumn: 1 );
            SeqNextValueNTP.updateLayout( CswEnumNbtLayoutType.Edit, true, TabId, DisplayRow: 5, DisplayColumn: 1 );

            // Add Layout
            SeqNameNTP.updateLayout( CswEnumNbtLayoutType.Add, false, Int32.MinValue, DisplayRow: 1, DisplayColumn: 1 );
            SeqPreNTP.updateLayout( CswEnumNbtLayoutType.Add, false, Int32.MinValue, DisplayRow: 2, DisplayColumn: 1 );
            SeqPostNTP.updateLayout( CswEnumNbtLayoutType.Add, false, Int32.MinValue, DisplayRow: 3, DisplayColumn: 1 );
            SeqPadNTP.updateLayout( CswEnumNbtLayoutType.Add, false, Int32.MinValue, DisplayRow: 4, DisplayColumn: 1 );
            SeqNextValueNTP.removeFromLayout( CswEnumNbtLayoutType.Add );

            // Populate nodes
            // Very important that this happens BEFORE we map to the nodetypes table, or else we'll end up duplicating rows!
            Dictionary<Int32, CswNbtObjClassDesignSequence> SequenceNodeMap = new Dictionary<int, CswNbtObjClassDesignSequence>();
            CswTableSelect SequencesTableSelect = _CswNbtSchemaModTrnsctn.makeCswTableSelect( "29311_sequencetable_select", "sequences" );
            DataTable SequencesTable = SequencesTableSelect.getTable();
            foreach( DataRow SeqRow in SequencesTable.Rows )
            {
                CswNbtObjClassDesignSequence node = _CswNbtSchemaModTrnsctn.Nodes.makeNodeFromNodeTypeId( SequenceNT.NodeTypeId, OverrideUniqueValidation: true, OnAfterMakeNode: delegate( CswNbtNode NewNode )
                    {
                        CswNbtObjClassDesignSequence NewSeqNode = NewNode;
                        NewSeqNode.Name.Text = SeqRow["sequencename"].ToString();
                        NewSeqNode.Pad.Value = CswConvert.ToInt32( SeqRow["pad"] );
                        NewSeqNode.Post.Text = SeqRow["post"].ToString();
                        NewSeqNode.Pre.Text = SeqRow["prep"].ToString();
                    } );
                node.RelationalId = new CswPrimaryKey( "sequences", CswConvert.ToInt32( SeqRow["sequenceid"] ) );
                node.postChanges( false );
                SequenceNodeMap.Add( node.RelationalId.PrimaryKey, node );
            }

            // Here's where the extra special super-secret magic comes in

            //SequenceNT.TableName = "sequences";
            SequenceNT._DataRow["tablename"] = "sequences";

            _addJctRow( jctTable, SeqNameNTP, SequenceNT.TableName, "sequencename" );
            _addJctRow( jctTable, SeqPadNTP, SequenceNT.TableName, "pad" );
            _addJctRow( jctTable, SeqPostNTP, SequenceNT.TableName, "post" );
            _addJctRow( jctTable, SeqPreNTP, SequenceNT.TableName, "prep" );
            jctUpdate.update( jctTable );

            // Set up existing relationships to sequences
            Dictionary<Int32, CswNbtObjClassDesignSequence> SequenceValueMap = new Dictionary<Int32, CswNbtObjClassDesignSequence>();
            string Sql = @"select n.nodeid, r.sequenceid
                             from nodetype_props p
                             join nodetypes t on p.nodetypeid = t.nodetypeid
                             join nodes n on t.nodetypeid = n.nodetypeid
                             join nodetype_props r on n.relationalid = r.nodetypepropid
                            where p.propname = 'Sequence' and t.nodetypename like 'Design%'";
            CswArbitrarySelect ExistingSequenceIdSelect = _CswNbtSchemaModTrnsctn.makeCswArbitrarySelect( "getExistingSequenceIds", Sql );
            DataTable ExistingSequenceIdTable = ExistingSequenceIdSelect.getTable();
            foreach( DataRow row in ExistingSequenceIdTable.Rows )
            {
                Int32 thisSeqId = CswConvert.ToInt32( row["sequenceid"] );
                if( Int32.MinValue != thisSeqId && SequenceNodeMap.ContainsKey( thisSeqId ) )
                {
                    SequenceValueMap.Add( CswConvert.ToInt32( row["nodeid"] ), SequenceNodeMap[thisSeqId] );
                }
            }

            foreach( CswEnumNbtFieldType ft in new CswEnumNbtFieldType[] { CswEnumNbtFieldType.Barcode, CswEnumNbtFieldType.Sequence } )
            {
                CswNbtMetaDataNodeType PropNT = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( CswNbtObjClassDesignNodeTypeProp.getNodeTypeName( ft ) );
                //CswNbtFieldTypeRuleSequence Rule = (CswNbtFieldTypeRuleSequence) _CswNbtSchemaModTrnsctn.MetaData.getFieldTypeRule( ft );
                //CswNbtFieldTypeAttribute SequenceAttribute = Rule.getAttributes().FirstOrDefault( a => a.Name == CswEnumNbtPropertyAttributeName.Sequence );
                CswNbtMetaDataNodeTypeProp SequenceNTP = PropNT.getNodeTypeProp( CswEnumNbtPropertyAttributeName.Sequence );
                SequenceNTP.SetFKDeprecated( CswEnumNbtViewRelatedIdType.ObjectClassId.ToString(), SequenceOC.ObjectClassId );

                CswNbtViewId ViewId = SequenceNTP.DesignNode.AttributeProperty[CswNbtFieldTypeRuleRelationship.AttributeName.View].AsViewReference.ViewId;
                CswNbtView View = _CswNbtSchemaModTrnsctn.ViewSelect.restoreView( ViewId );
                CswNbtFieldTypeRuleDefaultImpl.setDefaultView( _CswNbtSchemaModTrnsctn.MetaData, SequenceNTP.DesignNode, View, CswEnumNbtViewRelatedIdType.ObjectClassId.ToString(), SequenceOC.ObjectClassId, false );

                foreach( CswNbtObjClassDesignNodeTypeProp PropNode in PropNT.getNodes( false, true ) )
                {
                    if( SequenceValueMap.ContainsKey( PropNode.NodeId.PrimaryKey ) )
                    {
                        CswNbtObjClassDesignSequence SeqNode = SequenceValueMap[PropNode.NodeId.PrimaryKey];
                        if( null != SeqNode )
                        {
                            PropNode.Node.Properties[SequenceNTP].AsRelationship.RelatedNodeId = SeqNode.NodeId;
                            PropNode.postChanges( false );
                        }
                    }
                }
            } // foreach( CswEnumNbtFieldType ft in new CswEnumNbtFieldType[] {CswEnumNbtFieldType.Barcode, CswEnumNbtFieldType.Sequence} )

        } // update()
 public void onSetFk(CswNbtMetaDataNodeTypeProp MetaDataProp, CswNbtObjClassDesignNodeTypeProp DesignNTPNode)
 {
     _CswNbtFieldTypeRuleDefault.onSetFk(MetaDataProp, DesignNTPNode);
 }
Esempio n. 23
0
        }// getDesignNodeType()

        public static void getDesignNodeTypePropDefinition( ICswResources CswResources, CswNbtDesignReturn Return, string FieldTypeId )
        {
            CswNbtResources _CswNbtResources = (CswNbtResources) CswResources;
            Int32 FieldTypePk = CswConvert.ToInt32( FieldTypeId );
            CswNbtMetaDataFieldType FT = _CswNbtResources.MetaData.getFieldType( FieldTypePk );
            CswNbtMetaDataNodeType FieldTypeNT = _CswNbtResources.MetaData.getNodeType( CswNbtObjClassDesignNodeTypeProp.getNodeTypeName( FT.FieldType ) );
            if( null != FieldTypeNT )
            {
                DesignResponse DesignResponse = new DesignResponse();
                DesignResponse.NodeTypeId = FieldTypeNT.NodeTypeId;
                DesignResponse.ObjectClassId = FieldTypeNT.ObjectClassId;
                Return.Data = DesignResponse;
            }
        }
Esempio n. 24
0
 public void onSetFk(CswNbtObjClassDesignNodeTypeProp DesignNTPNode)
 {
     //doSetFk( inFKType, inFKValue, inValuePropType, inValuePropId );
 }