本文整理汇总了C#中TransactionManager类的典型用法代码示例。如果您正苦于以下问题:C# TransactionManager类的具体用法?C# TransactionManager怎么用?C# TransactionManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TransactionManager类属于命名空间,在下文中一共展示了TransactionManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SaveEdits
public static bool SaveEdits(IApplication app, TransactionManager tm)
{
bool result = false;
try
{
if (HasEdits(app, tm))
{
UID pUID = new UIDClass();
pUID.Value = "esriEditor.Editor";
IWorkspaceEdit workspace = (IWorkspaceEdit)tm.Current().PGDBConnection;
IEditor2 editor2 = (IEditor2)app.FindExtensionByCLSID(pUID);
editor2.StopEditing(true);
editor2.StartEditing((IWorkspace)workspace);
workspace.StopEditing(true);
workspace.StartEditing(false);
}
result = true;
}
catch (Exception e)
{
Logger.Write("Error saving edits to PGDB", Logger.LogLevel.Debug);
MessageBox.Show("An error occured while attempting to save current edits.");
result = false;
}
return result;
}
开发者ID:EAWCS1,项目名称:SUITT,代码行数:28,代码来源:Utils.cs
示例2: HasEdits
public static bool HasEdits(IApplication app, TransactionManager tm)
{
try
{
IWorkspaceEdit workspace = (IWorkspaceEdit)tm.Current().PGDBConnection;
bool processQA = false;
bool hasEdits = false;
workspace.HasEdits(ref hasEdits);
UID pUID = new UIDClass();
pUID.Value = "esriEditor.Editor";
IEditor editor = (IEditor)app.FindExtensionByCLSID(pUID);
IEditTask task = editor.CurrentTask;
IEditTask resetTask = editor.get_Task(0);
editor.CurrentTask = resetTask;
editor.CurrentTask = task;
IEditor2 editor2 = (IEditor2)app.FindExtensionByCLSID(pUID);
bool hasCachedEdits = editor2.HasEdits();
return hasCachedEdits || hasEdits;
}
catch (Exception e)
{
Logger.Write("Error testing if transaction has edits: " + e.Message + " : " + e.StackTrace, Logger.LogLevel.Debug);
throw new Exception("Error", e);
}
}
开发者ID:EAWCS1,项目名称:SUITT,代码行数:29,代码来源:Utils.cs
示例3: RunTestsForm
public RunTestsForm(ref dao.QATestCollection tests, IMap map, TransactionManager tm, QAManager qa)
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
if (tests == null)
throw new ArgumentNullException("tests", "Must pass collection of QA tests to RunTestsForm");
if (tests.Count == 0)
throw new ArgumentException("No QA tests passed to RunTestsForm", "tests");
if (map == null)
throw new ArgumentNullException("map", "Must pass the focus map to RunTestsForm");
this._tests = tests;
this._tm = tm;
this._qa = qa;
this._map = map;
this._defaults = new util.SystemDefaults();
// Throw TM stuff at the QA tests and see if it sticks
if (tm.Current() != null)
{
object[] theArgs = new object[2] {
new ISDUTLib.tm.dao.EditsDAO((IFeatureWorkspace)tm.Current().PGDBConnection, tm.transactionConfig()),
tm.transactionConfig()
};
for (int i = 0; i < this._tests.Count; i++)
{
this._tests.get_Test(i).Test.UserData = theArgs;
}
}
}
开发者ID:EAWCS1,项目名称:SUITT,代码行数:33,代码来源:RunTestsForm.cs
示例4: AfmReturnsRightNumberOfJObjects
public void AfmReturnsRightNumberOfJObjects()
{
_testName = MethodInfo.GetCurrentMethod().Name.GetHashCode().ToString();
Cleanup();
var formatter = new BSONFormatter();
var core = new FileCore<int, long>() { IdSeed = new Seed32(999), SegmentSeed = new Seed64(), MinimumCoreStride = 512 };
var addEntities = TestResourceFactory.GetMockClassAObjects(10000).ToList();
foreach (var entity in addEntities)
entity.Id = _seed.Increment();
IDictionary<int, long> returnSegments = null;
using (var afm = new AtomicFileManager<MockClassA>(_testName + ".database", core))
{
afm.Load<int>();
using (var manager = new TransactionManager<int, MockClassA>
(new MockTransactionFactory<int, MockClassA>()
, new TransactionSynchronizer<int, MockClassA>()))
{
manager.TransactionCommitted += new TransactionCommit<int, MockClassA>(
delegate(ITransaction<int, MockClassA> tranny)
{
returnSegments = afm.CommitTransaction(tranny, new Dictionary<int, long>());
tranny.MarkComplete();
});
using (var tLock1 = manager.BeginTransaction())
{
addEntities.ForEach(delegate(MockClassA entity)
{
tLock1.Transaction.Enlist(Action.Create, entity.Id, entity);
});
tLock1.Transaction.Commit();
Assert.AreEqual(10000, afm.Length);
}
foreach (var group in afm.AsEnumerable())
{
var match = group.Where(i => i.SelectToken("Id").Value<int>() > 9999).ToList();
if (match == null || !match.Any())
continue;
var result = match.First(r => r.Value<int>("Id") == 10000).ToObject<MockClassC>();
Assert.IsNotNull(result);
Assert.AreEqual(10000, result.Id);
break;
}
}
}
}
开发者ID:thehexgod,项目名称:BESSY-DB,代码行数:59,代码来源:AtomicFileManagerQueryTests.cs
示例5: Instead02
private void Instead02(TransactionManager tm, Customer cus)
{
tm.BeginTransaction();
DataRepository.CustomerProvider.Insert(tm, cus);
tm.Commit();
// Or, show the message box after the transaction completed,
// e.g. to notify them of an event after saving
MessageBox.Show("Something...");
}
开发者ID:ITAfrique,项目名称:CodingStandards,代码行数:9,代码来源:C06_TransactionMisuse.cs
示例6: Instead01
private void Instead01(TransactionManager tm, Customer cus)
{
MessageBox.Show("Something...");
// Begin the transaction after the message box,
// e.g. if you want to prompt them to do something before saving.
tm.BeginTransaction();
DataRepository.CustomerProvider.Insert(tm, cus);
tm.Commit();
}
开发者ID:ITAfrique,项目名称:CodingStandards,代码行数:9,代码来源:C06_TransactionMisuse.cs
示例7: CreateSession
public IDatabaseSession CreateSession(string connectionString)
{
var sqlConnectionProvider = new SqlConnectionProvider(connectionString);
var transactionManager = new TransactionManager(sqlConnectionProvider);
var databaseConnectionManager = new DatabaseCommandProvider(sqlConnectionProvider, transactionManager);
var databaseCommandCreator = new DatabaseCommandFactory(databaseConnectionManager);
var databaseReaderFactory = new SqlDatabaseReaderFactory();
var connectionHandler = new ConnectionHandler();
return new DatabaseSession(databaseCommandCreator, transactionManager, databaseReaderFactory, connectionHandler);
}
开发者ID:shizzlator,项目名称:Dazzle,代码行数:10,代码来源:DatabaseSessionFactory.cs
示例8: Get
public IList<Transaction> Get(int pageNumber, int pageSize, string filter)
{
var transactionManager = new TransactionManager();
return transactionManager.GetTransactions(new ListOptions
{
PageSize = pageSize,
PageNumber = pageNumber
});
}
开发者ID:julsn,项目名称:financialMonitor,代码行数:10,代码来源:TransactionsController.cs
示例9: ApplyRecord
/// <summary>
/// Apply a record to placeholders
/// </summary>
/// <param name="placeHolders">List of placeholder which should be applied</param>
/// <param name="recordName">Name of record</param>
/// <returns>Return true if one or more was applied</returns>
public static void ApplyRecord(IEnumerable<PlaceHolder> placeHolders, string recordName)
{
using (Transaction transaction = new TransactionManager().CreateTransaction())
{
foreach (PlaceHolder placeHolder in placeHolders)
{
placeHolder.ApplyRecord(recordName, true); // apply (with page data)
transaction.Commit(); // needed if not placed in project
}
}
}
开发者ID:Suplanus,项目名称:Suplanus.Sepla,代码行数:17,代码来源:PlaceHolderUtility.cs
示例10: GetTransactionsByCategory
public IList<Transaction> GetTransactionsByCategory(string from, string to, string balanceType, string category)
{
var dateFrom = DateTime.ParseExact(from, "yyyyMMdd", CultureInfo.InvariantCulture);
var dateTo = DateTime.ParseExact(to, "yyyyMMdd", CultureInfo.InvariantCulture);
var type = (BalanceType) Enum.Parse(typeof (BalanceType), balanceType, true);
var transactionManager = new TransactionManager();
var list = transactionManager.GetTransactions(dateFrom, dateTo, type, category);
return list;
}
开发者ID:julsn,项目名称:financialMonitor,代码行数:11,代码来源:TransactionsController.cs
示例11: BadlyMisplacedCode
// SAMPLE 01
//
// As mentioned in "C01_TransactionManager," the idea behind transactions
// is that it should surround a block of code that either saves everything
// or nothing.
//
// Here is the thing to remember: While the transaction is open it will prevent
// anything from accessing the database tables that you are busy with. This is
// to prevent "dirty" or incomplete records.
//
// The caveat: you want your transaction to execute as fast as possible. Be
// like a ninja: get in, do your thing, and get out.
//
private void BadlyMisplacedCode(TransactionManager tm, Customer cus)
{
tm.BeginTransaction();
DataRepository.CustomerProvider.Insert(tm, cus);
MessageBox.Show("Something...");
tm.Commit();
// Can you see it?
// This code will block the Customer table on the entire branch until the user
// clicks "OK" on the message box. The impact of this is enourmous.
}
开发者ID:ITAfrique,项目名称:CodingStandards,代码行数:24,代码来源:C06_TransactionMisuse.cs
示例12: ReadTransactionsFromFile_Valid_ObserverNeverCalled
public void ReadTransactionsFromFile_Valid_ObserverNeverCalled()
{
var mockObserver = new Moq.Mock<Observer>();
List<Observer> ol = new List<Observer>();
ol.Add(mockObserver.Object);
List<Product> listOfProducts = new List<Product>();
TransactionManager tm = new TransactionManager(ol, listOfProducts);
tm.ReadTransactionsFromFile(new StreamReader(@"C:\Users\vbhujan\Documents\Cart.txt"));
mockObserver.Verify(o => o.update(), Times.Never);
}
开发者ID:avinashbhujan,项目名称:SalesTaxObserverPatternWithLucene,代码行数:12,代码来源:TransactionManagerTests.cs
示例13: LsbLinuxHostInstaller
public LsbLinuxHostInstaller(LinuxServiceSettings settings, Installer[] installers, LinuxServiceLogWriter logWriter)
{
if (settings == null)
{
throw new ArgumentNullException(nameof(settings));
}
_settings = settings;
_installers = installers;
_logWriter = logWriter;
_installTransaction = new TransactionManager<LinuxServiceSettings>(_logWriter)
.Stage(Properties.Resources.CreateServiceFileStage, CreateServiceFile, DeleteServiceFile)
.Stage(Properties.Resources.SetServiceFileAsExecutableStage, SetServiceFileAsExecutable)
.Stage(Properties.Resources.RegisterServiceFileStage, RegisterServiceFile, UnregisterServiceFile);
}
开发者ID:AlexMAS,项目名称:Mono.Helpers,代码行数:16,代码来源:LsbLinuxHostInstaller.cs
示例14: Delete
public override bool Delete(long id, TransactionManager trans)
{
var sqlStatement = "Delete From BoxContract Where Id = @Id";
var parms = new[] { new OleDbParameter("@Id", OleDbType.BigInt) { Value = id } };
try
{
if (trans == null)
AccessHelper.ExecuteNonQuery(this.ConnectionString, sqlStatement, parms);
else
AccessHelper.ExecuteNonQuery(trans.TransactionObject as OleDbTransaction, sqlStatement, parms);
return true;
}
catch (Exception ex)
{
Logger.Error(ex.Message, ex);
return false ;
}
}
开发者ID:x16man,项目名称:x16man,代码行数:19,代码来源:AccessBoxContractProvider.cs
示例15: CreateRecordWithValueAndApply
/// <summary>
/// Create a record to a placeHolder by name and apply a record
/// </summary>
/// <param name="placeHolders">List of placeholder which should be applied</param>
/// <param name="placeHolderName">Name of placeholder</param>
/// <param name="recordName">Name of record</param>
/// <param name="variableName">Variable to set</param>
/// <param name="value">New value of the variable</param>
/// <returns>Return true if one or more was applied</returns>
public bool CreateRecordWithValueAndApply(PlaceHolder[] placeHolders, string placeHolderName, string recordName, string variableName, string value)
{
List<PlaceHolder> foundPlaceHolder = placeHolders
.Where(placeHolder => placeHolder.Name.Equals(placeHolderName)) // name
.ToList();
foreach (PlaceHolder placeHolder in foundPlaceHolder)
{
placeHolder.AddRecord(recordName);
placeHolder.set_Value(recordName, variableName, value);
using (Transaction transaction = new TransactionManager().CreateTransaction())
{
placeHolder.ApplyRecord(recordName, true); // apply (with page data)
transaction.Commit(); // needed if not placed in project
}
}
return foundPlaceHolder.Any(); // true == found | false == not found
}
开发者ID:Suplanus,项目名称:Suplanus.Sepla,代码行数:28,代码来源:PlaceHolderUtility.cs
示例16: Delete
public override bool Delete(string itemName, TransactionManager trans)
{
var sqlStatement = "Delete From Item Where ItemName = @ItemName";
var parms = new[] {
new OleDbParameter("@ItemName",OleDbType.VarWChar,50){Value = itemName},
};
try
{
if (trans == null)
AccessHelper.ExecuteNonQuery(this.ConnectionString, sqlStatement, parms);
else
AccessHelper.ExecuteNonQuery(trans.TransactionObject as OleDbTransaction, sqlStatement, parms);
return true;
}
catch (Exception ex)
{
Logger.Error(ex.Message, ex);
return false;
}
}
开发者ID:x16man,项目名称:x16man,代码行数:21,代码来源:AccessItemProvider.cs
示例17: AmbientTransactionCommitsIteself
public void AmbientTransactionCommitsIteself()
{
var seed = new Seed32();
var hits = 0;
using (var manager = new TransactionManager<int, MockClassA>() )
{
manager.TransactionCommitted += new TransactionCommit<int, MockClassA>
(delegate(ITransaction<int, MockClassA> transaction)
{
Assert.AreEqual(3, transaction.GetEnlistedActions().Count());
hits++;
transaction.MarkComplete();
hits = 1;
});
var testEntities = TestResourceFactory.GetMockClassAObjects(3).ToList();
testEntities.ForEach(e => e.Id = seed.Increment());
using (var tLock1 = manager.GetActiveTransaction(false))
{
foreach (var entity in testEntities)
tLock1.Transaction.Enlist(Action.Create, entity.Id, entity);
var sw = new Stopwatch();
sw.Start();
while (sw.ElapsedMilliseconds < 5500)
Thread.Sleep(10);
}
Thread.Sleep(500);
Assert.AreEqual(1, hits);
}
}
开发者ID:thehexgod,项目名称:BESSY-DB,代码行数:38,代码来源:TransactionManagerTests.cs
示例18: Insert
/// <summary>
/// Inserts a Nettiers.AdventureWorks.Entities.TransactionHistory object into the datasource using a transaction.
/// </summary>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <param name="entity">Nettiers.AdventureWorks.Entities.TransactionHistory object to insert.</param>
/// <remarks>
/// After inserting into the datasource, the Nettiers.AdventureWorks.Entities.TransactionHistory object will be updated
/// to refelect any changes made by the datasource. (ie: identity or computed columns)
/// </remarks>
/// <returns>Returns true if operation is successful.</returns>
/// <exception cref="System.Exception">The command could not be executed.</exception>
/// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
/// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
public override bool Insert(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.TransactionHistory entity)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "Production.usp_adwTiers_TransactionHistory_Insert", _useStoredProcedure);
database.AddOutParameter(commandWrapper, "@TransactionId", DbType.Int32, 4);
database.AddInParameter(commandWrapper, "@ProductId", DbType.Int32, entity.ProductId );
database.AddInParameter(commandWrapper, "@ReferenceOrderId", DbType.Int32, entity.ReferenceOrderId );
database.AddInParameter(commandWrapper, "@ReferenceOrderLineId", DbType.Int32, entity.ReferenceOrderLineId );
database.AddInParameter(commandWrapper, "@TransactionDate", DbType.DateTime, entity.TransactionDate );
database.AddInParameter(commandWrapper, "@TransactionType", DbType.StringFixedLength, entity.TransactionType );
database.AddInParameter(commandWrapper, "@Quantity", DbType.Int32, entity.Quantity );
database.AddInParameter(commandWrapper, "@ActualCost", DbType.Currency, entity.ActualCost );
database.AddInParameter(commandWrapper, "@ModifiedDate", DbType.DateTime, entity.ModifiedDate );
int results = 0;
//Provider Data Requesting Command Event
OnDataRequesting(new CommandEventArgs(commandWrapper, "Insert", entity));
if (transactionManager != null)
{
results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
}
else
{
results = Utility.ExecuteNonQuery(database,commandWrapper);
}
object _transactionId = database.GetParameterValue(commandWrapper, "@TransactionId");
entity.TransactionId = (System.Int32)_transactionId;
entity.AcceptChanges();
//Provider Data Requested Command Event
OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));
return Convert.ToBoolean(results);
}
开发者ID:WildGenie,项目名称:NetTiers,代码行数:53,代码来源:SqlTransactionHistoryProviderBase.generated.cs
示例19: Update
/// <summary>
/// Update an existing row in the datasource.
/// </summary>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <param name="entity">Nettiers.AdventureWorks.Entities.TransactionHistory object to update.</param>
/// <remarks>
/// After updating the datasource, the Nettiers.AdventureWorks.Entities.TransactionHistory object will be updated
/// to refelect any changes made by the datasource. (ie: identity or computed columns)
/// </remarks>
/// <returns>Returns true if operation is successful.</returns>
/// <exception cref="System.Exception">The command could not be executed.</exception>
/// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
/// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
public override bool Update(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.TransactionHistory entity)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "Production.usp_adwTiers_TransactionHistory_Update", _useStoredProcedure);
database.AddInParameter(commandWrapper, "@TransactionId", DbType.Int32, entity.TransactionId );
database.AddInParameter(commandWrapper, "@ProductId", DbType.Int32, entity.ProductId );
database.AddInParameter(commandWrapper, "@ReferenceOrderId", DbType.Int32, entity.ReferenceOrderId );
database.AddInParameter(commandWrapper, "@ReferenceOrderLineId", DbType.Int32, entity.ReferenceOrderLineId );
database.AddInParameter(commandWrapper, "@TransactionDate", DbType.DateTime, entity.TransactionDate );
database.AddInParameter(commandWrapper, "@TransactionType", DbType.StringFixedLength, entity.TransactionType );
database.AddInParameter(commandWrapper, "@Quantity", DbType.Int32, entity.Quantity );
database.AddInParameter(commandWrapper, "@ActualCost", DbType.Currency, entity.ActualCost );
database.AddInParameter(commandWrapper, "@ModifiedDate", DbType.DateTime, entity.ModifiedDate );
int results = 0;
//Provider Data Requesting Command Event
OnDataRequesting(new CommandEventArgs(commandWrapper, "Update", entity));
if (transactionManager != null)
{
results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
}
else
{
results = Utility.ExecuteNonQuery(database,commandWrapper);
}
//Stop Tracking Now that it has been updated and persisted.
if (DataRepository.Provider.EnableEntityTracking)
EntityManager.StopTracking(entity.EntityTrackingKey);
entity.AcceptChanges();
//Provider Data Requested Command Event
OnDataRequested(new CommandEventArgs(commandWrapper, "Update", entity));
return Convert.ToBoolean(results);
}
开发者ID:WildGenie,项目名称:NetTiers,代码行数:54,代码来源:SqlTransactionHistoryProviderBase.generated.cs
示例20: GetByTransactionId
/// <summary>
/// Gets rows from the datasource based on the PK_TransactionHistory_TransactionID index.
/// </summary>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <param name="_transactionId">Primary key for TransactionHistory records.</param>
/// <param name="start">Row number at which to start reading.</param>
/// <param name="pageLength">Number of rows to return.</param>
/// <param name="count">out parameter to get total records for query.</param>
/// <returns>Returns an instance of the <see cref="Nettiers.AdventureWorks.Entities.TransactionHistory"/> class.</returns>
/// <remarks></remarks>
/// <exception cref="System.Exception">The command could not be executed.</exception>
/// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
/// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
public override Nettiers.AdventureWorks.Entities.TransactionHistory GetByTransactionId(TransactionManager transactionManager, System.Int32 _transactionId, int start, int pageLength, out int count)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "Production.usp_adwTiers_TransactionHistory_GetByTransactionId", _useStoredProcedure);
database.AddInParameter(commandWrapper, "@TransactionId", DbType.Int32, _transactionId);
IDataReader reader = null;
TList<TransactionHistory> tmp = new TList<TransactionHistory>();
try
{
//Provider Data Requesting Command Event
OnDataRequesting(new CommandEventArgs(commandWrapper, "GetByTransactionId", tmp));
if (transactionManager != null)
{
reader = Utility.ExecuteReader(transactionManager, commandWrapper);
}
else
{
reader = Utility.ExecuteReader(database, commandWrapper);
}
//Create collection and fill
Fill(reader, tmp, start, pageLength);
count = -1;
if(reader.NextResult())
{
if(reader.Read())
{
count = reader.GetInt32(0);
}
}
//Provider Data Requested Command Event
OnDataRequested(new CommandEventArgs(commandWrapper, "GetByTransactionId", tmp));
}
finally
{
if (reader != null)
reader.Close();
commandWrapper = null;
}
if (tmp.Count == 1)
{
return tmp[0];
}
else if (tmp.Count == 0)
{
return null;
}
else
{
throw new DataException("Cannot find the unique instance of the class.");
}
//return rows;
}
开发者ID:WildGenie,项目名称:NetTiers,代码行数:73,代码来源:SqlTransactionHistoryProviderBase.generated.cs
注:本文中的TransactionManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论