Esempio n. 1
0
        public virtual T Run()
        {
            if (!Client.IsConnected())
            {
                Logger.Instance.Info($"Client not connected, Connect.");
                Client.Connect();
            }
            Sshcmd = Client.Client.CreateCommand(CmdString);


            string str;

            using (Sshcmd)
            {
                Logger.Instance.Info($"Running command : {CmdString}.");
                str = Sshcmd.Execute();
                Logger.Instance.Info($"Return Value from command : {str}.");
            }

            var result = PaseResult(str);
            //TODO Doods : QueryResult
            var objres = new QueryResult <T>()
            {
                Query      = CmdString,
                BashLines  = str,
                Result     = result,
                ExitStatus = Sshcmd.ExitStatus,
                Error      = Sshcmd.Error
            };

            return(result);
        }
Esempio n. 2
0
        public virtual T Run()
        {
            if (!Client.IsConnected())
            {
                Client.Logger.Info("Client not connected, Connect.");
                Client.Connect();
            }

            Sshcmd = Client.Client.CreateCommand(CmdString);


            using (Sshcmd)
            {
                Client.Logger.Info($"Running command : {CmdString}.");
                _resultStr = Sshcmd.Execute();


                if (!string.IsNullOrEmpty(Sshcmd.Error))
                {
                    Client.Logger.Info($"Running command ({CmdString}) Error : {Sshcmd.Error}.");
                }

                Client.Logger.Info($"Return Value from command : {_resultStr}.");
                _state = QueryState.CommandSent;
            }

            var result = PaseResult(_resultStr);

            _state = QueryState.ResultParsed;
            //TODO Doods : QueryResult
            var queryResult = ToQueryResult(result);

            return(result);
        }
Esempio n. 3
0
 public virtual void RunInShell(EventHandler <ShellDataEventArgs> ondataReseved)
 {
     if (!Client.IsConnected())
     {
         Logger.Instance.Info("Client not connected, Connect. for run in shell");
         Client.Connect();
     }
     shell = Client.CreateShell();
     shell.DataReceived += ondataReseved;
     shell.WriteLine(CmdString);
 }