You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to insert RetailTransactionPaymentTransExt. However, I need it to be part of the transaction scope of the SaveSalesTransactionDataRequest. If it fails on my code it needs to fail everything and if it fails on the standard code or the ISV partner code then it needs to roll back my code too.
In the RetailSDK examples for commerceruntime there is code that shows how to do it. I also decoded one of our ISV partner's DLL and they use the code that is in the example in RetailSDK.
Example:
See Runtime.Extensions.SaleSPaymentTransExt project as well as Runtime.Extensions.SalesPaymentTransExtFrance project.
The latter is the one that uses the setup in the first example project. The latter is also the one that our ISV partner uses.
Then there is also the example CommerceRuntime.Extensions.SalesTransactionSignatureNorway whcih add the transactionscope slightly different.
The first example and our ISV partner uses:
`using (var databaseContext = new DatabaseContext(request.RequestContext))
using (var transactionScope = CreateReadCommittedTransactionScope())
{
// Execute original logic.
// Execute custom logic.
transactionScope.Complete();
}
private static TransactionScope CreateReadCommittedTransactionScope()
{
var options = new TransactionOptions()
{
IsolationLevel = IsolationLevel.ReadCommitted
};
return new TransactionScope(TransactionScopeOption.Required, options, TransactionScopeAsyncFlowOption.Enabled);
}
`
The second example uses the approach:
`
using (var databaseContext = new DatabaseContext(request.RequestContext))
using (var transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
{
// Execute original logic.
// Execute custom logic.
transactionScope.Complete();
}
`
When I override the handler and use any of the 2 example approaches, I get an error:
Microsoft.Dynamics.Commerce.Runtime.Data.DatabaseContext.<>c__DisplayClass61_0.<<ExecuteStoredProcedure>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.Dynamics.Commerce.Runtime.Framework.RetryPolicy.ExecuteActionAsync[TResult](Func1 asyncFunc, Action3 onTransientError) at Microsoft.Dynamics.Commerce.Runtime.Data.DatabaseContext.ExecuteStoredProcedure(String procedureName, ParameterSet parameters, ParameterSet outputParameters, Func2 resultCallback, QueryResultSettings resultSettings, Boolean isAsync)
--- End of inner exception stack trace ---
at Microsoft.Dynamics.Commerce.Runtime.Data.DatabaseContext.ExecuteStoredProcedure(String procedureName, ParameterSet parameters, ParameterSet outputParameters, Func2 resultCallback, QueryResultSettings resultSettings, Boolean isAsync) at CommerceRuntime.TMCSalesTransactionExtSqlServerDataService.InsertExtTableAsync(Request request, DataTable sourceTable, String sourceTableNamePrm, String insertProcName) at CommerceRuntime.TMCSalesTransactionExtSqlServerDataService.InsertExtTableAsync(Request request, DataTable sourceTable, String sourceTableNamePrm, String insertProcName) at CommerceRuntime.TMCSalesTransactionExtSqlServerDataService.Execute(Request vRequest) at Microsoft.Dynamics.Commerce.Runtime.CommerceRuntime.ExecuteCore[TResponse](Request request, RequestContext context, IReadOnlyCollection1 handlersToInvoke, Boolean skipRequestTriggers, Boolean isAsyncExecution)
at Microsoft.Dynamics.Commerce.Runtime.CommerceRuntime.ExecuteCore[TResponse](Request request, RequestContext context, IReadOnlyCollection1 handlersToInvoke, Boolean skipRequestTriggers, Boolean isAsyncExecution) at Microsoft.Dynamics.Commerce.Runtime.CommerceRuntime.Execute[TResponse](Request request, RequestContext context, IReadOnlyCollection1 handlersToInvoke, Boolean skipRequestTriggers, Boolean isAsync)
at CommerceRuntime.SaveSalesTransactionHandlerTMC.SavePaymentExtAsync(SaveSalesTransactionDataRequest request, IEnumerable1 COATenderTypes)
Can it suddenly not handle transaction scope? I saw the following GitHub question but an answer was never provided.
[https://github.com//discussions/199]
Or is it because I need to add custom now on the same handler as the ISV partner and the standard code can't handle the override of the handler more than once with transaction scopes added in both?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to insert RetailTransactionPaymentTransExt. However, I need it to be part of the transaction scope of the SaveSalesTransactionDataRequest. If it fails on my code it needs to fail everything and if it fails on the standard code or the ISV partner code then it needs to roll back my code too.
In the RetailSDK examples for commerceruntime there is code that shows how to do it. I also decoded one of our ISV partner's DLL and they use the code that is in the example in RetailSDK.
Example:
See Runtime.Extensions.SaleSPaymentTransExt project as well as Runtime.Extensions.SalesPaymentTransExtFrance project.
The latter is the one that uses the setup in the first example project. The latter is also the one that our ISV partner uses.
Then there is also the example CommerceRuntime.Extensions.SalesTransactionSignatureNorway whcih add the transactionscope slightly different.
The first example and our ISV partner uses:
`using (var databaseContext = new DatabaseContext(request.RequestContext))
using (var transactionScope = CreateReadCommittedTransactionScope())
{
// Execute original logic.
// Execute custom logic.
private static TransactionScope CreateReadCommittedTransactionScope()
{
var options = new TransactionOptions()
{
IsolationLevel = IsolationLevel.ReadCommitted
};
`
The second example uses the approach:
`
using (var databaseContext = new DatabaseContext(request.RequestContext))
using (var transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
{
// Execute original logic.
// Execute custom logic.
`
When I override the handler and use any of the 2 example approaches, I get an error:
Microsoft.Dynamics.Commerce.Runtime.Data.DatabaseContext.<>c__DisplayClass61_0.<<ExecuteStoredProcedure>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.Dynamics.Commerce.Runtime.Framework.RetryPolicy.ExecuteActionAsync[TResult](Func
1 asyncFunc, Action3 onTransientError) at Microsoft.Dynamics.Commerce.Runtime.Data.DatabaseContext.ExecuteStoredProcedure(String procedureName, ParameterSet parameters, ParameterSet outputParameters, Func
2 resultCallback, QueryResultSettings resultSettings, Boolean isAsync)--- End of inner exception stack trace ---
at Microsoft.Dynamics.Commerce.Runtime.Data.DatabaseContext.ExecuteStoredProcedure(String procedureName, ParameterSet parameters, ParameterSet outputParameters, Func
2 resultCallback, QueryResultSettings resultSettings, Boolean isAsync) at CommerceRuntime.TMCSalesTransactionExtSqlServerDataService.InsertExtTableAsync(Request request, DataTable sourceTable, String sourceTableNamePrm, String insertProcName) at CommerceRuntime.TMCSalesTransactionExtSqlServerDataService.InsertExtTableAsync(Request request, DataTable sourceTable, String sourceTableNamePrm, String insertProcName) at CommerceRuntime.TMCSalesTransactionExtSqlServerDataService.Execute(Request vRequest) at Microsoft.Dynamics.Commerce.Runtime.CommerceRuntime.ExecuteCore[TResponse](Request request, RequestContext context, IReadOnlyCollection
1 handlersToInvoke, Boolean skipRequestTriggers, Boolean isAsyncExecution)at Microsoft.Dynamics.Commerce.Runtime.CommerceRuntime.ExecuteCore[TResponse](Request request, RequestContext context, IReadOnlyCollection
1 handlersToInvoke, Boolean skipRequestTriggers, Boolean isAsyncExecution) at Microsoft.Dynamics.Commerce.Runtime.CommerceRuntime.Execute[TResponse](Request request, RequestContext context, IReadOnlyCollection
1 handlersToInvoke, Boolean skipRequestTriggers, Boolean isAsync)at CommerceRuntime.SaveSalesTransactionHandlerTMC.SavePaymentExtAsync(SaveSalesTransactionDataRequest request, IEnumerable
1 COATenderTypes)
Can it suddenly not handle transaction scope? I saw the following GitHub question but an answer was never provided.
[https://github.com//discussions/199]
Or is it because I need to add custom now on the same handler as the ISV partner and the standard code can't handle the override of the handler more than once with transaction scopes added in both?
Beta Was this translation helpful? Give feedback.
All reactions