Exemplo n.º 1
0
        public static ConnectionSettings FromConnection
        (
            [NotNull] IrbisConnection connection
        )
        {
            Sure.NotNull(connection, nameof(connection));

            ConnectionSettings result = new ConnectionSettings
            {
                Host        = connection.Host,
                Port        = connection.Port,
                Username    = connection.Username,
                Password    = connection.Password,
                Database    = connection.Database,
                Workstation = connection.Workstation,
                UserData    = connection.UserData as string,
                Connected   = connection.Connected
            };

            LoggingClientSocket loggingSocket = connection.Socket as LoggingClientSocket;

            if (!ReferenceEquals(loggingSocket, null))
            {
                result.NetworkLogging = loggingSocket.DebugPath;
            }

            RetryClientSocket retrySocket = connection.Socket as RetryClientSocket;

            if (retrySocket != null)
            {
                result.RetryLimit = retrySocket.RetryManager.RetryLimit;
            }

            if (connection.Socket.GetType() != typeof(SimpleClientSocket) &&
                retrySocket == null &&
                loggingSocket == null
                )
            {
                result.SocketTypeName = connection.Socket
                                        .GetType().AssemblyQualifiedName;
            }

            if (connection.CommandFactory.GetType() != typeof(CommandFactory))
            {
                result.FactoryTypeName = connection.CommandFactory
                                         .GetType().AssemblyQualifiedName;
            }

            if (connection.Executive.GetType() != typeof(StandardEngine))
            {
                result.EngineTypeName = connection.Executive
                                        .GetType().AssemblyQualifiedName;
            }

            return(result);
        }
Exemplo n.º 2
0
        private void MainForm_Load
        (
            object sender,
            EventArgs e
        )
        {
            this.ShowVersionInfoInTitle();
            Output.PrintSystemInformation();

            //SlowSocket slowSocket = new SlowSocket
            //    (
            //        Connection,
            //        Connection.Socket
            //    );
            //Connection.SetSocket(slowSocket);

            RetryManager manager = new RetryManager
                                   (
                5,
                _Resolver
                                   );
            RetryClientSocket retrySocket
                = new RetryClientSocket
                  (
                      Connection,
                      Connection.Socket,
                      manager
                  );

            Connection.SetSocket(retrySocket);

            string connectionString
                = CM.AppSettings["connectionString"];

            Connection.ParseConnectionString
            (
                connectionString
            );
            Connection.Connect();

            WriteLine
            (
                "Connected to {0}, database {1}",
                Connection.Host,
                Connection.Database
            );
        }
Exemplo n.º 3
0
        private void ConnectionDisposing
        (
            object sender,
            EventArgs eventArgs
        )
        {
            IrbisConnection connection = sender as IrbisConnection;

            if (!ReferenceEquals(connection, null))
            {
                RetryClientSocket socket = connection.Socket
                                           as RetryClientSocket;
                if (!ReferenceEquals(socket, null))
                {
                    RetryManager manager = socket.RetryManager;
                    manager.ExceptionOccurs -= ExceptionOccurs;
                    manager.Resolved        -= ExceptionResolved;
                }
                connection.Disposing -= ConnectionDisposing;
            }

            WriteLine("Disconnected");
        }