Ejemplo n.º 1
0
        /// <summary>
        /// Defines a SSH transaction
        /// </summary>
        /// <param name="_cred">The SSH transaction credentials</param>
        /// <param name="task">The Transaction task</param>
        /// <param name="remotePath">Changes how the remote path is transformed before
        /// it is passed to the scp command on the remote server.
        /// DoubleQuote, ShellQuote, None</param>
        /// <returns>The transaction result</returns>
        public static Object SSHTransaction(SiteCredentials _cred, Func <AuraSftpClient, Object> task, IRemotePathTransformation remotePath = null)
        {
            Object result = null;

            using (var client = new AuraSftpClient(_cred))
            {
                try
                {
                    if (remotePath == null)
                    {
                        client.RemotePathTransformation = ShellQuote;
                    }
                    else
                    {
                        client.RemotePathTransformation = remotePath;
                    }
                    client.Connect();
                    result = task(client);
                    client.Disconnect();
                }
                catch (System.Exception exc)
                {
                    Console.WriteLine(exc.Message);
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Defines a SSH transaction
 /// </summary>
 /// <param name="_cred">The SSH transaction credentials</param>
 /// <param name="task">The Transaction task</param>
 /// <param name="remotePath">Changes how the remote path is transformed before
 /// it is passed to the scp command on the remote server.
 /// DoubleQuote, ShellQuote, None</param>
 public static void SSHTransactionVoid(SiteCredentials _cred, Action <AuraSftpClient> task, IRemotePathTransformation remotePath = null)
 {
     using (var client = new AuraSftpClient(_cred))
     {
         try
         {
             if (remotePath == null)
             {
                 client.RemotePathTransformation = ShellQuote;
             }
             else
             {
                 client.RemotePathTransformation = remotePath;
             }
             client.Connect();
             task(client);
             client.Disconnect();
         }
         catch (System.Exception exc)
         {
             Console.WriteLine(exc.Message);
         }
     }
 }