Exemple #1
0
        public Enrich(string interchangeId, string tag)
        {
            SqlServerConnection connection = null;

            try
            {
                connection = new SqlServerConnection("MessageArchive");
                connection.RefreshConfiguration();
                connection.Open();
                SplitArchiveTag(tag);
                LoadParts(connection, interchangeId, tag);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                    connection.Dispose();
                    connection = null;
                }
            }
        }
        public void Dispose_DisposesTheConnection_IfOwned()
        {
            using (var sqlConnection = ConnectionUtils.CreateConnection())
            {
                var connection = new SqlServerConnection(sqlConnection, IsolationLevel.Serializable, _providers);

                connection.Dispose();

                Assert.Equal(ConnectionState.Closed, sqlConnection.State);
            }
        }
        public void Dispose_DoesNotDisposeTheConnection_IfNotOwned()
        {
            using (var sqlConnection = ConnectionUtils.CreateConnection())
            {
                var connection = new SqlServerConnection(sqlConnection, IsolationLevel.Serializable, _providers, ownsConnection: false);

                connection.Dispose();

                Assert.Equal(ConnectionState.Open, sqlConnection.State);
            }
        }
        public void Dispose_DoesNotDisposeTheConnection_IfNotOwned()
        {
            using (var sqlConnection = ConnectionUtils.CreateConnection())
            {
                var connection = new SqlServerConnection(sqlConnection, _providers, ownsConnection: false);

                connection.Dispose();

                Assert.Equal(ConnectionState.Open, sqlConnection.State);
            }
        }
        public void Dispose_DisposesTheConnection_IfOwned()
        {
            using (var sqlConnection = ConnectionUtils.CreateConnection())
            {
                var connection = new SqlServerConnection(sqlConnection, _providers);

                connection.Dispose();

                Assert.Equal(ConnectionState.Closed, sqlConnection.State);
            }
        }
Exemple #6
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposed && disposing)
            {
                if (connection != null)
                {
                    connection.Dispose();
                }
            }

            disposed = true;
        }
Exemple #7
0
        private static Dictionary <string, Endpoint> LoadEndpointDictionary()
        {
            SqlServerConnection           connection = null;
            Dictionary <string, Endpoint> endpoints  = new Dictionary <string, Endpoint>(StringComparer.InvariantCultureIgnoreCase);

            try
            {
                // Connect to the database to load settings.
                string     sql        = null;
                SqlCommand sqlCommand = null;
                connection = new SqlServerConnection("MessageArchive");
                connection.RefreshConfiguration();
                connection.Open();

                // Load the dictionary of Endpoint records.
                sql = "SELECT [Id], [Name] " +
                      "FROM [MessageArchive].[dbo].[Endpoint]";
                sqlCommand = new SqlCommand(sql);
                using (SqlDataReader reader = connection.ExecuteReader(sqlCommand))
                {
                    while (reader.Read())
                    {
                        IDataRecord record   = (IDataRecord)reader;
                        Endpoint    endpoint = new Endpoint(record);
                        endpoints.Add(endpoint.Name, endpoint);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.WriteWarning("Error while loading Tag data." + ex);
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                    connection.Dispose();
                    connection = null;
                }
            }

            return(endpoints);
        }
Exemple #8
0
        private static Dictionary <string, ArchiveType> LoadArchiveTypeDictionary()
        {
            SqlServerConnection connection = null;
            Dictionary <string, ArchiveType> archiveTypes = new Dictionary <string, ArchiveType>(StringComparer.InvariantCultureIgnoreCase);

            try
            {
                // Connect to the database to load settings.
                string     sql        = null;
                SqlCommand sqlCommand = null;
                connection = new SqlServerConnection("MessageArchive");
                connection.RefreshConfiguration();
                connection.Open();
                // Load the dictionary of ArchiveType records.
                sql = "SELECT [Id], [Name], [Active], [DefaultExpiry] " +
                      "FROM [MessageArchive].[dbo].[ArchiveType]";
                sqlCommand = new SqlCommand(sql);
                using (SqlDataReader reader = connection.ExecuteReader(sqlCommand))
                {
                    while (reader.Read())
                    {
                        IDataRecord record      = (IDataRecord)reader;
                        ArchiveType archiveType = new ArchiveType(record);
                        archiveTypes.Add(archiveType.Name, archiveType);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.WriteWarning("Error while loading Tag data." + ex);
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                    connection.Dispose();
                    connection = null;
                }
            }
            return(archiveTypes);
        }