Programmer:Simple program to test connection to AutoCount Accounting v2: Difference between revisions

no edit summary
(Created page with "==Version Applicable== AutoCount Accounting '''1.8.30'''.136 and higher ==Introduction== In order to connect to one of the account book in AutoCount Accounting, there are fe...")
 
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 1:
{{DRAFT}}
==Version Applicable==
AutoCount Accounting '''12.80.307'''.136115 and higher
 
==Introduction==
In order to connect to one of the account book inof 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.<br />
STEP 1. Create UserSession & DBSetting
STEP 2. Call (Create) SubProjectStartup
STEP 3. Login to AutoCount Accounting 2.0
 
{{SourceDownload|link=https://drive.google.com/open?id=1PWAV4FkSLXoC6xYyeb7jb9U6ooXoJDzA10Au8sEjrY3UeDykSCcjx-cVqSgWQPzAS|remark=(Visual Studio 20152017)|Download Sample Project|Sample project to test connection to AutoCount Accounting 2.0.}}
[[File:ProgramSampleTestConnect.png|link=]]<br />
<br />
 
==UserSession and DBSetting==
'''DBSettingUserSession''' isand one'''DBSetting''' ofare the most frequentlyfrequent useduse classclasses in AutoCount Accounting 2.0, whether it is plug-in or integratingintegrate system.
Even when writing scripting for report script orand application script, you may find the object of UserSession and DBSetting isare provided.<br />
UserSession and DBSetting isare required by almost all transactions and documents when accessing to databaseAutoCount server is needed.<br />
Moreover, it provides methods such as GetDataTable(...), ExecuteScalar(...), ExecuteNonQuery(...) and more for programmer to easily access to currently connected account book.<br />
During its creation, two pieces of information is important, they are the '''server name''' and '''database name'''.
 
Namespace: BCEAutoCount.Data
 
===Create DBSetting with AutoCount default configuration===
Line 26 ⟶ 27:
Below example code shows the DBSetting is created with new operator.
<syntaxhighlight lang="csharp">
BCEAutoCount.Data.DBSetting dbSetting = new BCEAutoCount.Data.DBSetting(DBServerType.SQL2000, serverName, dbName);
</syntaxhighlight>
 
* DBServerType which is the First parameter is always DBServerType.SQL2000, regardless of which Microsoft SQL Server version is being applied.
* To obtain available '''Server Name''' and '''Database Name''':
** Programatically, you may refer to "[[Programmer:Create BCEAutoCount.Data.DBSetting with Database Info|Create BCEAutoCount.Data.DBSetting with Database Info in AutoCount Accounting 12.80]]".
** Manually, at the login screen of AutoCount Accounting.
::[[File:ProgramLoginForm.png|450px|link=]]
<br />
===Create DBSetting while specifyingspecify SQL Server sa password===
<syntaxhighlight lang="csharp">
BCEAutoCount.Data.DBSetting dbSetting = new BCEAutoCount.Data.DBSetting(DBServerType.SQL2000, serverName, "sa", "mYsApAsSwOrD", dbName);
</syntaxhighlight>
* sa login password can be omitted when the password is using AutoCount default sa login password.
Line 46:
<br />
 
<!--
==SubProjectStartupWithLogin==
*When using '''SubProjectStartupWithLogin''' it does the following tasks:
Line 116 ⟶ 117:
<br />
{{Warn|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.}}
 
 
==Error: InvalidLCPFileException==
'''Invalid LCP File Exception''' is common error when calling SubProjectStartup or SubProjectStartupWithLogin when loading from a ''standalone program'' or ''web application''.
 
Exception Namespace: BCE.LCP.InvalidLCPDecryptFileException
[[File:ProgramInvalidLCP.png|link=]]
 
===Solution===
Include LCP files together with your exe or dll which is calling SubProjectStartup.<br /><br />
*To let Visual Studio copy these files to output folder for debugging, follow steps below:
# Find these files in AutoCount Accounting folder.
#* LCPDecrypt.wdl
#* LCPDecrypt2.exe
#* LCPDecrypt2.wdl
#* LCPDecryptApp.exe
#Add these files to your Project as existing items.
#* Set Build Action = none (empty)
#* Copy to Output = Copy if newer
:So that these files will be copied to project output folder.
:Refer to [[Invalid LCPDecryptFileException was unhandled]]
 
<br />
==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.
 
<syntaxhighlight lang="csharp">
bool loginSuccess = BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbset)userSession.Login(userID, password);
 
if (loginSuccess)
Line 154 ⟶ 135:
}
</syntaxhighlight>
-->
 
<br/>
==See Also==
*[[Programmer:Create BCE.Data.DBSetting with Database Info|Create BCE.Data.DBSetting with Database Info in AutoCount Accounting 1.8]]
*[[Programmer:Simple program to test connection to AutoCount Accounting v2|A simple program to test connection to AutoCount Accounting 2.0]]
*[[Programmer:Simple program to test connection to AutoCount Accounting|A simple program to test connection to AutoCount Accounting 1.8/1.9]]
*[[Programmer:Create BCE.Data.DBSetting with Database Info|Create BCE.Data.DBSetting with Database Info in AutoCount Accounting 1.8/1.9]]
*[[Invalid LCPDecryptFileException was unhandled]]
<br />