Mercurial > servermonitor
annotate ServerMonitor/Controls/HttpCheckControl.cs @ 10:9e77c0dccb66
Add update checker
author | Brad Greco <brad@bgreco.net> |
---|---|
date | Mon, 08 Apr 2019 21:31:03 -0400 |
parents | 7127d5b5ac75 |
children | b713b9db4c82 |
rev | line source |
---|---|
9 | 1 namespace ServerMonitorApp |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
2 { |
9 | 3 /// <summary>Control for editing an HTTP check.</summary> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
4 [CheckType(typeof(HttpCheck))] |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
5 public partial class HttpCheckControl : CheckControl |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
6 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
7 public HttpCheckControl() |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
8 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
9 InitializeComponent(); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
10 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
11 |
9 | 12 /// <summary>Sets the values of the controls from a check's properties.</summary> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
13 public override void LoadCheck(Check check1) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
14 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
15 HttpCheck check = (HttpCheck)check1; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
16 UrlTextBox.Text = check.Url; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
17 ResponseCodeCheckBox.Checked = check.CheckResponseCode; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
18 ResponseCodeTextBox.Text = check.ResponseCode.ToString(); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
19 ResponseLengthCheckbox.Checked = check.CheckResponseLength; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
20 ResponseLengthMinTextBox.Text = check.ResponseLengthMin; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
21 ResponseLengthMaxTextBox.Text = check.ResponseLengthMax; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
22 ResponseBodyCheckBox.Checked = check.CheckResponseBody; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
23 ResponseBodyComboBox.SelectedIndex = (int)check.ResponseBodyMatchType; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
24 ResponseBodyTextBox.Text = check.ResponseBodyPattern; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
25 ResponseBodyRegexCheckBox.Checked = check.ResponseBodyUseRegex; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
26 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
27 |
9 | 28 /// <summary>Updates the properties of a check from user input.</summary> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
29 public override void UpdateCheck(Check check1) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
30 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
31 HttpCheck check = (HttpCheck)check1; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
32 check.Url = UrlTextBox.Text.Trim(); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
33 check.CheckResponseCode = ResponseCodeCheckBox.Checked; |
1
9e92780ebc0f
Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents:
0
diff
changeset
|
34 try |
9e92780ebc0f
Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents:
0
diff
changeset
|
35 { |
9e92780ebc0f
Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents:
0
diff
changeset
|
36 check.ResponseCode = int.Parse(ResponseCodeTextBox.Text); |
9e92780ebc0f
Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents:
0
diff
changeset
|
37 } |
9e92780ebc0f
Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents:
0
diff
changeset
|
38 catch |
9e92780ebc0f
Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents:
0
diff
changeset
|
39 { |
9e92780ebc0f
Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents:
0
diff
changeset
|
40 throw new UpdateCheckException("Response code must be an integer."); |
9e92780ebc0f
Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents:
0
diff
changeset
|
41 } |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
42 check.CheckResponseLength = ResponseLengthCheckbox.Checked; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
43 check.ResponseLengthMin = ResponseLengthMinTextBox.Text; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
44 check.ResponseLengthMax = ResponseLengthMaxTextBox.Text; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
45 check.CheckResponseBody = ResponseBodyCheckBox.Checked; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
46 check.ResponseBodyMatchType = (MatchType)ResponseBodyComboBox.SelectedIndex; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
47 check.ResponseBodyPattern = ResponseBodyTextBox.Text; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
48 check.ResponseBodyUseRegex = ResponseBodyRegexCheckBox.Checked; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
49 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
50 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
51 } |