async void OnPartialResultMessage(string clientId, PartialResultMsg msg)
        {
            using var scope = scopeProvider.CreateScope();
            var db = GetDb(scope);

            using var tx = await db.Database.BeginTransactionAsync();

            var job = await db.Jobs.Where(j => j.Id == msg.JobId).SingleAsync();

            if (!ShouldAddResult(job))
            {
                logger.LogError("Judger {0} tried to add result to a stopped job {1}, error?", clientId, msg.JobId);
                return;
            }

            job.Results.Add(msg.TestId, msg.TestResult);
            await db.SaveChangesAsync();

            await tx.CommitAsync();

            frontendService.OnJobStautsUpdate(msg.JobId, new Models.WebsocketApi.JobStatusUpdateMsg {
                JobId      = msg.JobId,
                Stage      = JobStage.Running,
                TestResult = new Dictionary <string, TestResult>()
                {
                    [msg.TestId] = msg.TestResult
                }
            });
        }
Exemple #2
0
        async void OnPartialResultMessage(string clientId, PartialResultMsg msg)
        {
            using var scope = scopeProvider.CreateScope();
            var db = GetDb(scope);

            var job = await db.Jobs.Where(j => j.Id == msg.JobId).SingleAsync();

            job.Results.Add(msg.TestId, msg.TestResult);
            await db.SaveChangesAsync();
        }
        async void OnPartialResultMessage(string clientId, PartialResultMsg msg)
        {
            using var scope = scopeProvider.CreateScope();
            var db = GetDb(scope);

            var job = await db.Jobs.Where(j => j.Id == msg.JobId).SingleAsync();

            job.Results.Add(msg.TestId, msg.TestResult);
            await db.SaveChangesAsync();

            frontendService.OnJobStautsUpdate(msg.JobId, new Models.WebsocketApi.JobStatusUpdateMsg
            {
                JobId      = msg.JobId,
                Stage      = JobStage.Running,
                TestResult = new Dictionary <string, TestResult>()
                {
                    [msg.TestId] = msg.TestResult
                }
            });
        }