Pass parameter to BAQ from configurator

I finally managed to figure this out, figured I would post the solution in case anyone searching finds this thread. Was not easy to figure out how to do it. Wish they would allow you to access more of the API or add references in a configurator so I did not have to use reflection.

object[] @BAQID = new object[]
{
	"GetOEMPanelVersion"
};
var OTrans = ((InputControlValueBound<EpiTextBox, string>)Inputs["JobComments"].Value).Control.EpiTransaction;
var BAQ = Ice.Lib.Framework.AdapterHelper.GetAdapterInstance(OTrans as ILaunch, "DynamicQueryAdapter");
var ExeParm = ProcessCaller.InvokeAdapterMethod(OTrans, "DynamicQueryAdapter", "GetQueryExecutionParametersByID", @BAQID);
var ep = ExeParm.GetType().GetProperty("ExecutionParameter").GetValue(ExeParm, null);
var ClearMethod = ep.GetType().GetMethod("Clear");
ClearMethod.Invoke(ep, null);
var AddParamMethod = ep.GetType().GetMethod("AddExecutionParameterRow", new Type[] { typeof(string), typeof(string), typeof(string), typeof(bool), typeof(Guid), typeof(string) });
object[] @params3 = new object[]
{
	"Make",
	Inputs.CmbManufacturer.Value,
	"nvarchar",
	false,
	Guid.NewGuid(),
	"A"
};
object[] @params3B = new object[]
{
	"Model",
	Inputs.CmbModel.Value,
	"nvarchar",
	false,
	Guid.NewGuid(),
	"A"
};
object[] @params3C = new object[]
{
	"Deck",
	Inputs.CmbDeck.Value,
	"nvarchar",
	false,
	Guid.NewGuid(),
	"A"
};
object[] @params3D = new object[]
{
	"Panel",
	Inputs.CmbPanel.Value,
	"nvarchar",
	false,
	Guid.NewGuid(),
	"A"
};
AddParamMethod.Invoke(ep, @params3);
AddParamMethod.Invoke(ep, @params3B);
AddParamMethod.Invoke(ep, @params3C);
AddParamMethod.Invoke(ep, @params3D);
object[] @params4 = new object[]
{
	"GetOEMPanelVersion",
	ExeParm
};
var ExecuteMethod = BAQ.GetType().GetMethod("ExecuteByID", new Type[] {typeof(string),  ExeParm.GetType()});
ExecuteMethod.Invoke(BAQ, @params4);
var results = BAQ.GetType().GetProperty("QueryResults").GetValue(BAQ, null) as System.Data.DataSet;
var ResultTable = results.Tables["Results"];
4 Likes