本文整理汇总了C#中IOrder.CommitADOTransaction方法的典型用法代码示例。如果您正苦于以下问题:C# IOrder.CommitADOTransaction方法的具体用法?C# IOrder.CommitADOTransaction怎么用?C# IOrder.CommitADOTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOrder
的用法示例。
在下文中一共展示了IOrder.CommitADOTransaction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: placeOrder
//.........这里部分代码省略.........
txOps.Timeout = TimeSpan.FromSeconds(Settings.SYSTEMDOTTRANSACTION_TIMEOUT);
//Start our System.Transactions tx with the options set above.
using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required, txOps))
{
dalOrder.Open(Settings.TRADEDB_SQL_CONN_STRING);
try
{
//Business Step 1: create the order header.
order = createOrder(orderType, userID, holdingID, symbol, quantity, ref holding);
//Business Step 2: Determine which order processing mode to use,
//and either process order right away (sync) and in-process with
//calling ASP.NET Web app; or interface with the
//async WCF Order Processing Service (cooler) via a service-to-service call,
//distributed/remote.
if (Settings.ORDER_PROCESSING_MODE != StockTraderUtility.OPS_INPROCESS)
{
//Fire up our async client; we follow the same model here as with the
//StockTrader Web App in that we do not talk 'directly' to the generated proxy
//for the service; rather we channel all calls through a single
//class that then talks to the service proxy. This will aid in more
//easily knowing where communication and proxy logic sits; and make changes to services
//you might want to interface with vs. littering proxy calls throughout the
//business tier itself.
TradeOrderServiceAsyncClient asyncclient = new TradeOrderServiceAsyncClient(Settings.ORDER_PROCESSING_MODE, new Settings());
asyncclient.processOrderASync(order);
}
else
{
processOrderSync(order, holding);
}
//Commit!
tx.Complete();
return order;
}
//If per chance you are doing step-through debugging through here and are getting a
// "TRANSACTION HAS ABORTED" exception and do not know why,
//it's quite likely you are hitting the 15-second timeout we set in
//ConfigurationSettings for the System.Transaction options so its just doing what we told it to.
//Simply adjust timeout higher, recompile if you need to.
catch
{
throw;
}
finally
{
dalOrder.Close();
}
}
}
//Repeat for ADO.NET transactions config option case.
case (StockTraderUtility.TRANSACTION_MODEL_ADONET_TRANSACTION):
{
if (Settings.ORDER_PROCESSING_MODE == StockTraderUtility.OPS_SELF_HOST_MSMQ)
goto case StockTraderUtility.TRANSACTION_MODEL_SYSTEMDOTTRANSACTION_TRANSACTION;
dalOrder.Open(Settings.TRADEDB_SQL_CONN_STRING);
dalOrder.BeginADOTransaction();
try
{
//Business Step 1: create the order header.
order = createOrder(orderType, userID, holdingID, symbol, quantity, ref holding);
//Business Step 2: Determine which order processing mode to use,
//and either process order right away (sync); or interface with the
//async WCF Order Processing Service (cooler) via a service-to-service call.
if (Settings.ORDER_PROCESSING_MODE != StockTraderUtility.OPS_INPROCESS)
{
//Fire up our async client; we follow the same model here as with the
//StockTrader Web App in that we do not talk 'directly' to the generated proxy
//for the service; rather we channel all calls through a single
//class that then talks to the service proxy. This will aid in more
//easily knowing where communication and proxy logic sits; and make changes to services
//you might want to interface with vs. littering proxy calls throughout the
//business tier itself.
TradeOrderServiceAsyncClient asyncclient = new TradeOrderServiceAsyncClient(Settings.ORDER_PROCESSING_MODE, new Settings());
asyncclient.processOrderASync(order);
dalOrder.CommitADOTransaction();
}
else
{
processOrderSync(order, holding);
}
dalOrder.CommitADOTransaction();
return order;
}
catch
{
dalOrder.RollBackTransaction();
throw;
}
finally
{
dalOrder.Close();
}
}
}
throw new Exception(Settings.ENABLE_GLOBAL_SYSTEM_DOT_TRANSACTIONS_CONFIGSTRING + ": " + StockTraderUtility.EXCEPTION_MESSAGE_INVALID_TXMMODEL_CONFIG + " Repository ConfigKey table.");
}