I am currently using the code below to define my BAQDataViews which populated my grids. I want to use a parameter-driven BAQ instead.
public void SetupECODV()
// Creates the view into EcoRev (BAQ = getPartRevOpECO)
{
dtEcoRevOps = new DataTable(); //instantiate DT
var colMyPart = new DataColumn("Part"); // inst column
colMyPart.ExtendedProperties["Like"]="Part.PartNum"; //add like for right click open with
dtEcoRevOps.Columns.Add(colMyPart); // add custom column to DT (repeat for all columns)
var colMyRev = new DataColumn("Rev"); // inst column
dtEcoRevOps.Columns.Add(colMyRev); // add custom column to DT (repeat for all columns)
dtEcoRevOps.Columns.Add(new DataColumn("SysRowId",typeof(Guid))); // add guid column to DT (required)
var dr = dtEcoRevOps.NewRow(); //inst a new row
dr["SysRowId"] = Guid.NewGuid(); // just set the guid for the new row
dtEcoRevOps.Rows.Add(dr); // add the row to the DT to enable fields in the table
dvEcoRevOps = new EpiDataView(); //inst the EDV
dvEcoRevOps.dataView = dtEcoRevOps.DefaultView; // set the EDV to the default view of the DT created above (default view is unfiltered view of entire DT)
oTrans.Add("OpsList",dvEcoRevOps); // adds the EDV to the binding list
bdvEco = new BAQDataView("getPartRevOpECO"); //inst the BDV
oTrans.Add("EcoRevOps",bdvEco); //add the BDV to the binding list (this is an unfiltered BDV. Filter the BDV with Pub/Sub)
var fromPubPart= "OpsList.Part"; //whenever the listed field changes publish the new value
oTrans.PublishColumnChange(fromPubPart,"FromPubPart"); //publish the value to otrans
var fromPub = oTrans.GetPublisher(fromPubPart); //this pulisher 'fromPub' gets the notification when above field changes.
bdvEco.SubscribeToPublisher(fromPub.PublishName,"ECORev_PartNum"); // subscribe BDV to fromPub created above. filer by listed field based on publisher.
var fromPubRev= "OpsList.Rev"; //whenever the listed field changes publish the new value
oTrans.PublishColumnChange(fromPubRev,"FromPubRev"); //publish the value to otrans
var fromPub2 = oTrans.GetPublisher(fromPubRev); //this pulisher 'fromPub' gets the notification when above field changes.
bdvEco.SubscribeToPublisher(fromPub2.PublishName,"ECORev_RevisionNum"); // subscribe BDV to fromPub created above. filer by listed field based on publisher.
}
public void SetupPartDV()
// creates the view into PartRev (BAQ = EditAnyOp)
{
dtPartRevOps = new DataTable(); //instantiate DT
var colMyPart = new DataColumn("Part"); // inst column
colMyPart.ExtendedProperties["Like"]="Part.PartNum"; //add like for right click open with
dtPartRevOps.Columns.Add(colMyPart); // add custom column to DT (repeat for all columns)
var colMyRev = new DataColumn("Rev"); // inst column
dtPartRevOps.Columns.Add(colMyRev); // add custom column to DT (repeat for all columns)
dtPartRevOps.Columns.Add(new DataColumn("SysRowId",typeof(Guid))); // add guid column to DT (required)
var dr = dtPartRevOps.NewRow(); //inst a new row
dr["SysRowId"] = Guid.NewGuid(); // just set the guid for the new row
dtPartRevOps.Rows.Add(dr); // add the row to the DT to enable fields in the table
dvPartRevOps = new EpiDataView(); //inst the EDV
dvPartRevOps.dataView = dtPartRevOps.DefaultView; // set the EDV to the default view of the DT created above (default view is unfiltered view of entire DT)
oTrans.Add("OpsList1",dvPartRevOps); // adds the EDV to the binding list
bdvPart = new BAQDataView("EditAnyOp"); //inst the BDV
oTrans.Add("PartRevOps",bdvPart); //add the BDV to the binding list (this is an unfiltered BDV. Filter the BDV with Pub/Sub)
var fromPubPart1= "OpsList1.Part"; //whenever the listed field changes publish the new value
oTrans.PublishColumnChange(fromPubPart1,"FromPubPart1"); //publish the value to otrans
var fromPub1a = oTrans.GetPublisher(fromPubPart1); //this pulisher 'fromPub' gets the notification when above field changes.
bdvPart.SubscribeToPublisher(fromPub1a.PublishName,"PartRev_PartNum"); // subscribe BDV to fromPub created above. filer by listed field based on publisher.
var fromPubRev1= "OpsList1.Rev"; //whenever the listed field changes publish the new value
oTrans.PublishColumnChange(fromPubRev1,"FromPubRev1"); //publish the value to otrans
var fromPub2a = oTrans.GetPublisher(fromPubRev1); //this pulisher 'fromPub' gets the notification when above field changes.
bdvPart.SubscribeToPublisher(fromPub2a.PublishName,"PartRev_RevisionNum"); // subscribe BDV to fromPub created above. filer by listed field based on publisher.
}
Once I setup my grids, I would like to filter the underlying BAQ to return results faster. With the method above, the BAQ pulls all parts and revs, then just displays the ones that match your criteria. I would rather put the parameter back into the BAQ and run the BAQ only on the part/rev that I need. I have mashed together some code below that I think will do this, but I am not sure how to integrate it with the code I am using above. I think I need to get rid of the pub/sub lines for each BAQDV. Then I need to somehow assign the results of the code below to the BAQDVs. Right?
private void New_FilterBAQDataView(BAQDataView iBaqView, string BAQ, string thisPart, string thisRev)
{
DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
dqa.BOConnect();
QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID(BAQ);
qeds.ExecutionParameter.Clear();
qeds.ExecutionParameter.AddExecutionParameterRow("part", thisPart, "nvarchar", false, Guid.NewGuid(), "A");
qeds.ExecutionParameter.AddExecutionParameterRow("rev", thisRev, "nvarchar", false, Guid.NewGuid(), "A");
dqa.ExecuteByID(BAQ, qeds);
if (dqa.QueryResults.Tables["Results"].Rows.Count > 0)
{
// apply the results of the BAQ to the BAQDV (and underlying grid)
//iBaqView.Source = dqa.QueryResults; //this pseudo code doesnt work...
}
}
EDIT: I forgot to add, that I am currently applying a filter to my BAQDVs like this:
FilterBAQDataView(bdvEco, "ECORev_PartNum = '" + txtPartNum.Text + "' AND ECORev_RevisionNum = '" + cmbRevNum.Text + "'");
FilterBAQDataView(bdvPart, "PartRev_PartNum = '" + txtPartNum.Text + "' AND PartRev_RevisionNum = '" + cmbRevNum.Text + "'");
And here is the code for that function:
private void FilterBAQDataView(BAQDataView iBaqView, string iWhereClause)
{
iBaqView.AdditionalFilter = iWhereClause;
iBaqView.dataView.RowFilter = iWhereClause;
iBaqView.Notify(new EpiNotifyArgs(oTrans, 0, EpiTransaction.NotifyType.Initialize));
//not sure if code below is needed...
MethodInfo mi = iBaqView.GetType().GetMethod("InvokeExecute", BindingFlags.Instance | BindingFlags.NonPublic);
mi.Invoke(iBaqView, new object[]{ true });
}
I want to replace the above filtering, with my ānewā parameter filtering at the BAQ level.
Thank you for your time!
Nate