Esempio n. 1
0
 protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
 {
     base.OnNavigatingFrom(e);
     if (CurrentNodeSshClient != null)
     {
         CurrentNodeSshClient.Disconnect();
     }
 }
Esempio n. 2
0
        private void ExecutingButton_Click(object sender, RoutedEventArgs e)
        {
            if (FileComboBox.SelectedItem is string filePath)
            {
                FileComboBox.IsEnabled     = false;
                FileTypeComboBox.IsEnabled = false;
                ExecutingButton.IsEnabled  = false;

                Task.Run(async() => {
                    try
                    {
                        var cmd    = CurrentNodeSshClient.CreateCommand(CurrentNode.HadoopHomeDirectory + filePath);
                        var result = cmd.BeginExecute();
                        using (var stdOutReader = new StreamReader(cmd.OutputStream))
                            using (var stdErrReader = new StreamReader(cmd.ExtendedOutputStream))
                            {
                                while (!result.IsCompleted || !stdOutReader.EndOfStream || !stdErrReader.EndOfStream)
                                {
                                    string outLine = stdOutReader.ReadLine();
                                    if (outLine != null)
                                    {
                                        await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                                        {
                                            ContentTextBox.Text += outLine + "\n";
                                        });
                                    }
                                    string errLine = stdErrReader.ReadLine();
                                    if (errLine != null)
                                    {
                                        await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                                        {
                                            ContentTextBox.Text += errLine + "\n";
                                        });
                                    }
                                }
                            }
                    }
                    catch (Exception ex)
                    {
                        if (AppShell.Current != null)
                        {
                            AppShell.Current.NotifyMessage($"Error occoured when excuting commands:\n{ex.Message}");
                        }
                    }


                    await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        FileComboBox.IsEnabled     = true;
                        FileTypeComboBox.IsEnabled = true;
                        ExecutingButton.IsEnabled  = true;
                    });
                });
            }
        }
Esempio n. 3
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     CurrentNode          = e.Parameter as HDFSNode;
     CurrentNodeSshClient = NetworkManager.CreateSSHClient(
         CurrentNode.Host,
         CurrentNode.User,
         CurrentNode.Pswd,
         CurrentNode.PrivateKey);
     CurrentNodeSshClient.Connect();
 }