本文整理汇总了C#中Microsoft.Isam.Esent.Interop.Transaction类的典型用法代码示例。如果您正苦于以下问题:C# Transaction类的具体用法?C# Transaction怎么用?C# Transaction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Transaction类属于Microsoft.Isam.Esent.Interop命名空间,在下文中一共展示了Transaction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StorageActionsAccessor
public StorageActionsAccessor(TableColumnsCache tableColumnsCache, JET_INSTANCE instance, string databaseName, UuidGenerator uuidGenerator, OrderedPartCollection<AbstractFileCodec> fileCodecs)
{
this.tableColumnsCache = tableColumnsCache;
this.uuidGenerator = uuidGenerator;
this.fileCodecs = fileCodecs;
try
{
session = new Session(instance);
transaction = new Transaction(session);
Api.JetOpenDatabase(session, databaseName, null, out database, OpenDatabaseGrbit.None);
}
catch (Exception original)
{
log.WarnException("Could not create accessor", original);
try
{
Dispose();
}
catch (Exception e)
{
log.WarnException("Could not properly dispose accessor after exception in ctor.", e);
}
throw;
}
}
示例2: CreateTable
internal static void CreateTable(Session session, JET_DBID dbid)
{
JET_TABLEID tableid;
Api.JetCreateTable(session, dbid, ifcHeaderTableName, 1, 100, out tableid);
using (var transaction = new Microsoft.Isam.Esent.Interop.Transaction(session))
{
JET_COLUMNID columnid;
var columndef = new JET_COLUMNDEF
{
coltyp = JET_coltyp.Long,
grbit = ColumndefGrbit.ColumnAutoincrement
};
Api.JetAddColumn(session, tableid, _colNameHeaderId, columndef, null, 0, out columnid);
columndef.coltyp = JET_coltyp.Currency;
columndef.grbit = ColumndefGrbit.ColumnNotNULL;
Api.JetAddColumn(session, tableid, _colNameEntityCount, columndef, null, 0, out columnid);
columndef.coltyp = JET_coltyp.LongBinary;
columndef.grbit = ColumndefGrbit.ColumnNotNULL;
Api.JetAddColumn(session, tableid, _colNameHeaderData, columndef, null, 0, out columnid);
columndef.coltyp = JET_coltyp.Text;
columndef.grbit = ColumndefGrbit.ColumnNotNULL;
columndef.cbMax = 32;
Api.JetAddColumn(session, tableid, _colNameFileVersion, columndef, null, 0, out columnid);
transaction.Commit(CommitTransactionGrbit.LazyFlush);
}
}
示例3: Create
public void Create(JET_SESID session, JET_DBID dbid)
{
using (var tran = new Transaction(session))
{
JET_TABLEID tblID;
Api.JetCreateTable(session, dbid, tableName, 1, 80, out tblID);
JET_COLUMNID c;
Api.JetAddColumn(session, tblID, colName_ID, new JET_COLUMNDEF()
{
coltyp = JET_coltyp.Currency,
grbit = ColumndefGrbit.ColumnAutoincrement | ColumndefGrbit.ColumnFixed | ColumndefGrbit.ColumnNotNULL,
}, null, 0, out c);
Api.JetAddColumn(session, tblID, colName_LogID, new JET_COLUMNDEF()
{
coltyp = JET_coltyp.Currency,
grbit = ColumndefGrbit.ColumnFixed | ColumndefGrbit.ColumnNotNULL,
}, null, 0, out c);
var indexDef = "+" + colName_ID + "\0\0";
Api.JetCreateIndex(session, tblID, idxName_Primary, CreateIndexGrbit.IndexPrimary, indexDef, indexDef.Length, 80);
tran.Commit(CommitTransactionGrbit.None);
}
}
示例4: Create
public void Create(TableDefinition def)
{
if (def.ColumnDefinitions.FindAll(x => x.IsPrimaryKey).Count != 1)
{
// TODO do we allow 0 primary keys?
throw new EseException("Ensure one primary key is defined for the table");
}
using (var transaction = new Transaction(connection.session))
{
JET_TABLEID tableid;
Api.JetCreateTable(connection.session, connection.dbid, def.TableName, 16, 100, out tableid);
foreach (var column in def.ColumnDefinitions) {
AddColumn(tableid, column);
}
foreach (var item in def.Indexes) {
// all indexes are ascending
var indexName = string.Join("|", item.ToArray());
var indexDef = "+" + string.Join("\0+", item.ToArray()) + "\0\0";
Api.JetCreateIndex(connection.session, tableid, indexName, CreateIndexGrbit.IndexSortNullsHigh, indexDef, indexDef.Length, 100);
}
transaction.Commit(CommitTransactionGrbit.LazyFlush);
}
}
示例5: PopImpl
protected override CrawlerQueueEntry PopImpl()
{
return m_EsentInstance.Cursor((session, dbid) =>
{
using (Transaction transaction = new Transaction(session))
{
using (Table table = new Table(session, dbid, EsentTableDefinitions.QueueTableName, OpenTableGrbit.None))
{
if (Api.TryMoveFirst(session, table))
{
byte[] data = Api.RetrieveColumn(session, table, dataColumn.columnid);
Api.JetDelete(session, table);
using (Table table2 = new Table(session, dbid, EsentTableDefinitions.GlobalsTableName, OpenTableGrbit.None))
{
Api.EscrowUpdate(session, table2, queueCountColumn.columnid, -1);
}
transaction.Commit(CommitTransactionGrbit.None);
return data.FromBinary<CrawlerQueueEntry>();
}
}
transaction.Rollback();
return null;
}
});
}
示例6: Create
public void Create(string database)
{
JET_DBID dbid;
Api.JetCreateDatabase(session, database, null, out dbid, CreateDatabaseGrbit.None);
try
{
using (var tx = new Transaction(session))
{
CreateDetailsTable(dbid);
CreateQueuesTable(dbid);
CreateSubQueuesTable(dbid);
CreateTransactionTable(dbid);
CreateRecoveryTable(dbid);
CreateOutgoingTable(dbid);
CreateOutgoingHistoryTable(dbid);
CreateReceivedMessagesTable(dbid);
tx.Commit(CommitTransactionGrbit.None);
}
}
finally
{
Api.JetCloseDatabase(session, dbid, CloseDatabaseGrbit.None);
}
}
示例7: DocumentStorageActions
public DocumentStorageActions(
JET_INSTANCE instance,
string database,
TableColumnsCache tableColumnsCache,
OrderedPartCollection<AbstractDocumentCodec> documentCodecs,
IUuidGenerator uuidGenerator,
IDocumentCacher cacher,
TransactionalStorage transactionalStorage)
{
this.tableColumnsCache = tableColumnsCache;
this.documentCodecs = documentCodecs;
this.uuidGenerator = uuidGenerator;
this.cacher = cacher;
this.transactionalStorage = transactionalStorage;
try
{
session = new Session(instance);
transaction = new Transaction(session);
Api.JetOpenDatabase(session, database, null, out dbid, OpenDatabaseGrbit.None);
}
catch (Exception)
{
Dispose();
throw;
}
}
示例8: CreateDatabase
private static void CreateDatabase()
{
using (var databaseInstance = new Instance(DatabasePath))
{
InitializeDatabaseInstance(databaseInstance);
if (File.Exists(DatabasePath))
{
return;
}
using (var session = new Session(databaseInstance))
{
JET_DBID dbid;
Api.JetCreateDatabase(session, DatabasePath, null, out dbid, CreateDatabaseGrbit.OverwriteExisting);
using (var transaction = new Transaction(session))
{
JET_TABLEID tableid;
Api.JetCreateTable(session, dbid, "Message", 0, 100, out tableid);
CreateIdColumn(session, tableid);
CreateDateCreatedColumn(session, tableid);
CreateIndexes(session, tableid);
transaction.Commit(CommitTransactionGrbit.LazyFlush);
}
Api.JetCloseDatabase(session, dbid, CloseDatabaseGrbit.None);
Api.JetDetachDatabase(session, DatabasePath);
}
}
}
示例9: WithDatabase
public static void WithDatabase(this JET_INSTANCE instance, string database, Func<Session, JET_DBID, Transaction, Transaction> action)
{
using (var session = new Session(instance))
{
var tx = new Transaction(session);
try
{
JET_DBID dbid;
Api.JetOpenDatabase(session, database, "", out dbid, OpenDatabaseGrbit.None);
try
{
tx = action(session, dbid, tx);
}
finally
{
Api.JetCloseDatabase(session, dbid, CloseDatabaseGrbit.None);
}
tx.Commit(CommitTransactionGrbit.None);
}
finally
{
if(tx != null)
tx.Dispose();
}
}
}
示例10: GetUniqueId
public int GetUniqueId(string value)
{
OpenTableForUpdatingWithoutTransaction();
while (true)
{
if (TrySeek(value))
{
return Api.RetrieveColumnAsInt32(SessionId, TableId, _idColumnId).Value;
}
using (var transaction = new Transaction(SessionId))
{
PrepareUpdate(JET_prep.Insert);
var id = Api.RetrieveColumnAsInt32(SessionId, TableId, _idColumnId, RetrieveColumnGrbit.RetrieveCopy).Value;
// set name
Api.SetColumn(SessionId, TableId, _nameColumnId, value, Encoding.Unicode);
if (ApplyChanges())
{
transaction.Commit(CommitTransactionGrbit.LazyFlush);
return id;
}
}
}
}
示例11: Update
public void Update(Session session, JET_DBID dbid)
{
using (var tx = new Transaction(session))
{
using (var files = new Table(session, dbid, "files", OpenTableGrbit.None))
{
const string indexDef = "+etag\0\0";
Api.JetCreateIndex(session, files, "by_etag", CreateIndexGrbit.IndexDisallowNull, indexDef, indexDef.Length,
100);
using (var details = new Table(session, dbid, "details", OpenTableGrbit.None))
{
Api.JetMove(session, details, JET_Move.First, MoveGrbit.None);
var columnids = Api.GetColumnDictionary(session, details);
using (var update = new Update(session, details, JET_prep.Replace))
{
Api.SetColumn(session, details, columnids["schema_version"], "2.7", Encoding.Unicode);
update.Save();
}
}
}
tx.Commit(CommitTransactionGrbit.None);
}
}
示例12: CreateBasicTableColumnIndex3OnXp
public void CreateBasicTableColumnIndex3OnXp()
{
var tablecreate = new JET_TABLECREATE { szTableName = "table" };
string directory = SetupHelper.CreateRandomDirectory();
string database = Path.Combine(directory, "test.db");
using (var instance = new Instance("XpCreateBasicTableColumnIndex3"))
{
instance.Parameters.Recovery = false;
instance.Parameters.NoInformationEvent = true;
instance.Parameters.MaxTemporaryTables = 0;
instance.Init();
using (var session = new Session(instance))
{
JET_DBID dbid;
Api.JetCreateDatabase(session, database, String.Empty, out dbid, CreateDatabaseGrbit.None);
using (var transaction = new Transaction(session))
{
Api.JetCreateTableColumnIndex3(session, dbid, tablecreate);
Assert.AreNotEqual(JET_TABLEID.Nil, tablecreate.tableid);
Assert.AreEqual(tablecreate.cCreated, 1);
Api.JetCloseTable(session, tablecreate.tableid);
transaction.Commit(CommitTransactionGrbit.LazyFlush);
}
}
}
}
示例13: AbstractActions
protected AbstractActions(JET_INSTANCE instance, ColumnsInformation columnsInformation, string database, Guid instanceId)
{
logger = LogManager.GetLogger(GetType());
try
{
this.instanceId = instanceId;
ColumnsInformation = columnsInformation;
session = new Session(instance);
transaction = new Transaction(session);
Api.JetOpenDatabase(session, database, null, out dbid, OpenDatabaseGrbit.None);
queues = new EsentTable(session, new Table(session, dbid, "queues", OpenTableGrbit.None));
subqueues = new EsentTable(session, new Table(session, dbid, "subqueues", OpenTableGrbit.None));
txs = new EsentTable(session, new Table(session, dbid, "transactions", OpenTableGrbit.None));
recovery = new EsentTable(session, new Table(session, dbid, "recovery", OpenTableGrbit.None));
outgoing = new EsentTable(session, new Table(session, dbid, "outgoing", OpenTableGrbit.None));
outgoingHistory = new EsentTable(session, new Table(session, dbid, "outgoing_history", OpenTableGrbit.None));
recveivedMsgs = new EsentTable(session, new Table(session, dbid, "recveived_msgs", OpenTableGrbit.None));
}
catch (Exception)
{
Dispose();
throw;
}
}
示例14: Update
public void Update(Session session, JET_DBID dbid)
{
using (var tx = new Transaction(session))
{
using (var tasks = new Table(session, dbid, "tasks", OpenTableGrbit.None))
{
JET_COLUMNID columnid;
Api.JetAddColumn(session, tasks, "added_at",new JET_COLUMNDEF
{
coltyp = JET_coltyp.DateTime,
grbit = ColumndefGrbit.ColumnNotNULL
}, null, 0, out columnid);
using (var details = new Table(session, dbid, "details", OpenTableGrbit.None))
{
Api.JetMove(session, details, JET_Move.First, MoveGrbit.None);
var columnids = Api.GetColumnDictionary(session, details);
using (var update = new Update(session, details, JET_prep.Replace))
{
Api.SetColumn(session, details, columnids["schema_version"], "2.5", Encoding.Unicode);
update.Save();
}
}
}
tx.Commit(CommitTransactionGrbit.None);
}
}
示例15: Create
public void Create(string database)
{
JET_DBID dbid;
Api.JetCreateDatabase(session, database, null, out dbid, CreateDatabaseGrbit.None);
try
{
using (var tx = new Transaction(session))
{
CreateDetailsTable(dbid);
CreateDocumentsTable(dbid);
CreateDocumentsBeingModifiedByTransactionsTable(dbid);
CreateTransactionsTable(dbid);
CreateTasksTable(dbid);
CreateMapResultsTable(dbid);
CreateIndexingStatsTable(dbid);
CreateIndexingStatsReduceTable(dbid);
CreateFilesTable(dbid);
CreateQueueTable(dbid);
CreateIdentityTable(dbid);
tx.Commit(CommitTransactionGrbit.None);
}
}
finally
{
Api.JetCloseDatabase(session, dbid, CloseDatabaseGrbit.None);
}
}