Exemplo n.º 1
0
 /// <summary>
 /// Asynchronously establishes connection to the SMM GSM database.
 /// </summary>
 /// <returns>Task to await connection establishment</returns>
 private Task EstablishConnnectionAsync()
 {
     _globalConnection = new SqlStoreConnection(
         StoreConnectionKind.Global,
         _credentials.ConnectionInfoShardMapManager);
     return(_globalConnection.OpenAsync());
 }
Exemplo n.º 2
0
 /// <summary>
 /// Establishes connection to the SMM GSM database.
 /// </summary>
 private void EstablishConnnection()
 {
     _globalConnection = new SqlStoreConnection(
         StoreConnectionKind.Global,
         _credentials.ConnectionInfoShardMapManager);
     _globalConnection.Open();
 }
Exemplo n.º 3
0
 /// <summary>
 /// Terminates the connections after finishing the operation.
 /// </summary>
 private void TeardownConnection()
 {
     if (_globalConnection != null)
     {
         _globalConnection.Close();
         _globalConnection = null;
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Performs actual Dispose of resources.
 /// </summary>
 /// <param name="disposing">Whether the invocation was from IDisposable.Dipose method.</param>
 protected virtual void Dispose(bool disposing)
 {
     if (_localConnection != null)
     {
         _localConnection.Dispose();
         _localConnection = null;
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Establishes connection to the target shard.
        /// </summary>
        private void EstablishConnnection()
        {
            // Open connection.
            SqlConnectionStringBuilder localConnectionString =
                new SqlConnectionStringBuilder(_credentials.ConnectionStringShard)
            {
                DataSource     = this.Location.DataSource,
                InitialCatalog = this.Location.Database
            };

            _localConnection = new SqlStoreConnection(StoreConnectionKind.LocalSource, localConnectionString.ConnectionString);
            _localConnection.Open();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Established connections to the target databases.
        /// </summary>
        /// <param name="undo">Is this undo operation.</param>
        private void EstablishConnnections(bool undo)
        {
            _operationState = undo ? StoreOperationState.UndoGlobalConnect : StoreOperationState.DoGlobalConnect;

            // Find the necessary information for connections.
            StoreConnectionInfo sci = this.GetStoreConnectionInfo();

            Debug.Assert(sci != null);

            // Open global & local connections and acquire application level locks for the corresponding scope.
            _globalConnection = this.Manager.StoreConnectionFactory.GetConnection(
                StoreConnectionKind.Global,
                this.Manager.Credentials.ConnectionStringShardMapManager,
                this.Manager.Credentials.SecureCredentialShardMapManager);

            _globalConnection.OpenWithLock(this.Id);

            if (sci.SourceLocation != null)
            {
                _operationState = undo ? StoreOperationState.UndoLocalSourceConnect : StoreOperationState.DoLocalSourceConnect;

                _localConnectionSource = this.Manager.StoreConnectionFactory.GetConnection(
                    StoreConnectionKind.LocalSource,
                    this.GetConnectionStringForShardLocation(sci.SourceLocation),
                    this.GetSecureCredentialForShardLocation(sci.SourceLocation));

                _localConnectionSource.OpenWithLock(this.Id);
            }

            if (sci.TargetLocation != null)
            {
                Debug.Assert(sci.SourceLocation != null);

                _operationState = undo ? StoreOperationState.UndoLocalTargetConnect : StoreOperationState.DoLocalTargetConnect;

                _localConnectionTarget = this.Manager.StoreConnectionFactory.GetConnection(
                    StoreConnectionKind.LocalTarget,
                    this.GetConnectionStringForShardLocation(sci.TargetLocation),
                    this.GetSecureCredentialForShardLocation(sci.TargetLocation));

                _localConnectionTarget.OpenWithLock(this.Id);
            }
        }
        /// <summary>
        /// Establishes connection to the target shard.
        /// </summary>
        private void EstablishConnnection()
        {
            // Open connection.
            SqlConnectionStringBuilder localConnectionString =
                new SqlConnectionStringBuilder(_credentials.ConnectionInfoShard.ConnectionString)
            {
                DataSource     = this.Location.DataSource,
                InitialCatalog = this.Location.Database
            };

            SqlConnectionInfo localConnectionInfo =
                _credentials.ConnectionInfoShard.CloneWithUpdatedConnectionString(
                    localConnectionString.ConnectionString);

            _localConnection = new SqlStoreConnection(
                StoreConnectionKind.LocalSource,
                localConnectionInfo);

            _localConnection.Open();
        }
Exemplo n.º 8
0
        /// <summary>
        /// Performs actual Dispose of resources.
        /// </summary>
        /// <param name="disposing">Whether the invocation was from IDisposable.Dipose method.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (_localConnectionTarget != null)
            {
                _localConnectionTarget.Dispose();
                _localConnectionTarget = null;
            }

            if (_localConnectionSource != null)
            {
                _localConnectionSource.Dispose();
                _localConnectionSource = null;
            }

            if (_globalConnection != null)
            {
                _globalConnection.Dispose();
                _globalConnection = null;
            }
        }
        /// <summary>
        /// Terminates connection on the source shard object.
        /// </summary>
        private void KillConnectionsOnSourceShard()
        {
            SqlUtils.WithSqlExceptionHandling(() =>
            {
                string sourceShardConnectionString        = this.GetConnectionStringForShardLocation(_mappingSource.StoreShard.Location);
                SqlCredential sourceShardSecureCredential = this.GetSecureCredentialForShardLocation(_mappingSource.StoreShard.Location);

                IStoreResults result;

                using (IStoreConnection connectionForKill = this.Manager.StoreConnectionFactory.GetConnection(
                           StoreConnectionKind.LocalSource,
                           sourceShardConnectionString,
                           sourceShardSecureCredential))
                {
                    connectionForKill.Open();

                    using (IStoreTransactionScope ts = connectionForKill.GetTransactionScope(StoreTransactionScopeKind.NonTransactional))
                    {
                        result = ts.ExecuteOperation(
                            StoreOperationRequestBuilder.SpKillSessionsForShardMappingLocal,
                            StoreOperationRequestBuilder.KillSessionsForShardMappingLocal(_patternForKill));
                    }
                }

                if (result.Result != StoreResult.Success)
                {
                    // Possible errors are:
                    // StoreResult.UnableToKillSessions
                    // StoreResult.StoreVersionMismatch
                    // StoreResult.MissingParametersForStoredProcedure
                    throw StoreOperationErrorHandler.OnShardMapErrorLocal(
                        result,
                        _shardMap,
                        _mappingSource.StoreShard.Location,
                        _errorCategory,
                        StoreOperationErrorHandler.OperationNameFromStoreOperationCode(this.OperationCode),
                        StoreOperationRequestBuilder.SpKillSessionsForShardMappingLocal);
                }
            });
        }
        /// <summary>
        /// Establishes connection to the target shard.
        /// </summary>
        private void EstablishConnnection()
        {
            // Open connection.
            SqlConnectionStringBuilder localConnectionString =
                new SqlConnectionStringBuilder(_credentials.ConnectionStringShard)
                {
                    DataSource = this.Location.DataSource,
                    InitialCatalog = this.Location.Database
                };

            _localConnection = new SqlStoreConnection(StoreConnectionKind.LocalSource, localConnectionString.ConnectionString);
            _localConnection.Open();
        }
Exemplo n.º 11
0
 /// <summary>
 /// Asynchronously establishes connection to the SMM GSM database.
 /// </summary>
 /// <returns>Task to await connection establishment</returns>
 private async Task EstablishConnnectionAsync()
 {
     _globalConnection = new SqlStoreConnection(StoreConnectionKind.Global, _credentials.ConnectionStringShardMapManager);
     await _globalConnection.OpenAsync();
 }
Exemplo n.º 12
0
 protected BaseRepository(IStoreConnection connection)
 {
     _connection = connection;
 }
Exemplo n.º 13
0
        /// <summary>
        /// Established connections to the target databases.
        /// </summary>
        /// <param name="undo">Is this undo operation.</param>
        private void EstablishConnnections(bool undo)
        {
            _operationState = undo ? StoreOperationState.UndoGlobalConnect : StoreOperationState.DoGlobalConnect;

            // Find the necessary information for connections.
            StoreConnectionInfo sci = this.GetStoreConnectionInfo();

            Debug.Assert(sci != null);

            // Open global & local connections and acquire application level locks for the corresponding scope.
            _globalConnection = this.Manager.StoreConnectionFactory.GetConnection(
                StoreConnectionKind.Global,
                this.Manager.Credentials.ConnectionStringShardMapManager);

            _globalConnection.OpenWithLock(this.Id);

            if (sci.SourceLocation != null)
            {
                _operationState = undo ? StoreOperationState.UndoLocalSourceConnect : StoreOperationState.DoLocalSourceConnect;

                _localConnectionSource = this.Manager.StoreConnectionFactory.GetConnection(
                    StoreConnectionKind.LocalSource,
                    this.GetConnectionStringForShardLocation(sci.SourceLocation));

                _localConnectionSource.OpenWithLock(this.Id);
            }

            if (sci.TargetLocation != null)
            {
                Debug.Assert(sci.SourceLocation != null);

                _operationState = undo ? StoreOperationState.UndoLocalTargetConnect : StoreOperationState.DoLocalTargetConnect;

                _localConnectionTarget = this.Manager.StoreConnectionFactory.GetConnection(
                    StoreConnectionKind.LocalTarget,
                    this.GetConnectionStringForShardLocation(sci.TargetLocation));

                _localConnectionTarget.OpenWithLock(this.Id);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Performs actual Dispose of resources.
        /// </summary>
        /// <param name="disposing">Whether the invocation was from IDisposable.Dipose method.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (_localConnectionTarget != null)
            {
                _localConnectionTarget.Dispose();
                _localConnectionTarget = null;
            }

            if (_localConnectionSource != null)
            {
                _localConnectionSource.Dispose();
                _localConnectionSource = null;
            }

            if (_globalConnection != null)
            {
                _globalConnection.Dispose();
                _globalConnection = null;
            }
        }
 /// <summary>
 /// Performs actual Dispose of resources.
 /// </summary>
 /// <param name="disposing">Whether the invocation was from IDisposable.Dipose method.</param>
 protected virtual void Dispose(bool disposing)
 {
     if (_globalConnection != null)
     {
         _globalConnection.Dispose();
         _globalConnection = null;
     }
 }
 /// <summary>
 /// Establishes connection to the SMM GSM database.
 /// </summary>
 private void EstablishConnnection()
 {
     _globalConnection = new SqlStoreConnection(StoreConnectionKind.Global, _credentials.ConnectionStringShardMapManager);
     _globalConnection.Open();
 }
Exemplo n.º 17
0
 public ProductRepository(IStoreConnection connection) : base(connection)
 {
 }
 /// <summary>
 /// Terminates the connections after finishing the operation.
 /// </summary>
 private void TeardownConnection()
 {
     if (_globalConnection != null)
     {
         _globalConnection.Close();
         _globalConnection = null;
     }
 }
 /// <summary>
 /// Asynchronously establishes connection to the SMM GSM database.
 /// </summary>
 /// <returns>Task to await connection establishment</returns>
 private Task EstablishConnnectionAsync()
 {
     _globalConnection = new SqlStoreConnection(StoreConnectionKind.Global, _credentials.ConnectionStringShardMapManager);
     return _globalConnection.OpenAsync();
 }