public HttpResponseMessage ConfirmStudent([FromBody] ExamID m) { var eInfo = MongoDbHelper.FindOne <E_Info>(m.ID, DbName.E_Info); eInfo.stcfm = 1; MongoDbHelper.ReplaceOne(m.ID, eInfo, DbName.E_Info); return(ResultHelper.OK()); }
public HttpResponseMessage ImportScore([FromBody] ExamID m) { try { var exam = MongoDbHelper.FindOne <E_Info>(m.ID, DbName.E_Info); if (exam == null) { return(ResultHelper.Failed("未找到考试信息")); } if (exam.btstate == 1) { var exam2 = MongoDbHelper.QueryOne <E_Info>(DbName.E_Info, w => w.btstate == 0 && w.IsDel == 0); if (exam2 != null) { return(ResultHelper.Failed("考试已结束,无法再次导入成绩")); } } var filter = new BsonDocument(); filter.Add("eid", exam._id); string path = AppDomain.CurrentDomain.BaseDirectory + "ftp\\"; string path1 = AppDomain.CurrentDomain.BaseDirectory + "ScoreBackUp\\"; string zipfile = path + "StudentScore.zip"; //Function.UnZipFile(zipfile, path); if (!File.Exists(zipfile)) { return(ResultHelper.Failed("暂未发布成绩")); } if (!Function.UnRarOrZip(zipfile, path, null)) { return(ResultHelper.Failed("成绩获取失败,请联系管理员")); } //File.Delete(zipfile); string filepath = path + "StudentScore.xls"; string filepath1 = path1 + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; if (!System.IO.Directory.Exists(path1)) { // 目录不存在,建立目录 System.IO.Directory.CreateDirectory(path1); } System.IO.File.Copy(filepath, filepath1, true); MongoDbHelper.DeleteByBson <St_Sc>(filter, DbName.St_Sc); exam.btstate = 1; MongoDbHelper.ReplaceOne(exam._id.ToString(), exam, DbName.E_Info); int errnum = 0; string msg = BLL.ExcelBLL.ImportScoreExcel(filepath, exam, out errnum); if (msg != "") { string url = RequestContext.Url.Request.RequestUri.Authority + "\\" + msg; return(ResultHelper.Failed("导入失败" + errnum + "条--" + url)); } return(ResultHelper.OK()); } catch (Exception e) { return(ResultHelper.Failed("导入失败" + e.Message)); } }
public HttpResponseMessage ReadMsg([FromBody] ExamID m) { var mg = MongoDbHelper.FindOne <Msg_S>(m.ID, DbName.Msg_S); if (mg == null) { return(ResultHelper.Failed("未找到该消息")); } mg.ir = 1; MongoDbHelper.ReplaceOne(m.ID, mg, DbName.Msg_S); return(ResultHelper.OK()); }
public HttpResponseMessage DelExam([FromBody] ExamID m) { var eInfo = MongoDbHelper.FindOne <E_Info>(m.ID, DbName.E_Info); if (eInfo == null) { return(ResultHelper.Failed("未找到该次考试信息")); } eInfo.IsDel = 1; MongoDbHelper.ReplaceOne <E_Info>(m.ID, eInfo, DbName.E_Info); return(ResultHelper.OK()); }
public HttpResponseMessage DelUser([FromBody] ExamID m) { var sch = MongoDbHelper.QueryOne <U_Info>(DbName.U_Info, w => w._id == m.ID); if (sch != null) { var filter = new BsonDocument(); filter.Add("_id", m.ID); MongoDbHelper.DeleteByBson <U_Info>(filter, DbName.U_Info); return(ResultHelper.OK()); } return(ResultHelper.Failed("未找到该学校")); }
public HttpResponseMessage SelectExam([FromBody] ExamID m) { if (m == null) { return(ResultHelper.Failed("类容不能为空")); } var eInfo = MongoDbHelper.FindOne <E_Info>(m.ID, DbName.E_Info); if (eInfo == null) { return(ResultHelper.Failed("未找到该次考试信息")); } ExamInfo e = new ExamInfo(); e.ID = eInfo._id.ToString(); e.PublishID = eInfo.ppid; e.PublishTime = eInfo.pt; e.PublishName = MongoDbHelper.QueryOne <U_Info>(DbName.U_Info, w => w._id == eInfo.ppid) == null ? "未知" : MongoDbHelper.QueryOne <U_Info>(DbName.U_Info, w => w._id == eInfo.ppid).pnm; e.ExamName = eInfo.enm; e.StuStartTime = eInfo.sst; e.StuEndTime = eInfo.set; e.TchStartTime = eInfo.tst; e.TchEndTime = eInfo.tet; e.StuConfirm = eInfo.stcfm; e.TchConfirm = eInfo.tchcfm; e.ButtonState = eInfo.btstate; e.StuStart = Function.ConvertDateI(DateTime.Now) > eInfo.sst ? 1 : 0; e.TchStart = Function.ConvertDateI(DateTime.Now) > eInfo.tst ? 1 : 0; e.StuEnd = Function.ConvertDateI(DateTime.Now) > eInfo.set ? 1 : 0; e.TchEnd = Function.ConvertDateI(DateTime.Now) > eInfo.tet ? 1 : 0; if (Function.ConvertDateI(DateTime.Now) < eInfo.sst && Function.ConvertDateI(DateTime.Now) < eInfo.tst) { e.IsScan = 0; } else { e.IsScan = 1; } foreach (var item in eInfo.sbs) { e.subNames.Add(item._id, item.sbnm); } foreach (var item in eInfo.stps) { e.stuTypes += item.tp + ","; } e.stuTypes = e.stuTypes.Remove(e.stuTypes.Length - 1); return(ResultHelper.OK(e)); }
public HttpResponseMessage Update0([FromBody] ExamID m) { ObjectId objectid = new ObjectId(); if (ObjectId.TryParse(m.ID, out objectid)) { var stus = MongoDbHelper.QueryBy <St_Info>(DbName.St_Info, w => w.eid == objectid); for (int i = 0; i < stus.Count; i++) { stus[i].stid = stus[i].stid.PadLeft(10, '0'); MongoDbHelper.ReplaceOne(stus[i]._id.ToString(), stus[i], DbName.St_Info); } return(ResultHelper.OK()); } return(ResultHelper.Failed("考试ID不对")); }
/// <summary> /// Determines whether the specified object is equal to the current object. /// </summary> /// <param name="obj"> The object to compare with the current object.</param> /// <returns></returns> public override bool Equals(object obj) { if (obj == null) { return(false); } SessionResult res = obj as SessionResult; if (res == null) { return(false); } return(ID.Equals(res.ID) && StudentID.Equals(res.StudentID) && ExamID.Equals(res.ExamID) && Grade.Equals(res.Grade)); }
public HttpResponseMessage BuildStuExcel([FromBody] ExamID m) { var eInfo = MongoDbHelper.FindOne <E_Info>(m.ID, DbName.E_Info); if (eInfo == null) { return(ResultHelper.Failed("未查到当前考试")); } List <string> data = ExcelBLL.GetStuColumn(eInfo); List <string> col = new List <string>(); foreach (var item in eInfo.stps) { col.Add(item.tp); } string file = BLL.ExcelBLL.BuildStuExcel(data, col); string url = RequestContext.Url.Request.RequestUri.Authority + "\\" + file; return(ResultHelper.OK(url)); }
public HttpResponseMessage ClearTeacher([FromBody] ExamID m) { var exam = MongoDbHelper.FindOne <E_Info>(m.ID, DbName.E_Info);//找到这次考试 if (exam == null) { return(ResultHelper.Failed("未找到该次考试")); } if (exam.tet < Function.ConvertDateI(DateTime.Now)) { return(ResultHelper.Failed("已经导入结束,不能清空老师")); } var filter = new BsonDocument(); filter.Add("eid", exam._id); MongoDbHelper.DeleteByBson <Tch_Info>(filter, DbName.Tch_Info); exam.sbs.ForEach(f => f.tchct = 0); MongoDbHelper.ReplaceOne(m.ID, exam, DbName.E_Info); return(ResultHelper.OK()); }