Exemplo n.º 1
0
        /// <summary>
        /// Release sftp connection to pool
        /// </summary>
        /// <param name="conn"></param>
        public void ReleaseConnection(ISftp conn)
        {
            if (conn != null)
            {
                if (ConnectionLimit == 0)
                {
                    TraceMessage("[SftpConnectionPool] Disposing connection object (no connection pool is used)");
                    conn.Disconnect();
                    conn.Dispose();
                    return;
                }

                if (_currentCount > ConnectionLimit)
                {
                    TraceMessage("[SftpConnectionPool] ReleaseConnectionToPool disposing connection object");
                    conn.Disconnect();
                    conn.Dispose();
                    _currentCount--;
                }
                else
                {
                    TraceMessage("[SftpConnectionPool] ReleaseConnectionToPool releasing connection to pool");
                    //conn.Disconnect();
                    Connections.Push(conn);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Release sftp connection to pool
        /// </summary>
        /// <param name="conn"></param>
        public void ReleaseConnection(ISftp conn)
        {
            if (conn != null)
            {
                if (this.ConnectionLimit == 0)
                {
                    TraceMessage("[SftpConnectionPool] Disposing connection object (no connection pool is used)");
                    conn.Disconnect();
                    conn.Dispose();
                    return;
                }

                lock (this.Connections)
                {
                    if (this._currentCount > this.ConnectionLimit)
                    {
                        TraceMessage("[SftpConnectionPool] ReleaseConnectionToPool disposing connection object");
                        conn.Disconnect();
                        conn.Dispose();
                        this._currentCount--;
                    }
                    else
                    {
                        TraceMessage("[SftpConnectionPool] ReleaseConnectionToPool releasing connection to pool");
                        //conn.Disconnect();
                        this.Connections.Insert(0, conn);
                        Monitor.Pulse(this.Connections);
                    }
                }
            }
        }
Exemplo n.º 3
0
 private void batchHandler_BatchComplete(ISftp sftp)
 {
     try
     {
         sftp.Disconnect();
         sftp.Dispose();
         //SftpConnectionPool.GetHostByName(this._properties.SSHHost).ReleaseConnection(sftp);
     }
     catch
     {
         throw ExceptionHandling.HandleComponentException(MethodBase.GetCurrentMethod(),
                                                          new Exception("Unable to release Sftp connection"));
     }
 }