private void GetPaperAfter() { // 根据 ProgressBar.htm 显示进度条界面 string templateFileName = Path.Combine(Server.MapPath("."), "ProgressBar.htm"); StreamReader reader = new StreamReader(@templateFileName, System.Text.Encoding.GetEncoding("gb2312")); string html = reader.ReadToEnd(); reader.Close(); Response.Write(html); Response.Flush(); System.Threading.Thread.Sleep(200); ViewState["BeginTime"] = DateTime.Now.ToString(); string strId = Request.QueryString.Get("RandomExamID"); //获取当前考试的生成试卷的状态和次数 RandomExamBLL objBll = new RandomExamBLL(); RailExam.Model.RandomExam obj = objBll.GetExam(Convert.ToInt32(strId)); int year = obj.BeginTime.Year; int ExamCount = obj.MaxExamTimes; System.Threading.Thread.Sleep(10); string jsBlock = "<script>SetPorgressBar('正在计算生成试卷数量,请等待......','" + ((1 * 100) / ((double)1) + "'); </script>"); Response.Write(jsBlock); Response.Flush(); if (!PrjPub.IsServerCenter) { RandomExamArrangeBLL objArrangeBll = new RandomExamArrangeBLL(); objArrangeBll.RefreshRandomExamArrange(); } //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 = ""; //} //RandomExamResultCurrentBLL objResultCurrentBll = new RandomExamResultCurrentBLL(); //IList<RandomExamResultCurrent> examResults = objResultCurrentBll.GetRandomExamResultInfo(Convert.ToInt32(strId)); //for (int i = 0; i < examResults.Count; i++) //{ // strChooseID = ("," + strChooseID + ",").Replace("," + examResults[i].ExamineeId + ",", ","); //} //strChooseID = strChooseID.TrimStart(',').TrimEnd(','); string strChooseID = Request.QueryString.Get("addIds"); if (strChooseID == string.Empty) { return; } string[] str = strChooseID.Split('|'); System.Threading.Thread.Sleep(10); jsBlock = "<script>SetPorgressBar('正在计算生成试卷数量,请等待......','" + ((2 * 100) / ((double)2) + "'); </script>"); Response.Write(jsBlock); Response.Flush(); OracleAccess db = new OracleAccess(); string strSql; RandomExamResultAnswerCurrentBLL randomExamResultAnswerBLL = new RandomExamResultAnswerCurrentBLL(); //定义全局答卷对象List IList <RandomExamResultAnswerCurrent> randomExamResultAnswersCurrentAll = new List <RandomExamResultAnswerCurrent>(); //定义一个考生一次答卷对象List IList <RandomExamResultAnswerCurrent> randomExamResultAnswers = null; System.Threading.Thread.Sleep(200); jsBlock = string.Empty; int progressNum = 1; for (int n = 1; n <= ExamCount; n++) { for (int m = 0; m < str.Length; m++) { RandomExamResultCurrentBLL randomExamResultBLL = new RandomExamResultCurrentBLL(); RandomExamResultCurrent randomExamResult = new RandomExamResultCurrent(); randomExamResult.RandomExamId = int.Parse(strId); randomExamResult.AutoScore = 0; randomExamResult.BeginDateTime = DateTime.Parse(ViewState["BeginTime"].ToString()); randomExamResult.CurrentDateTime = DateTime.Parse(ViewState["BeginTime"].ToString()); randomExamResult.ExamTime = 0; randomExamResult.EndDateTime = DateTime.Parse(ViewState["BeginTime"].ToString()); randomExamResult.Score = 0; randomExamResult.OrganizationId = int.Parse(ConfigurationManager.AppSettings["StationID"]); randomExamResult.Memo = ""; randomExamResult.StatusId = 0; randomExamResult.AutoScore = 0; randomExamResult.CorrectRate = 0; randomExamResult.ExamineeId = int.Parse(str[m]); randomExamResult.ExamSeqNo = n; int nRandomExamResultPK = randomExamResultBLL.AddRandomExamResultCurrent(randomExamResult); ViewState["RandomExamResultPK"] = nRandomExamResultPK; strSql = "select a.* from Random_Exam_Arrange_Detail a " + " where ','||User_Ids||',' like '%," + str[m] + ",%' " + " and Random_Exam_ID=" + strId; DataRow dr = db.RunSqlDataSet(strSql).Tables[0].Rows[0]; //strSql = "insert into Random_Exam_Result_Detail(Random_Exam_Result_Detail_ID," // + "Random_Exam_Result_ID,Random_Exam_ID,Employee_ID,Computer_Room_SEAT,Computer_Room_ID) " // + "values(Random_Exam_Result_Detail_SEQ.NextVal," // + nRandomExamResultPK + "," // + randomExamResult.RandomExamId + "," // + randomExamResult.ExamineeId + "," // + "0," + dr["Computer_Room_ID"] + ") "; //db.ExecuteNonQuery(strSql); strSql = "insert into Random_Exam_Result_Detail_Temp(Random_Exam_Result_Detail_ID," + "Random_Exam_Result_ID,Random_Exam_ID,Employee_ID,Computer_Room_SEAT,Computer_Room_ID,Is_Remove) " + "values(Random_Exam_Result_Detail_SEQ.NextVal," + nRandomExamResultPK + "," + randomExamResult.RandomExamId + "," + randomExamResult.ExamineeId + "," + "0," + dr["Computer_Room_ID"] + ",0) "; db.ExecuteNonQuery(strSql); RandomExamItemBLL randomItemBLL = new RandomExamItemBLL(); RandomExamSubjectBLL subjectBLL = new RandomExamSubjectBLL(); RandomExamStrategyBLL strategyBLL = new RandomExamStrategyBLL(); IList <RandomExamSubject> randomExamSubjects = subjectBLL.GetRandomExamSubjectByRandomExamId(int.Parse(strId)); if (randomExamSubjects != null) { Hashtable hashTableItemIds = new Hashtable(); Hashtable htSubjectItemIds = new Hashtable(); for (int i = 0; i < randomExamSubjects.Count; i++) { RandomExamSubject paperSubject = randomExamSubjects[i]; int nSubjectId = paperSubject.RandomExamSubjectId; // int nItemCount = paperSubject.ItemCount; IList <RandomExamStrategy> strategys = strategyBLL.GetRandomExamStrategys(nSubjectId); for (int j = 0; j < strategys.Count; j++) { int nStrategyId = strategys[j].RandomExamStrategyId; int nItemCount = strategys[j].ItemCount; IList <RandomExamItem> itemList = randomItemBLL.GetItemsByStrategyId(nStrategyId, year); // IList<RandomExamItem> itemList = randomItemBLL.GetItemsBySubjectId(nSubjectId); Random ObjRandom = new Random(); Hashtable hashTable = new Hashtable(); Hashtable hashTableCount = new Hashtable(); int index = 0; while (hashTable.Count < nItemCount) { int k = ObjRandom.Next(itemList.Count); hashTableCount[index] = k; index = index + 1; int itemID = itemList[k].ItemId; int examItemID = itemList[k].RandomExamItemId; if (!hashTableItemIds.ContainsKey(itemID)) { hashTable[examItemID] = examItemID; hashTableItemIds[itemID] = itemID; htSubjectItemIds[examItemID] = examItemID; } //if (hashTableCount.Count == itemList.Count && hashTable.Count < nItemCount) //{ // SessionSet.PageMessage = "随机考试在设定的取题范围内的试题量不够,请重新设置取题范围!"; // return; //} } } } randomExamResultAnswers = new List <RandomExamResultAnswerCurrent>(); foreach (int key in htSubjectItemIds.Keys) { string strItemId = htSubjectItemIds[key].ToString(); RandomExamItem item = randomItemBLL.GetRandomExamItem(Convert.ToInt32(strItemId), year); string nowSelectAnswer = string.Empty; string nowStandardAnswer = string.Empty; if (item.TypeId != PrjPub.ITEMTYPE_FILLBLANK) { Pub.GetNowAnswer(item, out nowSelectAnswer, out nowStandardAnswer); } RandomExamResultAnswerCurrent randomExamResultAnswer = new RandomExamResultAnswerCurrent(); randomExamResultAnswer.RandomExamResultId = nRandomExamResultPK; randomExamResultAnswer.RandomExamItemId = int.Parse(strItemId); randomExamResultAnswer.JudgeStatusId = 0; randomExamResultAnswer.JudgeRemark = string.Empty; randomExamResultAnswer.ExamTime = 0; randomExamResultAnswer.Answer = string.Empty; randomExamResultAnswer.SelectAnswer = nowSelectAnswer; randomExamResultAnswer.StandardAnswer = nowStandardAnswer; randomExamResultAnswerBLL.AddExamResultAnswerCurrent(randomExamResultAnswer); //完型填空子题 IList <RandomExamItem> randomExamItems = randomItemBLL.GetItemsByParentItemID(item.ItemId, obj.RandomExamId, year); foreach (RandomExamItem randomExamItem in randomExamItems) { Pub.GetNowAnswer(randomExamItem, out nowSelectAnswer, out nowStandardAnswer); randomExamResultAnswer = new RandomExamResultAnswerCurrent(); randomExamResultAnswer.RandomExamResultId = nRandomExamResultPK; randomExamResultAnswer.RandomExamItemId = randomExamItem.RandomExamItemId; randomExamResultAnswer.JudgeStatusId = 0; randomExamResultAnswer.JudgeRemark = string.Empty; randomExamResultAnswer.ExamTime = 0; randomExamResultAnswer.Answer = string.Empty; randomExamResultAnswer.SelectAnswer = nowSelectAnswer; randomExamResultAnswer.StandardAnswer = nowStandardAnswer; randomExamResultAnswerBLL.AddExamResultAnswerCurrent(randomExamResultAnswer); } System.Threading.Thread.Sleep(10); jsBlock = "<script>SetPorgressBar('正在生成试卷,请等待......','" + ((progressNum * 100) / ((double)ExamCount * str.Length * htSubjectItemIds.Count)).ToString("0.00") + "'); </script>"; Response.Write(jsBlock); Response.Flush(); progressNum++; } } else { SessionSet.PageMessage = "未找到记录!"; } } } //临时添加考生无需更改考试状态,因为考试状态肯定是正在进行和生成试卷 //objBll.UpdateHasPaper(Convert.ToInt32(strId), PrjPub.ServerNo, true); ////如果考试是随到随考,考试状态自动变为正在进行 //if (obj.StartMode == 1) //{ // objBll.UpdateIsStart(Convert.ToInt32(strId), PrjPub.ServerNo, 1); //} SystemLogBLL objLogBll = new SystemLogBLL(); objLogBll.WriteLog("“" + obj.ExamName + "”生成新增考生试卷"); Response.Write("<script>top.returnValue='true';top.close();</script>"); }
protected void ButtonOutPut_Click(object sender, EventArgs e) { string strAllId = ViewState["ChooseId"].ToString(); if (strAllId == "") { return; } string strOldAllId = "," + strAllId + ","; string strRemove = string.Empty; for (int i = 0; i < this.gvChoose.Rows.Count; i++) { CheckBox CheckBox1 = (CheckBox)this.gvChoose.Rows[i].FindControl("chkSelect2"); string strEmId = ((Label)this.gvChoose.Rows[i].FindControl("LabelEmployeeID")).Text; if (CheckBox1.Checked) { strOldAllId = strOldAllId.Replace(strEmId + ",", ""); if (strRemove == string.Empty) { strRemove = strEmId; } else { strRemove += "," + strEmId; } } } int n = strOldAllId.Length; if (n == 1) { ViewState["ChooseId"] = ""; } else { ViewState["ChooseId"] = strOldAllId.Substring(1, n - 2); } //移除考生需要清楚考生安排明细 string strID = ViewState["ExamID"].ToString(); OracleAccess db = new OracleAccess(); //查询当前考试所有考生安排明细 string strSql = "select * from Random_Exam_Arrange_Detail where Random_Exam_ID=" + strID; DataSet dsOther = db.RunSqlDataSet(strSql); //遍历当前需要移除的考生信息,查询考生安排明细是否存在当前需要移除的考生,如果存在则需修改去除该考生 string[] str = strRemove.ToString().Split(','); for (int i = 0; i < str.Length; i++) { string strReplace = "," + str[i] + ","; DataRow[] drs = dsOther.Tables[0].Select("','+User_Ids+',' like '%" + strReplace + "%'"); if (drs.Length > 0) { strSql = "update Random_Exam_Arrange_Detail " + "set User_ids = substr(Replace(','||User_ids||',','" + strReplace + "',','),2,length(Replace(','||User_ids||',','" + strReplace + "',','))-2) " + "where ','|| User_ids || ',' like '%" + strReplace + "%' and Random_Exam_ID=" + strID; if (PrjPub.IsServerCenter) { db.ExecuteNonQuery(strSql); } else { string strConn = ConfigurationManager.ConnectionStrings["OracleCenter"].ConnectionString; OracleAccess dbCenter = new OracleAccess(strConn); dbCenter.ExecuteNonQuery(strSql); RandomExamArrangeBLL objBll = new RandomExamArrangeBLL(); objBll.RefreshRandomExamArrange(); } } hfAddIds.Value = ("," + (hfAddIds.Value.Replace("|", ",")) + ",").Replace(strReplace, ",").TrimStart(',').TrimEnd(',').Replace(",", "|"); } BindChoosedGrid(ViewState["ChooseId"].ToString()); SaveChoose(); }
protected void btnCancel_Click(object sender, EventArgs e) { //移除考生需要清楚考生安排明细 string strID = ViewState["ExamID"].ToString(); OracleAccess db = new OracleAccess(); //查询当前考试所有考生安排明细 string strSql = "select * from Random_Exam_Arrange_Detail where Random_Exam_ID=" + strID; DataSet dsOther = db.RunSqlDataSet(strSql); //遍历当前需要移除的考生信息,查询考生安排明细是否存在当前需要移除的考生,如果存在则需修改去除该考生 string[] str = ViewState["AddIds"].ToString().Split('|'); for (int i = 0; i < str.Length; i++) { string strReplace = "," + str[i] + ","; DataRow[] drs = dsOther.Tables[0].Select("','+User_Ids+',' like '%" + strReplace + "%'"); if (drs.Length > 0) { strSql = "update Random_Exam_Arrange_Detail " + "set User_ids = substr(Replace(','||User_ids||',','" + strReplace + "',','),2,length(Replace(','||User_ids||',','" + strReplace + "',','))-2) " + "where ','|| User_ids || ',' like '%" + strReplace + "%' and Random_Exam_ID=" + strID; if (PrjPub.IsServerCenter) { db.ExecuteNonQuery(strSql); } else { string strConn = ConfigurationManager.ConnectionStrings["OracleCenter"].ConnectionString; OracleAccess dbCenter = new OracleAccess(strConn); dbCenter.ExecuteNonQuery(strSql); RandomExamArrangeBLL objBll = new RandomExamArrangeBLL(); objBll.RefreshRandomExamArrange(); } } } //查询考试在当前站段考试的考生信息 strSql = "select a.* from Random_Exam_Arrange_Detail a " + " inner join Computer_Room b on a.Computer_Room_ID=b.Computer_Room_ID" + " where Random_Exam_ID=" + ViewState["ExamID"]; DataSet ds = db.RunSqlDataSet(strSql); string strEndId = string.Empty; foreach (DataRow dr in ds.Tables[0].Rows) { if (strEndId.Length == 0) { strEndId += dr["User_Ids"].ToString(); } else { strEndId += "," + dr["User_Ids"]; } } RandomExamArrangeBLL examArrangeBLL = new RandomExamArrangeBLL(); if (!PrjPub.IsServerCenter) { examArrangeBLL.UpdateRandomExamArrangeToServer(int.Parse(ViewState["ExamID"].ToString()), strEndId); } else { examArrangeBLL.UpdateRandomExamArrange(int.Parse(ViewState["ExamID"].ToString()), strEndId); } Response.Write("<script>top.returnValue ='true';top.close();</script>"); }
protected void SaveChoose() { string strId = Request.QueryString.Get("id"); string strEndId = ViewState["ChooseId"].ToString(); if (strEndId == "") { strEndId = "0"; } else { RandomExamBLL objBll = new RandomExamBLL(); RailExam.Model.RandomExam random = objBll.GetExam(int.Parse(strId)); if (random.RandomExamModularTypeID > 1) { OracleAccess db = new OracleAccess(); string strSql = "select * from Random_Exam_Modular_Type where Random_Exam_Modular_Type_ID=" + random.RandomExamModularTypeID; DataRow dr = db.RunSqlDataSet(strSql).Tables[0].Rows[0]; strSql = "select * from Random_Exam_Modular_Type where Level_Num=" + (Convert.ToInt32(dr["Level_NUM"]) - 1); DataRow drPre = db.RunSqlDataSet(strSql).Tables[0].Rows[0]; strSql = " select a.* " + "from Random_Exam_Result a " + " inner join Random_Exam b on a.Random_Exam_ID=b.Random_Exam_ID " + " left join Random_Exam_Modular_Type c on b.Random_Exam_Modular_Type_ID=c.Random_Exam_Modular_Type_ID " + " where c.Level_Num=" + (Convert.ToInt32(dr["Level_NUM"]) - 1); DataSet ds = db.RunSqlDataSet(strSql); strSql = "select * from Employee where Employee_ID in (" + strEndId + ")"; DataSet dsEmp = db.RunSqlDataSet(strSql); string[] str = strEndId.Split(','); string strErrorMessage = string.Empty; for (int i = 0; i < str.Length; i++) { DataRow[] drs = ds.Tables[0].Select("EXAMINEE_ID=" + str[i]); if (drs.Length == 0) { DataRow[] drsEmp = dsEmp.Tables[0].Select("Employee_ID=" + str[i]); strErrorMessage = "所选考生【" + drsEmp[0]["Employee_Name"] + "】未能通过【" + drPre["Random_Exam_Modular_Type_Name"] + "】考试,不能参加【" + dr["Random_Exam_Modular_Type_Name"] + "】考试!"; break; } } if (!string.IsNullOrEmpty(strErrorMessage)) { SessionSet.PageMessage = strErrorMessage; return; } } } if (ViewState["UpdateMode"] != null && ViewState["UpdateMode"].ToString() == "0") { RandomExamArrangeBLL examArrangeBLL = new RandomExamArrangeBLL(); IList <RandomExamArrange> objList = examArrangeBLL.GetRandomExamArranges(int.Parse(strId)); if (objList.Count == 0) { RandomExamArrange examArrange = new RandomExamArrange(); examArrange.RandomExamId = int.Parse(strId); examArrange.UserIds = strEndId; examArrange.Memo = ""; if (!string.IsNullOrEmpty(Request.QueryString.Get("selectType")) && !PrjPub.IsServerCenter) { examArrangeBLL.AddRandomExamArrangeToServer(examArrange); } else { examArrangeBLL.AddRandomExamArrange(examArrange); } ViewState["UpdateMode"] = 1; if (!string.IsNullOrEmpty(Request.QueryString.Get("selectType"))) { Response.Write("<script>alert('添加成功!');window.opener.form1.Refresh.value='true';window.opener.form1.submit();window.close();</script>"); } else { string strSql = ""; OracleAccess db = new OracleAccess(); strSql = "update Random_Exam set Is_All_Arrange = 0 where Random_Exam_ID=" + strId; db.ExecuteNonQuery(strSql); SessionSet.PageMessage = "添加成功!"; return; } } else { ViewState["UpdateMode"] = "1"; } } if (ViewState["UpdateMode"] != null && ViewState["UpdateMode"].ToString() == "1") { RandomExamArrangeBLL examArrangeBLL = new RandomExamArrangeBLL(); IList <RandomExamArrange> objList = examArrangeBLL.GetRandomExamArranges(int.Parse(strId)); string strNew = objList[0].UserIds; string[] str = strEndId.Split(','); for (int i = 0; i < str.Length; i++) { if (("," + strNew + ",").IndexOf("," + str[i] + ",") < 0) { strNew += strNew == string.Empty ? str[i] : "," + str[i]; } } if (!string.IsNullOrEmpty(Request.QueryString.Get("selectType"))) { //examArrangeBLL.UpdateRandomExamArrangeToServer(int.Parse(strId), strAdd); string strAddIds = string.Empty; for (int i = 0; i < str.Length; i++) { if (("," + objList[0].UserIds + ",").IndexOf("," + str[i] + ",") < 0) { strAddIds += strAddIds == string.Empty ? str[i] : "," + str[i]; } } OracleAccess db = new OracleAccess(); OracleAccess dbCenter = new OracleAccess(System.Configuration.ConfigurationManager.ConnectionStrings["OracleCenter"].ConnectionString); XmlDocument doc = new XmlDocument(); //Request.PhysicalApplicationPath取得config文件路径 doc.Load(Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, "web.config")); XmlNode node = doc.SelectSingleNode("configuration/dataConfiguration/@defaultDatabase"); string value = node.Value; if (value == "Oracle") { OracleParameter para1 = new OracleParameter("p_User_Ids", OracleType.Clob); OracleParameter para2 = new OracleParameter("p_random_Exam_ID", OracleType.Number); para2.Value = int.Parse(strId); IDataParameter[] paras = new IDataParameter[] { para1, para2 }; examArrangeBLL.RunUpdateProcedure(true, "USP_random_Exam_Arrange_U", paras, System.Text.Encoding.Unicode.GetBytes(strEndId)); } string strSql = "select a.* 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 c.Computer_server_ID=b.Computer_Server_ID" + " where c.Computer_Server_No='" + PrjPub.ServerNo + "' " + " and Random_Exam_ID=" + strId; DataSet ds = db.RunSqlDataSet(strSql); strSql = "update Random_Exam_Arrange_Detail " + "set User_ids = User_ids || '," + strAddIds + "' " + "where Random_Exam_Arrange_Detail_ID =" + ds.Tables[0].Rows[0]["Random_Exam_Arrange_Detail_ID"]; dbCenter.ExecuteNonQuery(strSql); if (!PrjPub.IsServerCenter) { examArrangeBLL.RefreshRandomExamArrange(); } } else { examArrangeBLL.UpdateRandomExamArrange(int.Parse(strId), strNew); } if (!string.IsNullOrEmpty(Request.QueryString.Get("selectType"))) { //SessionSet.PageMessage = "添加成功!"; Response.Write("<script>alert('添加成功!');window.opener.form1.Refresh.value='true';window.opener.form1.submit();window.close();</script>"); } else { string strSql = ""; OracleAccess db = new OracleAccess(); strSql = "update Random_Exam set Is_All_Arrange = 0 where Random_Exam_ID=" + strId; db.ExecuteNonQuery(strSql); SessionSet.PageMessage = "添加成功!"; return; } } }