public ActionResult GetQuestionById(int id) { MODEL.T_Question model = OperateContext.Current.BLLSession.IQuestionBLL.GetListBy(q => q.ID == id).First(); MODEL.DTOModel.T_QuestionDTO modelDTO = model.ToDTO(); //如果是选择题,则需要查找选项 if (model.QuestionTypeID == 1) { List <MODEL.T_QuestionOption> qoList = OperateContext.Current.BLLSession .IQuestionOptionBLL.GetListBy(qo => qo.QuestionID == model.ID).ToList(); foreach (MODEL.T_QuestionOption qo in qoList) { modelDTO.T_QuestionOption.Add(qo.ToDTO()); } } MODEL.FormatModel.AjaxMsgModel jsonModel = new MODEL.FormatModel.AjaxMsgModel() { BackUrl = null, Data = modelDTO, Msg = "ok", Statu = "ok" }; return(Json(jsonModel, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 8.0 获取试卷中的题目列表 /// </summary> public ActionResult GetPaperQuestionList(int id) { List <MODEL.T_Question> list = OperateContext.Current.BLLSession .IPaperQuestionBLL.GetListBy(p => p.PaperID == id) .Select(p => p.T_Question).OrderBy(p => p.QuestionTypeID).ToList(); //如果试卷中题目为空 if (list.Count == 0) { MODEL.FormatModel.AjaxMsgModel jsonModel = new MODEL.FormatModel.AjaxMsgModel() { Data = null, BackUrl = "", Statu = "null", Msg = "该试卷并没有题目~" }; return(Json(jsonModel, JsonRequestBehavior.AllowGet)); } else { //DTO格式数据 List <MODEL.DTOModel.T_QuestionDTO> listDTO = new List <MODEL.DTOModel.T_QuestionDTO>(); foreach (MODEL.T_Question q in list) { //DTO MODEL.DTOModel.T_QuestionDTO qDTO = q.ToDTO(); //简答题 if (q.QuestionTypeID == 2) { listDTO.Add(qDTO); } else if (q.QuestionTypeID == 1) { List <MODEL.T_QuestionOption> qoList = OperateContext.Current.BLLSession .IQuestionOptionBLL.GetListBy(qo => qo.QuestionID == q.ID).ToList(); foreach (MODEL.T_QuestionOption qo in qoList) { qDTO.T_QuestionOption.Add(qo.ToDTO()); } listDTO.Add(qDTO); } } //返回JSON MODEL.FormatModel.AjaxMsgModel jsonModel = new MODEL.FormatModel.AjaxMsgModel() { Data = listDTO, BackUrl = "", Statu = "ok", Msg = "ok" }; return(Json(jsonModel, JsonRequestBehavior.AllowGet)); } }
//---------------------------------------------3.0 公用操作方法-------------------- #region 3.1 生成 Json 格式的返回值 +ActionResult RedirectAjax(string statu, string msg, object data, string backurl) /// <summary> /// 生成 Json 格式的返回值 /// </summary> /// <param name="statu"></param> /// <param name="msg"></param> /// <param name="data"></param> /// <param name="backurl"></param> /// <returns></returns> public ActionResult RedirectAjax(string statu, string msg, object data, string backurl) { MODEL.FormatModel.AjaxMsgModel ajax = new MODEL.FormatModel.AjaxMsgModel() { Statu = statu, Msg = msg, Data = data, BackUrl = backurl }; JsonResult res = new JsonResult(); res.Data = ajax; return(res); }
///// #region 5.0 加载出卷人信息 +GetProducerInfo() /// <summary> /// 5.0 加载出卷人信息 /// </summary> public ActionResult GetProducerInfo() { //并转为DTO格式 List <MODEL.DTOModel.T_TeacherInfoDTO> list = OperateContext.Current.BLLSession.ITeacherInfoBLL.GetListBy(ti => ti.ID > 0) .Select(ti => ti.ToDTO()).ToList(); MODEL.FormatModel.AjaxMsgModel jsonModel = new MODEL.FormatModel.AjaxMsgModel() { Data = list, BackUrl = "", Msg = "ok", Statu = "ok" }; return(Json(jsonModel, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 生成 Json 格式的返回值 /// </summary> /// <param name="statu"></param> /// <param name="msg"></param> /// <param name="data"></param> /// <param name="backurl"></param> /// <returns></returns> public ActionResult RedirectAjax(string statu, string msg, object data, string backurl) { MODEL.FormatModel.AjaxMsgModel ajax = new MODEL.FormatModel.AjaxMsgModel() { Statu = statu, Msg = msg, Data = data, BackUrl = backurl }; JsonResult res = new JsonResult(); res.JsonRequestBehavior = JsonRequestBehavior.AllowGet; res.Data = ajax; return res; }
/// <summary> /// 5.0 加载出卷人信息 /// </summary> public ActionResult GetProducerInfo() { //并转为DTO格式 List<MODEL.DTOModel.T_TeacherInfoDTO> list = OperateContext.Current.BLLSession.ITeacherInfoBLL.GetListBy(ti => ti.ID > 0) .Select(ti => ti.ToDTO()).ToList(); MODEL.FormatModel.AjaxMsgModel jsonModel = new MODEL.FormatModel.AjaxMsgModel() { Data = list, BackUrl = "", Msg = "ok", Statu = "ok" }; return Json(jsonModel, JsonRequestBehavior.AllowGet); }
/// <summary> /// 8.0 获取试卷中的题目列表 /// </summary> public ActionResult GetPaperQuestionList(int id) { List<MODEL.T_Question> list = OperateContext.Current.BLLSession .IPaperQuestionBLL.GetListBy(p => p.PaperID == id) .Select(p => p.T_Question).OrderBy(p => p.QuestionTypeID).ToList(); //如果试卷中题目为空 if (list.Count == 0) { MODEL.FormatModel.AjaxMsgModel jsonModel = new MODEL.FormatModel.AjaxMsgModel() { Data = null, BackUrl = "", Statu = "null", Msg = "该试卷并没有题目~" }; return Json(jsonModel, JsonRequestBehavior.AllowGet); } else { //DTO格式数据 List<MODEL.DTOModel.T_QuestionDTO> listDTO = new List<MODEL.DTOModel.T_QuestionDTO>(); foreach (MODEL.T_Question q in list) { //DTO MODEL.DTOModel.T_QuestionDTO qDTO = q.ToDTO(); //简答题 if (q.QuestionTypeID == 2) { listDTO.Add(qDTO); } else if (q.QuestionTypeID == 1) { List<MODEL.T_QuestionOption> qoList = OperateContext.Current.BLLSession .IQuestionOptionBLL.GetListBy(qo => qo.QuestionID == q.ID).ToList(); foreach (MODEL.T_QuestionOption qo in qoList) { qDTO.T_QuestionOption.Add(qo.ToDTO()); } listDTO.Add(qDTO); } } //返回JSON MODEL.FormatModel.AjaxMsgModel jsonModel = new MODEL.FormatModel.AjaxMsgModel() { Data = listDTO, BackUrl = "", Statu = "ok", Msg = "ok" }; return Json(jsonModel, JsonRequestBehavior.AllowGet); } }
/// <summary> /// 4.0 GetModelById /// </summary> public ActionResult GetModelById() { int id = int.Parse(Request.QueryString["id"]); MODEL.T_Question model = OperateContext.Current.BLLSession.IQuestionBLL.GetListBy(q => q.ID == id).First(); MODEL.DTOModel.T_QuestionDTO modelDTO = model.ToDTO(); //如果是选择题,则需要查找选项 if (model.QuestionTypeID == 1) { List<MODEL.T_QuestionOption> qoList = OperateContext.Current.BLLSession .IQuestionOptionBLL.GetListBy(qo => qo.QuestionID == model.ID).ToList(); foreach (MODEL.T_QuestionOption qo in qoList) { modelDTO.T_QuestionOption.Add(qo.ToDTO()); } } MODEL.FormatModel.AjaxMsgModel jsonModel = new MODEL.FormatModel.AjaxMsgModel() { BackUrl = null, Data = modelDTO, Msg = "ok", Statu = "ok" }; return Json(jsonModel, JsonRequestBehavior.AllowGet); }
/// <summary> /// 6.0 获取简答题答卷 /// </summary> public ActionResult GetBriefAnswerSheet() { int id = int.Parse(Request.Params["id"]); //根据答卷ID找到对应的简答题答卷记录 List<MODEL.T_BriefAnswerSheet> basList = OperateContext.Current.BLLSession .IBriefAnswerSheetBLL.GetListBy(b => b.AnswerSheetID == id).ToList(); //转为DTO List<MODEL.DTOModel.T_BriefAnswerSheetDTO> bDTO = new List<MODEL.DTOModel.T_BriefAnswerSheetDTO>(); foreach (MODEL.T_BriefAnswerSheet b in basList) { bDTO.Add(b.ToDTO()); } //查找题目对象 foreach (MODEL.DTOModel.T_BriefAnswerSheetDTO b in bDTO) { b.Question = OperateContext.Current.BLLSession .IQuestionBLL.GetListBy(q => q.ID == b.QuestionID).FirstOrDefault().ToDTO(); } //转为jsonModel MODEL.FormatModel.AjaxMsgModel jsonModel = new MODEL.FormatModel.AjaxMsgModel() { Data = bDTO, BackUrl = "", Msg = "ok", Statu = "ok" }; return Json(jsonModel, JsonRequestBehavior.AllowGet); }
/// <summary> /// 9.0 导出Excel(有错) /// </summary> public ActionResult ToWord() { //整理要导出面试者的ID string pageIndexNow = Request.Params["pageIndex"]; string idArrStrOrigin = Request.Params["idArr"]; int id = int.Parse(pageIndexNow); string[] idArrStr = idArrStrOrigin.Split(','); int[] idArr = new int[idArrStr.Length - 1]; for (int i = 0; i < idArrStr.Length; i++) { if (idArrStr[i] != "") idArr[i] = int.Parse(idArrStr[i]); } if (CreateWord(Response, Request, idArr) > 0) { //Response.Write(" <script type='text/javascript'>alert('导入成功!')</script>"); //return Redirect("/JoinUs/AnswerSheet/Index/" + id); MODEL.FormatModel.AjaxMsgModel jsonModel = new MODEL.FormatModel.AjaxMsgModel() { Data = "导出成功", BackUrl = "", Msg = "ok", Statu = "ok" }; return Json(jsonModel, JsonRequestBehavior.AllowGet); } else { MODEL.FormatModel.AjaxMsgModel jsonModel = new MODEL.FormatModel.AjaxMsgModel() { Data = "导出失败", BackUrl = "", Msg = "ok", Statu = "ok" }; return Json(jsonModel, JsonRequestBehavior.AllowGet); } }
/// <summary> /// 11.0 获取试卷中的题目列表 /// </summary> public ActionResult GetPaperList(int id) { MODEL.T_AnswerSheet modelanswer = OperateContext.Current.BLLSession.IAnswerSheetBLL .GetListBy(p => p.ID == id).First(); int interviewId = modelanswer.InterviewerID; int paperId = modelanswer.PaperID; List<MODEL.T_Question> list = OperateContext.Current.BLLSession .IPaperQuestionBLL.GetListBy(p => p.PaperID == paperId) .Select(p => p.T_Question).OrderBy(p => p.QuestionTypeID).ToList(); if (list.Count == 0) { MODEL.FormatModel.AjaxMsgModel jsonModel = new MODEL.FormatModel.AjaxMsgModel() { Data = null, BackUrl = "", Statu = "null", Msg = "该试卷信息已删除~" }; return Json(jsonModel, JsonRequestBehavior.AllowGet); } else { //DTO格式数据 List<MODEL.DTOModel.T_QuestionDTO> listDTO = new List<MODEL.DTOModel.T_QuestionDTO>(); int cout = 0; foreach (MODEL.T_Question q in list) { //DTO MODEL.DTOModel.T_QuestionDTO qDTO = q.ToDTO(); //简答题 if (q.QuestionTypeID == 2) { cout++; listDTO.Add(qDTO); //查找题目对象 MODEL.T_BriefAnswerSheet model = OperateContext.Current.BLLSession.IBriefAnswerSheetBLL .GetListBy(t => t.AnswerSheetID == id && t.QuestionID == q.ID).First(); foreach (MODEL.DTOModel.T_QuestionDTO b in listDTO) { b.BriefAnswerSheet = OperateContext.Current.BLLSession .IBriefAnswerSheetBLL.GetListBy(t => t.AnswerSheetID == id && t.QuestionID == q.ID).FirstOrDefault().ToDTO(); b.BriefScore = OperateContext.Current.BLLSession .IBriefScoreBLL.GetListBy(t => t.BriefAnswerSheetID == model.ID).FirstOrDefault().ToDTO(); List<MODEL.T_BriefScore> listb = OperateContext.Current.BLLSession.IBriefScoreBLL .GetListBy(qo => qo.BriefAnswerSheetID == model.ID).ToList(); int i = 0; foreach (MODEL.T_BriefScore m in listb) { if (i == 0) { qDTO.ScoreF = m.Score; qDTO.TeacherF = m.UserB; } if (i == 1) { qDTO.ScoreS = m.Score; qDTO.TeacherS = m.UserB; } if (i == 2) { qDTO.ScoreT = m.Score; qDTO.TeacherT = m.UserB; } i++; } } } else if (q.QuestionTypeID == 1) { cout++; List<MODEL.T_QuestionOption> qoList = OperateContext.Current.BLLSession .IQuestionOptionBLL.GetListBy(qo => qo.QuestionID == q.ID).ToList(); foreach (MODEL.T_QuestionOption qo in qoList) { qDTO.T_QuestionOption.Add(qo.ToDTO()); } listDTO.Add(qDTO); foreach (MODEL.DTOModel.T_QuestionDTO b in listDTO) { b.ChoiceAnswerSheet = OperateContext.Current.BLLSession .IChoiceAnswerSheetBLL.GetListBy(t => t.AnswerSheetID == id && t.QuestionID == q.ID).FirstOrDefault().ToDTO(); } } if (cout == list.Count) { foreach (MODEL.DTOModel.T_QuestionDTO b in listDTO) { b.AnswerSheetComment = OperateContext.Current.BLLSession .IAnswerSheetCommentBLL.GetListBy(t => t.AnswerSheetID == id).FirstOrDefault().ToDTO(); } } } //返回JSON MODEL.FormatModel.AjaxMsgModel jsonModel = new MODEL.FormatModel.AjaxMsgModel() { Data = listDTO, BackUrl = "", Statu = "ok", Msg = "ok" }; return Json(jsonModel, JsonRequestBehavior.AllowGet); } }
/// <summary> /// 3.0 GetModelById /// </summary> public ActionResult GetModelById(int id) { //根据ID获取面试者的详细信息 MODEL.T_InterviewerInfo model = OperateContext.Current.BLLSession .IInterviewerInfoBLL.GetListBy(ii => ii.ID == id).First(); //返回json信息 MODEL.FormatModel.AjaxMsgModel jsonModel = new MODEL.FormatModel.AjaxMsgModel() { Data = model.ToDTO(), BackUrl = "", Msg = "成功", Statu = "ok" }; return Json(jsonModel, JsonRequestBehavior.AllowGet); }