view ServerMonitor/Controls/SshCheckControl.cs @ 0:3e1a2131f897

Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
author Brad Greco <brad@bgreco.net>
date Mon, 31 Dec 2018 18:32:14 -0500
parents
children 9e92780ebc0f
line wrap: on
line source

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ServerMonitorApp
{
    [CheckType(typeof(SshCheck))]
    public partial class SshCheckControl : CheckControl
    {
        public SshCheckControl()
        {
            InitializeComponent();
        }

        public override void LoadCheck(Check check1)
        {
            SshCheck check = (SshCheck)check1;
            CommandTextBox.Text = check.Command;
            ExitCodeCheckBox.Checked = check.CheckExitCode;
            ExitCodeTextBox.Text = check.ExitCode.ToString();
            CommandOutputCheckBox.Checked = check.CheckCommandOutput;
            CommandOutputComboBox.SelectedIndex = (int)check.CommandOutputMatchType;
            CommandOutputTextBox.Text = check.CommandOutputPattern;
            CommandOutputRegexCheckBox.Checked = check.CommandOutputUseRegex;
        }

        public override void UpdateCheck(Check check1)
        {
            SshCheck check = (SshCheck)check1;
            check.Command = CommandTextBox.Text.Trim();
            check.CheckExitCode = ExitCodeCheckBox.Checked;
            check.ExitCode = int.Parse(ExitCodeTextBox.Text);
            check.CheckCommandOutput = CommandOutputCheckBox.Checked;
            check.CommandOutputMatchType = (MatchType)CommandOutputComboBox.SelectedIndex;
            check.CommandOutputPattern = CommandOutputTextBox.Text;
            check.CommandOutputUseRegex = CommandOutputRegexCheckBox.Checked;
        }
    }
}