private void CodeFileSystemWatcher_Changed(object sender, FileSystemEventArgs e) { changed++; UpdateStats(); if (e.ChangeType == WatcherChangeTypes.Changed) { // Stop current timer. RunTimer.Stop(); // Restart it again. RunTimer.Start(); } }
private void btnAutoRun_Click(object sender, EventArgs e) { if (RunTimer.Enabled) { RunTimer.Stop(); btnAutoRun.Text = "Run Auto"; } else { RunTimer.Start(); btnAutoRun.Text = "Stop Auto"; } }
public ValidationResponse Validate(Connection testConnection, Test test) { if (test == null) { return(null); } _scriptResolver = new ScriptResolverFactory(test).GetScriptResolver(); if (_scriptResolver == null) { return(null); } var scriptValue = _scriptResolver.GetSqlScript(); var runLog = new StringBuilder(); var resultMessage = new StringBuilder(); var valResponse = new ValidationResponse { RunDateTime = DateTime.Now, TestId = test.Id, TestName = test.Name, TestValue = test.TestValue }; RunTimer.Reset(); RunTimer.Start(); try { using (var dbConnection = (DbConnection)DbConnectionFactory.GetConnection(testConnection)) { using ( var reader = _sqlScriptRunner.RunScript(dbConnection, scriptValue)) { while (reader.Read()) { foreach (var expResult in test.ExpectedResults.Clone()) { if (reader[expResult.ResultIndex].IsNullOrDbNull()) { continue; } var actual = reader[expResult.ResultIndex].ToString(); runLog.AppendFormat("Comparing results: Expected = {0} \n Response = {1} \n", expResult.ExpectedValue, actual); var comparerFactory = new ComparerFactory(); var comparer = comparerFactory.GetComparer(expResult.AssertType.Name); valResponse.IsValid = comparer.Compare(expResult.ExpectedValue, actual); if (valResponse.IsValid) { resultMessage.Append("Is Valid!"); continue; } resultMessage.AppendFormat("expected: {0} \n but was: {1}", expResult.ExpectedValue, actual); break; } } } } } catch (Exception exception) { runLog.AppendFormat("Exception caught: {0}", exception.Message); valResponse.IsValid = false; resultMessage.AppendFormat("Error occurred while trying to run validation {0}. \n \n {1} : {2}", scriptValue, exception.Message, exception.StackTrace); } finally { RunTimer.Stop(); valResponse.Duration = (decimal)RunTimer.Elapsed.TotalMilliseconds; valResponse.RunLog = runLog.ToString(); valResponse.ResultMessage = resultMessage.ToString(); } return(valResponse); }
private void trackSatellites() { // main function // does not loop, is run each time a satellite is tracked, or the second photograph is taken // this is to allow the timers to run, as well as to easily allow missed passes lbTime.Text = DateTime.Now.Add(new TimeSpan(offsetHours, offsetMins, 0)).ToString(); objTelescope.Tracking = true; if (idx < nTargets) { if (imagesCaptured == 0) { try { findNextTarget(); lbTargetLocked.Text = "Slewing"; double offsetRa; // this if statement accounts for the overflow of offsetting RA, which cycles through 0 to 24 to 0 if (nextRa > offsetHours + 1.0 / 60.0 * offsetMins) { // RA is offset in the opposite direction to time, as we simulate seeing events occuring later, but want to ensure // that they are above the horizon offsetRa = nextRa - offsetHours - 1.0 / 60.0 * offsetMins; } else { offsetRa = 24 - (offsetHours + 1.0 / 60.0 * offsetMins - nextRa); } try { objTelescope.SlewToCoordinates(offsetRa, nextDec); RunTimer.Start(); imagesCaptured = 1; } catch { } } catch { lbWarningText.Text = "All satellite passes have finished"; } } else if (imagesCaptured == 1) { goToNextImage(); lbTargetLocked.Text = "Slewing"; double offsetRa; if (nextRa > offsetHours + 1.0 / 60.0 * offsetMins) { offsetRa = nextRa - offsetHours - 1.0 / 60.0 * offsetMins; } else { offsetRa = 24 - (offsetHours + 1.0 / 60.0 * offsetMins - nextRa); } try { objTelescope.SlewToCoordinates(offsetRa, nextDec); RunTimer.Start(); imagesCaptured = 0; } catch { } } } }
private void btn_Start_Click(object sender, EventArgs e) { Start(); RunTimer.Start(); }