Mercurial > servermonitor
comparison ServerMonitor/Objects/CheckResult.cs @ 29:f6235dc0a8ec
Add ability to play a sound on check failure.
author | Brad Greco <brad@bgreco.net> |
---|---|
date | Fri, 14 Jun 2019 21:01:55 -0400 |
parents | 68d7834dc28e |
children |
comparison
equal
deleted
inserted
replaced
28:437442cd8090 | 29:f6235dc0a8ec |
---|---|
42 case CheckStatus.Warning: return Settings.Default.WarningAction; | 42 case CheckStatus.Warning: return Settings.Default.WarningAction; |
43 case CheckStatus.Information: return Settings.Default.InformationAction; | 43 case CheckStatus.Information: return Settings.Default.InformationAction; |
44 // On success (or any other status), do nothing. | 44 // On success (or any other status), do nothing. |
45 default: return FailAction.None; | 45 default: return FailAction.None; |
46 } | 46 } |
47 } | |
48 } | |
49 | |
50 /// <summary>Sound to play when the check fails.</summary> | |
51 /// <remarks> | |
52 /// Returns null if no sound should be played. | |
53 /// Returns string.Empty if the Windows default error sound should be played. | |
54 /// Otherwise, returns the path to the custom sound file that should be played. | |
55 /// </remarks> | |
56 public string FailSound | |
57 { | |
58 get | |
59 { | |
60 string setting = null; | |
61 // Use the global preferences for each status to determine the action to take. | |
62 switch (CheckStatus) | |
63 { | |
64 case CheckStatus.Error: setting = Settings.Default.ErrorSound; break; | |
65 case CheckStatus.Warning: setting = Settings.Default.WarningSound; break; | |
66 case CheckStatus.Information: setting = Settings.Default.InformationSound; break; | |
67 // On success (or any other status), do nothing. | |
68 } | |
69 if (int.TryParse(setting, out int index)) { | |
70 return index == 0 ? null : string.Empty; | |
71 } | |
72 return setting; | |
47 } | 73 } |
48 } | 74 } |
49 | 75 |
50 /// <summary>CheckResult constructor.</summary> | 76 /// <summary>CheckResult constructor.</summary> |
51 /// <param name="check">The originating check of this check result.</param> | 77 /// <param name="check">The originating check of this check result.</param> |