• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# DB.MooDB类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Moo.DB.MooDB的典型用法代码示例。如果您正苦于以下问题:C# MooDB类的具体用法?C# MooDB怎么用?C# MooDB使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MooDB类属于Moo.DB命名空间,在下文中一共展示了MooDB类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: btnSubmit_Click

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid) return;
        if (!Permission.Check("file.create", false)) return;

        string fileName = Resources.Moo.File_UploadPath + Path.GetRandomFileName() + "." + fileUpload.FileName.Split('.').Last();
        fileUpload.SaveAs(fileName);
        int fileID;
        using (MooDB db = new MooDB())
        {
            User currentUser = ((SiteUser)User.Identity).GetDBUser(db);
            UploadedFile file = new UploadedFile()
            {
                Name = txtName.Text,
                Description = txtDescription.Text,
                Path = fileName,
                CreatedBy=currentUser
            };
            db.UploadedFiles.AddObject(file);
            db.SaveChanges();
            fileID = file.ID;

            Logger.Info(db, "创建文件#" + fileID);
        }

        PageUtil.Redirect("创建成功", "~/File/?id=" + fileID);
    }
开发者ID:MooDevTeam,项目名称:MooOJ,代码行数:27,代码来源:Create.aspx.cs


示例2: AddTestData

 public static void AddTestData()
 {
     using (MooDB db = new MooDB())
     {
         AddTestData(db);
     }
 }
开发者ID:MooDevTeam,项目名称:MooOJ,代码行数:7,代码来源:MooTestData.cs


示例3: MainLoop

        static int MainLoop()
        {
            using (MooDB db = new MooDB())
            {
                Record record = (from r in db.Records
                                 where r.JudgeInfo == null && r.Problem.AllowTesting
                                 select r).FirstOrDefault<Record>();
                var a = (from r in db.Records
                         where r.JudgeInfo == null
                         select r);
                if (record == null)
                {
                    return 5 * 1000;
                }
                else
                {
                    record.JudgeInfo = new JudgeInfo()
                    {
                        Record = record,
                        Score = -1,
                        Info = "<color:blue>*正在评测*</color>"
                    };
                    db.SaveChanges();

                    Logger.Info(db, "开始评测记录#" + record.ID);

                    Test(db, record);
                    db.SaveChanges();

                    Logger.Info(db, "记录#" + record.ID + "评测完成");

                    return 0;
                }
            }
        }
开发者ID:MooDevTeam,项目名称:MooOJ,代码行数:35,代码来源:TesterManager.cs


示例4: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Permission.Check("file.read", true)) return;

        if (!Page.IsPostBack)
        {
            using (MooDB db = new MooDB())
            {
                if (Request["id"] != null)
                {
                    int fileID = int.Parse(Request["id"]);
                    file = (from f in db.UploadedFiles
                            where f.ID == fileID
                            select f).SingleOrDefault<UploadedFile>();
                }

                if (file == null)
                {
                    PageUtil.Redirect(Resources.Moo.FoundNothing, "~/");
                    return;
                }

                Page.DataBind();
            }
        }
    }
开发者ID:MooDevTeam,项目名称:MooOJ,代码行数:26,代码来源:Default.aspx.cs


示例5: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            using (MooDB db = new MooDB())
            {
                if (Request["id"] != null)
                {
                    int recordID = int.Parse(Request["id"]);
                    record = (from r in db.Records
                              where r.ID == recordID
                              select r).SingleOrDefault<Record>();
                }

                if (record == null)
                {
                    PageUtil.Redirect(Resources.Moo.FoundNothing, "~/");
                    return;
                }

                canModify = Permission.Check("record.modify", false, false)
                    || User.Identity.IsAuthenticated && record.User.ID == ((SiteUser)User.Identity).ID;

                ViewState["recordID"] = record.ID;
                Page.DataBind();
            }
        }
    }
开发者ID:MooDevTeam,项目名称:MooOJ,代码行数:28,代码来源:Modify.aspx.cs


示例6: grid_RowDeleted

 protected void grid_RowDeleted(object sender, GridViewDeletedEventArgs e)
 {
     using (MooDB db = new MooDB())
     {
         Logger.Warning(db, string.Format("删除帖子#{0}的项#{1}", ViewState["postID"], e.Keys[0]));
     }
 }
开发者ID:MooDevTeam,项目名称:MooOJ,代码行数:7,代码来源:Default.aspx.cs


示例7: btnSubmit_Click

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid) return;
        if (!Permission.Check("problem.modify", false)) return;

        int problemID = (int)ViewState["problemID"];
        using (MooDB db = new MooDB())
        {
            problem = (from p in db.Problems
                       where p.ID == problemID
                       select p).Single<Problem>();
            problem.Name = txtName.Text;
            problem.Type = ddlType.SelectedValue;
            problem.Hidden = chkHidden.Checked;
            problem.TestCaseHidden = chkTestCaseHidden.Checked;
            problem.AllowTesting = chkAllowTesting.Checked;
            problem.Lock = chkLock.Checked;
            problem.LockPost = chkLockPost.Checked;
            problem.LockRecord = chkLockRecord.Checked;
            problem.LockSolution = chkLockSolution.Checked;
            problem.LockTestCase = chkLockTestCase.Checked;

            db.SaveChanges();
            Logger.Info(db, "修改题目#" + problem.ID);
        }

        PageUtil.Redirect("修改成功", "~/Problem/?id=" + problemID);
    }
开发者ID:MooDevTeam,项目名称:MooOJ,代码行数:28,代码来源:Modify.aspx.cs


示例8: CollectEntityByID

 void CollectEntityByID(MooDB db, int id)
 {
     testCase = (from t in db.TestCases
                 where t.ID == id
                 select t).SingleOrDefault<TestCase>();
     problem = testCase.Problem;
 }
开发者ID:MooDevTeam,项目名称:MooOJ,代码行数:7,代码来源:Default.aspx.cs


示例9: btnSubmit_Click

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid) return;
        if (!Permission.Check("user.create", true)) return;

        using (MooDB db = new MooDB())
        {
            User user = new User()
            {
                Name = txtUserName.Text,
                Password = Converter.ToSHA256Hash(txtPassword.Text),
                Role = SiteRoles.ByType[RoleType.NormalUser].GetDBRole(db),
                BriefDescription = "我很懒,什么都没留下~",
                Description = "我懒到头了,*真的*啥都没写",
                Email = "",
                Score = 0,
                PreferredLanguage = "c++"
            };
            db.Users.AddObject(user);
            db.SaveChanges();

            Logger.Info(db, "创建用户#" + user.ID);
        }
        PageUtil.Redirect("注册成功,请登录", "~/Special/Login.aspx");
    }
开发者ID:MooDevTeam,项目名称:MooOJ,代码行数:25,代码来源:Register.aspx.cs


示例10: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Permission.Check("user.read", true)) return;

        if (!Page.IsPostBack)
        {
            using (MooDB db = new MooDB())
            {
                int userAID = int.Parse(Request["userA"]);
                int userBID = int.Parse(Request["userB"]);
                userA = (from u in db.Users
                         where u.ID == userAID
                         select u).SingleOrDefault<User>();
                userB = (from u in db.Users
                         where u.ID == userBID
                         select u).SingleOrDefault<User>();
                if (userA == null || userB == null)
                {
                    PageUtil.Redirect(Resources.Moo.FoundNothing, "~/");
                    return;
                }

                BindDatas(db);

                Page.DataBind();
            }
        }
    }
开发者ID:MooDevTeam,项目名称:MooOJ,代码行数:28,代码来源:Compare.aspx.cs


示例11: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            using (MooDB db = new MooDB())
            {
                if (Request["replyTo"] != null)
                {
                    CollectEntityByReplyTo(db, int.Parse(Request["replyTo"]));
                }
                else if (Request["id"] != null)
                {
                    CollectEntityByID(db, int.Parse(Request["id"]));
                }

                if (post == null)
                {
                    PageUtil.Redirect(Resources.Moo.FoundNothing, "~/");
                    return;
                }

                if (post.Lock || post.Problem != null && post.Problem.LockPost)
                {
                    canReply = Permission.Check("post.locked.reply", false, false);
                }
                else
                {
                    canReply = Permission.Check("post.reply", false, false);
                }

                ViewState["postID"] = post.ID;
                Page.DataBind();
            }
        }
    }
开发者ID:MooDevTeam,项目名称:MooOJ,代码行数:35,代码来源:Reply.aspx.cs


示例12: btnAttend_Click

    protected void btnAttend_Click(object sender, EventArgs e)
    {
        if (!Permission.Check("contest.attend", false)) return;

        int contestID = (int)ViewState["contestID"];
        using (MooDB db = new MooDB())
        {
            contest = (from c in db.Contests
                       where c.ID == contestID
                       select c).Single<Contest>();

            if (DateTimeOffset.Now > contest.EndTime)
            {
                return;
            }

            User currentUser = ((SiteUser)User.Identity).GetDBUser(db);
            if (contest.User.Contains(currentUser))
            {
                return;
            }

            contest.User.Add(currentUser);
            db.SaveChanges();

            Logger.Info(db, "报名比赛#" + contest.ID);
        }

        Response.Redirect("~/Contest/?id=" + contestID, true);
    }
开发者ID:MooDevTeam,项目名称:MooOJ,代码行数:30,代码来源:Default.aspx.cs


示例13: grid_RowDeleted

 protected void grid_RowDeleted(object sender, GridViewDeletedEventArgs e)
 {
     using (MooDB db = new MooDB())
     {
         Logger.Warning(db, "删除邮件#" + e.Keys[0]);
     }
 }
开发者ID:MooDevTeam,项目名称:MooOJ,代码行数:7,代码来源:List.aspx.cs


示例14: btnSubmit_Click

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid) return;
        int problemID = (int)ViewState["problemID"];

        using (MooDB db = new MooDB())
        {
            Problem problem = (from p in db.Problems
                               where p.ID == problemID
                               select p).Single<Problem>();
            if (problem.Lock)
            {
                if (!Permission.Check("problem.locked.update", false)) return;
            }
            else
            {
                if (!Permission.Check("problem.update", false)) return;
            }

            User user = ((SiteUser)User.Identity).GetDBUser(db);
            ProblemRevision revision = new ProblemRevision()
            {
                Content = txtContent.Text,
                Problem = problem,
                Reason = txtReason.Text,
                CreatedBy = user
            };
            db.ProblemRevisions.AddObject(revision);
            problem.LatestRevision = revision;
            db.SaveChanges();

            Logger.Info(db, string.Format("更新题目#{0},新版本为#{1}", problem.ID, revision.ID));
        }
        PageUtil.Redirect("更新成功", "~/Problem/?id=" + problemID);
    }
开发者ID:MooDevTeam,项目名称:MooOJ,代码行数:35,代码来源:Update.aspx.cs


示例15: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            using (MooDB db = new MooDB())
            {
                if (Request["revision"] != null)
                {
                    CollectEntityByRevision(db, int.Parse(Request["revision"]));
                }
                else if (Request["id"] != null)
                {
                    CollectEntityById(db, int.Parse(Request["id"]));
                }

                if (problem == null || revision == null)
                {
                    PageUtil.Redirect(Resources.Moo.FoundNothing, "~/");
                    return;
                }

                if (problem.LatestRevision.ID != revision.ID)
                {
                    if (!Permission.Check("problem.history.read", true)) return;
                }

                canRead = problem.Hidden ? Permission.Check("problem.hidden.read", false,false) : Permission.Check("problem.read", true,false);

                canUpdate = problem.Lock ? Permission.Check("problem.locked.update", false, false) : Permission.Check("problem.update", false, false);

                ViewState["problemID"] = problem.ID;
                Page.DataBind();
            }
        }
    }
开发者ID:MooDevTeam,项目名称:MooOJ,代码行数:35,代码来源:Update.aspx.cs


示例16: grid_RowDeleting

    protected void grid_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        e.Cancel = true;

        int testCaseID = (int)e.Keys[0];
        using (MooDB db = new MooDB())
        {
            TestCase testCase = (from t in db.TestCases
                                 where t.ID == testCaseID
                                 select t).Single<TestCase>();
            bool allowed = Permission.Check("testcase.delete", false, false)
                   || User.Identity.IsAuthenticated && ((SiteUser)User.Identity).ID == testCase.CreatedBy.ID;
            if (!allowed)
            {
                Permission.Check("i'm superman.", false);
                return;
            }
            db.TestCases.DeleteObject(testCase);
            db.SaveChanges();

            Logger.Warning(db, "删除测试数据#" + testCase.ID);
        }

        grid.Rows[e.RowIndex].Visible = false;
    }
开发者ID:MooDevTeam,项目名称:MooOJ,代码行数:25,代码来源:List.aspx.cs


示例17: CollectEntityByRevision

 void CollectEntityByRevision(MooDB db, int id)
 {
     revision = (from r in db.SolutionRevisions
                 where r.ID == id
                 select r).SingleOrDefault<SolutionRevision>();
     problem = revision == null ? null : revision.Problem;
 }
开发者ID:MooDevTeam,项目名称:MooOJ,代码行数:7,代码来源:Default.aspx.cs


示例18: ValidateUserName

 protected void ValidateUserName(object sender, ServerValidateEventArgs e)
 {
     using (MooDB db = new MooDB())
     {
         e.IsValid = (from u in db.Users
                      where u.Name == txtUserName.Text
                      select u).SingleOrDefault<User>() == null;
     }
 }
开发者ID:MooDevTeam,项目名称:MooOJ,代码行数:9,代码来源:Register.aspx.cs


示例19: validateOtherName_ServerValidate

 protected void validateOtherName_ServerValidate(object source, ServerValidateEventArgs args)
 {
     using (MooDB db = new MooDB())
     {
         args.IsValid = (from u in db.Users
                         where u.Name == txtOtherName.Text
                         select u).Any();
     }
 }
开发者ID:MooDevTeam,项目名称:MooOJ,代码行数:9,代码来源:List.aspx.cs


示例20: grid_PageIndexChanging

 protected void grid_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     using (MooDB db = new MooDB())
     {
         grid.PageIndex = e.NewPageIndex;
         grid.DataSource = GetDataToBind(db);
         grid.DataBind();
     }
 }
开发者ID:MooDevTeam,项目名称:MooOJ,代码行数:9,代码来源:Default.aspx.cs



注:本文中的Moo.DB.MooDB类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# FileFormats.ItemTable类代码示例发布时间:2022-05-26
下一篇:
C# Monodoc.Tree类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap