Ejemplo n.º 1
0
 private void RunTimer_Tick(object sender, EventArgs e)
 {
     RunTimer.Stop();
     loaded++;
     UpdateStats();
     LoadFile(FileToolStripStatusLabel.Text);
 }
Ejemplo n.º 2
0
 public void OnCompleted()
 {
     this.Invoke(new Action(() =>
     {
         RunTimer.Stop();
         MessageBox.Show($"Task completed in {Math.Round(TestSec / 60d, 2)}", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
         btn_Upload.Enabled        = true;
         toolStripStatusLabel.Text = "Done";
     }));
 }
Ejemplo n.º 3
0
 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();
     }
 }
Ejemplo n.º 4
0
 private void btnAutoRun_Click(object sender, EventArgs e)
 {
     if (RunTimer.Enabled)
     {
         RunTimer.Stop();
         btnAutoRun.Text = "Run Auto";
     }
     else
     {
         RunTimer.Start();
         btnAutoRun.Text = "Stop Auto";
     }
 }
Ejemplo n.º 5
0
 private void RunTimer_Tick(object sender, EventArgs e)
 {
     // this timer keeps the mount in position while it is waiting for the satellite to pass
     if (nextAos < DateTime.Now.Add(new TimeSpan(offsetHours, offsetMins, 1)) && nextAos > DateTime.Now.Add(new TimeSpan(offsetHours, offsetMins, -1))) // need to include a tolerence
     {
         sdx = 0;
         ImageTimer.Start();
         RunTimer.Stop();
     }
     else if (nextAos < DateTime.Now.Add(new TimeSpan(offsetHours, offsetMins, 0)))
     {
         RunTimer.Stop();
         lbTargetLocked.Text = "Missed image";
         trackSatellites();
     }
     else
     {
         lbTargetLocked.Text = "Awaiting frame";
         lbTime.Text         = DateTime.Now.Add(new TimeSpan(offsetHours, offsetMins, 0)).ToString();
     }
 }
Ejemplo n.º 6
0
        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);
        }