Created
August 31, 2016 15:22
-
-
Save hasokeric/28264c55b06bd7b90ee855c828069885 to your computer and use it in GitHub Desktop.
E10 - Call BAQ From Code (Adapter & BO)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Epicor 10.1 Calling BAQ from C# Sample by Haso Keric | |
// | |
// If you have seen and are using the following in your BAQ Call: | |
// QueryExecutionDataSet q = dynamicQuery.GetQueryExecutionParametersByID("BAQ_NAME"); | |
// q.ExecutionParameter.Clear(); | |
// | |
// There is really no need. That is if you are working with multiple methods or you would like to check for possible params | |
// It makes absolutely no sense to Get The Params only to Clear them. Because you end up adding Param // Rows again anyways. | |
// | |
// Execute a BAQ by Calling the Business Object via WCF | |
private void CallBAQUsingBO() | |
{ | |
try | |
{ | |
// Declare and Initialize Variables | |
string BAQName = "DIEN-HASO"; | |
Ice.BO.QueryExecutionDataSet ds = new Ice.BO.QueryExecutionDataSet(); | |
// Add Parameter Rows | |
// Definition: AddExecutionParameterRow(string ParameterID, string ParameterValue, string ValueType, bool IsEmpty, Guid SysRowID, string RowMod) | |
// Possible ValueTypes: nvarchar, int, decimal, date, datetime, bit, uniqueidentifier, bigint | |
// IsEmpty indicates if your passed value Is Empty because if it is, you can define in your params to use a default value if empty. | |
// Typically you use string.IsNullOrEmpty(yourValueVariable) but if you are hard coding a value then you can simply set it to false | |
ds.ExecutionParameter.AddExecutionParameterRow("QuoteNumber", "10003", "int", false, Guid.Empty, "A"); | |
ds.ExecutionParameter.AddExecutionParameterRow("FirstName", "Bill", "nvarchar", false, Guid.Empty, "A"); | |
// Use Business Object Directly | |
Ice.Proxy.BO.DynamicQueryImpl dynamicQuery = WCFServiceSupport.CreateImpl<Ice.Proxy.BO.DynamicQueryImpl>((Ice.Core.Session)oTrans.Session, Epicor.ServiceModel.Channels.ImplBase<Ice.Contracts.DynamicQuerySvcContract>.UriPath); | |
System.Data.DataSet results = dynamicQuery.ExecuteByID(BAQName, ds); | |
// Lets Loop through our results | |
if (results.Tables["Results"].Rows.Count > 0) | |
{ | |
foreach (DataRow item in results.Tables["Results"].Rows) | |
{ | |
// In E9 you used TableName.Column in E10 it is TableName_Column | |
string val = item["QuoteHed_QuoteNum"].ToString(); | |
} | |
} | |
} catch (System.Exception ex) | |
{ | |
ExceptionBox.Show(ex); | |
} | |
} | |
// Execute a BAQ by Calling the Client Adapter | |
private void CallBAQUsingAdapter() | |
{ | |
try | |
{ | |
// Declare and create an instance of the Adapter. | |
DynamicQueryAdapter adapterDynamicQuery = new DynamicQueryAdapter(this.oTrans); | |
adapterDynamicQuery.BOConnect(); | |
// Declare and Initialize Variables | |
string BAQName = "DIEN-HASO"; | |
Ice.BO.QueryExecutionDataSet ds = new Ice.BO.QueryExecutionDataSet(); | |
// Add Parameter Rows | |
// Definition: AddExecutionParameterRow(string ParameterID, string ParameterValue, string ValueType, bool IsEmpty, Guid SysRowID, string RowMod) | |
// Possible ValueTypes: nvarchar, int, decimal, date, datetime, bit, uniqueidentifier, bigint | |
// IsEmpty indicates if your passed value Is Empty because if it is, you can define in your params to use a default value if empty. | |
// Typically you use string.IsNullOrEmpty(yourValueVariable) but if you are hard coding a value then you can simply set it to false | |
ds.ExecutionParameter.AddExecutionParameterRow("QuoteNumber", "10003", "int", false, Guid.Empty, "A"); | |
ds.ExecutionParameter.AddExecutionParameterRow("FirstName", "Bill", "nvarchar", false, Guid.Empty, "A"); | |
// Call Adapter method | |
adapterDynamicQuery.ExecuteByID(BAQName, ds); | |
// Lets Loop through our results | |
if (adapterDynamicQuery.QueryResults.Tables["Results"].Rows.Count > 0) | |
{ | |
foreach (DataRow item in adapterDynamicQuery.QueryResults.Tables["Results"].Rows) | |
{ | |
// In E9 you used TableName.Column in E10 it is TableName_Column | |
string val = item["QuoteHed_QuoteNum"].ToString(); | |
} | |
} | |
// Cleanup Adapter Reference | |
adapterDynamicQuery.Dispose(); | |
} catch (System.Exception ex) | |
{ | |
ExceptionBox.Show(ex); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment