protected void btnLogout_Click(object sender, EventArgs e) { //记录退出日志 SystemLog oLog = new SystemLog(); oLog.UserId = SystemUtil.GetCurrentUserId(); oLog.AccessFunctionName = "退出系统"; oLog.AccessActionName = "退出"; oLog.AccessTime = DateTime.Now; oLog.AccessURL = this.Page.Request.Url.AbsoluteUri; oLog.Remark = "用户安全退出系统"; SystemLog.Save(oLog); SystemUtil.LogoutUser(); PageUtil.PageRefreshLayout(this.Page); }
private void SaveLoginUserItem(string _strUserName) { UserInformation loginItem = UserInformation.Get(_strUserName); if (null == loginItem) return; SystemUtil.LoginUser(loginItem); //记录登陆日志 SystemLog oLog = new SystemLog(); oLog.UserId = loginItem.Id; oLog.AccessFunctionName = "系统登陆"; oLog.AccessActionName = "系统登陆"; oLog.AccessTime = DateTime.Now; oLog.AccessURL = this.Page.Request.Url.AbsoluteUri; oLog.Remark = ""; SystemLog.Save(oLog); }
public static int Save(SystemLog _Entity) { if (null != _Entity) { return EntityAccess<SystemLog>.Access.Save(_Entity); } return -1; }
//public int nFunctionId = -1; protected void Page_Load(object sender, EventArgs e) { //Session过期后,进入登陆界面 int nCurrrentUserId = SystemUtil.GetCurrentUserId(); if (nCurrrentUserId <= 0) { Control loginControl = TemplateControl.LoadControl(SystemUtil.ResovleControlPath("SystemManage", "Login")); ph.Controls.Add(loginControl); return; } int nFunctionId = PageUtil.GetQueryInt(this.Request, "fn", -1); int nModuleId = PageUtil.GetQueryInt(this.Request, "m", -1); if (nFunctionId <= 0 && nModuleId <= 0) return; SystemFunction oFunction = new SystemFunction(); if (nFunctionId >= 1) { oFunction = SystemFunction.Get(nFunctionId); if (null == oFunction) return; nModuleId = oFunction.ModuleId; } SystemModule oModule = SystemModule.Get(nModuleId); if (null == oModule) return; string strSingleForm = PageUtil.GetQueryString(this.Request, "fm"); string strActionKey = PageUtil.GetQueryString(this.Request, "akey"); string strControlName = strSingleForm; SystemAction[] alActions = null; if (string.IsNullOrEmpty(strControlName)) { alActions = SystemAction.GetUserAction(nCurrrentUserId, nFunctionId); if (null == alActions) return; foreach (SystemAction action in alActions) { if (!string.IsNullOrEmpty(strActionKey) && action.Key.Equals(strActionKey)) { strControlName = action.ControlName; break; } else if (string.IsNullOrEmpty(strActionKey) && action.IsDefault == 1) { strControlName = action.ControlName; strActionKey = action.Key; break; } } if (strActionKey.IsNullOrEmpty()) { this.ShowException("您还没有改功能的操作权限,请您联系系统管理人员解决!"); return; } if (!IsPostBack) { //记录用户操作日志 SystemLog oLog = new SystemLog(); oLog.UserId = nCurrrentUserId; oLog.AccessFunctionName = oFunction.Name; oLog.AccessActionName = SystemAction.Get(strActionKey).Name; oLog.AccessTime = DateTime.Now; oLog.AccessURL = this.Page.Request.Url.AbsoluteUri; oLog.Remark = string.Format("[ControlName:{0}][IP:{1}]", strControlName, this.Request.ServerVariables["REMOTE_ADDR"]); SystemLog.Save(oLog); } } string strOtherUrl = ""; if (!string.IsNullOrEmpty(strOtherUrl) && strOtherUrl.Length > 4 && strOtherUrl.Substring(0, 4) == "http") { Response.Write(string.Format("<iframe frameborder=\"0\" src=\"{0}\" scrolling=\"auto\" height=\"100%\" width=\"100%\"></iframe>", strOtherUrl)); return; } string strControlPath = string.IsNullOrEmpty(strOtherUrl) ? SystemUtil.ResovleControlPath(oModule.Controller, strControlName) : strOtherUrl; Control loadControl = null; try { loadControl = LoadControl(strControlPath); ph.Controls.Add(loadControl); } catch(Exception ex) { this.ShowException(string.Format("控件加载失败!<br /><br />原因:{0}", ex.Message)); return; } Control toolBar = loadControl.FindControl("toolBar"); if (null != toolBar) { (toolBar as HtmlControl).Attributes["class"] = "toolBar"; foreach (SystemAction action in alActions) { HyperLink toolAction = new HyperLink(); toolAction.ID = "Action_" + action.Key; toolAction.CssClass = action.Key == strActionKey ? "action-active" : "action-normal"; toolAction.ToolTip = action.Tip; toolAction.Attributes["onclick"] = action.Key == strActionKey ? "void(0);" : string.Format("formUtil.actionDone({0});", action.ToActionJson()); toolAction.NavigateUrl = "javascript:void(0);"; HtmlGenericControl spanText = new HtmlGenericControl("span"); spanText.InnerText = action.Name; HtmlImage toolIcon = new HtmlImage(); //图标必须是16像素宽高 toolIcon.Width = 16; toolIcon.Height = 16; toolIcon.Align = "absMiddle"; toolIcon.Attributes["hspace"] = "2"; toolIcon.Src = SystemUtil.ResovleActionImagePath(action.IconName); toolAction.Controls.Add(toolIcon); toolAction.Controls.Add(spanText); toolBar.Controls.Add(toolAction); } } //页面Postback后清空复选框选择值隐藏域 hiddenSelectedValue.Value = ""; }
public void SaveLog(object _para) { LogParams para = (LogParams)_para; //记录登陆日志 SystemLog oLog = new SystemLog(); oLog.UserId = para.UserId; oLog.AccessFunctionName = para.FunctionName; oLog.AccessActionName = para.ActionName; oLog.AccessTime = DateTime.Now; oLog.AccessURL = para.RequestURI; oLog.Remark = ""; SystemLog.Save(oLog); }