Beispiel #1
0
 /// <summary>
 /// 用于向 Contests EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToContests(Contest contest)
 {
     base.AddObject("Contests", contest);
 }
Beispiel #2
0
 /// <summary>
 /// 创建新的 Contest 对象。
 /// </summary>
 /// <param name="id">ID 属性的初始值。</param>
 /// <param name="startTime">StartTime 属性的初始值。</param>
 /// <param name="endTime">EndTime 属性的初始值。</param>
 /// <param name="title">Title 属性的初始值。</param>
 /// <param name="lockProblemOnStart">LockProblemOnStart 属性的初始值。</param>
 /// <param name="lockTestCaseOnStart">LockTestCaseOnStart 属性的初始值。</param>
 /// <param name="lockSolutionOnStart">LockSolutionOnStart 属性的初始值。</param>
 /// <param name="lockPostOnStart">LockPostOnStart 属性的初始值。</param>
 /// <param name="hideTestCaseOnStart">HideTestCaseOnStart 属性的初始值。</param>
 /// <param name="allowTestingOnStart">AllowTestingOnStart 属性的初始值。</param>
 /// <param name="description">Description 属性的初始值。</param>
 /// <param name="status">Status 属性的初始值。</param>
 /// <param name="hideProblemOnStart">HideProblemOnStart 属性的初始值。</param>
 /// <param name="lockRecordOnStart">LockRecordOnStart 属性的初始值。</param>
 /// <param name="lockProblemOnEnd">LockProblemOnEnd 属性的初始值。</param>
 /// <param name="lockSolutionOnEnd">LockSolutionOnEnd 属性的初始值。</param>
 /// <param name="lockTestCaseOnEnd">LockTestCaseOnEnd 属性的初始值。</param>
 /// <param name="lockPostOnEnd">LockPostOnEnd 属性的初始值。</param>
 /// <param name="lockRecordOnEnd">LockRecordOnEnd 属性的初始值。</param>
 /// <param name="allowTestingOnEnd">AllowTestingOnEnd 属性的初始值。</param>
 /// <param name="hideProblemOnEnd">HideProblemOnEnd 属性的初始值。</param>
 /// <param name="hideTestCaseOnEnd">HideTestCaseOnEnd 属性的初始值。</param>
 public static Contest CreateContest(global::System.Int32 id, global::System.DateTimeOffset startTime, global::System.DateTimeOffset endTime, global::System.String title, global::System.Boolean lockProblemOnStart, global::System.Boolean lockTestCaseOnStart, global::System.Boolean lockSolutionOnStart, global::System.Boolean lockPostOnStart, global::System.Boolean hideTestCaseOnStart, global::System.Boolean allowTestingOnStart, global::System.String description, global::System.String status, global::System.Boolean hideProblemOnStart, global::System.Boolean lockRecordOnStart, global::System.Boolean lockProblemOnEnd, global::System.Boolean lockSolutionOnEnd, global::System.Boolean lockTestCaseOnEnd, global::System.Boolean lockPostOnEnd, global::System.Boolean lockRecordOnEnd, global::System.Boolean allowTestingOnEnd, global::System.Boolean hideProblemOnEnd, global::System.Boolean hideTestCaseOnEnd)
 {
     Contest contest = new Contest();
     contest.ID = id;
     contest.StartTime = startTime;
     contest.EndTime = endTime;
     contest.Title = title;
     contest.LockProblemOnStart = lockProblemOnStart;
     contest.LockTestCaseOnStart = lockTestCaseOnStart;
     contest.LockSolutionOnStart = lockSolutionOnStart;
     contest.LockPostOnStart = lockPostOnStart;
     contest.HideTestCaseOnStart = hideTestCaseOnStart;
     contest.AllowTestingOnStart = allowTestingOnStart;
     contest.Description = description;
     contest.Status = status;
     contest.HideProblemOnStart = hideProblemOnStart;
     contest.LockRecordOnStart = lockRecordOnStart;
     contest.LockProblemOnEnd = lockProblemOnEnd;
     contest.LockSolutionOnEnd = lockSolutionOnEnd;
     contest.LockTestCaseOnEnd = lockTestCaseOnEnd;
     contest.LockPostOnEnd = lockPostOnEnd;
     contest.LockRecordOnEnd = lockRecordOnEnd;
     contest.AllowTestingOnEnd = allowTestingOnEnd;
     contest.HideProblemOnEnd = hideProblemOnEnd;
     contest.HideTestCaseOnEnd = hideTestCaseOnEnd;
     return contest;
 }
Beispiel #3
0
        public static void AddTestData(MooDB db)
        {
            //Users
            User MrPhone = new User()
            {
                Name = "onetwogoo",
                Password = Converter.ToSHA256Hash("123456"),
                Role = SiteRoles.ByType[RoleType.Organizer].GetDBRole(db),
                BriefDescription = "我觉得我写这么多应该够两行了",
                Description = "我是--屌丝--我骄傲,我为国家省钞票!",
                Email = "*****@*****.**",
                Score = 256,
                PreferredLanguage="c++"
            };
            db.Users.AddObject(MrPhone);

            User ShaBi = new User()
            {
                Name = "ShaBi",
                Password = Converter.ToSHA256Hash("ShaBi"),
                Role = SiteRoles.ByType[RoleType.Worker].GetDBRole(db),
                BriefDescription = "我觉得我写这么多应该够两行了",
                Description = "Moo*真*他妈的好!",
                Email = "*****@*****.**",
                Score = 128,
                PreferredLanguage="c++"
            };
            db.Users.AddObject(ShaBi);

            User Baby = new User()
            {
                Name = "Baby",
                Password = Converter.ToSHA256Hash("Baby"),
                Role = SiteRoles.ByType[RoleType.NormalUser].GetDBRole(db),
                BriefDescription = "我啥都不懂",
                Description = "真不懂",
                Email = "*****@*****.**",
                Score = 1000,
                PreferredLanguage="pascal"
            };
            db.Users.AddObject(Baby);

            db.Users.AddObject(new User()
            {
                Name = "BeiJu",
                Password = Converter.ToSHA256Hash("BeiJu"),
                Role = SiteRoles.ByType[RoleType.Malefactor].GetDBRole(db),
                BriefDescription = "冤枉啊!啥都没干就被封了!",
                Description = "太他妈冤枉了!",
                Email = "",
                Score = 0,
                PreferredLanguage="c"
            });

            //Homepage
            db.HomepageRevisions.AddObject(new HomepageRevision()
            {
                Title = "欢迎测试",
                Content = "测试用户:\n"
                + "onetwogoo/123456 组织者\n"
                + "ShaBi/ShaBi 工作者\n"
                + "Baby/Baby 普通用户\n"
                + "BeiJu/BeiJu 作恶者",
                Reason = "测试用原因",
                CreatedBy = ShaBi
            });

            //Problems
            Problem APlusB = new Problem()
            {
                Name = "A+B问题",
                Type = "Tranditional",
                Lock = false,
                Hidden = false,
                TestCaseHidden = false,
                AllowTesting = true,
                LockPost = false,
                LockRecord = false,
                LockSolution = false,
                LockTestCase = false,
                SubmissionCount = 10,
                ScoreSum = 100,
                SubmissionUser = 1,
                MaximumScore = 30
            };

            Problem CPlusD = new Problem()
            {
                Name = "C+D问题",
                Type = "Tranditional",
                Lock = true,
                Hidden = false,
                TestCaseHidden = false,
                LockPost = true,
                LockTestCase = true,
                LockSolution = true,
                LockRecord = true,
                AllowTesting = true,
                SubmissionCount = 20,
                ScoreSum = 5,
                SubmissionUser = 2,
                MaximumScore = 120
            };
            db.Problems.AddObject(CPlusD);

            Problem EPlusF = new Problem()
            {
                Name = "E+F问题",
                Type = "Tranditional",
                Lock = false,
                LockPost = false,
                LockRecord = false,
                LockSolution = false,
                LockTestCase = false,
                AllowTesting = true,
                Hidden = true,
                TestCaseHidden = true,
                SubmissionCount = 40,
                ScoreSum = 300,
                SubmissionUser = 4,
                MaximumScore = 110
            };
            db.Problems.AddObject(EPlusF);

            Problem Cat = new Problem()
            {
                Name = "Cat",
                Type = "SpecialJudged",
                Lock = false,
                LockPost = false,
                LockRecord = false,
                LockSolution = false,
                LockTestCase = false,
                AllowTesting = true,
                Hidden = false,
                TestCaseHidden = false
            };
            db.Problems.AddObject(Cat);

            Problem EasyAPlusB = new Problem()
            {
                Name = "Easy A+B",
                Type = "Interactive",
                Lock = false,
                LockPost = false,
                LockRecord = false,
                LockSolution = false,
                LockTestCase = false,
                AllowTesting = true,
                Hidden = false,
                TestCaseHidden = false
            };
            db.Problems.AddObject(EasyAPlusB);

            Problem AnswerAPlusB = new Problem()
            {
                Name = "Answer A+B",
                Type = "AnswerOnly",
                Lock = false,
                LockPost = false,
                LockRecord = false,
                LockSolution = false,
                LockTestCase = false,
                AllowTesting = true,
                Hidden = false,
                TestCaseHidden = false
            };

            //File
            UploadedFile file = new UploadedFile()
            {
                Name = "SPJ for Cat",
                Description = "给Cat的SPJ",
                Path = "D:\\Cat.exe",
                CreatedBy=MrPhone
            };
            db.UploadedFiles.AddObject(file);

            //Test Cases
            db.TestCases.AddObject(new TranditionalTestCase()
            {
                Problem = CPlusD,
                Input = Encoding.ASCII.GetBytes("qwertyuioplkjhgfdsazxcvbnm"),
                Answer = Encoding.ASCII.GetBytes("mnbvcxzasdfghjklpoiuytrewq"),
                TimeLimit = 1000,
                MemoryLimit = 1024 * 1024 * 6,
                Score = 12,
                CreatedBy=MrPhone
            });
            db.SaveChanges();

            db.TestCases.AddObject(new TranditionalTestCase()
            {
                Problem = APlusB,
                Input = Encoding.ASCII.GetBytes("1 2"),
                Answer = Encoding.ASCII.GetBytes("3"),
                TimeLimit = 1000,
                MemoryLimit = 60 * 1024 * 1024,
                Score = 50,
                CreatedBy = MrPhone
            });

            db.TestCases.AddObject(new TranditionalTestCase()
            {
                Problem = APlusB,
                Input = Encoding.ASCII.GetBytes("100 345"),
                Answer = Encoding.ASCII.GetBytes("445"),
                TimeLimit = 1000,
                MemoryLimit = 60 * 1024 * 1024,
                Score = 50,
                CreatedBy = MrPhone
            });

            db.TestCases.AddObject(new SpecialJudgedTestCase()
            {
                Problem = Cat,
                Input = Encoding.ASCII.GetBytes("1 2"),
                Answer = Encoding.ASCII.GetBytes("Miao~"),
                TimeLimit = 1000,
                MemoryLimit = 60 * 1024 * 1024,
                Judger = file,
                CreatedBy = MrPhone
            });

            file = new UploadedFile()
            {
                Name = "Invoker for EasyA+B",
                Description = "EasyA+B的调用程序",
                Path = "D:\\EasyA+B.o",
                CreatedBy = MrPhone
            };

            db.TestCases.AddObject(new InteractiveTestCase()
            {
                Problem = EasyAPlusB,
                TestData = Encoding.ASCII.GetBytes("1123 3212"),
                TimeLimit = 1000,
                MemoryLimit = 60 * 1024 * 1024,
                Invoker = file,
                CreatedBy = MrPhone
            });

            db.TestCases.AddObject(new InteractiveTestCase()
            {
                Problem = EasyAPlusB,
                TestData = Encoding.ASCII.GetBytes("1 3"),
                TimeLimit = 1000,
                MemoryLimit = 60 * 1024 * 1024,
                Invoker = file,
                CreatedBy = MrPhone
            });

            file = new UploadedFile()
            {
                Name = "Judger Of Answer A+B",
                Description="*测评程序*啊",
                Path = "D:\\AnswerA+B.exe",
                CreatedBy = MrPhone
            };

            AnswerOnlyTestCase answerOnlyTestCase1 = new AnswerOnlyTestCase()
            {
                Problem = AnswerAPlusB,
                TestData = Encoding.ASCII.GetBytes("23 345"),
                Judger = file,
                CreatedBy = MrPhone
            };
            db.TestCases.AddObject(answerOnlyTestCase1);

            AnswerOnlyTestCase answerOnlyTestCase2 = new AnswerOnlyTestCase()
            {
                Problem = AnswerAPlusB,
                TestData = Encoding.ASCII.GetBytes("453 123"),
                Judger = file,
                CreatedBy = MrPhone
            };
            db.TestCases.AddObject(answerOnlyTestCase2);

            //Problem Revision
            db.ProblemRevisions.AddObject(new ProblemRevision()
             {
                 Problem = APlusB,
                 Content = "输入A,B。输出A+B。啊!输错了!",
                 Reason = "蛋疼",
                 CreatedBy = ShaBi
             });

            db.ProblemRevisions.AddObject(new ProblemRevision()
            {
                Problem = APlusB,
                Content = "输入A,B。输出它们的和。",
                Reason = "蛋疼",
                CreatedBy = MrPhone
            });

            db.ProblemRevisions.AddObject(new ProblemRevision()
            {
                Problem = APlusB,
                Content = "输入俩蛋,输出它们的和。",
                Reason = "蛋疼",
                CreatedBy = ShaBi
            });

            APlusB.LatestRevision = new ProblemRevision()
            {
                Problem = APlusB,
                Content = "输入两个Int32,输出它们的和。",
                Reason = "蛋疼",
                CreatedBy = MrPhone
            };

            CPlusD.LatestRevision = new ProblemRevision()
            {
                Problem = CPlusD,
                Content = "输入C,D。*注意是Int64*输出它们的和。",
                Reason = "蛋疼",
                CreatedBy = ShaBi
            };

            EPlusF.LatestRevision = new ProblemRevision()
            {
                Problem = EPlusF,
                Content = "输入E,F。输出它们的和。",
                Reason = "蛋疼",
                CreatedBy = ShaBi
            };

            Cat.LatestRevision = new ProblemRevision()
            {
                Problem = Cat,
                Content = "模拟Cat",
                Reason = "擦!",
                CreatedBy = MrPhone
            };

            EasyAPlusB.LatestRevision = new ProblemRevision()
            {
                Problem = EasyAPlusB,
                Content = "仅需编写一个int APlusB(int,int);即可。",
                Reason = "This is Interactive",
                CreatedBy = ShaBi
            };

            AnswerAPlusB.LatestRevision = new ProblemRevision()
            {
                Problem = AnswerAPlusB,
                Content = "提交答案吧!",
                Reason = "None",
                CreatedBy = MrPhone
            };

            //Solution
            db.SolutionRevisions.AddObject(new SolutionRevision()
            {
                Problem = APlusB,
                Content = "很简单。水题不解释。",
                Reason = "太水了",
                CreatedBy = ShaBi
            });

            APlusB.LatestSolution = new SolutionRevision()
            {
                Problem = APlusB,
                Content = "var a,b:*int64*; begin read(a,b); write(a+b); end.",
                Reason = "上代码",
                CreatedBy = MrPhone
            };

            CPlusD.LatestSolution = new SolutionRevision()
            {
                Problem = CPlusD,
                Content = "这个好像跟A+B一样吧",
                Reason = "神犇题解",
                CreatedBy = ShaBi
            };

            EPlusF.LatestSolution = new SolutionRevision()
            {
                Problem = EPlusF,
                Content = "太难了,不会啊",
                Reason = "垃圾题解",
                CreatedBy = ShaBi
            };

            Cat.LatestSolution = new SolutionRevision()
            {
                Problem = Cat,
                Content = "抄!",
                Reason = "",
                CreatedBy = ShaBi
            };

            EasyAPlusB.LatestSolution = new SolutionRevision()
            {
                Problem = EasyAPlusB,
                Content = "就……就A了。",
                Reason = "",
                CreatedBy = MrPhone
            };

            AnswerAPlusB.LatestSolution = new SolutionRevision()
            {
                Problem = AnswerAPlusB,
                Content = "弱爆了",
                Reason = "xxx",
                CreatedBy = ShaBi
            };

            //Post
            Post post = new Post()
            {
                Name = "讨论一下出题人心理",
                Problem = APlusB,
                Lock = false,
                OnTop = true,
            };
            db.Posts.AddObject(post);

            db.PostItems.AddObject(new PostItem()
            {
                Post = post,
                Content = "出--这么水--的题,找死啊",
                CreatedBy = ShaBi,
            });
            db.SaveChanges();

            db.PostItems.AddObject(new PostItem()
            {
                Post = post,
                Content = "靠!作为出题人我压力很大啊!",
                CreatedBy = MrPhone
            });

            post = new Post()
            {
                Name = "认真研究一下此题变形",
                Problem = APlusB,
                Lock = false,
                OnTop = false
            };
            db.Posts.AddObject(post);

            db.PostItems.AddObject(new PostItem()
            {
                Post = post,
                Content = "A+B能有什么变形呢?",
                CreatedBy = MrPhone
            });
            db.SaveChanges();

            db.PostItems.AddObject(new PostItem()
            {
                Post = post,
                Content = "靠!没人回答,我寂寞了~",
                CreatedBy = MrPhone
            });

            post = new Post()
            {
                Name = "讨论一下Moo好不好",
                Lock = true,
                OnTop = false
            };
            db.Posts.AddObject(post);

            db.PostItems.AddObject(new PostItem()
            {
                Post = post,
                Content = "Moo很好啊。*注意此贴没有对应题目且被锁*",
                CreatedBy = MrPhone
            });

            //Mail
            db.Mails.AddObject(new Mail()
            {
                Title = "咱把Moo黑了如何?",
                Content = "嘿!onetwogoo!把Moo--黑--了吧!",
                IsRead = true,
                From = ShaBi,
                To = MrPhone
            });
            db.SaveChanges();

            db.Mails.AddObject(new Mail()
            {
                Title = "找死啊!",
                Content = "我会去黑自己网站吗?",
                IsRead = true,
                From = MrPhone,
                To = ShaBi
            });
            db.SaveChanges();

            db.Mails.AddObject(new Mail()
            {
                Title = "没准嘞!",
                Content = "敢说你没这想法",
                IsRead = true,
                From = ShaBi,
                To = MrPhone
            });
            db.SaveChanges();

            db.Mails.AddObject(new Mail()
            {
                Title = "傻逼",
                Content = "不解释!",
                IsRead = false,
                From = MrPhone,
                To = ShaBi
            });
            db.SaveChanges();

            db.Mails.AddObject(new Mail()
            {
                Title = "把我弄成组织者如何啊",
                Content = "???",
                IsRead = false,
                From = Baby,
                To = MrPhone
            });
            db.SaveChanges();

            db.Mails.AddObject(new Mail()
            {
                Title = "美死你",
                Content = "怎么可能",
                IsRead = true,
                From = MrPhone,
                To = Baby
            });
            db.SaveChanges();

            //Contest
            Contest contest = new Contest()
            {
                StartTime = DateTimeOffset.Now.AddMinutes(1),
                EndTime = DateTimeOffset.Now.AddMinutes(2),
                Status = "Before",
                Title = "Moo水题大赛",
                Description = "全是--水--题啊!",
                LockProblemOnStart = true,
                LockPostOnStart = true,
                LockSolutionOnStart = true,
                LockTestCaseOnStart = true,
                AllowTestingOnStart = false,
                HideTestCaseOnStart = true,
                LockRecordOnStart = false,
                HideProblemOnStart = false,
                AllowTestingOnEnd = true,
                LockPostOnEnd = false,
                LockProblemOnEnd = false,
                LockRecordOnEnd = false,
                LockSolutionOnEnd = false,
                LockTestCaseOnEnd = false,
                HideProblemOnEnd = false,
                HideTestCaseOnEnd = false,
            };
            //contest.Problem.Add(APlusB);
            contest.Problem.Add(CPlusD);
            contest.User.Add(ShaBi);

            //Record
            JudgeInfo info = new JudgeInfo()
            {
                Info = "Test",
                Score = 10
            };

            Record record = new Record()
            {
                Code = "",
                Language = "cxx",
                CreateTime = DateTimeOffset.Now.AddMinutes(1.5),
                User = ShaBi,
                Problem = APlusB,
                PublicCode = true
            };
            record.JudgeInfo = info;
            info.Record = record;
            db.Records.AddObject(record);

            info = new JudgeInfo()
            {
                Info = "test",
                Score = 30
            };

            record = new Record()
            {
                Code = "",
                Language = "c++",
                CreateTime = DateTimeOffset.Now.AddMinutes(1.5),
                User = ShaBi,
                Problem = APlusB,
                PublicCode = true
            };
            record.JudgeInfo = info;
            info.Record = record;
            db.Records.AddObject(record);

            info = new JudgeInfo()
            {
                Info = "test",
                Score = 60
            };

            record = new Record()
            {
                Code = "",
                Language = "c++",
                CreateTime = DateTimeOffset.Now.AddMinutes(1.5),
                User = ShaBi,
                Problem = CPlusD,
                PublicCode = true
            };
            record.JudgeInfo = info;
            info.Record = record;
            db.Records.AddObject(record);

            db.Records.AddObject(new Record()
            {
                Code = "int APlusB(int x,int y){return 4;}",
                CreateTime = DateTimeOffset.Now,
                Language = "c++",
                Problem = EasyAPlusB,
                User = MrPhone,
                PublicCode = true
            });

            db.Records.AddObject(new Record()
            {
                Code = "<Moo:Answer testCase='" + answerOnlyTestCase1.ID + "'>368</Moo:Answer>\n"
                + "<Moo:Answer testCase='" + answerOnlyTestCase2.ID + "'>496</Moo:Answer>",
                CreateTime = DateTimeOffset.Now,
                Language = "plaintext",
                Problem = AnswerAPlusB,
                User = MrPhone,
                PublicCode = true
            });

            db.SaveChanges();
        }