public ActionResult AnAjaxList() { int start = 0; int length = 0; start = Convert.ToInt32(Request.Params["start"]); length = Convert.ToInt32(Request.Params["length"]); var strSql = ""; BLL.AnswerTable answer = new BLL.AnswerTable(); List <Model.AnswerTable> list = answer.DataTableToList(answer.GetListByPage(strSql, "", start + 1, start + length).Tables[0]); int filterTotal = answer.GetRecordCount(strSql); int total = answer.GetRecordCount(""); return(this.Json(new { result = 1, data = new { draw = Request.Params["draw"], recordsTotal = total, recordsFiltered = filterTotal, data = list.Select(o => new { ID = o.ID, Student = o.Student, Filepath = o.Filepath, }) } })); }
public void DownloadFile(int id) { string strSql = "select * from AnswerTable where Exam = '" + id + "' and Student = '" + Session["username"] + "'"; List <Model.AnswerTable> tableList = new BLL.AnswerTable().DataTableToList(DbHelperSQL.Query(strSql).Tables[0]); if (tableList.Count != 0) { string path = ""; foreach (Model.AnswerTable tableModel in tableList) { path += tableModel.Filepath + "|"; } ZipFileDownload(path.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries), DateTime.Now.ToString("yyyyMMddhhMmss") + "_Answer.zip"); } }
public ActionResult Clear(int id) { bool result = false; BLL.ExamTable exam = new BLL.ExamTable(); string strSql = "select * from ExamTable where Id = '" + id + "'"; List <Model.ExamTable> tableList = new BLL.ExamTable().DataTableToList(DbHelperSQL.Query(strSql).Tables[0]); if (tableList.Count != 0) { foreach (Model.ExamTable tableModel in tableList) { string path = Server.MapPath(tableModel.Filepath); bool exi = System.IO.File.Exists(path); if (exi) { System.IO.File.Delete(path); } } } exam.Delete(id); BLL.AnswerTable answer = new BLL.AnswerTable(); string strSql1 = "select * from AnswerTable where Exam = '" + id + "'"; List <Model.AnswerTable> tableList1 = new BLL.AnswerTable().DataTableToList(DbHelperSQL.Query(strSql1).Tables[0]); if (tableList1.Count != 0) { foreach (Model.AnswerTable tableModel in tableList1) { string path = Server.MapPath(tableModel.Filepath); bool exi = System.IO.File.Exists(path); if (exi) { System.IO.File.Delete(path); } answer.Delete(tableModel.ID); } } BLL.IPTable IP = new BLL.IPTable(); string strSql2 = "select * from IPTable"; List <Model.IPTable> tableList2 = new BLL.IPTable().DataTableToList(DbHelperSQL.Query(strSql2).Tables[0]); if (tableList2.Count != 0) { foreach (Model.IPTable tableModel in tableList2) { IP.Delete(tableModel.ID); } } result = true; if (result) { return(this.Json(new { result = 1, data = "" })); } else { return(this.Json(new { result = 0, msg = "没有这条数据" })); } }