예제 #1
0
        public void DeleteSolutionTestResult(SolutionTestResult SolutionTestResult)
        {
            context.Entry(SolutionTestResult).State = EntityState.Deleted;

            context.SaveChanges();

            return;
        }
예제 #2
0
        protected void solutionChecked(byte[] data, IRepository repository)
        {
            ClientFreeThreadsCount++;
            SolutionChecked.Set();

            int solutionID = BitConverter.ToInt32(data, 8);

            _logger.Info("Begin saving solution checked info from " + Address + ", for solution " + solutionID);

            Solution solution = repository.Solutions.FirstOrDefault(s => s.SolutionID == solutionID);

            ProblemTypes pt = (ProblemTypes)BitConverter.ToInt32(data, 12);
            TestResults result = (TestResults)BitConverter.ToInt32(data, 16);
            int score = BitConverter.ToInt32(data, 20);
            int testsCount = BitConverter.ToInt32(data, 24);

            _logger.Debug("Received " + testsCount + " tests results");

            solution.Result = result;
            solution.Score = score;

            if (pt == ProblemTypes.Standart)
            {
                int errorOnTest = 0;
                SolutionTestResult str;
                for (int i = 0; i < testsCount; i++)
                {
                    str = new SolutionTestResult()
                    {
                        SolutionID = solutionID,
                        Time = BitConverter.ToInt64(data, 28 + 20 * i),
                        Memory = BitConverter.ToInt64(data, 36 + 20 * i),
                        Result = (TestResults)BitConverter.ToInt32(data, 44 + 20 * i)
                    };

                    if (str.Result != TestResults.OK && errorOnTest == 0)
                        errorOnTest = i + 1;

                    repository.AddSolutionTestResult(str);
                }

                solution.ErrorOnTest = errorOnTest;
            }

            if (solution.Result == TestResults.OK)
            {
                solution.User.NotSolvedProblems.Remove(solution.Problem);
                solution.User.SolvedProblems.Add(solution.Problem);
            }
            else
            {
                if (!solution.User.SolvedProblems.Contains(solution.Problem))
                {
                    solution.User.NotSolvedProblems.Add(solution.Problem);
                }
            }
            repository.SaveSolution(solution);

            _logger.Info("Solution checked info from " + Address + ", for solution " + solutionID + " saved");
            _logger.Info("Solution " + solutionID + " checked: Result " + result + ", Score " + score);
        }
예제 #3
0
        public int AddSolutionTestResult(SolutionTestResult SolutionTestResult)
        {
            if (SolutionTestResult.SolutionTestResultID == 0)
            {
                SolutionTestResult = context.SolutionTestResults.Add(SolutionTestResult);
            }
            else
            {
                context.Entry(SolutionTestResult).State = EntityState.Modified;
            }
            context.SaveChanges();
            context.Entry(SolutionTestResult).Reload();

            return SolutionTestResult.SolutionTestResultID;
        }