コード例 #1
0
        public void DeleteSolutionTestResult(SolutionTestResult SolutionTestResult)
        {
            context.Entry(SolutionTestResult).State = EntityState.Deleted;

            context.SaveChanges();

            return;
        }
コード例 #2
0
        public void DeleteSolutionTestResult(int SolutionTestResultID)
        {
            SolutionTestResult solutionTestResult = context.SolutionTestResults.FirstOrDefault(str => str.SolutionTestResultID == SolutionTestResultID);

            if (solutionTestResult != null)
            {
                DeleteSolutionTestResult(solutionTestResult);
            }

            return;
        }
コード例 #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);
        }
コード例 #4
0
ファイル: SocketClient.cs プロジェクト: JosefDzeranov/Solomon
        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);
        }