private void CreateRecord() { bool NewTransaction; TDBTransaction ReadWriteTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.Serializable, out NewTransaction); try { ALedgerInitFlagTable aLedgerInitFlagTable = ALedgerInitFlagAccess.LoadByPrimaryKey( intLedgerNumber, strFlagName, ReadWriteTransaction); ALedgerInitFlagRow aLedgerInitFlagRow = (ALedgerInitFlagRow)aLedgerInitFlagTable.NewRow(); aLedgerInitFlagRow.LedgerNumber = intLedgerNumber; aLedgerInitFlagRow.InitOptionName = strFlagName; aLedgerInitFlagTable.Rows.Add(aLedgerInitFlagRow); ALedgerInitFlagAccess.SubmitChanges(aLedgerInitFlagTable, ReadWriteTransaction); if (NewTransaction) { DBAccess.GDBAccessObj.CommitTransaction(); } } catch (Exception Exc) { TLogging.Log("An Exception occured in CreateRecord:" + Environment.NewLine + Exc.ToString()); if (NewTransaction) { DBAccess.GDBAccessObj.RollbackTransaction(); } throw; } }
private void CreateRecord() { TDBTransaction ReadWriteTransaction = null; Boolean SubmissionOK = false; try { DBAccess.GDBAccessObj.GetNewOrExistingAutoTransaction(IsolationLevel.Serializable, TEnforceIsolationLevel.eilMinimum, ref ReadWriteTransaction, ref SubmissionOK, delegate { ALedgerInitFlagTable ledgerInitFlagTable = ALedgerInitFlagAccess.LoadByPrimaryKey( FLedgerNumber, FFlagName, ReadWriteTransaction); ALedgerInitFlagRow ledgerInitFlagRow = (ALedgerInitFlagRow)ledgerInitFlagTable.NewRow(); ledgerInitFlagRow.LedgerNumber = FLedgerNumber; ledgerInitFlagRow.InitOptionName = FFlagName; ledgerInitFlagTable.Rows.Add(ledgerInitFlagRow); ALedgerInitFlagAccess.SubmitChanges(ledgerInitFlagTable, ReadWriteTransaction); SubmissionOK = true; }); } catch (Exception ex) { TLogging.Log(String.Format("Method:{0} - Unexpected error!{1}{1}{2}", Utilities.GetMethodSignature(), Environment.NewLine, ex.Message)); throw ex; } }
/// <summary> /// /// </summary> public TLedgerLock(int ALedgerNum) { bool NewTransaction; intLegerNumber = ALedgerNum; TDBTransaction Transaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.Serializable, out NewTransaction); ALedgerInitFlagTable aLedgerInitFlagTable = ALedgerInitFlagAccess.LoadByPrimaryKey( intLegerNumber, TLedgerInitFlagEnum.LedgerLock.ToString(), Transaction); ALedgerInitFlagRow aLedgerInitFlagRow = (ALedgerInitFlagRow)aLedgerInitFlagTable.NewRow(); aLedgerInitFlagRow.LedgerNumber = intLegerNumber; aLedgerInitFlagRow.InitOptionName = TLedgerInitFlagEnum.LedgerLock.ToString(); lock (synchRoot) { try { aLedgerInitFlagTable.Rows.Add(aLedgerInitFlagRow); ALedgerInitFlagAccess.SubmitChanges(aLedgerInitFlagTable, Transaction); blnResult = true; if (NewTransaction) { DBAccess.GDBAccessObj.CommitTransaction(); } } catch (System.Data.ConstraintException Exc) { TLogging.Log("A ConstraintException occured during a call to the TLedgerLock constructor:" + Environment.NewLine + Exc.ToString()); if (NewTransaction) { DBAccess.GDBAccessObj.RollbackTransaction(); } blnResult = false; throw; } catch (Exception Exc) { TLogging.Log("An Exception occured during during a call to the TLedgerLock constructor:" + Environment.NewLine + Exc.ToString()); if (NewTransaction) { DBAccess.GDBAccessObj.RollbackTransaction(); } blnResult = false; throw; } } }