Initiate UserSession and DBSetting

From AutoCount Resource Center
Revision as of 07:18, 1 February 2023 by DanielY (talk | contribs) (Created page with " ==Initiate UserSession and Connect to AutoCount Accounting 2.1== There are 3 methods to establish connection to AutoCount Accounting 2.1. # Unattended connection without loading UI components # Unattended connection that load UI components # User login to establish connection (needs UI components) UI Components require System.Windows.Forms and DevExpress winForm components. ===Unattended Connection without loading UI components=== {{NugetPackages|AutoCount2.Accounti...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Initiate UserSession and Connect to AutoCount Accounting 2.1

There are 3 methods to establish connection to AutoCount Accounting 2.1.

  1. Unattended connection without loading UI components
  2. Unattended connection that load UI components
  3. User login to establish connection (needs UI components)
UI Components require System.Windows.Forms and DevExpress winForm components. 

Unattended Connection without loading UI components

Nuget package: AutoCount2.Accounting

internal UserSession InitiateUserSessionUnattended(string serverName, string dbName, string userLogin, string userPasswd)
{
    AutoCount.MainEntry.Startup startup = new AutoCount.MainEntry.Startup();
    AutoCount.Data.DBSetting dbSetting = new AutoCount.Dadta.DBSetting(
                                          DBServerType.SQL2000, serverName, dbName);
    AutoCount.Authentication.UserSession userSession = new 
                                         AutoCount.Authentication.UserSession(dbSetting);
            
    if (userSession.Login(userLogin, userPasswd))
    {
        //2nd parameter is to load plug-in when value is true.
        //set 2nd parameter to false if do not want to load plug-in.
        startup.SubProjectStartup(userSession, true);
    }
    return userSession;
}


Unattended connection that load UI components

Nuget package: AutoCount2.Accounting.UI

internal UserSession InitiateUserSessionUnattendedWithUI(string serverName, string dbName, string userLogin, string userPasswd)
{
    AutoCount.MainEntry.UIStartup startup = new AutoCount.MainEntry.UIStartup();
    AutoCount.Data.DBSetting dbSetting = new AutoCount.Dadta.DBSetting(
                                          DBServerType.SQL2000, serverName, dbName);
    AutoCount.Authentication.UserSession userSession = new 
                                         AutoCount.Authentication.UserSession(dbSetting);
            
    if (userSession.Login(userLogin, userPasswd))
    {
        //2nd parameter is to load plug-in when value is true.
        //set 2nd parameter to false if do not want to load plug-in.
        startup.SubProjectStartup(userSession, true);
    }
    return userSession;
}

User login to establish connection (needs UI components)

Nuget package: AutoCount2.MainEntry

internal AutoCount.Authentication.UserSession InitiateUserSessionWithLogin()
{
    return AutoCount.MainEntry.MainStartup.Default.SubProjectStartupWithLogin("", "");
}