Developing plugins for Jiwa 7 using Visual Studio 2012

Samples and Examples of using the Jiwa 7 framework - including plugins, stand-alone applications and scripts.

Developing plugins for Jiwa 7 using Visual Studio 2012

Postby Mike.Sheen » Wed Feb 12, 2014 5:09 pm

Note : This guide will only work with Jiwa 7.00.49 and later installed on your system, as well as Visual Studio 2012 (There is no reason why Visual Studio 2013 would not work as well - I've just not tested that yet).

You will need the following 3rd party components :
  • Infragistics for Windows Forms 13.1.20131.2060
  • Farpoint Spread for Windows Forms 7.35.20132.1

Without the above components you will get licence errors. You can get the free trial versions of the above components, but if you're doing, or plan to do, a reasonable amount of plugin work you should buy their components - they're well worth their price. Jiwa users won't need such licences, they are not required for using the Jiwa product or any plugins which use these components. It's only the developing of plugins using Visual Studio that licences are needed for these components.

JiwaSurrogate.rar
VS2012 Solution
(295.62 KiB) Downloaded 310 times

This is a simple guide for how to develop plugins for Jiwa 7 using Visual Studio 2012. Whilst we do have a reasonably good code editor inside Jiwa 7 with intellisense and code completion - we don't yet have a visual form designer, so making forms is a little tricky.

The best way to develop a form for Jiwa 7 is to design and build it in Visual Studio, and then copy and paste the form and form designer code into the plugin. This guide goes one step further, and (with the accompanying download) shows how to use the provided surrogate Jiwa application to allow you to develop the bulk of your plugin code in Visual Studio - including debugging and edit-and-continue functionality.

Note : If your database you are testing on already has the "Pantry List" plugin enabled (a standard plugin as of Jiwa 7.00.49) - disable it before attempting to follow these steps. This guide is based on how we built the plugin "Pantry List" plugin, and there will be conflicts with the Ribbon / Toolbar tools being added.

1. Download and extract the VS2012 solution attached to this post.
2. Copy all the Jiwa*.DLL files from your Jiwa installation into the output folder of the surrogate project (both projects in the surrogate solution output to the same folder)
3. Open the solution, and check the references are valid in both the JiwaSurrogate project and the Plugins project. If any Jiwa assembly references are invalid, remove them and re-add them, referencing the assemblies in the output folder (NOT the assemblies in your Jiwa program files folder). We need to do this becase when a plugin is compiled and run by the jiwa application, we override the assembly resolver and tell it to look in the current processes (Jiwa - or in this case, the Jiwa surrogate) folder. So any plugins trying to reference Jiwa assemblies will fail unless you copy the assemblies to the output folder of the Surrogate application.
4. Build the solution, then run.

5. You should then see the Jiwa Login dialog, login and then choose plugin maintenance from the menu.

6. Create a new plugin, call it "Surrogate Test".
7. Add a reference to the Plugins.dll located in the output folder of the solution.
8. Add a Form to the forms tab - Sales Orders - this tells the plugin to invoke the FormPlugin class when the Sales Order form is loaded. This will also add any assembly references related to the sales order form for you to the plugin references.
9. Add the following code to the Setup method of the Form Plugin class

Code: Select all
Dim salesOrderForm As JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm = DirectCast(JiwaForm, JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm)
Dim pantryListDialog As PantryList = JiwaApplication.Manager.Instance.DialogFactory.CreateDialog(Of PantryList)(salesOrderForm)
pantryListDialog.Setup(salesOrderForm)


This code is using the DialogFactory of the JiwaApplication Manager to load a dialog. The provided solution contains a project containing a class called "PantryList " which is the dialog we want to load for this guide. The Setup method of the "PantryList" class adds a tool to the ribbon and toolbar, and adds some handlers to the tool clicked event of the sales order form, and the CreateNewCompleted event from the business logic.

10. Tick the "Enabled" checkbox and save.

What we just created was the bootstrapper - it is still a plugin, but it's only enough code to hook into the Assembly built by the Plugins project of the JiwaSurrogate solution. Because this is still a plugin, we need to quit the Jiwa Surrogate solution, run it again and log back in - but only this once - from now on all your changes to the code in the Plugins project of the Surrogate solution are live and real-time (including edit-and-continue!).

11. Quit Jiwa
12. Run the solution again, and login
13. Open the sales order entry form, and press the "Pantry List" button on the ribbon - the pantry dialog should open.

At this point, put a breakpoint in the Setup method of the PantryList.vb code of the Plugins project - then load the press the "Pantry List" button on the sales order form again - your breakpoint will be hit.

You can open the PantryList.vb form in design mode, and add additional forms and classes as you would any normal Visual Studio project.

When you've finished development, and want to put all the code into the plugin code - simply copy all the code from the PantryList.vb and PantryList.Designer.vb classes after the existing code in the plugin code - then run Jiwa (not the surrogate) as per normal.

TIP : If you want to debug the plugin code after you have migrated all the classes to the plugin (ie: using Jiwa and not the surrogate), then just add system.diagnostics.debugger.break() to any part of the plugin where you want the start debugging - if you have Visual Studio installed, it will being a debugging session using Visual Studio at that point - and you will be able to step over, inspect and debug, etc like any other project - but without the edit-and-continue capability. This might be useful in tracking down behaviour differences in the surrogate environment compared to the native Jiwa application environment.

TIP #2: When you're done with your plugin, use the Export XML option under the utilities tab of the plugin maintenance form to package up all the code, references, custom field info, etc into an XML file. On the customer system, Import XML and selecting the previously exported file will create the plugin.
Attachments
JiwaSurrogate.rar
(295.62 KiB) Downloaded 275 times
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Developing plugins for Jiwa 7 using Visual Studio 2012

Postby Mike.Sheen » Mon May 09, 2016 6:07 pm

Updated for Visual Studio 2015 and Jiwa 7.00.157.00.
Attachments
JiwaSurrogate.rar
VS2015 Solution
(504.45 KiB) Downloaded 199 times
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756


Return to Samples and Examples

Who is online

Users browsing this forum: No registered users and 1 guest

cron