Leadtools.Medical.Workstation.DataAccessLayer Requires Medical product license | Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
UserName Property
See Also  Example
Leadtools.Medical.Workstation.DataAccessLayer Namespace > User Class : UserName Property



Gets or sets the user's name.

Syntax

Visual Basic (Declaration)  
Public Property UserName As String
Visual Basic (Usage) Copy Code
Dim instance As User
Dim value As String
 
instance.UserName = value
 
value = instance.UserName
C#  
public string UserName {get; set;}
C++/CLI  
public:
property String^ UserName {
   String^ get();
   void set (String^ value);
}

Return Value

A String representing the user's name.

Example

Visual Basic Copy Code
<Test> _
Public Sub CreateDbUser()
  Dim dataAccessAgent As IWorkstationDataAccessAgent = Nothing
  Try
     'make sure you have configured the application configuration file with a valid
     'SqlCe connection string which have the same connection name 'WorkstationSqlCeConnection'
     dataAccessAgent = DataAccessAgentFactory.Instance.CreateAccessAgent("WorkstationSqlCeConnection")

     If Nothing Is dataAccessAgent Then
       Console.WriteLine("You have not configured a valid database connection.")

       Return
     End If
  Catch exception As Exception
     Console.WriteLine(exception.Message," :You have not configured a valid database connection.")

     Return
  End Try

  Dim administratorUser As String = "Administrator" 'make sure you have an existent administrator this administrator user should be created when you create the database.
  Dim newUserName As String = "NewUser"
  Dim adminPassword As SecureString = New SecureString()
  Dim newUserPassword As SecureString = New SecureString()

  adminPassword.AppendChar("a"c)
  adminPassword.AppendChar("d"c)
  adminPassword.AppendChar("m"c)
  adminPassword.AppendChar("i"c)
  adminPassword.AppendChar("n"c)

  newUserPassword.AppendChar("u"c)
  newUserPassword.AppendChar("s"c)
  newUserPassword.AppendChar("e"c)
  newUserPassword.AppendChar("r"c)

  dataAccessAgent.AddUser(administratorUser, adminPassword, newUserName, newUserPassword, False)

  Console.WriteLine("Is User Authenticated:", newUserName, dataAccessAgent.IsUserValid(newUserName, newUserPassword))
  Console.WriteLine("Is User Administrator:", newUserName, dataAccessAgent.IsAdmin(newUserName))

  dataAccessAgent.SetAdminUser(administratorUser, adminPassword, newUserName, True)

  Console.WriteLine("Is User Administrator:", newUserName, dataAccessAgent.IsAdmin(newUserName))

  dataAccessAgent.SetUserPassword(administratorUser, adminPassword, newUserName, adminPassword)

  Dim users As User() = dataAccessAgent.GetUsers()

  Console.WriteLine("Listing all database users...")

  For Each dbUser As User In users
     Console.WriteLine(dbUser.UserName)
  Next dbUser

  adminPassword.Dispose()
  newUserPassword.Dispose()
End Sub
C# Copy Code
public void CreateDbUser() 

   IWorkstationDataAccessAgent dataAccessAgent = null ; 
 
   try 
   { 
      //make sure you have configured the application configuration file with a valid  
      //SqlCe connection string which have the same connection name 'WorkstationSqlCeConnection' 
      dataAccessAgent = DataAccessAgentFactory.Instance.CreateAccessAgent("WorkstationSqlCeConnection"); 
 
      if (null == dataAccessAgent) 
      { 
         Console.WriteLine("You have not configured a valid database connection."); 
 
         return; 
      } 
   } 
   catch ( Exception exception ) 
   { 
      Console.WriteLine( exception.Message," :You have not configured a valid database connection."); 
 
      return ; 
   } 
 
   string administratorUser = "Administrator";//make sure you have an existent administrator this administrator user should be created when you create the database. 
   string newUserName = "NewUser"; 
   SecureString adminPassword = new SecureString(); 
   SecureString newUserPassword = new SecureString(); 
 
   adminPassword.AppendChar('a'); 
   adminPassword.AppendChar('d'); 
   adminPassword.AppendChar('m'); 
   adminPassword.AppendChar('i'); 
   adminPassword.AppendChar('n'); 
 
   newUserPassword.AppendChar('u'); 
   newUserPassword.AppendChar('s'); 
   newUserPassword.AppendChar('e'); 
   newUserPassword.AppendChar('r'); 
 
   dataAccessAgent.AddUser(administratorUser, adminPassword, newUserName, newUserPassword, false); 
 
   Console.WriteLine("Is User Authenticated:", newUserName, dataAccessAgent.IsUserValid(newUserName, newUserPassword)); 
   Console.WriteLine("Is User Administrator:", newUserName, dataAccessAgent.IsAdmin(newUserName)); 
 
   dataAccessAgent.SetAdminUser(administratorUser, adminPassword, newUserName, true); 
 
   Console.WriteLine("Is User Administrator:", newUserName, dataAccessAgent.IsAdmin(newUserName)); 
 
   dataAccessAgent.SetUserPassword(administratorUser, adminPassword, newUserName, adminPassword); 
 
   User [ ] users = dataAccessAgent.GetUsers(); 
 
   Console.WriteLine("Listing all database users..."); 
 
   foreach (User dbUser in users) 
   { 
      Console.WriteLine(dbUser.UserName); 
   } 
 
   adminPassword.Dispose(); 
   newUserPassword.Dispose(); 
}

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also

Leadtools.Medical.Workstation.DataAccessLayer requires a Medical toolkit license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features