Esempio n. 1
0
        public void Connect()
        {
            if (Connector == null) {
                Connector = CreateConnector();
                Processor = Connector.CreateProcessor();
            }

            remoteEndPoint = MakeRemoteEndPoint();

            var request = new ConnectRequest(Connector.LocalEndPoint, remoteEndPoint) {
                DatabaseName = Settings.Database,
                Timeout = Settings.QueryTimeout,
                IgnoreIdentifiersCase = Settings.IgnoreIdentifiersCase,
                ParameterStyle = Settings.ParameterStyle,
                AutoCommit = Settings.AutoCommit
            };

            var response = SendMessage(request) as ConnectResponse;
            if (response == null)
                throw new ProtocolException("The returned message is invalid");

            if (!response.Opened)
                throw new DeveelDbServerException("Was not able to open the connection on the server.", -1, -1);

            if (response.IsEncryted)
                Connector.SetEncrypton(response.EncryptionData);

            IsClosed = false;
            ServerVersion = response.Version;
        }
Esempio n. 2
0
            private IMessageEnvelope ProcessConnect(IDictionary<string, object> metadata, ConnectRequest request)
            {
                Exception error = null;
                ConnectResponse response;

                try {
                    connector.OpenConnector(request.RemoteEndPoint, request.DatabaseName);
                    if (request.AutoCommit)
                        connector.SetAutoCommit(request.AutoCommit);

                    connector.SetIgnoreIdentifiersCase(request.IgnoreIdentifiersCase);
                    connector.SetParameterStyle(request.ParameterStyle);

                    var encryptionData = connector.GetEncryptionData();

                    var serverVersion = connector.Database.Version.ToString(2);
                    response = new ConnectResponse(true, serverVersion, encryptionData != null, encryptionData);
                } catch (Exception ex) {
                    // TODO: Log the error ...
                    error = ex;
                    response = new ConnectResponse(false, null);
                }

                var envelope = connector.CreateEnvelope(metadata, response);
                if (error != null)
                    envelope.SetError(error);

                return connector.CreateEnvelope(metadata, response);
            }