Ejemplo n.º 1
0
        /// <summary>
        /// 处理学生不交卷,故障的情况
        /// </summary>
        public static void UpdateScoreStatus()
        {
            tbScoreBLL scoreBLL = new tbScoreBLL();

            while (true)
            {
                System.Threading.Thread.Sleep(1000 * 60 * 5);//每5分钟
                List <tbScore> list = scoreBLL.GetModelList("scorestatus=2");
                DateTime       dt   = DateTime.Now;
                foreach (tbScore item in list)
                {
                    int      duration = (int)DbHelperSQL.GetSingle("select durationtime from tbPaper,tbArrange where tbArrange.id=" + item.arrangeid + " and tbPaper.id=tbArrange.paperid");
                    TimeSpan ts       = dt - item.starttime;
                    if ((ts.Duration().TotalMinutes - (duration + 5)) > 0)//给5分钟的时间误差
                    {
                        item.scorestatus = 4;
                        scoreBLL.Update(item);
                    }
                }
            }
        }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        arrangeid = Convert.ToInt32(Request.QueryString["id"]);
        arrange   = arrangeBLL.GetModel(arrangeid);
        paper     = paperBLL.GetModel(arrange.paperid);
        subject   = subjectBLL.GetModel(arrange.subjectid);

        if (!IsPostBack)
        {
            //取得数据库连接
            SqlConnection conn = SQLHelper.GetConnection();
            //打开数据库连接
            conn.Open();
            //创建事务
            SqlTransaction SqlTransaction = conn.BeginTransaction();

            try
            {
                PaperGenerateDAL pgd = new PaperGenerateDAL(paper, SqlTransaction);
                pc = pgd.GetPaperContent();
                SqlTransaction.Commit();
            }
            catch (Exception)
            {
                try
                {
                    SqlTransaction.Rollback();
                }
                catch (Exception)
                {
                    //事务回滚出错
                }
            }
            finally
            {
                //关闭各种资源
                SqlTransaction.Dispose();
                conn.Close();
            }
            if (arrange.arrangetype == 2)
            {
                //考试,记录考试时间,成绩状态
                tbUser  user  = (tbUser)Session[Constant.User];
                tbScore score = this.GetScore(arrangeid, user.id);
                score.starttime   = DateTime.Now;
                score.scorestatus = 2;//正在考试
                scoreBLL.Update(score);

                //把scoreid存放在ViewState
                ViewState[Constant.ScoreID] = score.id;
            }
            if (pc.SRContent.Count != 0)
            {
                rptSR.DataSource = pc.SRContent;
                rptSR.DataBind();
            }

            if (pc.CBContent.Count != 0)
            {
                rptCB.DataSource = pc.CBContent;
                rptCB.DataBind();
            }

            if (pc.JDContent.Count != 0)
            {
                rptJD.DataSource = pc.JDContent;
                rptJD.DataBind();
            }

            if (pc.BFContent.Count != 0)
            {
                rptBF.DataSource = pc.BFContent;
                rptBF.DataBind();
            }

            if (pc.SAContent.Count != 0)
            {
                rptSA.DataSource = pc.SAContent;
                rptSA.DataBind();
            }
        }
    }