public RandomExamComputerServer GetRandomExamComputerServer(int examid, int serverNo) { RandomExamComputerServer obj = new RandomExamComputerServer(); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("USP_Random_EXAM_Server_G"); db.AddInParameter(dbCommand, "p_exam_id", DbType.Int32, examid); db.AddInParameter(dbCommand, "p_server_no", DbType.Int32, serverNo); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { obj = CreateModelObject(dataReader); } } return(obj); }
protected void btnEnd_Click(object sender, EventArgs e) { string strId = Request.QueryString.Get("RandomExamID"); if (string.IsNullOrEmpty(strId)) { SessionSet.PageMessage = "缺少参数!"; return; } //获取当前考试的生成试卷的状态和次数 RandomExamBLL objBll = new RandomExamBLL(); RailExam.Model.RandomExam objExam = objBll.GetExam(Convert.ToInt32(strId)); RandomExamComputerServerBLL serverBll = new RandomExamComputerServerBLL(); RandomExamComputerServer server = serverBll.GetRandomExamComputerServer(objExam.RandomExamId, PrjPub.ServerNo); if (server.IsStart == 0) { if (objExam.EndTime >= DateTime.Today) { SessionSet.PageMessage = "当前考试还未开始考试!"; return; } } else if (server.IsStart == 2) { SessionSet.PageMessage = "当前考试已经结束!"; return; } ClientScript.RegisterStartupScript(GetType(), "jsSelectFirstNode", @"EndPaper();", true); }
protected void btnStop_Click(object sender, EventArgs e) { ViewState["EndTime"] = DateTime.Now.ToString(); //记录当前考试所在地的OrgID ViewState["OrgID"] = ConfigurationManager.AppSettings["StationID"]; string strId = Request.QueryString.Get("RandomExamID"); if (string.IsNullOrEmpty(strId)) { SessionSet.PageMessage = "缺少参数!"; return; } //获取当前考试的生成试卷的状态和次数 RandomExamBLL objBll = new RandomExamBLL(); RailExam.Model.RandomExam objExam = objBll.GetExam(Convert.ToInt32(strId)); RandomExamComputerServerBLL serverBll = new RandomExamComputerServerBLL(); RandomExamComputerServer server = serverBll.GetRandomExamComputerServer(objExam.RandomExamId, PrjPub.ServerNo); if (server.IsStart == 0) { if (objExam.EndTime >= DateTime.Today) { SessionSet.PageMessage = "当前考试还未开始考试!"; return; } } else if (server.IsStart == 2) { SessionSet.PageMessage = "当前考试已经结束!"; return; } RandomExamResultCurrentBLL objResultCurrentBll = new RandomExamResultCurrentBLL(); IList <RandomExamResultCurrent> objResultCurrent = objResultCurrentBll.GetStartRandomExamResultInfo(Convert.ToInt32(strId)); IList <RandomExamResultCurrent> objResultCurrentNew = new List <RandomExamResultCurrent>(); try { RandomExamResultBLL objResultBll = new RandomExamResultBLL(); foreach (RandomExamResultCurrent current in objResultCurrent) { current.CurrentDateTime = DateTime.Parse(ViewState["EndTime"].ToString()); current.ExamTime = GetSecondBetweenTwoDate(DateTime.Parse(ViewState["EndTime"].ToString()), current.BeginDateTime); current.EndDateTime = DateTime.Parse(ViewState["EndTime"].ToString()); current.Score = 0; current.OrganizationId = int.Parse(ViewState["OrgID"].ToString()); current.Memo = ""; //参加考试将当前考试的标志置为2-已经结束 current.StatusId = 2; current.AutoScore = 0; current.CorrectRate = 0; //objResultCurrentNew.Add(current); objResultCurrentBll.UpdateRandomExamResultCurrent(current); int randomExamResultID = objResultBll.RemoveResultAnswer(Convert.ToInt32(current.RandomExamResultId)); //int randomExamResultID = objResultBll.RemoveResultAnswerCurrent(Convert.ToInt32(current.RandomExamResultId)); try { OracleAccess dbPhoto = new OracleAccess(); string strSql = "select * from Random_Exam_Result_Detail where Random_Exam_Result_ID=" + randomExamResultID + " and Random_Exam_ID=" + current.RandomExamId; DataSet dsPhoto = dbPhoto.RunSqlDataSet(strSql); if (dsPhoto.Tables[0].Rows.Count > 0) { DataRow drPhoto = dsPhoto.Tables[0].Rows[0]; int employeeId = Convert.ToInt32(drPhoto["Employee_ID"]); if (drPhoto["FingerPrint"] != DBNull.Value) { Pub.SavePhotoToLocal(current.RandomExamId, employeeId, (byte[])drPhoto["FingerPrint"], 0, randomExamResultID); } if (drPhoto["Photo1"] != DBNull.Value) { Pub.SavePhotoToLocal(current.RandomExamId, employeeId, (byte[])drPhoto["Photo1"], 1, randomExamResultID); } if (drPhoto["Photo2"] != DBNull.Value) { Pub.SavePhotoToLocal(current.RandomExamId, employeeId, (byte[])drPhoto["Photo2"], 2, randomExamResultID); } if (drPhoto["Photo3"] != DBNull.Value) { Pub.SavePhotoToLocal(current.RandomExamId, employeeId, (byte[])drPhoto["Photo3"], 3, randomExamResultID); } } } catch { hfSql.Value = GetSql(); } } hfSql.Value = GetSql(); examsGrid.DataBind(); SystemLogBLL objLogBll = new SystemLogBLL(); objLogBll.WriteLog("“" + objExam.ExamName + "”终止正在进行的所有考试"); SessionSet.PageMessage = "终止当前考试成功!"; } catch { SessionSet.PageMessage = "终止当前考试失败!"; } }
protected void btnStart_Click(object sender, EventArgs e) { string strId = Request.QueryString.Get("RandomExamID"); if (string.IsNullOrEmpty(strId)) { SessionSet.PageMessage = "缺少参数!"; return; } //获取当前考试的生成试卷的状态和次数 RandomExamBLL objBll = new RandomExamBLL(); RailExam.Model.RandomExam objExam; objExam = objBll.GetExam(Convert.ToInt32(strId)); RandomExamComputerServerBLL serverBll = new RandomExamComputerServerBLL(); RandomExamComputerServer server = serverBll.GetRandomExamComputerServer(objExam.RandomExamId, PrjPub.ServerNo); if (!server.HasPaper) { SessionSet.PageMessage = "当前考试还未生成试卷,不能开始考试!"; return; } if (objExam.StartMode == 1) { SessionSet.PageMessage = "当前考试的开考模式为随到随考,不需要开始考试!"; return; } OracleAccess db = new OracleAccess(); string strSql = @"select * from Random_Exam_Result_Answer_Cur where Random_Exam_Result_ID in ( select Random_Exam_Result_ID from Random_Exam_Result_Current where Random_Exam_ID=" + objExam.RandomExamId + ")"; DataSet dsAnswer = db.RunSqlDataSet(strSql); if (dsAnswer.Tables[0].Rows.Count == 0) { SessionSet.PageMessage = "该考试试卷生成有误,请删除所有考生试卷后重新生成!"; return; } if (server.IsStart == 1) { SessionSet.PageMessage = "当前考试已经开考!"; return; } else if (server.IsStart == 2) { SessionSet.PageMessage = "当前考试已经结束!"; return; } ClientScript.RegisterStartupScript(GetType(), "jsSelectFirstNode", @"StartPaper();", true); //} }
protected void btnDelPaper_Click(object sender, EventArgs e) { string strId = Request.QueryString.Get("RandomExamID"); if (string.IsNullOrEmpty(strId)) { SessionSet.PageMessage = "缺少参数!"; return; } //获取当前考试的生成试卷的状态和次数 RandomExamBLL objBll = new RandomExamBLL(); RailExam.Model.RandomExam objExam = objBll.GetExam(Convert.ToInt32(strId)); RandomExamResultCurrentBLL objResultCurrentBll = new RandomExamResultCurrentBLL(); IList <RandomExamResultCurrent> objList = objResultCurrentBll.GetRandomExamResultInfo(Convert.ToInt32(strId)); int n = 0; foreach (RandomExamResultCurrent current in objList) { if (current.StatusId > 0) { n = 1; break; } } if (n > 0) { SessionSet.PageMessage = "当前考试有考生参加考试,不能再删除试卷!"; return; } RandomExamComputerServerBLL serverBll = new RandomExamComputerServerBLL(); RandomExamComputerServer server = serverBll.GetRandomExamComputerServer(objExam.RandomExamId, PrjPub.ServerNo); //if (!server.HasPaper) //{ // SessionSet.PageMessage = "当前考试还未生成试卷,不能删除试卷!"; // return; //} if (server.IsStart == 2) { SessionSet.PageMessage = "当前考试已经结束,不能再删除试卷!"; return; } try { objResultCurrentBll.DelRandomExamResultCurrent(Convert.ToInt32(strId)); objBll.UpdateHasPaper(Convert.ToInt32(strId), PrjPub.ServerNo, false); objBll.UpdateIsStart(Convert.ToInt32(strId), PrjPub.ServerNo, 0); if (objExam.StartMode == 2) { objBll.UpdateStartCode(Convert.ToInt32(strId), PrjPub.ServerNo, string.Empty); lblTitle.Visible = false; lblCode.Visible = false; btnApply.Visible = false; } SystemLogBLL objLogBll = new SystemLogBLL(); objLogBll.WriteLog("“" + objExam.ExamName + "”删除所有考试试卷"); SessionSet.PageMessage = "删除试卷成功!"; ClientScript.RegisterStartupScript(GetType(), "jsSelectFirstNode", @"refreshGrid();", true); } catch (Exception ex) { SessionSet.PageMessage = "删除试卷失败!"; Pub.ShowErrorPage(ex.Message); } }
protected void btnGetPaper_Click(object sender, EventArgs e) { string strId = Request.QueryString.Get("RandomExamID"); if (string.IsNullOrEmpty(strId)) { SessionSet.PageMessage = "缺少参数!"; return; } //获取当前考试的生成试卷的状态和次数 RandomExamBLL objBll = new RandomExamBLL(); RailExam.Model.RandomExam objExam = objBll.GetExam(Convert.ToInt32(strId)); if (!PrjPub.IsServerCenter) { int nowVersion = objBll.GetExamServer(Convert.ToInt32(strId)).Version; if (nowVersion != objExam.Version) { SessionSet.PageMessage = "当前考试版本与路局不匹配,请重新同步基础数据!"; return; } } if (objExam.EndTime < DateTime.Today) { SessionSet.PageMessage = "当前考试已过期,不能生成考试试卷!"; return; } RandomExamComputerServerBLL serverBll = new RandomExamComputerServerBLL(); RandomExamComputerServer server = serverBll.GetRandomExamComputerServer(objExam.RandomExamId, PrjPub.ServerNo); if (server.HasPaper) { SessionSet.PageMessage = "当前考试已生成试卷!"; return; } //获取当前考试的考生信息 RandomExamArrangeBLL eaBll = new RandomExamArrangeBLL(); IList <RailExam.Model.RandomExamArrange> ExamArranges = eaBll.GetRandomExamArranges(int.Parse(strId)); string strChooseID = ""; if (ExamArranges.Count > 0) { strChooseID = ExamArranges[0].UserIds; } else { strChooseID = ""; } string[] str = strChooseID.Split(','); if (str[0] == "") { SessionSet.PageMessage = "请为该考试添加考生!"; return; } ClientScript.RegisterStartupScript(GetType(), "jsSelectFirstNode", @"GetPaper();", true); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack && !searchExamCallBack.IsCallback) { //如果是系统管理员访问站段服务器则没有权限监控站段考试 if (!PrjPub.IsServerCenter && PrjPub.CurrentLoginUser.IsAdmin && PrjPub.CurrentLoginUser.RoleID == 1) { btnGetPaper.Enabled = false; btnDelPaper.Enabled = false; btnStart.Enabled = false; btnStop.Enabled = false; btnEnd.Enabled = false; btnUpload.Enabled = false; btnUploadScore.Enabled = false; HfUpdateRight.Value = "False"; } //if (PrjPub.IsWuhan()) //{ // examsGrid.Levels[0].Columns[3].HeadingText = "员工编码"; //} //else //{ // examsGrid.Levels[0].Columns[3].HeadingText = "工资编号"; //} if (PrjPub.IsServerCenter) { btnUpload.Enabled = false; btnUploadScore.Enabled = false; } //当前站段有两台服务器并且当前服务器为次服务器时屏蔽“删除所有考生试卷”和“上传考试成绩”按钮 //if(!PrjPub.IsServerCenter && PrjPub.HasTwoServer() && !PrjPub.IsMainServer()) //{ // btnGetPaper.Visible = false; // btnDelPaper.Visible = false; // btnUpload.Visible = false; //} hfOrgID.Value = ConfigurationManager.AppSettings["StationID"].ToString(); string strId = Request.QueryString.Get("RandomExamID"); RandomExamArrangeBLL objArrangeBll = new RandomExamArrangeBLL(); IList <RandomExamArrange> objArrangeList = objArrangeBll.GetRandomExamArranges(Convert.ToInt32(strId)); string[] str = { "0" }; hfNowCount.Value = "0"; if (objArrangeList.Count == 1) { string strSql = "select * from Random_Exam_Arrange_Detail a " + " inner join Computer_Room b on a.Computer_Room_ID=b.Computer_Room_ID" + " inner join Computer_Server c on b.Computer_Server_ID=c.Computer_Server_ID" + " where b.Org_ID='" + ConfigurationManager.AppSettings["StationID"] + "'" + " and c.Computer_Server_No='" + PrjPub.ServerNo + "'" + " and Random_Exam_ID=" + strId; OracleAccess db = new OracleAccess(); DataSet ds = db.RunSqlDataSet(strSql); string strUserId = ""; foreach (DataRow dr in ds.Tables[0].Rows) { if (string.IsNullOrEmpty(strUserId)) { strUserId += dr["User_Ids"].ToString(); } else { strUserId += "," + dr["User_Ids"]; } } strUserId = ("," + strUserId + ",").Replace(",0,", ","); str = ((strUserId.TrimStart(',')).TrimEnd(',')).Split(','); ExamBLL objexambll = new ExamBLL(); IList <RailExam.Model.Exam> objExamList = objexambll.GetExamsInfoByOrgID(null, -1, Convert.ToDateTime("0001-01-01"), Convert.ToDateTime("0001-01-01"), Convert.ToInt32(hfOrgID.Value), PrjPub.IsServerCenter.ToString()); foreach (RailExam.Model.Exam objExam in objExamList) { if (objExam.ExamId == Convert.ToInt32(strId)) { hfNowCount.Value = (str.Length - objExam.ExamineeCount).ToString(); break; } } } //获取当前考试的生成试卷的状态和次数 RandomExamBLL objBll = new RandomExamBLL(); RailExam.Model.RandomExam objRandomExam = objBll.GetExam(Convert.ToInt32(strId)); RandomExamComputerServerBLL serverBll = new RandomExamComputerServerBLL(); RandomExamComputerServer server = serverBll.GetRandomExamComputerServer(objRandomExam.RandomExamId, PrjPub.ServerNo); if (server.HasPaper && objRandomExam.StartMode == 2 && server.IsStart != 0) { lblTitle.Text = "考试验证码:"; lblCode.Text = server.RandomExamCode; btnApply.Visible = true; } if (server.HasPaper && server.IsStart != 2)// && !objRandomExam.HasTrainClass { btnAddEmployee.Visible = true; } if (PrjPub.CurrentLoginUser.EmployeeID != 0) { examsGrid.Levels[0].Columns[12].Visible = false; } } if (!searchExamCallBack.IsCallback) { hfSql.Value = GetSql(); examsGrid.DataBind(); } if (Request.Form.Get("OutPutRandom") != null && Request.Form.Get("OutPutRandom") != "") { OutputWord(Request.Form.Get("OutPutRandom")); } if (Request.Form.Get("StopExam") != null && Request.Form.Get("StopExam") != "") { StopExam(Request.Form.Get("StopExam")); } if (Request.Form.Get("DeleteExam") != null && Request.Form.Get("DeleteExam") != "") { DeleteExam(Request.Form.Get("DeleteExam")); } if (Request.Form.Get("ClearExam") != null && Request.Form.Get("ClearExam") != "") { ClearExam(Request.Form.Get("ClearExam")); } if (Request.Form.Get("ReplyExam") != null && Request.Form.Get("ReplyExam") != "") { ReplyExam(Request.Form.Get("ReplyExam")); } if (Request.Form.Get("IsGet") != null && Request.Form.Get("IsGet") != "") { hfSql.Value = GetSql(); examsGrid.DataBind(); string strId = Request.QueryString.Get("RandomExamID"); RandomExamBLL objBll = new RandomExamBLL(); RailExam.Model.RandomExam obj = objBll.GetExam(Convert.ToInt32(strId)); //if(!obj.HasTrainClass) //{ btnAddEmployee.Visible = true; //} SessionSet.PageMessage = "生成成功!"; } if (Request.Form.Get("IsEnd") != null && Request.Form.Get("IsEnd") != "") { hfSql.Value = GetSql(); examsGrid.DataBind(); SessionSet.PageMessage = "结束考试成功!"; } if (Request.Form.Get("IsUpload") != null && Request.Form.Get("IsUpload") != "") { hfSql.Value = GetSql(); examsGrid.DataBind(); string strId = Request.QueryString.Get("RandomExamID"); RandomExamBLL objBll = new RandomExamBLL(); RailExam.Model.RandomExam obj = objBll.GetExam(Convert.ToInt32(strId)); SystemLogBLL objLogBll = new SystemLogBLL(); objLogBll.WriteLog("“" + obj.ExamName + "”上传考试成绩和答卷"); SessionSet.PageMessage = "上传成功!"; } if (Request.Form.Get("IsStart") != null && Request.Form.Get("IsStart") != "") { hfSql.Value = GetSql(); examsGrid.DataBind(); SessionSet.PageMessage = "开始考试成功!"; string strId = Request.QueryString.Get("RandomExamID"); //获取当前考试的生成试卷的状态和次数 RandomExamBLL objBll = new RandomExamBLL(); RailExam.Model.RandomExam objExam = objBll.GetExam(Convert.ToInt32(strId)); RandomExamComputerServerBLL serverBll = new RandomExamComputerServerBLL(); RandomExamComputerServer server = serverBll.GetRandomExamComputerServer(objExam.RandomExamId, PrjPub.ServerNo); if (server.HasPaper && objExam.StartMode == 2) { lblCode.Text = "考试验证码:" + server.RandomExamCode; btnApply.Visible = true; } ClientScript.RegisterStartupScript(GetType(), "jsSelectFirstNode", @"ApplyExam();", true); } if (Request.Form.Get("StudentInfo") != null && Request.Form.Get("StudentInfo") != "" && !searchExamCallBack.IsCallback) { DownloadStudentInfoExcel(); } refreshGridCallback.RefreshInterval = Convert.ToInt32(ConfigurationManager.AppSettings["RefreshInterval"]); btnUpload.Visible = btnUploadScore.Visible = false; // 包神这里用不著上传 2014-03-18 }