/// <summary>
        /// Ends a connection to the server. It is called after processing is completed with the server to release resources
        /// </summary>
        void IMAExtensible2Password.ClosePasswordConnection()
        {
            OperationBase operation = MAConfig.GlobalOperations.FirstOrDefault(t => t is PasswordEndOperation);

            if (operation != null)
            {
                try
                {
                    SshConnection.ExecuteOperation(operation);
                }
                catch (Exception ex)
                {
                    Logger.WriteLine("Could not perform password end operation");
                    Logger.WriteException(ex);
                    throw new ExtensibleExtensionException("Password end operation failed", ex);
                }
            }

            try
            {
                SshConnection.CloseSshConnection();
            }
            catch (Exception ex)
            {
                Logger.WriteLine("Could not close SSH connection");
                Logger.WriteException(ex);
            }

            Logger.WriteLine("Ending password operation");
            Logger.WriteSeparatorLine('*');
        }
        /// <summary>
        /// Ends an export session
        /// </summary>
        /// <param name="exportRunStep">The results of the export session close</param>
        void IMAExtensible2CallExport.CloseExportConnection(CloseExportConnectionRunStep exportRunStep)
        {
            OperationBase operation = MAConfig.GlobalOperations.FirstOrDefault(t => t is ExportEndOperation);

            if (operation != null)
            {
                try
                {
                    SshConnection.ExecuteOperation(operation);
                }
                catch (Exception ex)
                {
                    Logger.WriteLine("Could not perform export end operation");
                    Logger.WriteException(ex);
                    throw new ExtensibleExtensionException("Export end operation failed", ex);
                }
            }

            try
            {
                SshConnection.CloseSshConnection();
            }
            catch (Exception ex)
            {
                Logger.WriteLine("Could not close SSH connection");
                Logger.WriteException(ex);
            }

            Logger.WriteLine("Export Complete");
            Logger.WriteSeparatorLine('*');
        }
        /// <summary>
        /// Closes the import session
        /// </summary>
        /// <param name="importRunStepInfo">The current run step</param>
        /// <returns>Results of the import session close</returns>
        CloseImportConnectionResults IMAExtensible2CallImport.CloseImportConnection(CloseImportConnectionRunStep importRunStepInfo)
        {
            try
            {
                OperationBase operation;
                if (this.ImportType == OperationType.Delta)
                {
                    operation = MAConfig.GlobalOperations.FirstOrDefault(t => t is ImportDeltaEndOperation);
                }
                else
                {
                    operation = MAConfig.GlobalOperations.FirstOrDefault(t => t is ImportFullEndOperation);
                }

                if (operation != null)
                {
                    try
                    {
                        SshConnection.ExecuteOperation(operation);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteLine("Could not perform import end operation");
                        Logger.WriteException(ex);
                        throw new ExtensibleExtensionException("Import end operation failed", ex);
                    }
                }

                try
                {
                    SshConnection.CloseSshConnection();
                }
                catch (Exception ex)
                {
                    Logger.WriteLine("Could not close SSH connection");
                    Logger.WriteException(ex);
                }

                Logger.WriteLine("Import Complete");
                Logger.WriteSeparatorLine('*');
            }
            catch (ExtensibleExtensionException)
            {
                throw;
            }
            catch (Exception ex)
            {
                Logger.WriteLine("A exception occured during the open export connection operartion");
                Logger.WriteException(ex);
                throw new ExtensibleExtensionException("An exception occured during the open export connection operation", ex);
            }

            return(new CloseImportConnectionResults());
        }
        /// <summary>
        /// Validates the host parameters and ensures a connection can be made to the server
        /// </summary>
        /// <param name="configParameters">The configuration parameters from the user interface</param>
        /// <param name="page">The configuration page</param>
        /// <returns>A ParameterValidationResult containing the validation status</returns>
        public static ParameterValidationResult ValidateHost(KeyedCollection <string, ConfigParameter> configParameters, ConfigParameterPage page)
        {
            ParameterValidationResult myResults = new ParameterValidationResult();

            if (string.IsNullOrWhiteSpace(configParameters[MAParameterNames.HostName].Value))
            {
                myResults.Code           = ParameterValidationResultCode.Failure;
                myResults.ErrorMessage   = "The hostname cannot be blank";
                myResults.ErrorParameter = MAParameterNames.HostName;
                return(myResults);
            }

            int result = 0;

            if (!int.TryParse(configParameters[MAParameterNames.Port].Value, out result))
            {
                myResults.Code           = ParameterValidationResultCode.Failure;
                myResults.ErrorMessage   = "The port number must be an integer";
                myResults.ErrorParameter = MAParameterNames.Port;
                return(myResults);
            }
            else if (result <= 0)
            {
                myResults.Code           = ParameterValidationResultCode.Failure;
                myResults.ErrorMessage   = "The port number must be an integer greater than 0";
                myResults.ErrorParameter = MAParameterNames.Port;
                return(myResults);
            }

            try
            {
                SshConnection.OpenSshConnection(new MAParameters(configParameters));
                SshConnection.CloseSshConnection();
            }
            catch (Exception ex)
            {
                myResults.Code           = ParameterValidationResultCode.Failure;
                myResults.ErrorMessage   = "Could not connect to the target server\n" + ex.Message;
                myResults.ErrorParameter = MAParameterNames.HostName;
                return(myResults);
            }

            myResults.Code = ParameterValidationResultCode.Success;

            return(myResults);
        }