Using a Business logic Object inside a scheduled plugin  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Using a Business logic Object inside a scheduled plugin

Postby SBarnes » Tue Jul 04, 2017 12:18 pm

How can you use a Business Logic object inside the scheduled plugin?

For example

Code: Select all
JiwaFinancials.Jiwa.JiwaSales.BatchProcessing.BatchProcess batch = Plugin.Manager.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaSales.BatchProcessing.BatchProcess>(null);


produces an exception?

I would imagine this would produce the same error for any CreateBusinessLogic call?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Using a Business logic Object inside a scheduled plugin

Postby Mike.Sheen » Tue Jul 04, 2017 2:03 pm

You shouldn't get any exceptions.

What is the exception, exactly?
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: Using a Business logic Object inside a scheduled plugin

Postby SBarnes » Tue Jul 04, 2017 2:22 pm

Hi Mike

here is the stack trace

Code: Select all
System.NullReferenceException was unhandled by user code
  HResult=-2147467261
  Message=Object reference not set to an instance of an object.
  Source=JiwaSales
  StackTrace:
       at JiwaFinancials.Jiwa.JiwaSales.BatchProcessing.BatchProcess.ReadUserSettings()
       at JiwaFinancials.Jiwa.JiwaSales.BatchProcessing.BatchProcess.Setup()
       at JiwaFinancials.Jiwa.JiwaApplication.BusinessLogicFactory.CreateBusinessLogic[BusinessLogicType](IJiwaForm Client)
       at ScheduledExecutionPlugin.Execute(Plugin Plugin, Schedule Schedule) in c:\ProgramData\Jiwa Financials\Jiwa 7\7.0.182\SYSTEM\WIN-EIBG30HI5AK\Cassons\Plugins\Admin\Compile\Attkey Debtor Term Deals\Attkey Debtor Term Deals.cs:line 259
       at JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin.RunScheduledExecutionPluginExecute(Schedule Schedule)
       at JiwaFinancials.Jiwa.JiwaPluginSchedulerService.JiwaPluginSchedulerService.ProcessPlugins()
  InnerException:


Interestingly the following in the same plugin works fine

Code: Select all
JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder workorder = Plugin.Manager.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder>(null);   


If you instantiate the batch object without the factory that works you can even assign a manager but as soon as you call setup to instantiate the ProcessCandidates Collection you get the same error.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Using a Business logic Object inside a scheduled plugin  Topic is solved

Postby Mike.Sheen » Tue Jul 04, 2017 3:00 pm

That's a bug - and it's not isolated to within the plugin scheduler - any code trying to create a batch process business logic using our factory and passing null for the form will get that error.

Logged as DEV-6053.

Your work-around is to provide a form to the BusinessLogicFactory.

e.g.:

Code: Select all
var form = Plugin.Manager.FormFactory.CreateForm<JiwaFinancials.Jiwa.JiwaSalesUI.BatchProcessing.BatchProcess>(); // create a form to work-around DEV-6053
JiwaFinancials.Jiwa.JiwaSales.BatchProcessing.BatchProcess batch = Plugin.Manager.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaSales.BatchProcessing.BatchProcess>(form);
batch.Client = null;
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: Using a Business logic Object inside a scheduled plugin

Postby SBarnes » Tue Jul 04, 2017 3:11 pm

HI Mike,

Thanks that works, one quick question, can the plugin scheduler print the reports if the properties are set properly, as I know it can be a real issue inside IIS if you try it with network printers i.e. network printers only exist if the user is logged in, just not sure about a windows service?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Using a Business logic Object inside a scheduled plugin

Postby Mike.Sheen » Tue Jul 04, 2017 3:19 pm

If the service is running under user credentials, and not local system, then yes - it will be able to print.
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: Using a Business logic Object inside a scheduled plugin

Postby SBarnes » Tue Jul 04, 2017 3:22 pm

As always thanks.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 13 guests