/// <summary> /// 增 zt:页面名 kt:方法名 action:类型,是常规性日志还是出错信息 result:日志详细信息 type:一级菜单 type1:二级菜单 /// </summary> /// <param name="model">new model</param> /// <returns></returns> public bool AddSys_Log(Sys_LogModel model) { string ip = HttpContext.Current.Request.UserHostAddress == "::1" ? "127.0.0.1" : HttpContext.Current.Request.UserHostAddress; model.ip = ip; StringBuilder sb = new StringBuilder(); sb.Append("insert into Sys_Log ( "); sb.Append("id,zt,kt,action,result,type,type1,uid,ip"); sb.Append(") values ( "); sb.Append("@id,@zt,@kt,@action,@result,@type,@type1,@uid,@ip"); sb.Append(") "); List <SqlParameter> pms = new List <SqlParameter>(); pms.Add(new SqlParameter("@id", model.id)); pms.Add(new SqlParameter("@zt", model.zt)); pms.Add(new SqlParameter("@kt", model.kt)); pms.Add(new SqlParameter("@action", model.action)); // pms.Add(new SqlParameter("@add_time", model.add_time)); pms.Add(new SqlParameter("@result", model.result)); pms.Add(new SqlParameter("@type", model.type)); pms.Add(new SqlParameter("@type1", model.type1)); pms.Add(new SqlParameter("@uid", model.uid)); pms.Add(new SqlParameter("@ip", model.ip)); int res = Base.SQLServerHelper.ExecuteSql(sb.ToString(), pms.ToArray()); return(res > 0); }
/// <summary> /// 删 /// </summary> /// <param name="model">empty model with key value</param> /// <returns></returns> public bool DeleteSys_Log(Sys_LogModel model) { StringBuilder sb = new StringBuilder(); sb.Append("delete from Sys_Log where 1=1 "); sb.Append("and id=@id "); List <SqlParameter> pms = new List <SqlParameter>(); pms.Add(new SqlParameter("@id", model.id)); int res = Base.SQLServerHelper.ExecuteSql(sb.ToString(), pms.ToArray()); return(res > 0); }
/// <summary> /// 查 /// </summary> /// <param name="model">empty model with key value</param> /// <returns></returns> public Sys_LogModel GetSys_LogInfo(Sys_LogModel model) { StringBuilder sb = new StringBuilder(); sb.Append("select * from Sys_Log where 1=1 "); sb.Append("and id=@id "); List <SqlParameter> pms = new List <SqlParameter>(); pms.Add(new SqlParameter("@id", model.id)); DataSet ds = Base.SQLServerHelper.Query(sb.ToString(), pms.ToArray()); if (ds == null || ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0) { return(null); } return(new Sys_LogModel(ds.Tables[0].Rows[0])); }
public ActionResult OutLogin() { Sys_LogBLL bll = new Sys_LogBLL(); Sys_LogModel lmodel = new Sys_LogModel { F_ModuleName = "系统登录", F_Type = DbLogType.Exit.ToString(), F_Account = OperatorProvider.Provider.GetCurrent().UserCode, F_NickName = OperatorProvider.Provider.GetCurrent().UserName, F_Result = true, F_Description = "安全退出系统", }; Session.Abandon(); Session.Clear(); OperatorProvider.Provider.RemoveCurrent(); return(RedirectToAction("Index", "Login", "Admin")); }
/// <summary> /// 改 zt:页面名 kt:方法名 action:类型,是常规性日志还是出错信息 result:日志详细信息 type:模块 /// </summary> /// <param name="model">model to be updated</param> /// <returns></returns> public bool UpdateSys_Log(Sys_LogModel model) { StringBuilder sb = new StringBuilder(); sb.Append("update Sys_Log set "); sb.Append("zt=@zt, kt=@kt, action=@action, result=@result, type=@type,type1=@type1,uid=@uid,ip=@ip "); sb.Append("where 1=1 "); sb.Append("and id=@id "); List <SqlParameter> pms = new List <SqlParameter>(); pms.Add(new SqlParameter("@id", model.id)); pms.Add(new SqlParameter("@zt", model.zt)); pms.Add(new SqlParameter("@kt", model.kt)); pms.Add(new SqlParameter("@action", model.action)); // pms.Add(new SqlParameter("@add_time", model.add_time)); pms.Add(new SqlParameter("@result", model.result)); pms.Add(new SqlParameter("@type", model.type)); pms.Add(new SqlParameter("@type1", model.type1)); pms.Add(new SqlParameter("@uid", model.uid)); pms.Add(new SqlParameter("@ip", model.ip)); int res = Base.SQLServerHelper.ExecuteSql(sb.ToString(), pms.ToArray()); return(res > 0); }
/// <summary> /// 查 /// </summary> /// <param name="model">empty model with key value</param> /// <returns></returns> public static Sys_LogModel GetSys_LogInfo(Sys_LogModel model) { return(Common.Instance._Sys_Log.GetSys_LogInfo(model)); }
/// <summary> /// 删 /// </summary> /// <param name="model">empty model with key value</param> /// <returns></returns> public static bool DeleteSys_Log(Sys_LogModel model) { return(Common.Instance._Sys_Log.DeleteSys_Log(model)); }
/// <summary> /// zt:页面名 kt:方法名 action:类型,是常规性日志还是出错信息 result:日志详细信息 type:一级菜单 type1:二级菜单 /// </summary> /// <param name="model">new model</param> /// <returns></returns> public static bool AddSys_Log(Sys_LogModel model) { return(Common.Instance._Sys_Log.AddSys_Log(model)); }
public ActionResult CheckLogin(string username, string password, string code) { Sys_UserBLL userbll = new Sys_UserBLL(); Sys_UserModel usermodel = new Sys_UserModel(); Sys_LogModel logModel = new Sys_LogModel(); Sys_LogBLL logbll = new Sys_LogBLL(); logModel.F_ModuleName = "系统登录"; logModel.F_Type = DbLogType.Login.ToString(); try { //if (Session["nfine_session_verifycode"].IsEmpty() || Md5.md5(code.ToLower(), 16) != Session["nfine_session_verifycode"].ToString()) //{ // throw new Exception("验证码错误,请重新输入"); //} usermodel = userbll.CheckLogin(username, password); if (usermodel != null) { OperatorModel operatorModel = new OperatorModel(); operatorModel.UserId = usermodel.F_Id; operatorModel.UserCode = usermodel.F_Account; operatorModel.UserName = usermodel.F_RealName; operatorModel.CompanyId = usermodel.F_OrganizeId; operatorModel.DepartmentId = usermodel.F_DepartmentId; operatorModel.RoleId = usermodel.F_RoleId; operatorModel.LoginIPAddress = Net.Ip; operatorModel.LoginIPAddressName = Net.GetLocation(operatorModel.LoginIPAddress); operatorModel.LoginTime = DateTime.Now; operatorModel.LoginToken = DESEncrypt.Encrypt(Guid.NewGuid().ToString()); if (usermodel.F_Account == "admin") { operatorModel.IsSystem = true; } else { operatorModel.IsSystem = false; } OperatorProvider.Provider.AddCurrent(operatorModel); logModel.F_Account = usermodel.F_Account; logModel.F_NickName = usermodel.F_RealName; logModel.F_Result = true; logModel.F_Description = "登录成功"; logModel.F_Id = Common.GuId(); logModel.F_Date = DateTime.Now; logModel.F_IPAddress = Net.Ip; logModel.F_IPAddressName = Net.GetLocation(logModel.F_IPAddress); logbll.Add(logModel); } return(Content(new AjaxResult { state = ResultType.success.ToString(), message = "登录成功。" }.ToJson())); } catch (Exception ex) { logModel.F_Account = username; logModel.F_NickName = username; logModel.F_Result = false; logModel.F_Description = "登录失败," + ex.Message; logModel.F_Id = Common.GuId(); logModel.F_Date = DateTime.Now; logModel.F_IPAddress = Net.Ip; logModel.F_IPAddressName = Net.GetLocation(logModel.F_IPAddress); logbll.Add(logModel); return(Content(new AjaxResult { state = ResultType.error.ToString(), message = ex.Message }.ToJson())); } }