public LogPropertiesDlg(IPlugInContainer container, StandardPage parentPage, EventlogPlugin plugin, ListView lvEvents, EventLogRecord el, EventFilter ef, string pageID) : base(container, parentPage) { InitializeComponent(); btnApply.Enabled = true; this.DataChanged = true; _plugin = plugin; _container = container; this._parentPage = parentPage; _eventsListView = lvEvents; _el = el; _ef = ef; sShowPage = pageID; if (parentPage != null && parentPage.LMCTree != null && parentPage.LMCTree.SelectedNode != null && !String.IsNullOrEmpty(parentPage.LMCTree.SelectedNode.Text)) { this.Text = parentPage.LMCTree.SelectedNode.Text + " " + "Properties"; } InitializePages(); }
/// <summary> /// This is the preferred constructor. /// </summary> /// <param name="el">Back reference to the event log being displayed</param> /// <param name="ef">Reference to current filter settings (can be null)</param> public EventFilterControl(EventFilter ef) : this() { this.pageID = "FilterProperities"; _ef = ef; }
/// <summary> /// Sets the UI widgets as per a given filter object /// </summary> /// <param name="ef">The given filter object</param> private void Initialize(EventFilter ef) { cbError.Checked = ef.ShowError; cbWarning.Checked = ef.ShowWarning; cbInformation.Checked = ef.ShowInformation; cbSuccessAudit.Checked = ef.ShowSuccessAudit; cbFailureAudit.Checked = ef.ShowFailureAudit; tbEventSource.Text = ef.EventSource; if (ef.Category != "") { cbCategory.Text = ef.Category; } else { cbCategory.Text = "(All)"; } if (ef.EventId != -1) { tbEventID.Text = ef.EventId.ToString(); } else { tbEventID.Text = ""; } tbCustomFilterString.Text = ef.CustomFilterString; tbUser.Text = ef.User; tbComputer.Text = tbComputer.Text; if (ef.StartDate == DateTime.MinValue && ef.EndDate == DateTime.MaxValue) { rbShowAll.Checked = true; } else { rbRestrictDates.Checked = true; if (ef.StartDate != null) { dtStart.Value = ef.StartDate; tmStart.Value = ef.StartDate; } if (ef.EndDate != null) { dtEnd.Value = ef.EndDate; tmEnd.Value = ef.EndDate; } } bDefaults = false; }
/// <summary> /// Called when the user selects the "Filter..." action in the action box /// </summary> private void OnFilter_Clicked(object sender, LinkLabelLinkClickedEventArgs e) { EventlogPlugin evtPlugin = (EventlogPlugin)base.pi; LogPropertiesDlg lpDlg = new LogPropertiesDlg( base.container, this, evtPlugin, lvEvents, null, ef, "FilterProperities"); lpDlg.SetData(); lpDlg.ShowDialog(this); if (lpDlg.DialogResult == DialogResult.OK) { EventFilterControl filterform = (EventFilterControl)lpDlg.GetPage("FilterProperities"); ef = filterform.Filter; lblFiltered.Visible = true; lactreeNode.Tag = ef; FillComboWithLogCount(); } }
/// <summary> /// Called when the user selects the "Event properties..." action in the action box /// </summary> private void OnEventProperties_Clicked() { LogPropertiesDlg lpDlg = new LogPropertiesDlg( base.container, this, (EventlogPlugin)base.pi, lvEvents, null, ef, "LogProperities"); lpDlg.SetData(); lpDlg.ShowDialog(this); if (lpDlg.DialogResult == DialogResult.OK) { EventFilterControl filterform = (EventFilterControl)lpDlg.GetPage("FilterProperities"); ef = filterform.Filter; lblFiltered.Visible = ef != null; lactreeNode.Tag = ef; FillComboWithLogCount(); } }
/// <summary> /// Forming SQL Query based on Filter parameter /// </summary> private string FilterSQLQuery(LACTreeNode lacTreeNode) { if (lacTreeNode == null) { return "EventTableCategoryId = 'Application'"; } ef = (EventFilter)lactreeNode.Tag; string sqlfilter = string.Empty; string categoryId = string.Empty; switch (lactreeNode.Text) { case "Application": categoryId = string.Format("EventTableCategoryId = 'Application'"); //(UInt32)EventAPI.TableCategoryType.Application); break; case "WebBrowser": categoryId = string.Format("EventTableCategoryId = 'WebBrowser'");// (UInt32)EventAPI.TableCategoryType.WebBrowser); break; case "Security": categoryId = string.Format("EventTableCategoryId = 'Security'");// (UInt32)EventAPI.TableCategoryType.Security); break; case "System": categoryId = string.Format("EventTableCategoryId = 'System'");// (UInt32)EventAPI.TableCategoryType.Security); break; default: categoryId = string.Format("EventTableCategoryId = 'Application'");// (UInt32)EventAPI.TableCategoryType.System); break; } if (!String.IsNullOrEmpty(categoryId)) { sqlfilter = categoryId; } if (ef != null) { string eventType = "("; string opStr = ""; if (ef.ShowInformation) { eventType += " (EventType LIKE 'Information')"; opStr = " OR "; } if (ef.ShowWarning) { eventType += opStr + "(EventType LIKE 'Warning')"; opStr = " OR "; } if (ef.ShowError) { eventType += opStr + "(EventType LIKE 'Error')"; opStr = " OR "; } if (ef.ShowSuccessAudit) { eventType += opStr + "(EventType LIKE 'Success Audit')"; opStr = " OR "; } if (ef.ShowFailureAudit) { eventType += opStr + "(EventType LIKE 'Failure Audit')"; } eventType += ")"; sqlfilter = sqlfilter + " AND " + eventType; if (!String.IsNullOrEmpty(ef.EventSource)) { string eventsource = string.Format("EventSource LIKE '{0}'", ef.EventSource); if (eventsource != "") { sqlfilter = sqlfilter + " AND " + eventsource; } } if (!String.IsNullOrEmpty(ef.Category)) { string category = string.Format("EventCategory LIKE '{0}'", ef.Category); if (category != "") { sqlfilter = sqlfilter + " AND " + category; } } if (ef.EventId != -1) { string eventid = string.Format("EventSourceId LIKE {0}", (UInt32)ef.EventId); if (eventid != "") { sqlfilter = sqlfilter + " AND " + eventid; } } if (!String.IsNullOrEmpty(ef.User)) { string user = string.Format("User LIKE '{0}'", ef.User); if (user != "") { sqlfilter = sqlfilter + " AND " + user; } } if (!String.IsNullOrEmpty(ef.Computer)) { string computer = string.Format("Computer LIKE '{0}'", ef.Computer); if (computer != "") { sqlfilter = sqlfilter + " AND " + computer; } } if (ef.StartDate != DateTime.MinValue && ef.EndDate != DateTime.MaxValue) { string datetime = string.Format( "EventDateTime between {0} and {1}", EventAPI.ConvertToUnixTimestamp(ef.StartDate), EventAPI.ConvertToUnixTimestamp(ef.EndDate)); if (datetime != "") { sqlfilter = sqlfilter + " AND " + datetime; } } if (ef.CustomFilterString != null && ef.CustomFilterString != "") { sqlfilter = sqlfilter + " AND " + ef.CustomFilterString; } } return sqlfilter; }