csharp E10 - 从代码调用BAQ(适配器和BO)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp E10 - 从代码调用BAQ(适配器和BO)相关的知识,希望对你有一定的参考价值。

//
// 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);
	}
}

以上是关于csharp E10 - 从代码调用BAQ(适配器和BO)的主要内容,如果未能解决你的问题,请参考以下文章

csharp 打印BAQ(和其他)报告

csharp E10致电BOReader

csharp 从代码调用SSRS报告并获取文件

从 javascript 适配器调用 java 代码时出错

从 javascript 适配器调用 java 代码

如何将数据从回收器适配器发送到片段 |如何从 recyclerview 适配器调用片段函数