コード例 #1
0
        /// <summary>
        /// Every table inside of the transaction before calling Transaction Commit, goes to this in-memory dictionary
        /// </summary>
        /// <param name="tranNumber"></param>
        /// <param name="table"></param>
        public void AddTableForTransaction(ulong tranNumber, ITransactable table)
        {
            _sync_transactionsTables.EnterWriteLock();
            try
            {
                Dictionary<string, ITransactable> tbls = null;
                _transactionsTables.TryGetValue(tranNumber, out tbls);

                if (tbls == null)
                {
                    tbls = new Dictionary<string, ITransactable>();
                    tbls.Add(table.TableName, table);
                    _transactionsTables.Add(tranNumber, tbls);
                }
                else
                {
                    if (!tbls.ContainsKey(table.TableName))
                        tbls.Add(table.TableName, table);
                }
            }
            catch (System.Exception ex)
            {
                //Called from TransactionCoordinator.Commit
                throw ex;
            }
            finally
            {
                _sync_transactionsTables.ExitWriteLock();
            }
        }
コード例 #2
0
ファイル: TransactionUnit.cs プロジェクト: hhblaze/DBreeze
        /// <summary>
        /// Adds a table which will take place in transaction operations.
        /// Reserved has value null, Real (which are acquired by Transaction for Write) has ITransactable filled.
        /// ITransactable = null, gives to differ from toched and reserved.
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="table">if null - will be added to Reservation table</param>
        public void AddTransactionWriteTable(string tableName, ITransactable table)
        {
            _sync_transactionWriteTables.EnterWriteLock();
            try
            {

                if (!_transactionWriteTables.ContainsKey(tableName))
                {
                    this._transactionWriteTables.Add(tableName, table);

                    transactionWriteTablesCount++;
                }
                else
                {
                    if (_transactionWriteTables[tableName] == null)
                        _transactionWriteTables[tableName] = table;
                }

            }
            catch (System.Exception ex)
            {
                //CIRCULAR
                throw ex;
            }
            finally
            {
                _sync_transactionWriteTables.ExitWriteLock();
            }
        }
コード例 #3
0
ファイル: ModelFactory.cs プロジェクト: kofrasa/BudgetPal
 public static Transaction CreateTransaction(TransactionType type, ITransactable source, ITransactable target, DateTime date)
 {
     Transaction transaction = new Transaction(type);
     transaction.Source = source;
     transaction.Target = target;
     transaction.Date = date;
     return transaction;
 }