Ejemplo n.º 1
0
 private void SharedTestTimerOnElapsed(object sender, ElapsedEventArgs e)
 {
     if (IsTestRunning)
     {
         if (IsTestCanceled)
         {
             IsTestRunning  = false;
             IsTestCanceled = true;
             TestComplete.Invoke(TestSysResult.Canceled);
         }
         else if (e.SignalTime - BeginTime > _testTimeout)
         {
             // timeout
             IsTestRunning = false;
             ProgressChanged.Invoke(100, TestSysStepResult.Bad, "МУК не включает Emerson");
             TestComplete.Invoke(TestSysResult.Fail);
         }
         else
         {
             if (LastReceivedData.Diagnostic3Parsed.MukIsSwitchingEmersionOn)
             {
                 IsTestRunning    = false;
                 LastReceivedData = null;
                 ProgressChanged.Invoke(100, TestSysStepResult.Good, "Включение Emerson осуществлено");
                 TestComplete.Invoke(TestSysResult.Success);
             }
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Starts the stopwatch and execute the function.
        /// </summary>
        private void RunTest()
        {
            _executionTimer = Stopwatch.StartNew();
            _testFunction.Invoke();
            _executionTimer.Stop();

            TestComplete?.Invoke(_executionTimer.Elapsed);
        }
        public BTestComplete(TestComplete testComplete)
        {
            var           config           = new MapperConfiguration(cfg => cfg.CreateMap <TestComplete, BTestComplete>());
            Mapper        mapper           = new Mapper(config);
            BTestComplete tmpBTestComplete = mapper.Map <BTestComplete>(testComplete);

            this.TestId      = tmpBTestComplete.TestId;
            this.StudentId   = tmpBTestComplete.StudentId;
            this.Status      = tmpBTestComplete.Status;
            this.ApproveDate = tmpBTestComplete.ApproveDate;
            this.Score       = tmpBTestComplete.Score;
        }
Ejemplo n.º 4
0
        public void Test(byte[,] input, byte[] input_tests)
        {
            List <double[]> features = new List <double[]>();

            for (int i = 0; i < input.GetLength(0); i++)
            {
                double[] f = new double[input.GetLength(1)];
                for (int j = 0; j < input.GetLength(1); j++)
                {
                    f[j] = NormalizePixelValues(input[i, j]);
                }
                features.Add(f);
            }

            int count = 0, correct = 0;

            for (int i = 0; i < input.GetLength(0); i++)
            {
                var res = nnet.FeedForward(features[i]);
                count++;
                double maxConfidence = 0;
                int    digit         = 0;
                for (int j = 0; j < res.Length; j++)
                {
                    if (res[j] > maxConfidence)
                    {
                        maxConfidence = res[j];
                        digit         = j;
                    }
                }
                if (digit == input_tests[i])
                {
                    correct++;
                }

                TestProgressChanged?.Invoke(this, new TestProgressChangedEventArgs(count, correct));

                //Debug.WriteLine("Predicted: " + digit + " Real: " + input_tests[i] + " Acc.: " + ((double)correct / count * 100).ToString("#.##") + "% Total: " + count + " Correct: " + correct);
            }

            TestComplete?.Invoke(this, new TestProgressChangedEventArgs(count, correct));
        }
        public void Execute(ServiceContext context, IEnumerable <Rule> rules, int rulecount, TestComplete ruleresult)
        {
            bool errorOccurred = false;

            if (context == null)
            {
                this.resultProvider.JobCompleted(true);
                var e = new RuntimeException(new ArgumentNullException("context"), Resource.NullServiceContext);
                this.LogRuntimeError(e);
                return;
            }

            if (rules == null)
            {
                throw new ArgumentNullException("rules");
            }

            int count = 0;

            try
            {
                foreach (var rule in rules)
                {
                    count++;
                    TestResult result;
                    try
                    {
                        result = RuleExecuter.ExecuteRule(context, rule);
                    }
                    catch (RuntimeException e)
                    {
                        errorOccurred = true;
                        result        = TestResult.CreateAbortedResult(rule, context.JobId);

                        e.JobId               = context.JobId;
                        e.RuleName            = rule.Name;
                        e.DestinationEndpoint = context.Destination.AbsolutePath;
                        this.LogRuntimeError(e);
                    }
                    catch (Exception ex)
                    {
                        if (!ExceptionHelper.IsCatchableExceptionType(ex))
                        {
                            throw;
                        }

                        errorOccurred = true;
                        result        = TestResult.CreateAbortedResult(rule, context.JobId);

                        var e = new RuntimeException(ex, null);
                        e.JobId               = context.JobId;
                        e.RuleName            = rule.Name;
                        e.DestinationEndpoint = context.Destination.AbsolutePath;
                        this.LogRuntimeError(e);
                    }
                    if (ruleresult != null)
                    {
                        ruleresult(result, rulecount, ref count);
                    }
                    this.resultProvider.Accept(result);
                }

                //this.resultProvider.JobCompleted(errorOccurred);
            }
            catch (Exception ex)
            {
                if (!ExceptionHelper.IsCatchableExceptionType(ex))
                {
                    throw;
                }

                this.resultProvider.JobCompleted(true);
            }
        }
Ejemplo n.º 6
0
        public void WriteTestResult(List <AnswersUser> tRes)
        {
            List <AnswersStudent> answers = new List <AnswersStudent>();
            List <TestComplete>   tCompl  = new List <TestComplete>();

            foreach (var i in tRes)
            {
                AnswersStudent atmp = new AnswersStudent()
                {
                    QID    = i.QID,
                    SID    = i.SID,
                    TID    = i.TID,
                    Answer = i.Answer ?? "",
                    ID     = 0
                };
                TestComplete ttmp = new TestComplete()
                {
                    ID     = 0,
                    SID    = i.SID,
                    TID    = i.TID,
                    Access = 0                           // чтобы ученик не смог увидеть результат сразу
                };

                answers.Add(atmp);

                if (tCompl.Where(x => ttmp.SID == x.SID && ttmp.TID == x.TID).Count() == 0)
                {
                    tCompl.Add(ttmp);
                }
            }

            using (var dbs = db.OpenSession()) {
                var answers_exist = dbs.CreateCriteria <AnswersStudent>().List <AnswersStudent>();
                var complit_exist = dbs.CreateCriteria <TestComplete>  ().List <TestComplete>();

                foreach (var i in answers)
                {
                    var tmp = answers_exist.Where(x => x.QID == i.QID && x.SID == i.SID && x.TID == i.TID).FirstOrDefault();

                    if (tmp != default)
                    {
                        i.ID = tmp.ID;
                    }
                }
                foreach (var i in tCompl)
                {
                    var tmp = complit_exist.Where(x => x.SID == i.SID && x.TID == i.TID).FirstOrDefault();

                    if (tmp != default)
                    {
                        i.ID = tmp.ID;
                    }
                }

                // запись в бд
                using (var tr = dbs.BeginTransaction()) {
                    answers.ForEach((x) => {
                        if (x.ID != 0)
                        {
                            dbs.Update(x);
                        }
                        else
                        {
                            dbs.Save(x);
                        }
                    });

                    tCompl.ForEach((x) => {
                        if (x.ID != 0)
                        {
                            dbs.Update(x);
                        }
                        else
                        {
                            dbs.Save(x);
                        }
                    });

                    tr.Commit();
                }
            }
        }
        public void Execute(ServiceContext context, IEnumerable <Rule> rules, int rulecount, TestComplete ruleresult)
        {
            if (context == null)
            {
                this.resultProvider.JobCompleted(true);
                var e = new RuntimeException(new ArgumentNullException("context"), Resource.NullServiceContext);
                this.LogRuntimeError(e);
                return;
            }

            if (rules == null)
            {
                throw new ArgumentNullException("rules");
            }

            int count = 0;

            try
            {
                foreach (var rule in rules)
                {
                    count++;
                    TestResult result;
                    try
                    {
                        result = RuleExecuter.ExecuteRule(context, rule);
                    }
                    catch (RuntimeException e)
                    {
                        result = TestResult.CreateAbortedResult(rule, context.JobId);

                        e.JobId               = context.JobId;
                        e.RuleName            = rule.Name;
                        e.DestinationEndpoint = context.Destination.AbsolutePath;
                        this.LogRuntimeError(e);
                    }
                    catch (Exception ex)
                    {
                        if (!ExceptionHelper.IsCatchableExceptionType(ex))
                        {
                            throw;
                        }


                        result = TestResult.CreateAbortedResult(rule, context.JobId);

                        if (result.Details == null)
                        {
                            result.Details = new List <ExtensionRuleResultDetail>();
                        }
                        ExtensionRuleResultDetail detail = new ExtensionRuleResultDetail(result.RuleName, string.Empty, HttpMethod.Get, "Exception:  " + ex.Message);
                        result.Details.Add(detail);
                        detail = new ExtensionRuleResultDetail(result.RuleName, string.Empty, HttpMethod.Get, "StackTrace:  " + ex.StackTrace);
                        result.Details.Add(detail);



                        var e = new RuntimeException(ex, null);
                        e.JobId               = context.JobId;
                        e.RuleName            = rule.Name;
                        e.DestinationEndpoint = context.Destination.AbsolutePath;

                        this.LogRuntimeError(e);
                        bool tryagain = false;
                        if (tryagain)
                        {
                            result = RuleExecuter.ExecuteRule(context, rule);
                        }
                    }
                    if (ruleresult != null)
                    {
                        ruleresult(result, rulecount, ref count);
                    }
                    this.resultProvider.Accept(result);
                }

                //this.resultProvider.JobCompleted(errorOccurred);
            }
            catch (Exception ex)
            {
                if (!ExceptionHelper.IsCatchableExceptionType(ex))
                {
                    throw;
                }

                this.resultProvider.JobCompleted(true);
            }
        }
Ejemplo n.º 8
0
 protected void OnTestComplete()
 {
     TestComplete?.Invoke(this);
 }
 public GoogleTestOutputParser(TestComplete a, LineRead b)
 {
     notifyTestComplete = a;
     notifyLineRead = b;
 }
Ejemplo n.º 10
0
 public GoogleTestOutputParser(TestComplete a, LineRead b)
 {
     notifyTestComplete = a;
     notifyLineRead     = b;
 }