Programmer:Simple program to test connection to AutoCount Accounting v2

Revision as of 09:50, 8 April 2019 by DanielY (talk | contribs)
[DRAFT]

Version Applicable

AutoCount Accounting 2.0.7.115 and higher

Introduction

In order to connect to one of the account book of AutoCount Accounting 2.0, there are few steps to start with.
To understand each of the steps, a program is written to test the result of each step.
STEP 1. Create UserSession & DBSetting STEP 2. Call (Create) SubProjectStartup STEP 3. Login to AutoCount Accounting 2.0
  Download Sample Project (Visual Studio 2017)

Sample project to test connection to AutoCount Accounting 2.0.

 

UserSession and DBSetting

UserSession and DBSetting are the most frequently used classes in AutoCount Accounting 2.0, whether it is plug-in or integrate system.
Even when writing scripting for report script and application script, you may find the object of UserSession and DBSetting are provided.
UserSession and DBSetting are required by almost all transactions and documents when accessing to AutoCount server.
Moreover, it provides methods such as GetDataTable(...), ExecuteScalar(...), ExecuteNonQuery(...) and more for programmer to access currently connected account book.
During its creation, two pieces of information is important, they are the server name and database name.
Namespace: AutoCount.Data

Create DBSetting with AutoCount default configuration

DBSetting object can be created with new operator, or via SubProjectStartupWithLogin method.
Below example code shows the DBSetting is created with new operator.

BCE.Data.DBSetting dbSetting = new BCE.Data.DBSetting(DBServerType.SQL2000, serverName, dbName);
 


Create DBSetting while specifying SQL Server sa password

BCE.Data.DBSetting dbSetting = new BCE.Data.DBSetting(DBServerType.SQL2000, serverName, "sa", "mYsApAsSwOrD", dbName);
  • sa login password can be omitted when the password is using AutoCount default sa login password.
  • Specify the sa password only when sa password has been changed.


  Success of created DBSetting does not justify whether the provided information connecting to SQL Server is correct.
DBSetting merely store the information that is essential to connect SQL Server.



SubProjectStartupWithLogin

  • When using SubProjectStartupWithLogin it does the following tasks:
    1. Return DBSetting upon success login. Whereas, return null when user clicks cancel.
    2. Initiate AutoCount Accounting system
    3. Login to AutoCount Accounting


BCE.Data.DBSetting dbSetting = BCE.AutoCount.MainEntry.Startup.Default.SubProjectStartupWithLogin("", "");

//dbSetting is null when user did not login by pressing 'Cancel'
if (dbSetting != null)
{
    //Do something after DBSetting, SubProjectStartup, and Login to AutoCount Accounting are all successful
}
else
{
    //Exit, prompt message or throw error
}
  • Requires two values to specify where AutoCount Accounting Database Info are stored;
  • To let AutoCount Accounting use default path, set the two values to empty string.
  When calling SubProjectStartupWithLogin, it prompts login form for user to input.
Upon successful login, it returns DBSetting, initialized AutoCount Accounting system and Login to AutoCount Accounting.
If user cancel login, the return value of DBSetting is null.


SubProjectStartup

When call SubProjectStartup, DBSetting object must be created before SubProjectStartup can be used.
It does not return any result. It throws exception, when error is encountered.

SubProjectStartup is to initialize AutoCount Accounting system, while it also perform below two important tasks:-

  1. Whether to load plug-in
    Some plug-in may contain script that calculate the subtotal which may require to be loaded.
  2. Load account book Licensing
    License Code or Dongle


Four overloading methods of SubProjectStartup

//Does not load Plug-In
//Load license control by license code
void BCE.AutoCount.MainEntry.Startup.Default.SubProjectStartup(DBSetting dbSetting);


//Programmer define whether plug-in will be loaded
//Load license control by license code
void BCE.AutoCount.MainEntry.Startup.Default.SubProjectStartup(DBSetting dbSetting, BCE.AutoCount.MainEntry.StartupPlugInOption loadPlugInOption);


//Programmer define whether plug-in will be loaded
//Programmer define which type of license control to be loaded, either License Code or Dongle
void BCE.AutoCount.MainEntry.Startup.Default.SubProjectStartup(DBSetting dbSetting, BCE.AutoCount.MainEntry.StartupPlugInOption loadPlugInOption,
    BCE.AutoCount.MainEntry.StartupLicenseControlType slcType);


//Programmer define whether plug-in will be loaded
//Programmer define which type of license control to be loaded, either License Code or Dongle
//and define the IP and Port of USB server for Dongle License
void BCE.AutoCount.MainEntry.Startup.Default.SubProjectStartup(DBSetting dbSetting, BCE.AutoCount.MainEntry.StartupPlugInOption loadPlugInOption,
    BCE.AutoCount.MainEntry.StartupLicenseControlType slcType, string dgServerName, int dgServerPort);
  • There are 4 overloading methods when calling SubProjectStartup (Reference of version 1.8.30.186)
    • Prior to version 1.8.30.186, SubProjectStatup does not include the parameter of StartupPlugInOption;
    • StartupPlugInOption allows programmer to set whether to load plug-in, when AutoCount Accounting is initialized.
  • Dongle server name is the IP address of the computer where USB Key Server (windows service) is installed.
  • The dongle's default server port is 9560.
    • Port setting can be found in, Tools | Options -> General | Miscellaneous -> USB Key Setting
    • Default value is used when port is not defined in SubProjectStartup.


  For inter-billing and integration, if StartupPlugInOption.LoadStandardPlugIn is not stated in SubProjectStartup, the target account book will not load plug-in that has/have installed.



Login to AutoCount Accounting

In order to create transaction and document, Login to AutoCount Accounting is required. To login to AutoCount Accounting, use object of AutoCount.Authentication.UserSession to login.

bool loginSuccess = userSession.Login(userID, password);

if (loginSuccess)
{
    //Do something
}
else
{
    //Exit, prompt message or throw error
}


See Also


Go to menu

  Go to top
  Resources For AutoCount Software Developers