Ejemplo n.º 1
0
        private bool InternalReconnect(bool checkAlreadyConnected, IConnectionInfo connectionInfo)
        {
            if (this.IsConnected)
            {
                if (checkAlreadyConnected)
                {
                    throw new InvalidOperationException("Already connected, call 'Disconnect' before 'Connect'");
                }

                if (this.sqlConnection != null && this.sqlConnection.State == ConnectionState.Open)
                {
                    this.sqlConnection.Close();
                    this.sqlConnection = null;

                    sqlDriver = null;
                }
            }

            this.connectionInfo = (ConnectionInfo)connectionInfo;
            this.IsConnected    = false;

            try
            {
                if (!string.IsNullOrEmpty(this.connectionInfo.ServerName) &&
                    !string.IsNullOrEmpty(this.connectionInfo.DatabaseName) &&
                    this.connectionInfo.InternalInfo != null)
                {
                    sqlDriver     = SqlDriver.Create(this.connectionInfo.InternalInfo.ConnectionUrl);
                    sqlConnection = this.sqlDriver.CreateConnection();
                    sqlConnection.Open();
                    this.IsConnected = sqlConnection.State == ConnectionState.Open;

                    //                    DomainConfiguration config = new DomainConfiguration(this.connectionInfo.InternalInfo);
                    //                    config.UpgradeMode = DomainUpgradeMode.LegacySkip;
                    //                    this.domain = Domain.Build(config);
                    //                    this.extractedSchema = this.domain.ExtractedSchema;)
                    //                    this.IsConnected = this.domain != null && this.extractedSchema != null;
                }
                else
                {
                    this.IsConnected = true;
                }
            }
            catch (Exception e)
            {
                this.IsConnected = false;
                UpdateLastError(e, true);
            }

            return(this.IsConnected);
        }