Пример #1
0
        public CswNbtNode makeRoleNodeFromRoleName(string RoleName)
        {
            CswNbtNode RoleNode = null;

            CswNbtMetaDataObjectClass     Role_ObjectClass         = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.RoleClass);
            CswNbtMetaDataObjectClassProp RoleName_ObjectClassProp = Role_ObjectClass.getObjectClassProp(CswNbtObjClassRole.PropertyName.Name);

            // generate the view
            CswNbtView View = new CswNbtView(_CswNbtResources);

            View.ViewName = "CswNbtNodes.makeRoleNodeFromRoleName(" + RoleName + ")";
            CswNbtViewRelationship   RoleRelationship = View.AddViewRelationship(Role_ObjectClass, false);
            CswNbtViewProperty       Prop             = View.AddViewProperty(RoleRelationship, RoleName_ObjectClassProp);
            CswNbtViewPropertyFilter Filter           = View.AddViewPropertyFilter(Prop, CswNbtFieldTypeRuleText.SubFieldName.Text, CswEnumNbtFilterMode.Equals, RoleName, false);

            // generate the tree
            ICswNbtTree UserTree = _CswNbtResources.Trees.getTreeFromView(View, false, true, IncludeHiddenNodes: true);

            // get user node
            UserTree.goToRoot();
            if (UserTree.getChildNodeCount() > 0)
            {
                UserTree.goToNthChild(0);
                RoleNode = UserTree.getNodeForCurrentPosition();
            }
            return(RoleNode);
        }
Пример #2
0
 public static CswNbtViewNode makeViewNode( CswNbtResources CswNbtResources, CswNbtView View, CswDelimitedString ViewNodeString )
 {
     CswNbtViewNode newNode = null;
     CswEnumNbtViewNodeType type = (CswEnumNbtViewNodeType) ViewNodeString[0];
     if( type == CswEnumNbtViewNodeType.CswNbtViewRelationship )
     {
         newNode = new CswNbtViewRelationship( CswNbtResources, View, ViewNodeString );
     }
     else if( type == CswEnumNbtViewNodeType.CswNbtViewProperty )
     {
         newNode = new CswNbtViewProperty( CswNbtResources, View, ViewNodeString );
     }
     else if( type == CswEnumNbtViewNodeType.CswNbtViewPropertyFilter )
     {
         newNode = new CswNbtViewPropertyFilter( CswNbtResources, View, ViewNodeString );
     }
     else if( type == CswEnumNbtViewNodeType.CswNbtViewRoot )
     {
         newNode = new CswNbtViewRoot( CswNbtResources, View, ViewNodeString );
     }
     else
     {
         throw new CswDniException( CswEnumErrorType.Error, "Invalid ViewNode", "CswNbtViewNode.makeViewNode() got an invalid ViewNodeString: " + ViewNodeString.ToString() );
     }
     return newNode;
 } // makeViewNode()
Пример #3
0
        }//makeNodeFromNodeTypeId()

        /// <summary>
        /// Fetches a User Node from the Username, using a View and a TreeLoader.
        /// </summary>
        /// <remarks>
        /// not sure if this belongs here in CswNbtNodeCollection
        /// </remarks>
        /// <param name="Username">Username of User</param>
        /// <param name="RequireViewPermissions"></param>
        public CswNbtNode makeUserNodeFromUsername(string Username, bool RequireViewPermissions = true)
        {
            CswTimer   Timer    = new CswTimer();
            CswNbtNode UserNode = null;

            CswNbtMetaDataObjectClass     User_ObjectClass         = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.UserClass);
            CswNbtMetaDataObjectClassProp UserName_ObjectClassProp = User_ObjectClass.getObjectClassProp(CswNbtObjClassUser.PropertyName.Username);

            _CswNbtResources.logTimerResult("makeUserNodeFromUsername 1", Timer);

            // generate the view
            CswNbtView View = new CswNbtView(_CswNbtResources);

            View.ViewName = "CswNbtNodes.makeUserNodeFromUsername(" + Username + ")";
            CswNbtViewRelationship   UserRelationship = View.AddViewRelationship(User_ObjectClass, false);
            CswNbtViewProperty       Prop             = View.AddViewProperty(UserRelationship, UserName_ObjectClassProp);
            CswNbtViewPropertyFilter Filter           = View.AddViewPropertyFilter(Prop, CswNbtFieldTypeRuleText.SubFieldName.Text, CswEnumNbtFilterMode.Equals, Username, false);

            _CswNbtResources.logTimerResult("makeUserNodeFromUsername 2", Timer);

            // generate the tree
            ICswNbtTree UserTree = _CswNbtResources.Trees.getTreeFromView(View, RequireViewPermissions, true, IncludeHiddenNodes: true);

            _CswNbtResources.logTimerResult("makeUserNodeFromUsername 3", Timer);

            // get user node
            UserTree.goToRoot();
            if (UserTree.getChildNodeCount() > 0)
            {
                UserTree.goToNthChild(0);
                _CswNbtResources.logTimerResult("makeUserNodeFromUsername 4", Timer);
                UserNode = UserTree.getNodeForCurrentPosition();
            }
            //else
            //{
            //    foreach( CswNbtMetaDataNodeType UserNodeTypes in User_ObjectClass.NodeTypes )
            //    {
            //        foreach( CswNbtNode user in UserNodeTypes.getNodes( true, false ) )
            //        {
            //            if( user.Properties[UserName_ObjectClassProp.PropName].AsText.Text == Username )
            //            {
            //                UserNode = user;
            //                break;
            //            }
            //        }
            //    }
            _CswNbtResources.logTimerResult("makeUserNodeFromUsername 5", Timer);
            return(UserNode);
        }
Пример #4
0
 public void removeFilter(CswNbtViewPropertyFilter Filter)
 {
     Filters.Remove(Filter);
     Filter.Parent = null;
 }
Пример #5
0
 public void addFilter(CswNbtViewPropertyFilter Filter)
 {
     Filters.Add(Filter);
     Filter.Parent = this;
 }
Пример #6
0
 /// <summary>
 /// For loading from XML
 /// </summary>
 public CswNbtViewProperty(CswNbtResources CswNbtResources, CswNbtView View, XmlNode PropNode)
     : base(CswNbtResources, View)
 {
     try
     {
         if (PropNode.Attributes["type"] != null)
         {
             Type = PropNode.Attributes["type"].Value;
         }
         if (PropNode.Attributes["value"] != null)    //backwards compatibility
         {
             if (Type == CswEnumNbtViewPropType.NodeTypePropId)
             {
                 NodeTypePropId = CswConvert.ToInt32(PropNode.Attributes["value"].Value);
             }
             else
             {
                 ObjectClassPropId = CswConvert.ToInt32(PropNode.Attributes["value"].Value);
             }
         }
         if (PropNode.Attributes["nodetypepropid"] != null)
         {
             NodeTypePropId = CswConvert.ToInt32(PropNode.Attributes["nodetypepropid"].Value);
         }
         if (PropNode.Attributes["objectclasspropid"] != null)
         {
             ObjectClassPropId = CswConvert.ToInt32(PropNode.Attributes["objectclasspropid"].Value);
         }
         if (PropNode.Attributes["name"] != null)
         {
             Name = PropNode.Attributes["name"].Value;
         }
         //if( PropNode.Attributes["arbitraryid"] != null )
         //    ArbitraryId = PropNode.Attributes["arbitraryid"].Value;
         if (PropNode.Attributes["sortby"] != null)
         {
             SortBy = Convert.ToBoolean(PropNode.Attributes["sortby"].Value);
         }
         if (PropNode.Attributes["sortmethod"] != null)
         {
             SortMethod = PropNode.Attributes["sortmethod"].Value;
         }
         if (PropNode.Attributes["fieldtype"] != null && PropNode.Attributes["fieldtype"].Value != string.Empty)
         {
             FieldType = CswNbtMetaDataFieldType.getFieldTypeFromString(PropNode.Attributes["fieldtype"].Value);
         }
         if (PropNode.Attributes["order"] != null && PropNode.Attributes["order"].Value != string.Empty)
         {
             Order = CswConvert.ToInt32(PropNode.Attributes["order"].Value);
         }
         if (PropNode.Attributes["width"] != null && PropNode.Attributes["width"].Value != string.Empty)
         {
             Width = CswConvert.ToInt32(PropNode.Attributes["width"].Value);
         }
         if (PropNode.Attributes["showingrid"] != null && PropNode.Attributes["showingrid"].Value != string.Empty)
         {
             ShowInGrid = CswConvert.ToBoolean(PropNode.Attributes["showingrid"].Value);
         }
     }
     catch (Exception ex)
     {
         throw new CswDniException(CswEnumErrorType.Error, "Misconfigured CswViewProperty",
                                   "CswViewProperty.constructor(xmlnode) encountered an invalid attribute value",
                                   ex);
     }
     try
     {
         foreach (XmlNode ChildNode in PropNode.ChildNodes)
         {
             if (ChildNode.Name.ToLower() == CswEnumNbtViewXmlNodeName.Filter.ToString().ToLower())
             {
                 CswNbtViewPropertyFilter Filter = new CswNbtViewPropertyFilter(CswNbtResources, _View, ChildNode);
                 this.addFilter(Filter);
             }
         }
     }
     catch (Exception ex)
     {
         throw new CswDniException(CswEnumErrorType.Error, "Misconfigured CswViewProperty",
                                   "CswViewProperty.constructor(xmlnode) encountered an invalid filter definition",
                                   ex);
     }
 }