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?
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());
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?
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> ();
}
}
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.
string myCustomField = JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomFieldValueCollection.ReadCustomFieldValue(salesOrder.Manager,"IN_CustomSettingValues","InventoryID","SettingID", "SettingID","IN_CustomSetting",item.InventoryID, "MyCustomField" );
Return to Technical and or Programming
Users browsing this forum: Google [Bot] and 8 guests