コード例 #1
0
        public static void SetSystemDefault(String AKey, String AValue)
        {
            Boolean NewTransaction = false;
            Boolean ShouldCommit   = false;

            try
            {
                TDBTransaction Transaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted,
                                                                                               TEnforceIsolationLevel.eilMinimum,
                                                                                               out NewTransaction);
                SSystemDefaultsTable tbl = SSystemDefaultsAccess.LoadByPrimaryKey(AKey, Transaction);

                if (tbl.Rows.Count > 0) // I already have this. (I expect this is the case usually!)
                {
                    DataRow Row = tbl[0];
                    ((SSystemDefaultsRow)Row).DefaultValue = AValue;
                }
                else
                {
                    DataRow Row = tbl.NewRowTyped(true);
                    ((SSystemDefaultsRow)Row).DefaultCode        = AKey;
                    ((SSystemDefaultsRow)Row).DefaultDescription = "Created in OpenPetra";
                    ((SSystemDefaultsRow)Row).DefaultValue       = AValue;
                    tbl.Rows.Add(Row);
                }

                SSystemDefaultsAccess.SubmitChanges(tbl, Transaction);
                ShouldCommit = true;
            }
            catch (Exception Exc)
            {
                TLogging.Log("An Exception occured during the saving of a single System Default:" + Environment.NewLine + Exc.ToString());
                ShouldCommit = false;
                throw;
            }
            finally
            {
                if (NewTransaction)
                {
                    if (ShouldCommit)
                    {
                        DBAccess.GDBAccessObj.CommitTransaction();
                    }
                    else
                    {
                        DBAccess.GDBAccessObj.RollbackTransaction();
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Updates the 'Last Reminder Date', that is the date when PartnerReminders last ran.
        /// <para>
        /// This is done by updating a certain SystemDefault.
        /// </para>
        /// </summary>
        /// <param name="ASystemDefaultsDR">SystemDefaults DataRow containing the date.</param>
        /// <param name="AReadWriteTransaction">Already instantiated DB Transaction.</param>
        private static void UpdateLastReminderDate(SSystemDefaultsRow ASystemDefaultsDR, TDBTransaction AReadWriteTransaction)
        {
            // Set SystemDefault value to today's date (mind the Format!)
            ASystemDefaultsDR.DefaultValue = String.Format("{0},{1},{2}", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);

            try
            {
                SSystemDefaultsAccess.SubmitChanges((SSystemDefaultsTable)ASystemDefaultsDR.Table, AReadWriteTransaction);
            }
            catch (Exception Exc)
            {
                TLogging.Log("TProcessPartnerReminders.UpdateLastReminderDate: An Exception occured:" + Environment.NewLine + Exc.ToString());

                throw;
            }
        }
コード例 #3
0
        public static TSubmitChangesResult SaveData(string ATablename,
                                                    ref TTypedDataTable ASubmitTable, out TVerificationResultCollection AVerificationResult,
                                                    TDBTransaction AWriteTransaction)
        {
            AVerificationResult = null;

            // TODO: check write permissions
            string context = string.Format("SaveData {0}", SharedConstants.MODULE_ACCESS_MANAGER);

            if (ASubmitTable != null)
            {
                AVerificationResult = new TVerificationResultCollection();

                try
                {
                    if (ATablename == AAccountingPeriodTable.GetTableDBName())
                    {
                        AAccountingPeriodAccess.SubmitChanges((AAccountingPeriodTable)ASubmitTable, AWriteTransaction);

                        TCacheableTablesManager.GCacheableTablesManager.MarkCachedTableNeedsRefreshing(
                            TCacheableFinanceTablesEnum.AccountingPeriodList.ToString());
                    }
                    else if (ATablename == ACurrencyTable.GetTableDBName())
                    {
                        ACurrencyAccess.SubmitChanges((ACurrencyTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == ADailyExchangeRateTable.GetTableDBName())
                    {
                        TSecurityChecks.CheckUserModulePermissions(
                            string.Format("AND({0},{1})", SharedConstants.PETRAGROUP_FINANCE1, SharedConstants.PETRAMODULE_FINEXRATE),
                            context);
                        ADailyExchangeRateAccess.SubmitChanges((ADailyExchangeRateTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == ACorporateExchangeRateTable.GetTableDBName())
                    {
                        // AlanP:  I don't think this is used any more.  There is a TDS Save method instead
                        ACorporateExchangeRateAccess.SubmitChanges((ACorporateExchangeRateTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == ACurrencyLanguageTable.GetTableDBName())
                    {
                        ACurrencyLanguageAccess.SubmitChanges((ACurrencyLanguageTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == AFeesPayableTable.GetTableDBName())
                    {
                        AFeesPayableAccess.SubmitChanges((AFeesPayableTable)ASubmitTable, AWriteTransaction);

                        TCacheableTablesManager.GCacheableTablesManager.MarkCachedTableNeedsRefreshing(
                            TCacheableFinanceTablesEnum.FeesPayableList.ToString());
                    }
                    else if (ATablename == AFeesReceivableTable.GetTableDBName())
                    {
                        AFeesReceivableAccess.SubmitChanges((AFeesReceivableTable)ASubmitTable, AWriteTransaction);

                        TCacheableTablesManager.GCacheableTablesManager.MarkCachedTableNeedsRefreshing(
                            TCacheableFinanceTablesEnum.FeesReceivableList.ToString());
                    }
                    else if (ATablename == AGiftBatchTable.GetTableDBName())
                    {
                        // This method is called from ADailyExchangeRate Setup - please do not remove
                        // The method is not required for changes made to the gift batch screens, which use a TDS
                        AGiftBatchAccess.SubmitChanges((AGiftBatchTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == AJournalTable.GetTableDBName())
                    {
                        // This method is called from ADailyExchangeRate Setup - please do not remove
                        // The method is not required for changes made to the journal screens, which use a TDS
                        AJournalAccess.SubmitChanges((AJournalTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == ARecurringJournalTable.GetTableDBName())
                    {
                        // This method is called from Submit Recurring GL Batch form - please do not remove
                        // The method is not required for changes made to the journal screens, which use a TDS
                        ARecurringJournalAccess.SubmitChanges((ARecurringJournalTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == ALedgerTable.GetTableDBName())
                    {
                        // This method is called from ADailyExchangeRate Testing - please do not remove
                        ALedgerAccess.SubmitChanges((ALedgerTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == AAnalysisTypeTable.GetTableDBName())
                    {
                        AAnalysisTypeAccess.SubmitChanges((AAnalysisTypeTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == ASuspenseAccountTable.GetTableDBName())
                    {
                        ASuspenseAccountAccess.SubmitChanges((ASuspenseAccountTable)ASubmitTable, AWriteTransaction);

                        TCacheableTablesManager.GCacheableTablesManager.MarkCachedTableNeedsRefreshing(
                            TCacheableFinanceTablesEnum.SuspenseAccountList.ToString());
                    }
                    else if (ATablename == PcAttendeeTable.GetTableDBName())
                    {
                        PcAttendeeAccess.SubmitChanges((PcAttendeeTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PcConferenceTable.GetTableDBName())
                    {
                        PcConferenceAccess.SubmitChanges((PcConferenceTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PcConferenceCostTable.GetTableDBName())
                    {
                        PcConferenceCostAccess.SubmitChanges((PcConferenceCostTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PcEarlyLateTable.GetTableDBName())
                    {
                        PcEarlyLateAccess.SubmitChanges((PcEarlyLateTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PcSupplementTable.GetTableDBName())
                    {
                        PcSupplementAccess.SubmitChanges((PcSupplementTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PcDiscountTable.GetTableDBName())
                    {
                        PcDiscountAccess.SubmitChanges((PcDiscountTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PInternationalPostalTypeTable.GetTableDBName())
                    {
                        ValidateInternationalPostalType(ref AVerificationResult, ASubmitTable);
                        ValidateInternationalPostalTypeManual(ref AVerificationResult, ASubmitTable);

                        if (TVerificationHelper.IsNullOrOnlyNonCritical(AVerificationResult))
                        {
                            PInternationalPostalTypeAccess.SubmitChanges((PInternationalPostalTypeTable)ASubmitTable, AWriteTransaction);
                        }
                    }
                    else if (ATablename == PtApplicationTypeTable.GetTableDBName())
                    {
                        PtApplicationTypeAccess.SubmitChanges((PtApplicationTypeTable)ASubmitTable, AWriteTransaction);

                        // mark dependent lists for needing to be refreshed since there was a change in base list
                        TCacheableTablesManager.GCacheableTablesManager.MarkCachedTableNeedsRefreshing(
                            TCacheablePersonTablesEnum.EventApplicationTypeList.ToString());
                        TCacheableTablesManager.GCacheableTablesManager.MarkCachedTableNeedsRefreshing(
                            TCacheablePersonTablesEnum.FieldApplicationTypeList.ToString());
                    }
                    else if (ATablename == PFormTable.GetTableDBName())
                    {
                        PFormAccess.SubmitChanges((PFormTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PFormalityTable.GetTableDBName())
                    {
                        PFormalityAccess.SubmitChanges((PFormalityTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PMailingTable.GetTableDBName())
                    {
                        PMailingAccess.SubmitChanges((PMailingTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PPartnerGiftDestinationTable.GetTableDBName())
                    {
                        PPartnerGiftDestinationAccess.SubmitChanges((PPartnerGiftDestinationTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PmDocumentTypeTable.GetTableDBName())
                    {
                        PmDocumentTypeAccess.SubmitChanges((PmDocumentTypeTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == SGroupTable.GetTableDBName())
                    {
                        SGroupAccess.SubmitChanges((SGroupTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == SSystemDefaultsTable.GetTableDBName())
                    {
                        SSystemDefaultsAccess.SubmitChanges((SSystemDefaultsTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == SSystemDefaultsGuiTable.GetTableDBName())
                    {
                        SSystemDefaultsGuiAccess.SubmitChanges((SSystemDefaultsGuiTable)ASubmitTable, AWriteTransaction);
                    }
                    else
                    {
                        throw new EOPAppException("TCommonDataReader.SaveData: unknown table '" + ATablename + "'");
                    }
                }
                catch (Exception Exc)
                {
                    AVerificationResult.Add(
                        new TVerificationResult(null, "Cannot SubmitChanges:" + Environment.NewLine +
                                                Exc.Message, "UNDEFINED", TResultSeverity.Resv_Critical));
                }
            }

            if ((AVerificationResult != null) &&
                (AVerificationResult.Count > 0))
            {
                // Downgrade TScreenVerificationResults to TVerificationResults in order to allow
                // Serialisation (needed for .NET Remoting).
                TVerificationResultCollection.DowngradeScreenVerificationResults(AVerificationResult);

                return(AVerificationResult.HasCriticalErrors ? TSubmitChangesResult.scrError : TSubmitChangesResult.scrOK);
            }

            return(TSubmitChangesResult.scrOK);
        }
コード例 #4
0
        /// <summary>
        /// Determines the 'Last Reminder Date', that is the date when PartnerReminders last ran.
        /// <para>
        /// This is done by reading a certain SystemDefault. If PartnerReminders was never run before,
        /// this SystemDefault is created.
        /// </para>
        /// </summary>
        /// <param name="ALastReminderDate">Date when PartnerReminders last ran. Will be January 1st, 1980
        /// if PartnerReminders never ran before.</param>
        /// <param name="ASystemDefaultsDR">SystemDefaults DataRow containing the date. This is used later for updating
        /// the date.</param>
        /// <param name="AReadWriteTransaction">Already instantiated DB Transaction.</param>
        /// <returns>True if the 'Last Reminder Date' could be read/created. False if PartnerReminders was never run before
        /// AND creation of the new SystemDefault record failed for some reason.</returns>
        private static bool GetLastReminderDate(out DateTime ALastReminderDate,
                                                out SSystemDefaultsRow ASystemDefaultsDR,
                                                TDBTransaction AReadWriteTransaction)
        {
            const string UNDEFINED_SYSTEMDEFAULT_LAST_REMINDER_DATE = "1980,1,1";   // Double check order!

            SSystemDefaultsTable SystemDefaultsDT = new SSystemDefaultsTable();
            string LastReminderDateStr;

            string[] DateParts;
            bool     ReturnValue = true;


            ASystemDefaultsDR = null;

            // Check if there is already a SystemDefault for the Last Reminder Date (most likely there is!)
            if (SSystemDefaultsAccess.Exists(SYSTEMDEFAULT_LAST_REMINDER_DATE, AReadWriteTransaction))
            {
                if (TLogging.DebugLevel >= 6)
                {
                    TLogging.Log("GetLastReminderDate: System Default for the Last Reminder Date exists: use it.");
                }

                // There is already a SystemDefault for the Last Reminder Date: read its value
                SystemDefaultsDT = SSystemDefaultsAccess.LoadByPrimaryKey(SYSTEMDEFAULT_LAST_REMINDER_DATE, AReadWriteTransaction);

                // Used later to update the row
                ASystemDefaultsDR = SystemDefaultsDT[0];
            }
            else
            {
                // System Default for the Last Reminder Date doesn't exist: add a new SystemDefault for future use
                if (TLogging.DebugLevel >= 6)
                {
                    TLogging.Log("GetLastReminderDate: System Default for the Last Reminder Date doesn't exist yet: creating it.");
                }

                ASystemDefaultsDR                    = SystemDefaultsDT.NewRowTyped();
                ASystemDefaultsDR.DefaultCode        = SYSTEMDEFAULT_LAST_REMINDER_DATE;
                ASystemDefaultsDR.DefaultDescription = SYSTEMDEFAULT_LAST_REMINDER_DATE_DESC;
                ASystemDefaultsDR.DefaultValue       = UNDEFINED_SYSTEMDEFAULT_LAST_REMINDER_DATE;

                try
                {
                    SSystemDefaultsAccess.SubmitChanges(SystemDefaultsDT, AReadWriteTransaction);
                }
                catch (Exception Exc)
                {
                    TLogging.Log("TProcessPartnerReminders.GetLastReminderDate: An Exception occured:" + Environment.NewLine + Exc.ToString());

                    throw;
                }
            }

            LastReminderDateStr = ASystemDefaultsDR.DefaultValue;

            // Last Reminder Date is stored as YEAR,MONTH,DAY
            DateParts         = LastReminderDateStr.Split(',');
            ALastReminderDate = new DateTime(
                Convert.ToInt32(DateParts[0]), Convert.ToInt32(DateParts[1]), Convert.ToInt32(DateParts[2]),
                0, 0, 1);   // One second past midnight

            if (TLogging.DebugLevel >= 6)
            {
                TLogging.Log(String.Format("GetLastReminderDate: DB Field value: {0}; Parsed date: {1}", LastReminderDateStr, ALastReminderDate));
            }

            return(ReturnValue);
        }
コード例 #5
0
        /// <summary>
        /// Stores a System Default in the DB. If it was already there it gets updated, if it wasn't there it gets added.
        /// </summary>
        /// <remarks>The change gets reflected in the System Defaults Cache the next time the System Defaults Cache
        /// gets accessed.</remarks>
        /// <param name="AKey">Name of the System Default.</param>
        /// <param name="AValue">Value of the System Default.</param>
        /// <param name="AAdded">True if the System Default got added, false if it already existed.</param>
        /// <remarks>SystemDefault Names are not case sensitive.</remarks>

        public void SetSystemDefault(String AKey, String AValue, out bool AAdded)
        {
            Boolean NewTransaction = false;
            Boolean ShouldCommit   = false;
            SSystemDefaultsTable SystemDefaultsDT;

            try
            {
                TDBTransaction ReadWriteTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(
                    IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, out NewTransaction);

                SystemDefaultsDT = SSystemDefaultsAccess.LoadAll(ReadWriteTransaction);

                // This will find the row that matches a case-insensitive search of the table primary keys
                SystemDefaultsDT.CaseSensitive = false;     // It is anyway
                SSystemDefaultsRow match = (SSystemDefaultsRow)SystemDefaultsDT.Rows.Find(AKey);

                if (match != null)
                {
                    // I already have this System Default in the DB --> simply update the Value in the DB.
                    // (This will often be the case!)
                    match.DefaultValue = AValue;

                    AAdded = false;
                }
                else
                {
                    // The System Default isn't in the DB yet --> store it in the DB.
                    var SystemDefaultsDR = SystemDefaultsDT.NewRowTyped(true);
                    SystemDefaultsDR.DefaultCode        = AKey;
                    SystemDefaultsDR.DefaultDescription = "Created in OpenPetra";
                    SystemDefaultsDR.DefaultValue       = AValue;

                    SystemDefaultsDT.Rows.Add(SystemDefaultsDR);

                    AAdded = true;
                }

                SSystemDefaultsAccess.SubmitChanges(SystemDefaultsDT, ReadWriteTransaction);

                ShouldCommit = true;
            }
            catch (Exception Exc)
            {
                TLogging.Log(
                    "TSystemDefaultCache.SetSystemDefault: An Exception occured during the saving of the System Default '" + AKey +
                    "'. Value to be saved: + '" + AValue + "'" +
                    Environment.NewLine + Exc.ToString());

                ShouldCommit = false;

                throw;
            }
            finally
            {
                if (NewTransaction)
                {
                    if (ShouldCommit)
                    {
                        DBAccess.GDBAccessObj.CommitTransaction();

                        // We need to ensure that the next time the System Defaults Caches gets accessed it is refreshed from the DB!!!

                        // Obtain thread-safe access to the FTableCached Field to prevent two (or more) Threads from getting a different
                        // FTableCached value!
                        lock (FTableCachedLockCookie)
                        {
                            FTableCached = false;
                        }
                    }
                    else
                    {
                        DBAccess.GDBAccessObj.RollbackTransaction();
                    }
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// Stores a System Default in the DB. If it was already there it gets updated, if it wasn't there it gets added.
        /// </summary>
        /// <remarks>The change gets reflected in the System Defaults Cache the next time the System Defaults Cache
        /// gets accessed.</remarks>
        /// <param name="AKey">Name of the System Default.</param>
        /// <param name="AValue">Value of the System Default.</param>
        /// <param name="AAdded">True if the System Default got added, false if it already existed.</param>
        /// <remarks>SystemDefault Names are not case sensitive.</remarks>
        public void SetSystemDefault(String AKey, String AValue, out bool AAdded)
        {
            TDataBase            DBConnectionObj  = null;
            TDBTransaction       WriteTransaction = null;
            Boolean              SubmissionOK     = false;
            SSystemDefaultsTable SystemDefaultsDT;
            Boolean              Added = false;

            try
            {
                // Open a separate DB Connection...
                DBConnectionObj = DBAccess.SimpleEstablishDBConnection("SetSystemDefault");

                // ...and start a DB Transaction on that separate DB Connection
                DBConnectionObj.BeginAutoTransaction(IsolationLevel.ReadCommitted, ref WriteTransaction, ref SubmissionOK,
                                                     "SetSystemDefault", delegate
                {
                    SystemDefaultsDT = SSystemDefaultsAccess.LoadAll(WriteTransaction);

                    // This will find the row that matches a case-insensitive search of the table primary keys
                    SystemDefaultsDT.CaseSensitive = false;         // It is anyway
                    SSystemDefaultsRow match       = (SSystemDefaultsRow)SystemDefaultsDT.Rows.Find(AKey);

                    if (match != null)
                    {
                        // I already have this System Default in the DB --> simply update the Value in the DB.
                        // (This will often be the case!)
                        match.DefaultValue = AValue;

                        Added = false;
                    }
                    else
                    {
                        // The System Default isn't in the DB yet --> store it in the DB.
                        var SystemDefaultsDR                = SystemDefaultsDT.NewRowTyped(true);
                        SystemDefaultsDR.DefaultCode        = AKey;
                        SystemDefaultsDR.DefaultDescription = "Created in OpenPetra";
                        SystemDefaultsDR.DefaultValue       = AValue;

                        SystemDefaultsDT.Rows.Add(SystemDefaultsDR);

                        Added = true;
                    }

                    SSystemDefaultsAccess.SubmitChanges(SystemDefaultsDT, WriteTransaction);

                    SubmissionOK = true;
                });

                AAdded = Added;
            }
            catch (Exception Exc)
            {
                TLogging.Log(
                    "TSystemDefaultCache.SetSystemDefault: An Exception occured during the saving of the System Default '" + AKey +
                    "'. Value to be saved: + '" + AValue + "'" +
                    Environment.NewLine + Exc.ToString());

                throw;
            }
            finally
            {
                if (SubmissionOK)
                {
                    // We need to ensure that the next time the System Defaults Caches gets accessed it is refreshed from the DB!!!

                    // Obtain thread-safe access to the FTableCached Field to prevent two (or more) Threads from getting a different
                    // FTableCached value!
                    lock (FTableCachedLockCookie)
                    {
                        FTableCached = false;
                    }
                }

                if (DBConnectionObj != null)
                {
                    DBConnectionObj.CloseDBConnection();
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// Stores a System Default in the DB. If it was already there it gets updated, if it wasn't there it gets added.
        /// </summary>
        /// <remarks>The change gets reflected in the System Defaults Cache the next time the System Defaults Cache
        /// gets accessed.</remarks>
        /// <param name="AKey">Name of the System Default.</param>
        /// <param name="AValue">Value of the System Default.</param>
        /// <param name="AAdded">True if the System Default got added, false if it already existed.</param>
        /// <param name="ADataBase"></param>
        /// <remarks>SystemDefault Names are not case sensitive.</remarks>
        public void SetSystemDefault(String AKey, String AValue, out bool AAdded, TDataBase ADataBase = null)
        {
            TDataBase            DBConnectionObj  = null;
            TDBTransaction       WriteTransaction = new TDBTransaction();
            bool                 SubmissionOK     = false;
            SSystemDefaultsTable SystemDefaultsDT;
            Boolean              Added = false;

            try
            {
                // Open a separate DB Connection...
                DBConnectionObj = DBAccess.Connect("SetSystemDefault", ADataBase);

                // ...and start a DB Transaction on that separate DB Connection
                DBConnectionObj.WriteTransaction(ref WriteTransaction, ref SubmissionOK,
                                                 delegate
                {
                    SystemDefaultsDT = SSystemDefaultsAccess.LoadAll(WriteTransaction);

                    // This will find the row that matches a case-insensitive search of the table primary keys
                    SystemDefaultsDT.CaseSensitive = false;         // It is anyway
                    SSystemDefaultsRow match       = (SSystemDefaultsRow)SystemDefaultsDT.Rows.Find(AKey);

                    if (match != null)
                    {
                        // I already have this System Default in the DB --> simply update the Value in the DB.
                        // (This will often be the case!)
                        match.DefaultValue = AValue;

                        Added = false;
                    }
                    else
                    {
                        // The System Default isn't in the DB yet --> store it in the DB.
                        var SystemDefaultsDR                = SystemDefaultsDT.NewRowTyped(true);
                        SystemDefaultsDR.DefaultCode        = AKey;
                        SystemDefaultsDR.DefaultDescription = "Created in OpenPetra";
                        SystemDefaultsDR.DefaultValue       = AValue;

                        SystemDefaultsDT.Rows.Add(SystemDefaultsDR);

                        Added = true;
                    }

                    SSystemDefaultsAccess.SubmitChanges(SystemDefaultsDT, WriteTransaction);

                    SubmissionOK = true;
                });

                AAdded = Added;
            }
            catch (Exception Exc)
            {
                TLogging.Log(
                    "TSystemDefaultCache.SetSystemDefault: An Exception occured during the saving of the System Default '" + AKey +
                    "'. Value to be saved: + '" + AValue + "'" +
                    Environment.NewLine + Exc.ToString());

                throw;
            }
            finally
            {
                if (ADataBase == null)
                {
                    DBConnectionObj.CloseDBConnection();
                }

                if (SubmissionOK && (FSystemDefaultsDT != null))
                {
                    // We need to ensure that the next time the System Defaults Caches gets accessed it is refreshed from the DB!!!
                    FSystemDefaultsDT.Clear();
                    FSystemDefaultsDT = null;
                }
            }
        }