Beispiel #1
0
        /// <summary>
        /// Loads the System Defaults into the cached Typed DataTable.
        ///
        /// The System Defaults are retrieved from the s_system_defaults table and are
        /// put into a Typed DataTable that has the structure of this table.
        ///
        /// </summary>
        /// <returns>void</returns>
        private void LoadSystemDefaultsTable()
        {
            TDataBase      DBAccessObj     = new Ict.Common.DB.TDataBase();
            TDBTransaction ReadTransaction = null;

            // Prevent other threads from obtaining a read lock on the cache table while we are (re)loading the cache table!
            FReadWriteLock.AcquireWriterLock(SharedConstants.THREADING_WAIT_INFINITE);

            try
            {
                if (FSystemDefaultsDT != null)
                {
                    FSystemDefaultsDT.Clear();
                }

                try
                {
                    DBAccessObj.EstablishDBConnection(TSrvSetting.RDMBSType,
                                                      TSrvSetting.PostgreSQLServer,
                                                      TSrvSetting.PostgreSQLServerPort,
                                                      TSrvSetting.PostgreSQLDatabaseName,
                                                      TSrvSetting.DBUsername,
                                                      TSrvSetting.DBPassword,
                                                      "",
                                                      "SystemDefaultsCache DB Connection");

                    DBAccessObj.BeginAutoReadTransaction(IsolationLevel.RepeatableRead, ref ReadTransaction,
                                                         delegate
                    {
                        FSystemDefaultsDT = SSystemDefaultsAccess.LoadAll(ReadTransaction);
                    });
                }
                finally
                {
                    DBAccessObj.CloseDBConnection();
                }

                // Thread.Sleep(5000);     uncomment this for debugging. This allows checking whether read access to FSystemDefaultsDT actually waits until we release the WriterLock in the finally block.
            }
            finally
            {
                // Other threads are now free to obtain a read lock on the cache table.
                FReadWriteLock.ReleaseWriterLock();
            }
        }
        /// <summary>
        /// Establishes a new Database connection to the Database
        /// for TTimedProcessing.
        /// </summary>
        /// <remarks>
        /// We don't want to use the global Ict.Common.DB.DBAccess.GDBAccessObj object in the Default
        /// AppDomain because this is reserved for OpenPetraServer's internal use (eg. verifying Client
        /// connection reqests)!
        /// </remarks>
        /// <returns>the database connection object</returns>
        private static TDataBase EstablishDBConnection()
        {
            TDataBase FDBAccessObj = new Ict.Common.DB.TDataBase();

            try
            {
                FDBAccessObj.EstablishDBConnection(TSrvSetting.RDMBSType,
                                                   TSrvSetting.PostgreSQLServer,
                                                   TSrvSetting.PostgreSQLServerPort,
                                                   TSrvSetting.PostgreSQLDatabaseName,
                                                   TSrvSetting.DBUsername,
                                                   TSrvSetting.DBPassword,
                                                   "");
            }
            catch (Exception)
            {
                /* TLogging.Log('Exception occured while establishing connection to Database Server: ' + exp.ToString); */
                throw;
            }

            return(FDBAccessObj);
        }
Beispiel #3
0
        /// <summary>
        /// Establishes a new Database connection to the Database
        /// for TTimedProcessing.
        /// </summary>
        /// <remarks>
        /// We don't want to use the global Ict.Common.DB.DBAccess.GDBAccessObj object in the Default
        /// AppDomain because this is reserved for OpenPetraServer's internal use (eg. verifying Client
        /// connection reqests)!
        /// </remarks>
        /// <returns>the database connection object</returns>
        private static TDataBase EstablishDBConnection()
        {
            TDataBase FDBAccessObj = new Ict.Common.DB.TDataBase();

            try
            {
                FDBAccessObj.EstablishDBConnection(TSrvSetting.RDMBSType,
                                                   TSrvSetting.PostgreSQLServer,
                                                   TSrvSetting.PostgreSQLServerPort,
                                                   TSrvSetting.PostgreSQLDatabaseName,
                                                   TSrvSetting.DBUsername,
                                                   TSrvSetting.DBPassword,
                                                   "",
                                                   "Servers's DB Connection for TimedProcessing");
            }
            catch (Exception Exc)
            {
                TLogging.Log("Timed Processing: Exception occured while establishing connection to Database Server: " + Exc.ToString());

                throw;
            }

            return(FDBAccessObj);
        }
Beispiel #4
0
        /// <summary>
        /// Establishes a new Database connection to the Database
        /// for TTimedProcessing.
        /// </summary>
        /// <remarks>
        /// We don't want to use the global Ict.Common.DB.DBAccess.GDBAccessObj object in the Default
        /// AppDomain because this is reserved for OpenPetraServer's internal use (eg. verifying Client
        /// connection reqests)!
        /// </remarks>
        /// <returns>the database connection object</returns>
        private static TDataBase EstablishDBConnection()
        {
            TDataBase FDBAccessObj = new Ict.Common.DB.TDataBase();

            try
            {
                FDBAccessObj.EstablishDBConnection(TSrvSetting.RDMBSType,
                    TSrvSetting.PostgreSQLServer,
                    TSrvSetting.PostgreSQLServerPort,
                    TSrvSetting.PostgreSQLDatabaseName,
                    TSrvSetting.DBUsername,
                    TSrvSetting.DBPassword,
                    "");
            }
            catch (Exception)
            {
                /* TLogging.Log('Exception occured while establishing connection to Database Server: ' + exp.ToString); */
                throw;
            }

            return FDBAccessObj;
        }