예제 #1
0
        static public IEnumerable <DataRow> QuestionList(DataBaseExecutor db, long groupid, int p)
        {
            string key = string.Format(QUESTIONLIST, groupid);

            return(AllQuestion(db).AsEnumerable().Where(c => c.Field <int>("GroupID") == groupid).OrderBy(c => c.Field <int>("ID")));
            //.Skip(20 * (p - 1)).Take(20);
        }
예제 #2
0
        static public IEnumerable <DataRow> Status(DataBaseExecutor db, int p)
        {
            return(db.GetTable(@"SELECT Answer.QuestionID, Answer.Username, 
Answer.Status, Answer.Addtime, Answer.Complier, Answer.UseTime, 
Answer.UseMemory, Question.Title, Answer.ID,Answer.Guid
FROM Answer INNER JOIN Question ON Answer.QuestionID = Question.ID 
order by answer.id desc").AsEnumerable().Skip(20 * (p - 1)).Take(20));
        }
예제 #3
0
        static public IEnumerable <DataRow> MySatus(DataBaseExecutor db, string username)
        {
            return(db.GetTable(@"SELECT Answer.QuestionID, Answer.Username, 
Answer.Status, Answer.Addtime, Answer.Complier, Answer.UseTime, 
Answer.UseMemory, Question.Title, Answer.ID,Answer.Guid
FROM Answer INNER JOIN Question ON Answer.QuestionID = Question.ID 
where answer.username=@un
order by answer.id desc", "@un", username).AsEnumerable().ToList());
        }
예제 #4
0
        static public void SaveAnswer(DataBaseExecutor db, long qid, string username, int st,
                                      string CompilerName, long UseTime, long UseMemory, Guid Guid)
        {
            db.Execute(@"INSERT INTO Answer 
(QuestionID, Username, Status, Addtime, Complier, Type, UseTime, UseMemory,[Guid] )
values(@qid,@un,@st, Now(),@cn,0,@UseTime,@UseMemory,@Guid)", "@qid", qid, "@un", username, "@st", st,
                       "@cn", CompilerName, "@UseTime", UseTime, "@UseMemory", UseMemory
                       , "@Guid", Guid.ToString()
                       );
        }
예제 #5
0
파일: GroupHelper.cs 프로젝트: chteam/choj
        static public DataRow GetGroup(DataBaseExecutor db, long id)
        {
            var rets = GroupTable(db).AsEnumerable().Where(c => c.Field <int>("id") == id).FirstOrDefault();

            if (rets != null)
            {
                return(rets);
            }
            return(null);
        }
예제 #6
0
파일: OJer.cs 프로젝트: chteam/choj
        public void Start(Object stateInfo)
        {
            //检查
            if (CheckCode())
            {
                //编译
                AnswerType = AnswerType.Compiling;
                if (CompileExecutable())
                {
                    //编译完成
                    //测试
                    AnswerType = AnswerType.Testing;
                    Test();
                }
                else
                {
                    AnswerType = AnswerType.CompileError;
                }
            }
            else
            {
                AnswerType = AnswerType.DangerCode;
            }
            var db = new DataBaseExecutor(new OleDbDataOpener(ConfigurationManager.ConnectionStrings["AccessFileName"].ConnectionString));

            AnswerHelper.SaveAnswer(db,
                                    Question.Field <int>("id"),
                                    Username,
                                    (int)AnswerType,
                                    Compiler.Name,
                                    UseTime,
                                    UseMemory,
                                    Guid
                                    );
            db.Dispose();
            if (!Directory.Exists(RootPath + @"SourceCode\"))
            {
                Directory.CreateDirectory(RootPath + @"SourceCode\");
            }
            File.WriteAllText(RootPath + string.Format(@"SourceCode\{0}.sc", Guid)
                              , Code);
            if (AnswerType == AnswerType.CompileError)
            {
                if (!Directory.Exists(RootPath + @"CompilerInfo\"))
                {
                    Directory.CreateDirectory(RootPath + @"CompilerInfo\");
                }
                File.WriteAllText(RootPath + string.Format(@"CompilerInfo\{0}.txt", Guid), Log.ToString());
            }
            if (!Directory.Exists(RootPath + @"temp\"))
            {
                Directory.CreateDirectory(RootPath + @"temp\");
            }
            File.Delete(ExeFile);
        }
예제 #7
0
파일: OJer.cs 프로젝트: chteam/choj
        public OJer(string username, string code, Guid guid, long questionId, string siteRoot)
        {
            var db =
                new DataBaseExecutor(
                    new OleDbDataOpener(ConfigurationManager.ConnectionStrings["AccessFileName"].ConnectionString));

            Guid       = Guid.NewGuid();
            Username   = username;
            Code       = code;
            Compiler   = ConfigSerializer.Load <List <Compiler> >("Compiler").Where(c => c.Guid == guid).FirstOrDefault();
            Question   = QuestionHelper.Question(db, questionId);
            RootPath   = siteRoot;
            AnswerType = AnswerType.Queuing;
            ExeFile    = RootPath + string.Format(@"temp\{0}.exe", guid);
            db.Dispose();
        }
예제 #8
0
        static DataTable AllQuestion(DataBaseExecutor db)
        {
            string    key = QUESTIONLIST;
            DataTable dt  = null;

            if (CHCache.Contains(key))
            {
                dt = CHCache.Get <DataTable>(key);
            }
            else
            {
                dt = db.GetTable(@"SELECT * FROM [Question]");                // where istrue=1
                CHCache.Add(key, dt);
            }
            return(dt);
        }
예제 #9
0
파일: GroupHelper.cs 프로젝트: chteam/choj
        static DataTable GroupTable(DataBaseExecutor db)
        {
            string    key = GROUP;
            DataTable dt  = null;

            if (CHCache.Contains(key))
            {
                dt = CHCache.Get <DataTable>(key);
            }
            else
            {
                dt = db.GetTable(@"SELECT * FROM [Group]");
                CHCache.Add(key, dt);
            }
            return(dt);
        }
예제 #10
0
 static public DataRow Question(DataBaseExecutor db, long id)
 {
     return(AllQuestion(db).AsEnumerable().Where(c => c.Field <int>("ID") == id).FirstOrDefault());
 }
예제 #11
0
        public static void Create(DataBaseExecutor db, string Username)
        {
            db.Execute(@"INSERT INTO [User]([Username],[NickName],[Name],[Sex],[Birthday],[Grade],[School],[SchoolDetails],[Submit],[Accepted])
VALUES(@Username,@Username,'',0,Now(),2008,'','',0,0)", "@Username", Username);
        }
예제 #12
0
파일: GroupHelper.cs 프로젝트: chteam/choj
        static public IEnumerable <DataRow> GroupList(DataBaseExecutor db)
        {
            var rows = GroupTable(db).AsEnumerable().Where(c => c.Field <int>("type") == 0).OrderBy(c => c.Field <int>("order"));

            return(rows);
        }