public ActionResult GetAdminFile() { Session["t"] = 1; AdminFileService sdfser = new AdminFileService(); IQueryable <AdminFile> iq = sdfser.GetPageAdminFile(); IList <string> strl = new List <string>(); foreach (var item in iq) { string str = item.SubTime + "=" + item.AdF_Name + "=" + item.Url; strl.Add(str); } string str1 = js.Serialize(strl); Session["strl"] = strl; Response.Write(str1); Response.End(); return(View()); }
// // GET: /Upload/ #region 管理员文件上传 public ActionResult AdminFileUpLoad() { AdminFileService adfs = new AdminFileService(); AdminFileDal adfd = new AdminFileDal(); Admin ad = (Admin)Session["admin"]; var file = Request.Files["file"]; if (file.ContentLength == 0) { return(Content("请选择要上传的文件")); } var filename = Request["filename"]; IQueryable <AdminFile> iq = adfd.GetEntities(u => u.AdF_Name == filename); if (iq.Count() >= 1) { return(Content("此文件或文件名已存在")); } var intro = Request["intro"]; AdminFile adf = new AdminFile(); adf.AdF_Intro = intro; adf.AdF_Name = filename; adf.Admin = ad; adf.SubTime = DateTime.Now; string s = file.FileName; //全路径的名字 int index = s.LastIndexOf("."); //获取最后面点的位置 string hzm = s.Substring(index); // 获取后缀名 // string path = "/Upload/" + Guid.NewGuid().ToString() + hzm; //防止命名相同 string path = "/Upload/" + Guid.NewGuid().ToString() + filename + hzm; adf.Url = path; adfs.AddAdminFile(adf); file.SaveAs(Request.MapPath(path)); return(Content("上传成功")); }
public ActionResult Login() { //加载admin文件 AdminFileService sdfser = new AdminFileService(); IQueryable <AdminFile> iq = sdfser.GetPageAdminFile(); IList <string> strl = new List <string>(); foreach (var item in iq) { string str = item.SubTime + "=" + item.AdF_Name + "=" + item.Url; strl.Add(str); } Session["strlist"] = strl; //加载老师文件 TeaFileService sdfser2 = new TeaFileService(); IQueryable <TeaFile> iq2 = sdfser2.GetPageTeaFile(); IList <string> strl2 = new List <string>(); foreach (var item in iq2) { string str = item.SubTime + "=" + item.TeaF_Name + "=" + item.Url; strl2.Add(str); } Session["strlist2"] = strl2; string role = Request["role"]; string num = Request["Num"]; string pwd = Request["Pwd"]; string vcode = Request["vCode"].Trim(); string sessionCode = (string)Session["validate"]; Session["validate"] = null; if (string.IsNullOrEmpty(sessionCode) || !String.Equals(vcode, sessionCode, StringComparison.CurrentCultureIgnoreCase)) { return(Content("验证码错误!")); } if (role == "student") { StudentService stus = new StudentService(); Student s = stus.StudentLoginByNumAndPwd(num, pwd); if (s != null) { Session["student"] = s; return(RedirectToAction("Index1", "Student")); } else { return(Content("学生用户名密码不正确1")); } } else if (role == "teacher") { TeacherService teas = new TeacherService(); Teacher t = teas.TeacherLoginByNumAndPwd(num, pwd); if (t != null) { Session["teacher"] = t; return(RedirectToAction("Index", "Teacher")); } else { return(Content("教师用户名密码不正确2")); } } else if (role == "admin") { AdminService adm = new AdminService(); Admin admin = new Admin(); Admin admin1 = adm.AdminLoginByNumAndPwd(num, pwd); if (admin1 != null) { Session["admin"] = admin1; return(RedirectToAction("Index", "Admin")); } else { return(Content("管理员用户名密码不正确")); } } return(Content("用户名密码不正确3")); }