Example #1
0
 public SshConnectionForm(SshSessionDetails sessionDetail, ProgramInfo info)
 {
     InitializeComponent();
     // Load in the object passed to the
     details     = sessionDetail;
     information = info;
 }
Example #2
0
 public VncWindow(SshSessionDetails conn, ProgramInfo info)
 {
     InitializeComponent();
     details     = conn;
     information = info;
 }
Example #3
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            //Decide if the server is SSH or VNC
            if (servers[lstServerList.SelectedIndex].ServerOsId == 3 || servers[lstServerList.SelectedIndex].ServerOsId == 4 || servers[lstServerList.SelectedIndex].ServerOsId == 5 || servers[lstServerList.SelectedIndex].ServerOsId == 6)
            {
                try
                {
                    // Start SSH session
                    GetAccessLevel current = new GetAccessLevel();
                    current.SessionKey = information.Token;
                    current.Id         = servers[lstServerList.SelectedIndex].ServerOsId;

                    string json = "";
                    json = JsonConvert.SerializeObject(current);
                    json = "=" + json;

                    string path = "";
                    path = information.URL + "/api/protectedAccount/get";

                    string           response = ApiConnector.SendToApi(path, json);
                    ProtectedAccount acc      = JsonConvert.DeserializeObject <ProtectedAccount>(response);

                    SshSessionDetails details = new SshSessionDetails
                    {
                        ServerIp = servers[lstServerList.SelectedIndex].ServerIp,
                        Port     = 22,
                        Username = acc.Username,
                        Password = acc.Password
                    };

                    SshConnectionForm sshCon = new SshConnectionForm(details, information);
                    sshCon.ShowDialog();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error connecting to server. Check the server is on.");
                }
            }
            else
            {
                // Start VNC session
                try
                {
                    GetAccessLevel current = new GetAccessLevel();
                    current.SessionKey = information.Token;
                    current.Id         = servers[lstServerList.SelectedIndex].ServerOsId;

                    string json = "";
                    json = JsonConvert.SerializeObject(current);
                    json = "=" + json;

                    string path = "";
                    path = information.URL + "/api/protectedAccount/get";

                    string           response = ApiConnector.SendToApi(path, json);
                    ProtectedAccount acc      = JsonConvert.DeserializeObject <ProtectedAccount>(response);

                    SshSessionDetails details = new SshSessionDetails
                    {
                        ServerIp = servers[lstServerList.SelectedIndex].ServerIp,
                        Port     = 22,
                        Username = acc.Username,
                        Password = acc.Password
                    };

                    VncWindow rdp = new VncWindow(details, information);
                    rdp.ShowDialog();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error connecting to server. Check the server is on.");
                }
            }
        }