Exercise 1: Build AutoCount Accounting 2.0 Plug-In: Difference between revisions

From AutoCount Resource Center
Content added Content deleted
No edit summary
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{NavigateDeveloper|collapsed}}
__TOC__
__TOC__
Objectives: Create a new Plug-in project for AutoCount Accounting 2.0
Objectives: Create a new Plug-in project for AutoCount Accounting 2.0
Line 13: Line 12:
# Enter project name: MyPlugIn2
# Enter project name: MyPlugIn2
*Click [OK]
*Click [OK]
<br />


<br />
===Check Project Properties===
===Check Project Properties===
{{Note|Right click Project "MyPlugIn2" and select Properties.<br />Or select Project "MyPlugIn2" and press Alt-Enter. [[Exercise_1:_Build_My_First_Plug-In|''Refer Exercise 1: Build My First Plug-In'']]}}
# Open Project Properties
# Open Project Properties
# Select '''Application''' page
# Select '''Application''' page
# Verify following properties:-
# Verify following properties:-
#*Target Framework: .NET Framework 4.5
#*Target Framework: '''.NET Framework 4.6.1'''
#*Output type: Class Library
#*Output type: '''Class Library'''
# Select '''Build''' page
# Select '''Build''' page
# Verify Platform target: '''Any CPU'''
# Verify Platform target: '''Any CPU'''


<br />
===Add AutoCount Accounting 2.0 References to Project===
===Add AutoCount Accounting 2.0 References to Project===
[[File:BrowseReference.PNG|link=]]
[[File:BrowseReference.PNG|link=]]
{{Note|Suggest to copy the dll to a folder and rename the folder to AutoCount Accounting version. Eg.: AC2.0.55.<br />So that when necessity arises, programmer can maintain multiple versions of Plug-Ins.}}
{{Note|Suggest to copy the dll to a folder and rename the folder to AutoCount Accounting version. Eg.: AC2.0.0.55.<br />So that when necessity arises, programmer can maintain multiple versions of Plug-Ins.}}
# Add References Window
# Add References Window
# Browse to AutoCount Accounting 2.0 folder
# Browse to AutoCount Accounting 2.0 folder
Line 47: Line 48:


<br />
<br />

==Plug-In Entry Point==
==Plug-In Entry Point==
===PlugInMain to Inherit from AutoCount.PlugIn.BasePlugIn===
===PlugInMain to Inherit from AutoCount.PlugIn.BasePlugIn===
Line 58: Line 60:
{
{
public PlugInMain() : base(new Guid("12D34B4A-692D-46DE-8D7D-B3520D4CA679"),
public PlugInMain() : base(new Guid("12D34B4A-692D-46DE-8D7D-B3520D4CA679"),
"My PlugIn for AC 2.0", "2.0.0")
"My PlugIn for AC 2.0", "1.0.0.1")
{
{
}
}
}
}
</syntaxhighlight>
</syntaxhighlight>
{{Note|While every Plug-In must not assigned with a same GUID.<br />It is advised to use the same GUID for the same plug-in, when the plug-in version is updated.}}
{{Note|While every Plug-In must not assigned with a same GUID.<br />It is advised to use the same GUID for the same plug-in, though plug-in version can be updated.}}


===Set Plug-In Profile and Properties===
===Set Plug-In Profile and Properties===
<syntaxhighlight lang="csharp" highlight="5-9,12,14">
<syntaxhighlight lang="csharp" highlight="5-9,12,14">
public PlugInMain() : base(new Guid("12D34B4A-692D-46DE-8D7D-B3520D4CA679"),
public PlugInMain() : base(new Guid("12D34B4A-692D-46DE-8D7D-B3520D4CA679"),
"My PlugIn for AC 2.0", "2.0.0")
"My PlugIn for AC 2.0", "1.0.0.1")
{
{
//Enter your Company Profile registered with AutoCount's Developer ID
//Enter your Company Profile registered with AutoCount's Developer ID
Line 78: Line 80:


//Minimum AutoCount Accounting version is required
//Minimum AutoCount Accounting version is required
SetMinimumAccountingVersionRequired("2.0.55");
SetMinimumAccountingVersionRequired("2.0.0.55");
//Set this Plug-In is free
//Set this Plug-In is free
SetIsFreeLicense(true);
SetIsFreeLicense(true);
Line 85: Line 87:


<syntaxhighlight lang="csharp">
<syntaxhighlight lang="csharp">
SetMinimumAccountingVersionRequired("2.0.55");
SetMinimumAccountingVersionRequired("2.0.0.55");
</syntaxhighlight>
</syntaxhighlight>
* AutoCount Accounting version that is lower than 2.0.55 will not be able to run this Plug-In.
* AutoCount Accounting version that is lower than 2.0.0.55 will not be able to run this Plug-In.
* To ensure assemblies version compatibility between AutoCount Accounting and Plug-In;
* To ensure assemblies version compatibility between AutoCount Accounting and Plug-In;
* when Plug-In applies methods and properties that are introduced in newer version of AutoCount Accounting.
* when Plug-In applies methods and properties that are introduced in newer version of AutoCount Accounting.
<syntaxhighlight lang="csharp">
SetIsFreeLicense(false);
</syntaxhighlight>
* Set whether the plug-in is '''free''' or '''License Required'''.
* Set to '''false''' if the plug-in has expiry date or license control.
[[File:PluginLicense.PNG|link=]]


<br />
===BeforeLoad===
===BeforeLoad===
<syntaxhighlight lang="csharp">
public override bool BeforeLoad(BeforeLoadArgs e)
{
e.MainMenuCaption = "My PlugIn 2";
//e.SystemReportFilename = "MyCustomReport.dat";
return base.BeforeLoad(e);
}
</syntaxhighlight>
* '''BeforeLoad(BeforeLoadArgs e)''' method is commonly use for initializing the necessary components or database custom tables before the plug-in is loaded;
* while these tasks can also be done using '''AfterLoad(AfterLoadArgs e)''' event method,
* '''AfterLoad(AfterLoadArgs e)''' does not consist of e.MainMenuCaption and e.SystemReportFilename in version 2.0.0.55.
<syntaxhighlight lang="csharp">
e.MainMenuCaption = "My PlugIn 2";
</syntaxhighlight>
* Assign a caption on the Main Menu.
<syntaxhighlight lang="csharp">
e.SystemReportFilename = "MyCustomReport.dat";
</syntaxhighlight>
* To load a report file that is embedded with the plug-in.


<br />



===GetLicenseStatus===
===GetLicenseStatus===

[[Category:Programmer]]
[[Category:Plug-In]]
[[Category:Programmer Exercise]]
{{NavigateDeveloper}}

Latest revision as of 03:51, 19 June 2020

Objectives: Create a new Plug-in project for AutoCount Accounting 2.0
This exercise is to build an AutoCount Accounting Plug-in Package, and successfully load the Plug-in at AutoCount Accounting 2.0 Plug-in Manager.
Project in this tutorial is created with Microsoft Visual Studio 2017 Community

Starting new AutoCount Accounting 2.0 Plug-In

Create New Plug-In Project

  1. Create a new "Visual C#" Project
  2. Framework is .Net Framework 4.5
  3. Select "Windows Forms App (.Net Framework)
  4. Enter project name: MyPlugIn2
  • Click [OK]


Check Project Properties

Right click Project "MyPlugIn2" and select Properties.
Or select Project "MyPlugIn2" and press Alt-Enter. Refer Exercise 1: Build My First Plug-In
  1. Open Project Properties
  2. Select Application page
  3. Verify following properties:-
    • Target Framework: .NET Framework 4.6.1
    • Output type: Class Library
  4. Select Build page
  5. Verify Platform target: Any CPU


Add AutoCount Accounting 2.0 References to Project

Suggest to copy the dll to a folder and rename the folder to AutoCount Accounting version. Eg.: AC2.0.0.55.
So that when necessity arises, programmer can maintain multiple versions of Plug-Ins.
  1. Add References Window
  2. Browse to AutoCount Accounting 2.0 folder
    • Default path of 64bit AutoCount Accounting is C:\Program Files\AutoCount\Accounting 2.0\
  3. DLL files are assemblies of AutoCount Accounting that can be added to project references
  • Click [Add]

Adding AutoCount Accounting 2.0 Base Assemblies

  1. AutoCount.dll
  2. AutoCount.CommonAccounting.dll
  3. AutoCount.MainEntry.dll
  4. AutoCount.WinForms.dll


Add Class "PlugInMain.cs"

  1. Add a class to project.
  2. Name the class "PlugInMain.cs"
  • Click [Add]


Plug-In Entry Point

PlugInMain to Inherit from AutoCount.PlugIn.BasePlugIn

  1. Inherit AutoCount.PlugIn.BasePlugIn to PlugInMain
  2. Add Constructor that is required by the base class, which constructor requires 3 arguments:-
    • Generate a new GUID for this plug-in.
    • Name this Plug-In
    • Version of this Plug-In
public class PlugInMain : AutoCount.PlugIn.BasePlugIn
{
    public PlugInMain() : base(new Guid("12D34B4A-692D-46DE-8D7D-B3520D4CA679"),
        "My PlugIn for AC 2.0", "1.0.0.1")
    {
    }
}
While every Plug-In must not assigned with a same GUID.
It is advised to use the same GUID for the same plug-in, though plug-in version can be updated.

Set Plug-In Profile and Properties

public PlugInMain() : base(new Guid("12D34B4A-692D-46DE-8D7D-B3520D4CA679"),
    "My PlugIn for AC 2.0", "1.0.0.1")
{
    //Enter your Company Profile registered with AutoCount's Developer ID
    SetManufacturer("Auto Count Sdn. Bhd.");
    SetManufacturerUrl("http://www.autocountsoft.com");
    SetCopyright("Copyright 2015 © Auto Count Sdn. Bhd.");
    SetSalesPhone("1-800-88-7766");
    SetSupportPhone("+60-3-3324-2148");

    //Minimum AutoCount Accounting version is required
    SetMinimumAccountingVersionRequired("2.0.0.55");
    //Set this Plug-In is free
    SetIsFreeLicense(true);
}
SetMinimumAccountingVersionRequired("2.0.0.55");
  • AutoCount Accounting version that is lower than 2.0.0.55 will not be able to run this Plug-In.
  • To ensure assemblies version compatibility between AutoCount Accounting and Plug-In;
  • when Plug-In applies methods and properties that are introduced in newer version of AutoCount Accounting.
SetIsFreeLicense(false);
  • Set whether the plug-in is free or License Required.
  • Set to false if the plug-in has expiry date or license control.


BeforeLoad

public override bool BeforeLoad(BeforeLoadArgs e)
{
    e.MainMenuCaption = "My PlugIn 2";
    //e.SystemReportFilename = "MyCustomReport.dat";
    return base.BeforeLoad(e);
}
  • BeforeLoad(BeforeLoadArgs e) method is commonly use for initializing the necessary components or database custom tables before the plug-in is loaded;
  • while these tasks can also be done using AfterLoad(AfterLoadArgs e) event method,
  • AfterLoad(AfterLoadArgs e) does not consist of e.MainMenuCaption and e.SystemReportFilename in version 2.0.0.55.
e.MainMenuCaption = "My PlugIn 2";
  • Assign a caption on the Main Menu.
e.SystemReportFilename = "MyCustomReport.dat";
  • To load a report file that is embedded with the plug-in.


GetLicenseStatus

Go to menu

Go to top
Resources For AutoCount Software Developers