I am working on the Work Queue screen in the MES. I am attempting to automate the search for work based on Resource Group.
Currently, you have to click the button “RESOURCE GROUP” which opens up a Resource Group search, when you select a record, it automatically closes the search (calls LoadUserResults), then performs WorkQueueAdapter.GetOpsInResourceGroup.
I have created a button, and I manually call GetOpsInResourceGroup using the data I want - OK here, no problems. It goes like this:
wq.GetOpsInResourceGroup(ResGrupID, EmpID, WhereWork, WherePart, 0, 1, out res,LaborType,out WorkRecs,ClearCache,Filter);
oTrans.NotifyAll();
oTrans.Update();
No data appears. So I add oTrans.Refresh(); It appears that it runs GetOpsInResourceGroup again but with whatever PARAMS the system uses. I.E. - Since I didn’t manually pick a resource, I get “No valid ResourceGroupID”.
Ultimately, how do I find out where the process is pulling it’s PARAMS from, I assume they will be available to me, IF I can find them. Tracing showed me what methods are called, and what params are passed - but I cant find the damn things.
Try getting your resource ID and your resourceeGroupDescription and then do the following
oTrans.GetByID(myResourceID,MyResourceDesc);
Then it gets tricky you need to set ClearWorQueueCACHE to true but this is an internal private variable so you’ll have ot use reflection… (do you know how to use reflection?)
the variable name is ClearWorQueueCACHE and you want to set it to true, it is defined in the oTrans object
Then you want to invoke another private function this time defined in WorkQueueEntry.WorkQUeueForm called setUpWorkQeueueRecordsPageInfo() again this needs to be invoked via reflection
last you want to also invoke the private function OnAfterResrouceGroupSearch() also defined in oTrans
If you don’t know reflection i can put an example together but otherwise this should do it
Note I can’t test the below example so I am going to do my best to type without scrwing thing up! But I can’t guarantee it, so if you have syntax issues let me know
using System.Reflection; //Add
public void mySelection(String resourceGroupID, String resourceGroupDesc)
{
var prop = oTrans.GetType().GetField("ClearWorQueueCACHE", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
prop.SetValue(oTrans, true);
oTrans.GetByID(resourceGroupID,resourceGroupDesc);
workQueueForm.GetType().GetMethod("setUpWorkQueueRecordsPageInfo",System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).Invoke(workQueueForm,null);
oTrans.GetType().GetMethod("OnAfterResourceGroupSearch",System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).Invoke(oTrans,null);
}
public void mySelection(String resourceGroupID, String resourceGroupDesc)
{
var prop = oTrans.GetType().GetField(“ClearWorQueueCACHE”, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
prop.SetValue(s, true); //<----- OFFENDER, what is the s object supposed to represent?
oTrans.GetByID(resourceGroupID,resourceGroupDesc);
WorkQueueForm.GetType().GetMethod(“setUpWorkQueueRecordsPageInfo”,System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).Invoke(WorkQueueForm,null);
oTrans.GetType().GetMethod(“OnAfterResourceGroupSearch”,System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).Invoke(oTrans,null);