Ejemplo n.º 1
0
        public bool TrpJudge(string uid, int depId, int teamId)
        {
            ExamGroup eg = null;

            if (depId != -1 || teamId != -1)
            {
                eg = Gateway.Default.From <ExamGroup>().Where(ExamGroup._.Exam_UID == uid).ToFirst <ExamGroup>();
            }
            return(eg == null ? false : true);
        }
        public ActionResult AddUsersToExamGroup(UsersExamGroupModel model)
        {
            if (!this.IsUsersExamGroupModelValid(model))
            {
                return(this.Json(false));
            }

            var externalExamGroup = model.ExamGroupInfoModel;

            var examGroupExists = true;
            var examGroup       = this.examGroupsData.GetByExternalIdAndAppId(externalExamGroup.Id, model.AppId);

            if (examGroup == null)
            {
                examGroupExists = false;

                examGroup = new ExamGroup
                {
                    ExternalExamGroupId = externalExamGroup.Id,
                    ExternalAppId       = model.AppId
                };
            }

            var contestIsValid = externalExamGroup.JudgeSystemContestId.HasValue &&
                                 this.contestsData
                                 .GetByIdQuery(externalExamGroup.JudgeSystemContestId.Value)
                                 .Any(c => c.Type == ContestType.OnlinePracticalExam);

            var startTime = externalExamGroup.StartTime?.ToString("g") ?? string.Empty;

            examGroup.Name      = $"{externalExamGroup.ExamName} => {externalExamGroup.ExamGroupTrainingLabName} | {startTime}";
            examGroup.ContestId = contestIsValid ? externalExamGroup.JudgeSystemContestId : null;

            if (examGroupExists)
            {
                this.examGroupsData.Update(examGroup);
            }
            else
            {
                this.examGroupsData.Add(examGroup);
            }

            var examGroupId = this.examGroupsData
                              .GetIdByExternalIdAndAppId(externalExamGroup.Id, model.AppId);

            if (examGroupId != default(int))
            {
                this.backgroundJobs.AddFireAndForgetJob <IExamGroupsBusinessService>(
                    x => x.AddUsersByIdAndUserIds(examGroupId, model.UserIds));
            }

            return(this.Json(true));
        }
        private void AddUsersToExamGroup(ExamGroup examGroup, IQueryable <UserProfile> users)
        {
            var usersToAdd = users
                             .Where(u => u.ExamGroups.All(eg => eg.Id != examGroup.Id))
                             .ToList();

            foreach (var user in usersToAdd)
            {
                if (user.IsDeleted)
                {
                    user.IsDeleted = false;
                }

                examGroup.Users.Add(user);
            }

            this.examGroupsData.Update(examGroup);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取参加考试的班组
        /// </summary>
        /// <returns></returns>
        private List <Song.Entities.ExamGroup> getGroupForSts()
        {
            List <Song.Entities.ExamGroup> groups = new List <ExamGroup>();

            foreach (string str in tbSortSelected.Text.Split(','))
            {
                if (str == string.Empty)
                {
                    continue;
                }
                int    teamid   = Convert.ToInt32(str.Substring(0, str.IndexOf("|")));
                string teamname = str.Substring(str.IndexOf("|") + 1);
                //
                Song.Entities.ExamGroup g = new ExamGroup();
                g.Exam_UID = getUID();
                g.Eg_Type  = 2;
                g.Sts_ID   = teamid;
                groups.Add(g);
            }
            return(groups);
        }
        private void AddExternalUser(ExamGroup examGroup, string userId, string username = null)
        {
            ExternalDataRetrievalResult <ExternalUserInfoModel> response;

            if (userId != null)
            {
                response = this.httpRequester.Get <ExternalUserInfoModel>(
                    new { userId },
                    string.Format(UrlConstants.GetUserInfoByIdApiFormat, this.sulsPlatformBaseUrl),
                    this.apiKey);
            }
            else if (username != null)
            {
                response = this.httpRequester.Get <ExternalUserInfoModel>(
                    new { username },
                    string.Format(UrlConstants.GetUserInfoByUsernameApiFormat, this.sulsPlatformBaseUrl),
                    this.apiKey);
            }
            else
            {
                throw new ArgumentNullException(nameof(username));
            }

            if (response.IsSuccess)
            {
                if (response.Data == null)
                {
                    return;
                }

                var user = response.Data.Entity;
                examGroup.Users.Add(user);
                this.examGroupsData.Update(examGroup);
            }
            else
            {
                throw new HttpException(response.ErrorMessage);
            }
        }