/// <summary> /// 添加与编辑LoginLog记录 /// </summary> /// <param name="page">当前页面指针</param> /// <param name="model">LoginLog表实体</param> /// <param name="content">更新说明</param> /// <param name="isCache">是否更新缓存</param> /// <param name="isAddUseLog">是否添加用户操作日志</param> public void Save(Page page, LoginLog model, string content = null, bool isCache = true, bool isAddUseLog = true) { try { //保存 model.Save(); //判断是否启用缓存 if (CommonBll.IsUseCache() && isCache) { SetModelForCache(model); } if (isAddUseLog) { if (string.IsNullOrEmpty(content)) { content = "{0}" + (model.Id == 0 ? "添加" : "编辑") + "LoginLog记录成功,ID为【" + model.Id + "】"; } //添加用户访问记录 UseLogBll.GetInstence().Save(page, content); } } catch (Exception e) { var result = "执行LoginLogBll.Save()函数出错!"; //出现异常,保存出错日志信息 CommonBll.WriteLog(result, e); } }
private void SetLogoutTime(int Id) { int outpar = 0; LoginLog objLoginLog = new LoginLog(); objLoginLog.LoginLogId = Id; objLoginLog.LoggOutTime = DateTime.Now; objLoginLog.ResonToLoggOut = "Sucssessfully LogOut"; objLoginLog.Save(out outpar); }
private void SetLogoutTime() { int outLoginLogId = 0; string ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (ipaddress == "" || ipaddress == null) { ipaddress = Request.ServerVariables["REMOTE_ADDR"]; } LoginLog objLoginLog = new LoginLog(); objLoginLog.LoginLogId = 0; objLoginLog.LoginTime = DateTime.Now; objLoginLog.LoginPesonId = Session["UserName"].ToString(); objLoginLog.IpAddress = ipaddress; objLoginLog.Save(out outLoginLogId); Session["LoginId"] = outLoginLogId.ToString(); }
/*********************************************************************** * 自定义函数 * ***********************************************************************/ #region 自定义函数 #region 添加用户登陆日志 /// <summary> /// 添加用户登陆日志 /// </summary> /// <param name="userHashKey">登录用户在线列表的HashTable Key</param> /// <param name="notes">用户登录内容备注,{0}=用户名称,{1}=用户在线时间</param> public void Save(string userHashKey, string notes) { try { //创建登录日志对象,便于登录日志的添加 var loginlog = new LoginLog(); //记录登录时间 loginlog.AddDate = DateTime.Now; //在线时长 var loginDuration = "未知"; //获取用户在线实体 var model = OnlineUsersBll.GetInstence().GetOnlineUsersModel(userHashKey); if (model != null) { //当前用户ID loginlog.Manager_Id = model.Manager_Id; //当前用户名称 loginlog.Manager_CName = model.Manager_CName; //当前用户IP loginlog.Ip = model.LoginIp; //计算在线时长 loginDuration = CommonBll.LoginDuration(model.LoginTime, model.UpdateTime); } else { //当前用户ID loginlog.Manager_Id = 0; //当前用户名称 loginlog.Manager_CName = ""; //当前用户IP loginlog.Ip = IpHelper.GetUserIp(); } //日志记录说明 loginlog.Notes = String.Format(notes, loginlog.Manager_CName, loginDuration); loginlog.Save(); } catch (Exception) { } }
/// <summary> /// 添加用户登陆日志 /// </summary> /// <param name="managerId">登录用户ID</param> /// <param name="notes">用户登录内容备注</param> public void Save(int managerId, string notes) { try { //创建登录日志对象,便于登录日志的添加 var loginlog = new LoginLog(); //记录登录时间 loginlog.AddDate = DateTime.Now; //当前用户ID loginlog.Manager_Id = managerId; //当前用户名称 loginlog.Manager_CName = ManagerBll.GetInstence().GetCName(null, managerId); //当前用户IP loginlog.Ip = IpHelper.GetUserIp(); //日志记录说明 loginlog.Notes = notes; loginlog.Save(); } catch (Exception) { } }
/*********************************************************************** * 自定义函数 * ***********************************************************************/ #region 自定义函数 #region 添加用户登陆日志 /// <summary> /// 添加用户登陆日志 /// </summary> /// <param name="userHashKey">登录用户在线列表的HashTable Key</param> /// <param name="notes">用户登录内容备注,{0}=用户名称,{1}=用户在线时间</param> public void Save(string userHashKey, string notes) { try { //创建登录日志对象,便于登录日志的添加 var loginlog = new LoginLog(); //记录登录时间 loginlog.AddDate = DateTime.Now; //当前用户ID loginlog.Manager_Id = ConvertHelper.Cint0(OnlineUsersBll.GetInstence().GetUserOnlineInfo(userHashKey, OnlineUsersTable.Manager_Id)); //当前用户名称 loginlog.Manager_CName = OnlineUsersBll.GetInstence().GetUserOnlineInfo(userHashKey, OnlineUsersTable.Manager_CName) + ""; //当前用户IP loginlog.Ip = OnlineUsersBll.GetInstence().GetUserOnlineInfo(userHashKey, OnlineUsersTable.LoginIp) + ""; //日志记录说明 loginlog.Notes = String.Format(notes, loginlog.Manager_CName, CommonBll.LoginDuration(OnlineUsersBll.GetInstence().GetUserOnlineInfo(userHashKey, OnlineUsersTable.LoginTime))); loginlog.Save(); } catch (Exception) { } }