コード例 #1
0
ファイル: LiveHub.cs プロジェクト: code-critic/cc.net
        private async Task SubmitSolution(string userIdOrGroupId, string courseName, string courseYear, string problemId, string langId, IList <SimpleFileDto> files, string type)
        {
            var ccData = default(CcData);

            if (type == "user")
            {
                ccData = await _submitSolutionService
                         .CreateItemSolveStudent(userIdOrGroupId, courseName, courseYear, problemId, langId, files);
            }
            else
            {
                ccData = await _submitSolutionService
                         .CreateItemSolveGroup(userIdOrGroupId, courseName, courseYear, problemId, langId, files);
            }

            var attemptId = ccData.Id;
            var attemptNo = ccData.Attempt;

            _idService.RemeberClient(Clients.Caller, attemptId);
            await Clients.Clients(_idService[ccData.UserOrGroupUsers]).ServerMessageToClient("info", $"Attempt {attemptNo} inserted into queue");

            _dbService.Data.Add(ccData);

            var itemsCount = await _dbService.Data.CountDocumentsAsync(i => i.Result.Status == ProcessStatus.InQueue.Value);

            await Clients.All.QueueStatus(new string[itemsCount]);
        }
コード例 #2
0
        public async Task <IActionResult> RerunSolution(string objectId)
        {
            var data = await _dbService.Data.SingleAsync(new ObjectId(objectId));

            var newData = data.GroupId != ObjectId.Empty
                ? await _submitSolutionService
                          .CreateItemSolveGroup(data.GroupId.ToString(),
                                                data.CourseName, data.CourseYear, data.Problem, data.Language,
                                                new List <SimpleFileDto> {
            })
                : await _submitSolutionService
                          .CreateItemSolveStudent(data.User,
                                                  data.CourseName, data.CourseYear, data.Problem, data.Language,
                                                  new List <SimpleFileDto> {
            });

            var newSolutions = data.Solutions
                               .Select(i => newData.Solutions.FirstOrDefault(j => j.Filename == i.Filename) ?? i)
                               .ToList();

            newData.Solutions     = newSolutions;
            newData.Id            = data.Id;
            newData.ReviewRequest = data.ReviewRequest;
            newData.Points        = data.Points;
            newData.GradeComment  = data.GradeComment;
            newData.Comments      = data.Comments;
            await _dbService.Data.UpdateDocumentAsync(newData);

            return(Ok());
        }