comparison ServerMonitor/Objects/Checks/FileCheck.cs @ 9:7127d5b5ac75

Code cleanup and comments
author Brad Greco <brad@bgreco.net>
date Mon, 08 Apr 2019 21:29:54 -0400
parents 3142e52cbe69
children a36cc5c123f4
comparison
equal deleted inserted replaced
8:052aa62cb42a 9:7127d5b5ac75
73 results.Add(Fail("Unable to parse ls output as integer: " + tokens[4])); 73 results.Add(Fail("Unable to parse ls output as integer: " + tokens[4]));
74 } 74 }
75 } 75 }
76 if (CheckDateModified) 76 if (CheckDateModified)
77 { 77 {
78 // TODO use the server time instead
78 string dateString = tokens[5] + " " + tokens[6]; 79 string dateString = tokens[5] + " " + tokens[6];
79 if (DateTime.TryParse(dateString, out DateTime modified)) 80 if (DateTime.TryParse(dateString, out DateTime modified))
80 { 81 {
81 string message = string.Format("Last modified date is {0}", modified); 82 string message = string.Format("Last modified date is {0}", modified);
82 TimeSpan age = DateTime.Now.Subtract(modified); 83 TimeSpan age = DateTime.Now.Subtract(modified);
102 string message = base.Validate(); 103 string message = base.Validate();
103 if (File.IsNullOrEmpty()) 104 if (File.IsNullOrEmpty())
104 message += "File is required." + Environment.NewLine; 105 message += "File is required." + Environment.NewLine;
105 if (!CheckFileSize && !CheckDateModified) 106 if (!CheckFileSize && !CheckDateModified)
106 message += "At least one check must be enabled." + Environment.NewLine; 107 message += "At least one check must be enabled." + Environment.NewLine;
107 if (CheckFileSize && FileSize <= 0) 108 if (CheckFileSize && FileSize < 0)
108 message += "File size must be greater than 0." + Environment.NewLine; 109 message += "File size must be at least 0." + Environment.NewLine;
109 if (CheckDateModified && DateModified <= 0) 110 if (CheckDateModified && DateModified <= 0)
110 message += "Date modified must be greater than 0." + Environment.NewLine; 111 message += "Date modified must be greater than 0." + Environment.NewLine;
111 return message; 112 return message;
112 } 113 }
113 114