Ejemplo n.º 1
0
        /// <summary>
        /// 获取题目数据物理路径
        /// </summary>
        /// <param name="problemID">题目ID</param>
        /// <returns>题目数据物理路径</returns>
        public static IMethodResult AdminGetProblemDataDownloadPath(Int32 problemID)
        {
            if (!AdminManager.HasPermission(PermissionType.ProblemManage))
            {
                throw new NoPermissionException();
            }

            if (problemID < ConfigurationManager.ProblemSetStartID)
            {
                return(MethodResult.InvalidRequest(RequestType.Problem));
            }

            String dataPath = ProblemDataManager.GetProblemDataRealPath(problemID);

            if (String.IsNullOrEmpty(dataPath))
            {
                return(MethodResult.FailedAndLog("This problem doesn't have data!"));
            }

            return(MethodResult.SuccessAndLog <String>(dataPath, "Admin download problem data, id = {0}", problemID.ToString()));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 删除题目数据
        /// </summary>
        /// <param name="problemID">题目ID</param>
        /// <returns>是否删除成功</returns>
        public static IMethodResult AdminDeleteProblemDataRealPath(Int32 problemID)
        {
            if (!AdminManager.HasPermission(PermissionType.ProblemManage))
            {
                throw new NoPermissionException();
            }

            if (problemID < ConfigurationManager.ProblemSetStartID)
            {
                return(MethodResult.InvalidRequest(RequestType.Problem));
            }

            String dataPath = ProblemDataManager.GetProblemDataRealPath(problemID);

            if (String.IsNullOrEmpty(dataPath))
            {
                return(MethodResult.FailedAndLog("This problem does not have data!"));
            }

            File.Delete(dataPath);
            ProblemDataCache.RemoveProblemDataVersionCache(problemID);

            return(MethodResult.SuccessAndLog("Admin delete problem data, id = {0}", problemID.ToString()));
        }