Esempio n. 1
0
        private void DeleteFlag(String AFlag)
        {
            TDBTransaction Transaction  = new TDBTransaction();
            TDataBase      db           = DBAccess.Connect("DeleteFlag", FDataBase);
            Boolean        SubmissionOK = true;

            db.WriteTransaction(
                ref Transaction,
                ref SubmissionOK,
                delegate
            {
                ALedgerInitFlagTable LedgerInitFlagTable = ALedgerInitFlagAccess.LoadByPrimaryKey(
                    FLedgerNumber, AFlag, Transaction);

                if (LedgerInitFlagTable.Rows.Count == 1)
                {
                    LedgerInitFlagTable[0].Delete();

                    ALedgerInitFlagAccess.SubmitChanges(LedgerInitFlagTable, Transaction);
                }
            });

            if (FDataBase == null)
            {
                db.CloseDBConnection();
            }
        }
Esempio n. 2
0
        private void DeleteRecord()
        {
            bool           NewTransaction;
            TDBTransaction ReadWriteTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.Serializable,
                                                                                                    out NewTransaction);

            try
            {
                ALedgerInitFlagTable aLedgerInitFlagTable = ALedgerInitFlagAccess.LoadByPrimaryKey(
                    intLedgerNumber, strFlagName, ReadWriteTransaction);

                if (aLedgerInitFlagTable.Rows.Count == 1)
                {
                    ((ALedgerInitFlagRow)aLedgerInitFlagTable.Rows[0]).Delete();

                    ALedgerInitFlagAccess.SubmitChanges(aLedgerInitFlagTable, ReadWriteTransaction);
                }

                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.CommitTransaction();
                }
            }
            catch (Exception Exc)
            {
                TLogging.Log("An Exception occured in DeleteRecord:" + Environment.NewLine + Exc.ToString());

                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.RollbackTransaction();
                }

                throw;
            }
        }
Esempio n. 3
0
        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;
            }
        }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ALedgerNumber"></param>
        /// <param name="AFlag"></param>
        /// <param name="AValue"></param>
        /// <param name="ADataBase"></param>
        public static void SetFlagValue(int ALedgerNumber, String AFlag, String AValue, TDataBase ADataBase = null)
        {
            TDBTransaction ReadWriteTransaction = null;
            Boolean        SubmissionOK         = false;

            DBAccess.GetDBAccessObj(ADataBase).GetNewOrExistingAutoTransaction(IsolationLevel.Serializable,
                                                                               TEnforceIsolationLevel.eilMinimum,
                                                                               ref ReadWriteTransaction,
                                                                               ref SubmissionOK,
                                                                               delegate
            {
                ALedgerInitFlagTable ledgerInitFlagTable = ALedgerInitFlagAccess.LoadByPrimaryKey(
                    ALedgerNumber, AFlag, ReadWriteTransaction);

                ALedgerInitFlagRow ledgerInitFlagRow =
                    ledgerInitFlagTable.Rows.Count == 0 ?
                    ledgerInitFlagTable.NewRowTyped()
                        : ledgerInitFlagTable[0];
                ledgerInitFlagRow.LedgerNumber   = ALedgerNumber;
                ledgerInitFlagRow.InitOptionName = AFlag;
                ledgerInitFlagRow.Value          = AValue;

                if (ledgerInitFlagTable.Rows.Count == 0)
                {
                    ledgerInitFlagTable.Rows.Add(ledgerInitFlagRow);
                }

                ALedgerInitFlagAccess.SubmitChanges(ledgerInitFlagTable, ReadWriteTransaction);

                SubmissionOK = true;
            });
        }
Esempio n. 5
0
        /// <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;
                }
            }
        }
Esempio n. 6
0
        private void DeleteRecord()
        {
            TDBTransaction Transaction  = null;
            Boolean        SubmissionOK = true;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoTransaction(IsolationLevel.Serializable, TEnforceIsolationLevel.eilMinimum,
                                                                  ref Transaction, ref SubmissionOK,
                                                                  delegate
            {
                ALedgerInitFlagTable LedgerInitFlagTable = ALedgerInitFlagAccess.LoadByPrimaryKey(
                    FLedgerNumber, FFlagName, Transaction);

                if (LedgerInitFlagTable.Rows.Count == 1)
                {
                    ((ALedgerInitFlagRow)LedgerInitFlagTable.Rows[0]).Delete();

                    ALedgerInitFlagAccess.SubmitChanges(LedgerInitFlagTable, Transaction);
                }
            });
        }
Esempio n. 7
0
        private static void DeleteFlag(int ALedgerNumber, String AFlag, TDataBase ADataBase = null)
        {
            TDBTransaction Transaction  = null;
            Boolean        SubmissionOK = true;

            DBAccess.GetDBAccessObj(ADataBase).GetNewOrExistingAutoTransaction(IsolationLevel.Serializable,
                                                                               TEnforceIsolationLevel.eilMinimum,
                                                                               ref Transaction,
                                                                               ref SubmissionOK,
                                                                               delegate
            {
                ALedgerInitFlagTable LedgerInitFlagTable = ALedgerInitFlagAccess.LoadByPrimaryKey(
                    ALedgerNumber, AFlag, Transaction);

                if (LedgerInitFlagTable.Rows.Count == 1)
                {
                    LedgerInitFlagTable[0].Delete();

                    ALedgerInitFlagAccess.SubmitChanges(LedgerInitFlagTable, Transaction);
                }
            });
        }
Esempio n. 8
0
        /// <summary>
        ///
        /// </summary>
        public void SetFlagAndName(string AName)
        {
            bool NewTransaction;

            TDBTransaction WriteTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.Serializable,
                                                                                                out NewTransaction);

            ALedgerInitFlagTable aLedgerInitFlagTable = ALedgerInitFlagAccess.LoadByPrimaryKey(
                intLedgerNumber, strFlagName, WriteTransaction);

            ALedgerInitFlagRow aLedgerInitFlagRow = (ALedgerInitFlagRow)aLedgerInitFlagTable.NewRow();

            aLedgerInitFlagRow.LedgerNumber   = intLedgerNumber;
            aLedgerInitFlagRow.InitOptionName = strFlagName;

            aLedgerInitFlagTable.Rows.Add(aLedgerInitFlagRow);

            try
            {
                ALedgerInitFlagAccess.SubmitChanges(aLedgerInitFlagTable, WriteTransaction);

                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.CommitTransaction();
                }
            }
            catch (Exception Exc)
            {
                TLogging.Log("An Exception occured in SetFlagAndName:" + Environment.NewLine + Exc.ToString());

                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.RollbackTransaction();
                }

                throw;
            }
        }
Esempio n. 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="AFlag"></param>
        /// <param name="AValue"></param>
        public void SetFlagValue(String AFlag, String AValue)
        {
            TDBTransaction ReadWriteTransaction = new TDBTransaction();
            TDataBase      db           = DBAccess.Connect("SetFlagValue", FDataBase);
            Boolean        SubmissionOK = false;

            db.WriteTransaction(
                ref ReadWriteTransaction,
                ref SubmissionOK,
                delegate
            {
                ALedgerInitFlagTable ledgerInitFlagTable = ALedgerInitFlagAccess.LoadByPrimaryKey(
                    FLedgerNumber, AFlag, ReadWriteTransaction);

                ALedgerInitFlagRow ledgerInitFlagRow =
                    ledgerInitFlagTable.Rows.Count == 0 ?
                    ledgerInitFlagTable.NewRowTyped()
                        : ledgerInitFlagTable[0];
                ledgerInitFlagRow.LedgerNumber   = FLedgerNumber;
                ledgerInitFlagRow.InitOptionName = AFlag;
                ledgerInitFlagRow.Value          = AValue;

                if (ledgerInitFlagTable.Rows.Count == 0)
                {
                    ledgerInitFlagTable.Rows.Add(ledgerInitFlagRow);
                }

                ALedgerInitFlagAccess.SubmitChanges(ledgerInitFlagTable, ReadWriteTransaction);

                SubmissionOK = true;
            });

            if (FDataBase == null)
            {
                db.CloseDBConnection();
            }
        }