Beispiel #1
0
 /// <summary>
 /// 获取最早等待评测的一个提交
 /// </summary>
 /// <param name="count">获取个数</param>
 /// <param name="languageSupport">支持语言</param>
 /// <returns>提交实体</returns>
 public static List<SolutionEntity> JudgeGetPendingSolution(Int32 count, LanguageType[] languageSupport)
 {
     lock (_selectLock)
     {
         return SolutionRepository.Instance.GetPendingEntities(count, ConfigurationManager.CheckJudgeErrorSolution, languageSupport);
     }
 }
Beispiel #2
0
        private static Boolean AdminGetSolutionParams(String sids, String cid, String pid, String name, String lang, String type, String startDate, String endDate,
            out String solutionIDs, out Int32 problemID, out Int32 contestID, out String userName, out LanguageType languageType, out ResultType? resultType, out DateTime? dtStart, out DateTime? dtEnd)
        {
            Boolean noCondition = true;
            String dateFormat = "yyyy-MM-dd HH:mm:ss";

            solutionIDs = String.Empty;
            contestID = -1;
            problemID = -1;
            userName = String.Empty;
            languageType = LanguageType.Null;
            resultType = new Nullable<ResultType>();
            dtStart = null;
            dtEnd = null;

            if (!String.IsNullOrEmpty(sids))
            {
                solutionIDs = sids.SearchOptimized();

                if (!RegexVerify.IsNumericIDs(solutionIDs))
                {
                    throw new InvalidRequstException(RequestType.Solution);
                }

                noCondition = false;
            }

            if (!String.IsNullOrEmpty(cid))
            {
                if (!Int32.TryParse(cid, out contestID))
                {
                    throw new InvalidRequstException(RequestType.Contest);
                }

                if (contestID < ContestRepository.NONECONTEST)
                {
                    throw new InvalidRequstException(RequestType.Contest);
                }

                noCondition = false;
            }

            if (!String.IsNullOrEmpty(pid))
            {
                if (!Int32.TryParse(pid, out problemID))
                {
                    throw new InvalidRequstException(RequestType.Problem);
                }

                if (problemID < ConfigurationManager.ProblemSetStartID)
                {
                    throw new InvalidRequstException(RequestType.Problem);
                }

                noCondition = false;
            }

            if (!String.IsNullOrEmpty(name))
            {
                if (!RegexVerify.IsUserName(name))
                {
                    throw new InvalidRequstException(RequestType.User);
                }

                userName = name;
                noCondition = false;
            }

            if (!String.IsNullOrEmpty(lang))
            {
                Byte langType = Byte.MaxValue;

                if (!Byte.TryParse(lang, out langType))
                {
                    throw new InvalidInputException("Language Type is INVALID!");
                }

                languageType = LanguageType.FromLanguageID(langType);
                noCondition = false;
            }

            if (!String.IsNullOrEmpty(type))
            {
                Byte resType = Byte.MaxValue;

                if (!Byte.TryParse(type, out resType))
                {
                    throw new InvalidInputException("Result Type is INVALID!");
                }

                resultType = (ResultType)resType;
                noCondition = false;
            }

            if (!String.IsNullOrEmpty(startDate))
            {
                DateTime temp;
                if (!DateTime.TryParseExact(startDate, dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out temp))
                {
                    throw new InvalidInputException("Datetime is INVALID!");
                }

                dtStart = temp;
                noCondition = false;
            }

            if (!String.IsNullOrEmpty(endDate))
            {
                DateTime temp;
                if (!DateTime.TryParseExact(endDate, dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out temp))
                {
                    throw new InvalidInputException("Datetime is INVALID!");
                }

                dtEnd = temp;

                if (dtStart.HasValue && dtStart.Value >= dtEnd.Value)
                {
                    throw new InvalidInputException("Start date CANNOT be later than end date!");
                }

                noCondition = false;
            }

            return noCondition;
        }
Beispiel #3
0
 /// <summary>
 /// 获取程序语言类型是否为空
 /// </summary>
 /// <param name="type">程序语言类型</param>
 /// <returns>是否为空</returns>
 public static Boolean IsNull(LanguageType type)
 {
     return(!LanguageManager.ContainsLanguageID(type._langID));
 }
Beispiel #4
0
        /// <summary>
        /// 从语言ID中创建语言类型
        /// </summary>
        /// <param name="langID">语言ID</param>
        /// <returns>语言类型</returns>
        public static LanguageType FromLanguageID(Byte langID)
        {
            LanguageType langType = new LanguageType(langID);

            return(langType);
        }
Beispiel #5
0
        /// <summary>
        /// 从语言ID中创建语言类型
        /// </summary>
        /// <param name="langID">语言ID</param>
        /// <returns>语言类型</returns>
        public static LanguageType FromLanguageID(Byte langID)
        {
            LanguageType langType = new LanguageType(langID);

            return langType;
        }
Beispiel #6
0
 /// <summary>
 /// 获取程序语言类型是否为空
 /// </summary>
 /// <param name="type">程序语言类型</param>
 /// <returns>是否为空</returns>
 public static Boolean IsNull(LanguageType type)
 {
     return !LanguageManager.ContainsLanguageID(type._langID);
 }
Beispiel #7
0
        /// <summary>
        /// 从语言ID中创建语言类型
        /// </summary>
        /// <param name="type">语言类型</param>
        /// <returns>语言类型</returns>
        public static LanguageType FromLanguagType(String type)
        {
            Byte langID = LanguageManager.GetLanguageID(type);
            LanguageType langType = new LanguageType(langID);

            return langType;
        }