} // update()

        private CswNbtView _editView( string DocumentNodeType, CswNbtMetaDataObjectClass ObjectClassOfProperty, string DocumentObjClassProp )
        {
            CswNbtView DocumentsView = null;

            CswNbtMetaDataNodeType DocumentNT = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( DocumentNodeType );
            if( null != DocumentNT )
            {
                CswNbtMetaDataNodeType NodeTypeOfProperty = ObjectClassOfProperty.FirstNodeType;
                if( null != NodeTypeOfProperty )
                {
                    // documents property that contains the viewxml
                    CswNbtMetaDataNodeTypeProp DocumentsNTP = NodeTypeOfProperty.getNodeTypePropByObjectClassProp( DocumentObjClassProp );
                    if( null != DocumentsNTP )
                    {
                        CswNbtMetaDataNodeTypeProp LinkNTP = DocumentNT.getNodeTypePropByObjectClassProp( CswNbtPropertySetDocument.PropertyName.Link );
                        CswNbtMetaDataNodeTypeProp FileNTP = DocumentNT.getNodeTypePropByObjectClassProp( CswNbtPropertySetDocument.PropertyName.File );
                        CswNbtMetaDataNodeTypeProp OpenFileNTP = DocumentNT.getNodeTypePropByObjectClassProp( CswNbtPropertySetDocument.PropertyName.OpenFile );

                        DocumentsView = _CswNbtSchemaModTrnsctn.restoreView( DocumentsNTP.ViewId );
                        if( false == DocumentsView.IsEmpty() )
                        {
                            // View.Root only gives us the <TreeView></TreeView> content. It does not give the first relationship. We are assuming
                            // that these views have two relationships: An OC (or PS) and a Document relationship
                            // To get at the Document relationship, we need to get the second relationship. If the view doesn't have this second relationship,
                            // we will just ignore it and won't make any changes
                            CswNbtViewRelationship ParentRel = DocumentsView.Root.ChildRelationships[0];
                            if( ParentRel.ChildRelationships.Count > 0 )
                            {
                                DocumentsView.removeViewProperty( LinkNTP );
                                DocumentsView.removeViewProperty( FileNTP );

                                CswNbtViewRelationship ChildRel = ParentRel.ChildRelationships[0];
                                if( null == ChildRel.findProperty( OpenFileNTP.NodeTypeId ) )
                                {
                                    DocumentsView.AddViewProperty( ChildRel, OpenFileNTP );
                                }
                                DocumentsView.save();
                            }
                        } //if( false == DocumentsView.IsEmpty() )

                    }//if( null != DocumentsNTP )

                }//if( null != NodeTypeOfProperty )

            }//if( null != DocumentNT )

            return DocumentsView;

        }//_editView()
Ejemplo n.º 2
0
        public override void update()
        {

            //get all views and find the dispense requests view
            DataTable Views = _CswNbtSchemaModTrnsctn.ViewSelect.getAllViews();
            CswNbtViewId dispenseRequestsViewId = new CswNbtViewId();
            foreach( DataRow row in Views.Rows )
            {
                if( row["viewname"].Equals( "Dispense Requests: Open" ) )
                {
                    dispenseRequestsViewId.set( CswConvert.ToInt32( row["nodeviewid"] ) );
                }
            }

            /*
             * The dispense requests view is broken. It has THREE 'Status' properties, each with different filters
             */

            if( dispenseRequestsViewId.isSet() )
            {
                CswNbtView DispenseRequestsView = _CswNbtSchemaModTrnsctn.ViewSelect.restoreView( dispenseRequestsViewId );
                LinkedList<CswNbtViewProperty> viewProps = DispenseRequestsView.getOrderedViewProps( false );
                CswNbtViewRelationship parent = null;
                foreach( CswNbtViewProperty viewProp in viewProps ) //delete the 3 duplicate 'Status' view props from this view
                {
                    if( viewProp.Name.Equals( "Status" ) )
                    {
                        DispenseRequestsView.removeViewProperty( viewProp.MetaDataProp );
                    }
                    else
                    {
                        parent = (CswNbtViewRelationship) viewProp.Parent; //get the view parent to add the Status prop later (in this specific case this get the root)
                    }
                }

                //add the property to the view ONCE
                CswNbtMetaDataObjectClass requestItemOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswNbtMetaDataObjectClass.NbtObjectClass.RequestItemClass );
                CswNbtViewProperty statusVP = DispenseRequestsView.AddViewProperty( parent, requestItemOC.getObjectClassProp( CswNbtObjClassRequestItem.PropertyName.Status ) );

                //now add the filters
                DispenseRequestsView.AddViewPropertyFilter( statusVP, FilterMode: CswNbtPropFilterSql.PropertyFilterMode.NotEquals, Value: "Completed" );
                DispenseRequestsView.AddViewPropertyFilter( statusVP, FilterMode: CswNbtPropFilterSql.PropertyFilterMode.NotEquals, Value: "Cancelled" );

                DispenseRequestsView.save();
            }

        }//Update()