/// <summary> /// 页面加载 /// </summary> public override void RenderPage() { if (ApplicationID.IsNoNull()) { objloger_application = objLogRule.loger_application.FirstOrDefault(s => s.ApplicationID == ApplicationID); if (CheckEditObjectIsNull(objloger_application)) { return; } ///是否自动释放 chkIsDispose.Checked = objloger_application.IsDispose; chkIsNotice.Checked = objloger_application.IsNotice; dropIntervalMinutes.SetSelectValue(objloger_application.IntervalMinutes); chkNoticeCategory.SetSelectValue(objloger_application.NoticeCategory); Page.DataBind(); } else { txtLogerCount.Text = "10"; txtNoticeInterval.Text = "3"; txtNoticeSleep.Text = "10"; dropIntervalMinutes.SelectedValue = "5"; txtMinutesMaxCount.Text = "30"; chkNoticeCategory.SetSelectValue("ExceptionError"); } }
public override void RenderPage() { objloger_applicationList = objLogRule.loger_application.ToList(); DataSet objDataSet = objDalBase.ExecuteDataSet("SELECT ApplicationID, COUNT(0) AS LogCount FROM loger_loging GROUP BY ApplicationID Order by LogCount desc"); if (ApplicationID != 1) { loger_application objloger_application = objloger_applicationList.FirstOrDefault(s => s.ApplicationID == ApplicationID); string ApplicationIDString = objloger_applicationList.Where(s => s.IDPath.StartsWith(objloger_application.IDPath)).Select(s => s.ApplicationID).ConvertListToString(); DataTable cloneTable = objDataSet.Tables[0].Clone(); foreach (DataRow objSelectDataRow in objDataSet.Tables[0].Select(" ApplicationID in (" + ApplicationIDString + ")")) { cloneTable.Rows.Add(objSelectDataRow.ItemArray); } DataView view = new DataView(); view = cloneTable.DefaultView; view.Sort = "LogCount desc"; gdvContent.DataSource = view; } else { gdvContent.DataSource = objDataSet; } gdvContent.RecordCount = 10000; gdvContent.PageSize = 10000; gdvContent.DataBind(); }
public string GetApplicationName(int ApplicationID) { loger_application objloger_application = objloger_applicationList.FirstOrDefault(s => s.ApplicationID == ApplicationID); if (objloger_application != null) { return(objloger_application.ApplicationName); } return("未知程序"); }
private void _QueuePoolHelper_SendMessage(object sender, QueuePoolEventArgs <OperationLogInfo> e) { OperationLogInfo message = e.Message; try { LogSection logSection = LogSectionHelper.GetLogSection(); if (!string.IsNullOrWhiteSpace(logSection.Application)) { LogRule rule = new LogRule(); loger_application cacheApplication = rule.GetCacheApplication(logSection.Application); if (cacheApplication != null) { loger_operationloging _operationloging = new loger_operationloging { ApplicationID = cacheApplication.ApplicationID, ApplicationName = cacheApplication.ApplicationName, Account = message.UserAccount, TableName = message.TableName, OperationTypeID = (int)message.OperationType, SqlQuery = message.SqlQuery, CreateDate = message.CreateDate, IDPath = cacheApplication.IDPath, ModuleTypeCode = message.LogModuleTypeCode, ApplicationHost = LogSectionHelper.Host, UserHostAddress = message.UserHostAddress, UrlReferrer = message.UrlReferrer, RawUrl = message.RawUrl }; rule.CurrentEntities.AddTologer_operationloging(_operationloging); rule.SaveChanges(); } } } catch (Exception exception) { try { LogHelper <LogModuleType> .Write(LogModuleType.LogManager, "记录操作日志出现异常", exception, ""); } catch (Exception exception2) { EventLogWriter.WriterLog(exception2); } } }
public LogInfo() { this.CreateDate = DateTime.Now; this.HeadersData = new List <LogDataInfo>(); this.RequestData = new List <LogDataInfo>(); try { if ((SysVariable.CurrentContext != null) && (SysVariable.CurrentContext.Request != null)) { this.UrlReferrer = (SysVariable.CurrentContext.Request.UrlReferrer == null) ? "" : SysVariable.CurrentContext.Request.UrlReferrer.ToString(); this.RawUrl = (SysVariable.CurrentContext.Request.Url == null) ? "" : SysVariable.CurrentContext.Request.Url.ToString(); this.UserHostAddress = RequestHelper.GetRealIp(); this.UserAgent = (SysVariable.CurrentContext.Request.UserAgent == null) ? "" : SysVariable.CurrentContext.Request.UserAgent; loger_application application = GetApplication(); if (application != null) { LogDataInfo info; if ((SysVariable.CurrentContext.Request.Headers != null) && application.HeaderKey.IsNoNullOrWhiteSpace()) { if (application.HeaderKey != "*") { foreach (string str in application.HeaderKey.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { info = new LogDataInfo { DataKey = str, DataValue = SysVariable.CurrentContext.Request.Headers[str] }; this.HeadersData.Add(info); } } else { foreach (string str in SysVariable.CurrentContext.Request.Headers.Keys) { info = new LogDataInfo { DataKey = str, DataValue = SysVariable.CurrentContext.Request.Headers[str] }; this.HeadersData.Add(info); } } } if (application.RequestKey.IsNoNullOrWhiteSpace()) { if (application.RequestKey != "*") { foreach (string str2 in application.RequestKey.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { info = new LogDataInfo { DataKey = str2, DataValue = SysVariable.CurrentContext.Request[str2] }; this.RequestData.Add(info); } } else { foreach (string str2 in SysVariable.CurrentContext.Request.Form.Keys) { info = new LogDataInfo { DataKey = str2, DataValue = SysVariable.CurrentContext.Request.Form[str2] }; this.RequestData.Add(info); } LogDataInfo item = new LogDataInfo { DataKey = "--Cookies--", DataValue = "---Cookies--" }; this.RequestData.Add(item); foreach (string str2 in SysVariable.CurrentContext.Request.Cookies.Keys) { info = new LogDataInfo { DataKey = str2, DataValue = SysVariable.CurrentContext.Request.Cookies[str2].Value }; this.RequestData.Add(info); } } } } } else { this.UrlReferrer = ""; this.RawUrl = ""; this.UserHostAddress = ""; this.UserAccount = ""; this.UserAgent = ""; } this.UserAccount = this.CurrentAccount(); } catch (Exception) { this.UrlReferrer = ""; this.RawUrl = ""; this.UserHostAddress = ""; this.UserAccount = ""; this.UserAgent = ""; } }
/// <summary> /// 保存信息 /// </summary> public void SaveInfo() { if (ApplicationID.IsNull()) { ///程序代码 objloger_application.ApplicationCode = txtApplicationCode.TextCutWord(100); objloger_application.ParentID = ParentID; ///程序名称 objloger_application.ApplicationName = txtApplicationName.TextCutWord(100); ///程序备注 objloger_application.Remark = txtRemark.TextCutWord(200); objloger_application.SortIndex = txtSortIndex.TextInt; ///是否自动释放 objloger_application.IsDispose = chkIsDispose.Checked; objloger_application.IsNotice = chkIsNotice.Checked; objloger_application.NoticePhone = txtNoticePhone.Text; objloger_application.NoticeEmail = txtNoticeEmail.Text; objloger_application.LogerCount = txtLogerCount.TextInt; objloger_application.NoticeInterval = txtNoticeInterval.TextInt; objloger_application.NoticeSleep = txtNoticeSleep.TextInt; objloger_application.NoticeCategory = chkNoticeCategory.SelectValueString; objloger_application.IntervalMinutes = dropIntervalMinutes.SelectValueInt; objloger_application.MinutesMaxCount = txtMinutesMaxCount.TextInt; objloger_application.HeaderKey = txtHeaderKey.TextTrim; objloger_application.RequestKey = txtRequestKey.TextTrim; if (objloger_application.IsNotice) { if (objloger_application.NoticeCategory.IsNull()) { MessageDialog("不好意思,选择日志通知必须选择通知日志类型"); return; } if (objloger_application.NoticeEmail.IsNull() && objloger_application.NoticePhone.IsNull()) { MessageDialog("不好意思,选择日志通知必须输入邮箱或手机号码其中一个"); return; } } objLogRule.InsertApplication(objloger_application); RefreshFrame("frmApplicationTree", "ApplicationTree.aspx?ApplicationID=" + objloger_application.ApplicationID.ToString(), "新增成功", "ApplicationInfo.aspx?ApplicationID=" + objloger_application.ApplicationID.ToString()); } else { objloger_application = objLogRule.loger_application.FirstOrDefault(p => p.ApplicationID == ApplicationID); if (CheckEditObjectIsNull(objloger_application)) { return; } ///程序代码 objloger_application.ApplicationCode = txtApplicationCode.TextCutWord(100); ///程序名称 objloger_application.ApplicationName = txtApplicationName.TextCutWord(100); ///程序备注 objloger_application.Remark = txtRemark.TextCutWord(200); objloger_application.SortIndex = txtSortIndex.TextInt; ///是否自动释放 objloger_application.IsDispose = chkIsDispose.Checked; objloger_application.IsNotice = chkIsNotice.Checked; objloger_application.NoticePhone = txtNoticePhone.Text; objloger_application.NoticeEmail = txtNoticeEmail.Text; objloger_application.LogerCount = txtLogerCount.TextInt; objloger_application.NoticeInterval = txtNoticeInterval.TextInt; objloger_application.NoticeSleep = txtNoticeSleep.TextInt; objloger_application.NoticeCategory = chkNoticeCategory.SelectValueString; objloger_application.IntervalMinutes = dropIntervalMinutes.SelectValueInt; objloger_application.MinutesMaxCount = txtMinutesMaxCount.TextInt; objloger_application.HeaderKey = txtHeaderKey.TextTrim; objloger_application.RequestKey = txtRequestKey.TextTrim; if (objloger_application.IsNotice) { if (objloger_application.NoticeCategory.IsNull()) { MessageDialog("不好意思,选择日志通知必须选择通知日志类型"); return; } if (objloger_application.NoticeEmail.IsNull() && objloger_application.NoticePhone.IsNull()) { MessageDialog("不好意思,选择日志通知必须输入邮箱或手机号码其中一个"); return; } } objLogRule.UpdateApplication(objloger_application); RefreshFrame("frmApplicationTree", "ApplicationTree.aspx?ApplicationID=" + objloger_application.ApplicationID.ToString(), "修改成功", "ApplicationInfo.aspx?ApplicationID=" + objloger_application.ApplicationID.ToString()); } }
public override void RenderPage() { objloger_application = objLogRule.loger_application.FirstOrDefault(s => s.ApplicationID == ApplicationID); this.CurrentBindData <loger_category>(gdvContent, objLogRule.loger_category); }