/// <summary> /// 记录日志 /// </summary> /// <param name="rizhi"></param> public static void Log(Model.t_log rizhi) { var log = new DAL.t_log(); rizhi.log_date = DateTime.Now; log.Add(rizhi); }
/// <summary> /// 记录日志-登录后操作 /// </summary> /// <param name="page">this</param> /// <param name="note">日志信息</param> public static void Log(Page page, string note) { var log = new BLL.t_log(); var rizhi = new Model.t_log { log_ip = page.Request.UserHostAddress, user_name = page.Session["login_name"].ToString(), log_info = note, }; log.Add(rizhi); }
/// <summary> /// 记录日志 /// </summary> /// <param name="login_name">登录名</param> /// <param name="ip">IP</param> /// <param name="note">日志信息</param> public static void Log(string login_name, string ip, string note) { var log = new BLL.t_log(); var rizhi = new Model.t_log { log_ip = ip, user_name = login_name, log_info = note, }; log.Add(rizhi); }
protected void Page_Load(object sender, EventArgs e) { if (Request["login_name"] != null && Request["pwd"] != null && Request["type"] != null) { var msg = new BLL.Message(); /// 验证输入长度 if (Request["login_name"].Length < 3 || Request["pwd"].Length < 6 || Request["login_name"].Length > 32 || Request["pwd"].Length > 16) { msg.Msg = "数据输入有误!"; Response.Write(BLL.Utils.toJson(msg)); Response.End(); } /// 构建日志Model Model.t_log log = new Model.t_log { log_ip = Request.UserHostAddress, user_name = Request["login_name"], }; try { string url = null; var login_name = Request["login_name"]; var pwd = Request["pwd"]; var type = Request["type"]; /// 登录验证 if (BLL.Utils.Login(login_name, pwd, type)) { // 登录成功 Session["type"] = type; // 类型 Session["login_name"] = login_name; //登录,学号,工号 Session["user_name"] = null; // 显示名称(姓名) Session["role"] = 0; // 为了方便母版页判断权限和修改菜单,特设此变量,值越小权限越低:1学生,2导师,3教研室主任,4教务管理员 /// 获取附加信息 var bll_major = new BLL.t_major(); // 专业 switch (type) { #region 教务管理员登录 case "admin": Session["role"] = 4; var bll_admin = new BLL.t_admin(); var admin = bll_admin.GetModel(login_name); Session["user_name"] = admin.user_name; url = "/admin/"; break; #endregion 教务管理员登录 #region 教务室主任登录 case "mteacher": Session["role"] = 3; var bll_mteacher = new BLL.t_teacher(); var mteacher = bll_mteacher.GetModel(login_name); /// 获取专业信息 Session["major_id"] = mteacher.teacher_major_id; /// 获取系别信息 Session["dept_id"] = mteacher.teacher_dept_id; Session["user_name"] = mteacher.teacher_name; url = "/admin/"; break; #endregion 教务室主任登录 #region 导师登录 case "teacher": Session["role"] = 2; var bll_teacher = new BLL.t_teacher(); var teacher = bll_teacher.GetModel(login_name); /// 获取专业信息 Session["major_id"] = teacher.teacher_major_id; /// 获取系别信息 Session["dept_id"] = teacher.teacher_dept_id; Session["user_name"] = teacher.teacher_name; url = "/topic/"; break; #endregion 导师登录 #region 学生登录 case "student": //学生 Session["role"] = 1; var bll_student = new BLL.t_student(); var student = bll_student.GetModel(login_name); Session["user_name"] = student.student_name; Session["class_id"] = student.student_class_id; /// 获取班级信息 var bll_class = new BLL.t_class(); var myclass = bll_class.GetModel(student.student_class_id); /// 获取专业信息 var major = bll_major.GetModel(myclass.class_major_id); Session["major_id"] = major.major_id; /// 获取系别信息 Session["dept_id"] = major.major_dept_id; url = "/select/list.aspx"; break; #endregion 学生登录 } msg.Msg = log.log_info = "登录成功!"; } else { // 登录失败 log.log_info = msg.Msg = "用户名或密码错误!"; } if (url != null) { msg.Body = (url); } } catch { msg.Msg = "发生错误!"; } var bll_log = new BLL.t_log(); bll_log.Add(log); Response.Write(BLL.Utils.toJson(msg)); Response.End(); } else { BLL.Utils.ShowMessage(this, "输入有误!"); } }
protected void Page_Load(object sender, EventArgs e) { if (Request["login_name"] != null && Request["type"] != null) { var msg = new BLL.Message(); try { /// 设置重试次数上限 if (Session["try"] == null) { Session["try"] = 0; } else { Session["try"] = int.Parse(Session["try"].ToString()) + 1; } if (Session["try"].Equals(10)) { msg.Msg = "重试次数已超过10次,系统拒绝操作!"; Response.Write(BLL.Utils.toJson(msg)); Response.End(); } string type = Request["type"].ToLower(); string login_name = Request["login_name"]; string my_a = Request["a"] == null ? null : Request["a"]; switch (type) { case "student": var bll_student = new BLL.t_student(); var model = bll_student.GetModel(login_name); if (model == null) { msg.Msg = "该学生不存在!"; } else if (!model.student_stat.Equals(0)) { msg.Msg = "该角色处于异常状态!"; } else if (model.student_pwd_q == null || model.student_pwd_q.Length < 1) { msg.Msg = "未设置密保问题,无法通过密保重置密码!"; } else { msg.Body = model.student_pwd_q; } if (my_a != null && model.student_pwd_a.Equals(my_a)) { /// 登录系统 Session["type"] = type; // 类型 Session["login_name"] = login_name; //登录,学号,工号 Session["user_name"] = model.student_name; // 显示名称(姓名) msg.Body = "/ChagePassword.aspx"; } else if (my_a != null && (!model.student_pwd_a.Equals(my_a))) { msg.Msg = "密保答案错误!"; msg.Body = null; } break; case "teacher": var bll_teachert = new BLL.t_teacher(); var model2 = bll_teachert.GetModel(login_name); if (model2 == null) { msg.Msg = "该导师不存在!"; } else if (!model2.teacher_stat.Equals(0)) { msg.Msg = "该角色处于异常状态!"; } else if (!model2.teacher_type.Equals(0)) { msg.Msg = "教研室主任请联系教务管理员重置密码!"; } else if (model2.teacher_pwd_q == null || model2.teacher_pwd_q.Length < 1) { msg.Msg = "未设置密保问题,无法通过密保重置密码!"; } else { msg.Body = model2.teacher_pwd_q; } if (my_a != null && model2.teacher_pwd_a.Equals(my_a)) { /// 登录系统 Session["type"] = type; // 类型 Session["login_name"] = login_name; //登录,学号,工号 Session["user_name"] = model2.teacher_name; // 显示名称(姓名) msg.Body = "/ChagePassword.aspx"; } else if (my_a != null && (!model2.teacher_pwd_a.Equals(my_a))) { msg.Msg = "密保答案错误!"; msg.Body = null; } break; } } finally { /// 写入日志 var log = new Model.t_log { log_info = "通过密保问题重置密码", log_ip = Request.UserHostAddress, user_name = Request["login_name"], }; BLL.Utils.Log(log); Response.Write(BLL.Utils.toJson(msg)); Response.End(); } } }