Any tips or diagnostic software to check slow Jiwa?

Discussions relating to plugin development, and the Jiwa API.

Re: Any tips or diagnostic software to check slow Jiwa?

Postby SBarnes » Tue Jan 14, 2020 10:25 am

Given there are about seven custom fields that have to be read how could you set them up as tasks and run them in parallel with something like Task.WhenAll?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Any tips or diagnostic software to check slow Jiwa?

Postby Mike.Sheen » Tue Jan 14, 2020 1:04 pm

SBarnes wrote:Given there are about seven custom fields that have to be read how could you set them up as tasks and run them in parallel with something like Task.WhenAll?


Something like this:

Code: Select all
string field1;
string field2;
string field3;

List<System.Threading.Tasks.Task> tasks = new List<System.Threading.Tasks.Task>();
System.Threading.Tasks.Task task = System.Threading.Tasks.Task.Factory.StartNew(() => { field1 = JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomFieldValueCollection.ReadCustomFieldValue(Plugin.Manager, "IN_CustomSettingValues", "InventoryID", "SettingID", "SettingID","IN_CustomSetting", inventoryID, "MyCustomField1" ); });      
tasks.Add(task);

task = System.Threading.Tasks.Task.Factory.StartNew(() => { field2 = JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomFieldValueCollection.ReadCustomFieldValue(Plugin.Manager, "IN_CustomSettingValues", "InventoryID", "SettingID", "SettingID","IN_CustomSetting", inventoryID, "MyCustomField2" ); });      
tasks.Add(task);

task = System.Threading.Tasks.Task.Factory.StartNew(() => { field3 = JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomFieldValueCollection.ReadCustomFieldValue(Plugin.Manager, "IN_CustomSettingValues", "InventoryID", "SettingID", "SettingID","IN_CustomSetting", inventoryID, "MyCustomField3" ); });      
tasks.Add(task);

System.Threading.Tasks.Task.WaitAll(tasks.ToArray());
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: Any tips or diagnostic software to check slow Jiwa?

Postby DannyC » Tue Jan 14, 2020 1:29 pm

Thanks Mike.

Next issue on the same plugin.
I am using the same instantiated inventory object to read the inventory.Groups collection. This isn't available in the item entity so it seems that the full inventory object serves 2 purposes in this plugin. (reading the custom fields and also reading the inventory groups).

In this case, I'll just knock up a quick SELECT statement and read the IN_GroupLink table. That'll do the trick for me.
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Any tips or diagnostic software to check slow Jiwa?

Postby pricerc » Tue Jan 14, 2020 2:23 pm

SBarnes wrote:Given there are about seven custom fields that have to be read how could you set them up as tasks and run them in parallel with something like Task.WhenAll?


If you only need to read them, you can use the technique I describe in https://forums.jiwa.com.au/viewtopic.php?f=25&t=1239 to create an easy-to-query view over your custom data. You could have a single, simple SQL query that gets them all, rather than firing of an individual query for each one.
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 504
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 20

Re: Any tips or diagnostic software to check slow Jiwa?

Postby SBarnes » Tue Jan 14, 2020 3:04 pm

Actually Danny is you want to get the group links in quicker way the following ORM Lite code will do it


Code: Select all
private List<JiwaServiceModel.Tables.IN_GroupLink> GetGroupLinks( JiwaFinancials.Jiwa.JiwaApplication.Manager manager)
{
            
       var dbFactory = new OrmLiteConnectionFactory(manager.Database.ConnectionString, ServiceStack.OrmLite.SqlServer2012Dialect.Provider);
      using (var db = dbFactory.Open())
      {
         return db.Select<JiwaServiceModel.Tables.IN_GroupLink> ();
                           
      }
}

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

Re: Any tips or diagnostic software to check slow Jiwa?

Postby Mike.Sheen » Tue Jan 14, 2020 5:07 pm

pricerc wrote:If you only need to read them, you can use the technique I describe in https://forums.jiwa.com.au/viewtopic.php?f=25&t=1239 to create an easy-to-query view over your custom data. You could have a single, simple SQL query that gets them all, rather than firing of an individual query for each one.


That's how I'd be inclined to do it also - just a single query returning each custom field value contents as a column.
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: Any tips or diagnostic software to check slow Jiwa?

Postby DannyC » Wed Jan 15, 2020 5:19 pm

As an FYI for anyone following this thread, the users have reported that line entry is much better.

All I did was stop the full inventory instantiating, and just used
Code: Select all
string myCustomField = JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomFieldValueCollection.ReadCustomFieldValue(salesOrder.Manager,"IN_CustomSettingValues","InventoryID","SettingID", "SettingID","IN_CustomSetting",item.InventoryID, "MyCustomField" );


Furthermore with this newfound knowledge, I've replaced similar code in a few other plugins.
Big thanks to Scott & Mike.
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Previous

Return to Technical and or Programming

Who is online

Users browsing this forum: Google [Bot] and 8 guests

cron