Initiate UserSession and DBSetting: Difference between revisions
Content added Content deleted
(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...") |
No edit summary |
||
Line 7: | Line 7: | ||
UI Components require System.Windows.Forms and DevExpress winForm components. |
UI Components require System.Windows.Forms and DevExpress winForm components. |
||
{{Warn|UserSession must only initiate once in the application. |
|||
Do not create more than one instance in a running application. As it may consume system resource and has an impact on your application performance.<br/> |
|||
After obtained the object of UserSession, pass it as parameter in constructor or method. |
|||
}} |
|||
===Unattended Connection without loading UI components=== |
===Unattended Connection without loading UI components=== |
Revision as of 07:46, 1 February 2023
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.
UserSession must only initiate once in the application.
Do not create more than one instance in a running application. As it may consume system resource and has an impact on your application performance. |
Unattended Connection without loading UI components
Nuget package: AutoCount2.Accounting
Assemblies : |
|
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
Assemblies : |
|
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
Assemblies : |
|
internal AutoCount.Authentication.UserSession InitiateUserSessionWithLogin()
{
return AutoCount.MainEntry.MainStartup.Default.SubProjectStartupWithLogin("", "");
}