Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Repair Jira Macros

Table of Contents

Version 7.00.177.00 of Jiwa included some changes that will likely cause plugins or applications using our assemblies to no longer compile, or produce unexpected errors at runtime.

What changed

We deprecated the Instance singleton property

"Instance" property has been deprecated (marked as obsolete) in the JiwaFinancials.Jiwa.JiwaApplication.Manager class.

The Manager class has a property named Instance, which could be used like this:

Code Block
languagec#
titleOld Login Example
JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.Logon("MyServer", "JiwaDemo", JiwaFinancials.Jiwa.JiwaODBC.database.AuthenticationModes.JiwaAuthentication, "Admin", password);
JiwaApplication.Manager.Instance.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder>(null);
var db = JiwaApplication.Manager.Instance.Database;
using (SqlCommand SQLCmd = new SqlCommand(sql, db.SQLConnection, db.SQLTransaction))
{
}


Warning

The above example - whilst it still compiles - is no longer supported.

 

To address this, you should no longer refer to the singleton instance property, but instead use an instance of the Manager class instead:

Code Block
languagec#
titleNew Login Example
var manager = new JiwaFinancials.Jiwa.JiwaApplication.Manager();
manager.Logon("MyServer", "JiwaDemo", JiwaFinancials.Jiwa.JiwaODBC.database.AuthenticationModes.JiwaAuthentication, "Admin", password);
manager.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder>(null);
var db = manager.Database;
using (SqlCommand SQLCmd = new SqlCommand(sql, db.SQLConnection, db.SQLTransaction))
{
}

As many classes require access to the Manager class instance, removing the singleton instance property meant we now needed to add a Manager property to all our Forms, Dialogs and Business Logic.

Our interfaces which are implemented by all our Forms, Dialogs and Business Logic have had a Manager property added:

  • JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogic
  • JiwaFinancials.Jiwa.JiwaApplication.IJiwaCollection
  • JiwaFinancials.Jiwa.JiwaApplication.IJiwaCollectionItem
  • JiwaFinancials.Jiwa.JiwaApplication.IJiwaDialog
  • JiwaFinancials.Jiwa.JiwaApplication.IJiwaEntity
  • JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm

So all classes implementing the above interfaces now have a Manager property also. We also included in the above interfaces a Setup method. The factories should always be used to create a new instance of any class implementing the above, as the factory will set the Manager property and then invoke the Setup method of the newly instantiated object.

The factories are accessible via properties of the Manager class - these are BusinessLogicFactory, CollectionFactory, CollectionItemFactory, DialogFactory, EntityFactory, FormFactory.

An example of using the Entity Factory of the Manager:

Code Block
languagec#
titleEntity Factory Example
var branch = Manager.EntityFactory.CreateEntity<JiwaFinancials.Jiwa.JiwaApplication.Entities.Sales.Branch>();
branch.ReadRecord("ABC123");

 

An example of using the CollectionItem Factory of the Manager:

Code Block
languagec#
titleCollectionItem Factory Example
var debtorPrice = Manager.CollectionItemFactory.CreateCollectionItem<JiwaFinancials.Jiwa.JiwaInventory.DebtorSpecificInventorySpecific>();
debtorPrice.Debtor.Search();
Inventory.DebtorPrices.Add(debtorPrice);

 

Why the changes were made

We found that in the development of our REST API, the singleton pattern was inhibiting the ability to have multiple users using the REST API concurrently. In order for us to provide the REST API we had to move away from the singleton pattern.

Jira Legacy
serverJiwa ServiceSystem JIRA
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
serverIdf9231aec91fbcd9b-a65a5d0b-32ae3b97-94f3a585-7114fec5f2531a06ec62a231
keyDEV-5680

Migration Steps

Use factories

Always use a factory to create an instance of a class implementing any of the following interfaces:

  • IJiwaBusinessLogic
  • IJiwaCollection
  • IJiwaCollectionItem
  • IJiwaDialog
  • IJiwaEntity
  • IJiwaForm

Move constructor code to Setup method

Any classes implementing the above interfaces should not have any reference in their constructor to their Manager property - move that to the Setup method and ensure the first line of code in the overridden Setup method is calling the base Setup method.

Code Block
languagec#
titleExample Setup override
public override void Setup()
{
	base.Setup();
    _Debtor = Manager.EntityFactory.CreateEntity<JiwaApplication.Entities.Debtor.Debtor>();
}

 

Filter by label (Content by label)
showLabelsfalse
max5
spacesJ7UG
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel = "plugin" and type = "page" and space = "J7UG"
labelsplugin

Page Properties
hiddentrue


Related issues