/OR.Lazarus/OR.Lazarus.Library/DataTier/Source/Lazarus/UserDetail.cs
# · C# · 191 lines · 138 code · 33 blank · 20 comment · 10 complexity · d0e3516b4a68981201714e951b0b1ea7 MD5 · raw file
- using System;
- using System.Data;
- using System.Xml;
-
- using OR.Reuse.Persistence;
-
- using Derived = OR.Lazarus.Library.DataTier.Source;
-
- namespace OR.Lazarus.Library.DataTier.Source.Lazarus
- {
- /// <summary>
- /// Defines a user, which may be a database-internal user, or a Windows Security User. As user may be a member of many roles.
- /// </summary>
- public class UserDetail : EntityBase
- {
- protected System.String mName;
- protected string mType;
- protected string mPassword;
- protected string mDescription;
-
- protected Derived.RoleCollection mRoles;
-
- public UserDetail()
- {
- mRoles = new Derived.RoleCollection();
- mRoles.ParentEntity = this;
-
- }
-
- /// <summary>
- /// Specifies a unique name for the entity.
- /// </summary>
- public System.String Name
- {
- get
- {
- return ( mName );
- }
- set
- {
- mName = value;
- }
- }
-
- /// <summary>
- /// Defines the type of user. Possible values are Internal and Windows. Internal users belong to the specific Database, while Windows users are Domain or Active Directory logins.
- /// </summary>
- public string Type
- {
- get
- {
- return ( mType );
- }
- set
- {
- mType = value;
- }
- }
-
- /// <summary>
- /// Defines the password for the user.
- /// </summary>
- public string Password
- {
- get
- {
- return ( mPassword );
- }
- set
- {
- mPassword = value;
- }
- }
-
- /// <summary>
- /// Provides a long-text description for the entity.
- /// </summary>
- public string Description
- {
- get
- {
- return ( mDescription );
- }
- set
- {
- mDescription = value;
- }
- }
-
- public Derived.RoleCollection Roles
- {
- get
- {
- return ( mRoles );
- }
- set
- {
- mRoles = value;
- }
- }
-
- public override void LoadXml( XmlElement pSource )
- {
- // Scalar Values
- mName = DataUtility.GetString( pSource, "name" );
- mType = DataUtility.GetString( pSource, "user-type" );
- mPassword = DataUtility.GetString( pSource, "password" );
- XmlElement vDescription = ( XmlElement )pSource.SelectSingleNode( "lz:description", PersistenceConfig.Namespaces );
-
- if ( vDescription != null )
- {
- mDescription = vDescription.InnerText;
- }
-
- XmlElement vRoles = ( XmlElement )pSource.SelectSingleNode( "lz:roles", PersistenceConfig.Namespaces );
-
- if ( vRoles != null )
- {
- mRoles.LoadXml( vRoles );
- }
- }
-
- public override XmlElement SaveXml( XmlDocument p_docContext )
- {
- XmlElement vNewElement = p_docContext.CreateElement( "lz", "user", "http://schemas.icitadel.com/Lazarus/Source.xsd" );
-
- // Scalar Values
- if ( !String.IsNullOrEmpty( mName ) )
- {
- vNewElement.SetAttribute( "name", mName );
- }
-
- if ( !String.IsNullOrEmpty( mType ) )
- {
- vNewElement.SetAttribute( "user-type", mType );
- }
-
- if ( !String.IsNullOrEmpty( mPassword ) )
- {
- vNewElement.SetAttribute( "password", mPassword );
- }
-
- if ( !String.IsNullOrEmpty( mDescription ) )
- {
- XmlElement vDescription = p_docContext.CreateElement( "lz", "description", "http://schemas.icitadel.com/Lazarus/Source.xsd" );
- vDescription.InnerText = mDescription;
- vNewElement.AppendChild( vDescription );
- }
-
-
- // Collections
-
- XmlElement vCollection = null;
-
- vCollection = mRoles.SaveXml( p_docContext );
- if ( vCollection != null )
- {
- vNewElement.AppendChild( vCollection );
- }
-
- return ( vNewElement );
- }
-
- public virtual object Clone()
- {
- Derived.UserDetail v_oReturn = new Derived.UserDetail();
-
- v_oReturn.Name = mName;
- v_oReturn.Type = mType;
- v_oReturn.Password = mPassword;
- v_oReturn.Description = mDescription;
-
- // FK Values
-
- // Collections
-
- foreach ( Derived.RoleDetail vDetail in mRoles )
- {
- v_oReturn.Roles.Add( vDetail.CloneTyped() );
- }
-
- return ( v_oReturn );
- }
-
- public virtual Derived.UserDetail CloneTyped()
- {
- return ( ( Derived.UserDetail )this.Clone() );
- }
- }
- }