问题描述
朋友,
世界自然基金会的新人。以下是我想要实现的目标。
设置状态成功后,我在SQL表中插入一些记录。如果失败,交易范围是否会回滚SetState?
使用(System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.RequiresNew))
{
尝试
{
workflowRuntime.StartRuntime();
StateMachineWorkflowInstance实例
= new StateMachineWorkflowInstance(workflowRuntime,new Guid(<某些GUID,存在>));
instance.SetState( new StateActivity(< COMPLETEDSTATE>));
workflowRuntime.StopRuntime();
某些数据库的活动性 - 可能会引发异常
Scope.Complete();
}
catch(Exception ex)
{
抛出TransactionAbortedException。
}
}
Friends,
New in WWF. Below is something I am trying to achieve.
After set state successful, I am inserting some record in a SQL table. if that failes, will the Transaction scope rolls back the SetState?
using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.RequiresNew))
{
try
{
workflowRuntime.StartRuntime();
StateMachineWorkflowInstance instance
= new StateMachineWorkflowInstance(workflowRuntime, new Guid(<some GUID that exists>));
instance.SetState(new StateActivity(<COMPLETEDSTATE>));
workflowRuntime.StopRuntime();
Some Database acticity - that may throw exception
Scope.Complete();
}
catch (Exception ex)
{
throw TransactionAbortedException.
}
}
这篇关于StateMachineWorkflowInstance.setState可以回滚吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!