/// <summary> /// 修改试题库 /// </summary> /// <param name="SortID"></param> /// <param name="qSort"></param> /// <returns></returns> public int ModifyByID(int SortID, tbQuestionSort qSort) { try { MongoCollection <tbQuestionSort> coll = BaseDB.CreateInstance().GetCollection <tbQuestionSort>("tbQuestionSort"); var update = new UpdateDocument { { "FatherID", qSort.FatherID }, { "Title", qSort.Title }, { "Description", qSort.Description }, { "Status", qSort.Status } }; coll.Update(Query.EQ("_id", SortID), update); return(SortID); } catch { return(0); } finally { BaseDB.MongoService.Disconnect(); } }
/// <summary> /// 根据ID修改分类 /// </summary> /// <returns></returns> public int ModifyByID(int id, tbExampaperSort sort) { try { MongoCollection <tbExampaperSort> coll = BaseDB.CreateInstance().GetCollection <tbExampaperSort>("tbExampaperSort"); var b = new UpdateDocument { { "Description", sort.Description }, { "Title", sort.Title }, { "FatherID", sort.FatherID }, { "Status", sort.Status } }; coll.Update(Query.EQ("_id", id), b); return(id); } catch { return(0); } finally { BaseDB.MongoService.Disconnect(); } }
/// <summary> /// 获取所有的试题 /// </summary> /// <returns></returns> public List <tbQuestion> GetQuestionList() { try { MongoCollection <tbQuestion> coll = BaseDB.CreateInstance().GetCollection <tbQuestion>("tbQuestion"); return(coll.Find(Query.EQ("Status", 0)).ToList()); } catch { return(new List <tbQuestion>()); } finally { BaseDB.MongoService.Disconnect(); } }
/// <summary> /// 根据ID获取单个实体 /// </summary> /// <returns></returns> public tbExampaper GetExampaper(int id) { try { MongoCollection <tbExampaper> coll = BaseDB.CreateInstance().GetCollection <tbExampaper>("tbExampaper"); return(coll.FindOne(Query.EQ("_id", id))); } catch { return(new tbExampaper()); } finally { BaseDB.MongoService.Disconnect(); } }
/// <summary> /// 获取已删除的试卷列表 /// </summary> /// <returns></returns> public List <tbExampaper> GetAllDeleteExampaperList() { try { MongoCollection <tbExampaper> coll = BaseDB.CreateInstance().GetCollection <tbExampaper>("tbExampaper"); return(coll.Find(Query.EQ("Status", 1)).ToList()); } catch { return(new List <tbExampaper>()); } finally { BaseDB.MongoService.Disconnect(); } }
/// <summary> /// 根据课程ID和学员ID 获取一条数据 /// </summary> /// <param name="relationId"></param> /// <param name="UserId"></param> /// <returns></returns> public tbExamSendStudent GetExamSendStudentBySQL2008(int relationId, int UserId, int CoursePaperId, int ExamPaperID, int SourceType) { try { MongoCollection <tbExamSendStudent> coll = BaseDB.CreateInstance().GetCollection <tbExamSendStudent>("tbExamSendStudent"); return(coll.FindOne(Query.And(new[] { Query.EQ("RelationID", relationId), Query.EQ("SourceType", SourceType), Query.EQ("UserID", UserId), Query.EQ("CoursePaperId", CoursePaperId), Query.EQ("ExamPaperID", ExamPaperID) }))); } catch { return(new tbExamSendStudent()); } finally { BaseDB.MongoService.Disconnect(); } }
/// <summary> /// 根据ID修改单个实体 /// </summary> /// <returns></returns> public bool UpdateExampaper(tbExampaper tbE) { try { MongoCollection <tbExampaper> coll = BaseDB.CreateInstance().GetCollection <tbExampaper>("tbExampaper"); tbExampaper exam = coll.FindOne(Query.EQ("_id", tbE._id)); tbE.UserID = exam.UserID; coll.Remove(Query.EQ("_id", tbE._id)); coll.Insert(tbE); return(true); } catch { return(false); } finally { BaseDB.MongoService.Disconnect(); } }
public int UpdateTestTimes(int tbexamsendstudentid, int TestTimes) { try { MongoCollection <tbExamSendStudent> coll = BaseDB.CreateInstance().GetCollection <tbExamSendStudent>("tbExamSendStudent"); //var update = new UpdateDocument // { // {"Number", number} // }; //coll.Update(Query.EQ("_id", tbexamsendstudentid), update,UpdateFlags.Multi);, //修改单条数据 coll.Update(Query.EQ("_id", tbexamsendstudentid), Update.Set("PaperScore", 0)); coll.Update(Query.EQ("_id", tbexamsendstudentid), Update.Set("TestTimes", TestTimes)); coll.Update(Query.EQ("_id", tbexamsendstudentid), Update.Set("StudentAnswerList", "")); //var update = new UpdateDocument // { // {"PaperScore", 0}, // {"TestTimes", TestTimes}, // {"Number",0} // }; //coll.Update(Query.EQ("_id", tbexamsendstudentid), update); return(tbexamsendstudentid); } catch { return(0); } finally { BaseDB.MongoService.Disconnect(); } }
/// <summary> /// 修改课程是否获得学时 0:没有获得 1:获得 获得后后面的考试就不在获得学时 标志位 /// </summary> /// <param name="tbexamsendstudentid">id</param> /// <param name="number">0:1</param> /// <returns></returns> public int UpdateNumber(int tbexamsendstudentid, int number) { try { MongoCollection <tbExamSendStudent> coll = BaseDB.CreateInstance().GetCollection <tbExamSendStudent>("tbExamSendStudent"); //var update = new UpdateDocument // { // {"Number", number} // }; //coll.Update(Query.EQ("_id", tbexamsendstudentid), update,UpdateFlags.Multi); //修改单条数据 coll.Update(Query.EQ("_id", tbexamsendstudentid), Update.Set("Number", number)); return(tbexamsendstudentid); } catch { return(0); } finally { BaseDB.MongoService.Disconnect(); } }
/// <summary> /// 根据ID删除单个实体 /// </summary> /// <returns></returns> public bool DeleteExampaper(int id, bool isTrueDelete) { try { MongoCollection <tbExampaper> coll = BaseDB.CreateInstance().GetCollection <tbExampaper>("tbExampaper"); if (isTrueDelete) { coll.Remove(Query.EQ("_id", id)); } else { coll.Update(Query.EQ("_id", id), Update.Set("Status", "1")); } return(true); } catch { return(false); } finally { BaseDB.MongoService.Disconnect(); } }
/// <summary> /// 根据ID批量删除单个实体 /// </summary> /// <returns></returns> public bool DeleteExampapers(string idlist) { try { MongoCollection <tbExampaper> coll = BaseDB.CreateInstance().GetCollection <tbExampaper>("tbExampaper"); //BsonArray b = new BsonArray(); string[] ids = idlist.Split(','); for (int i = 0; i < ids.Length - 1; i++) { //b.Add(ids[i].StringToInt32()); coll.Update(Query.EQ("_id", Convert.ToInt32(ids[i])), Update.Set("Status", 1)); } return(true); } catch { return(false); } finally { BaseDB.MongoService.Disconnect(); } }