public void CloseEventLog() { if (eventLogHandle == null) { return; } eventLogHandle.Dispose(); eventLogHandle = null; }
public bool OpenEventLog(string hostname) { try { if (eventLogHandle == null) { eventLogHandle = EventlogAdapter.OpenEventlog(hostname); } return(eventLogHandle != null); } catch (Exception e) { Logger.LogException("EventViewerPlugin.OpenEventLog", e); eventLogHandle = null; return(false); } }
private void ConnectToDomain() { Logger.Log("EventlogPlugin.ConnectToDomain", Logger.eventLogLogLevel); if (_hn.creds.Invalidated) { _container.ShowError("EventlogPlugin cannot connect to domain due to invalid credentials"); _hn.IsConnectionSuccess = false; return; } if (!String.IsNullOrEmpty(_hn.hostName)) { if (_currentHost != _hn.hostName) { if (eventLogHandle != null) { eventLogHandle.Dispose(); eventLogHandle = null; } if (_pluginNode != null && !String.IsNullOrEmpty(_hn.hostName)) { _hn.IsConnectionSuccess = OpenEventLog(_hn.hostName); if (!_hn.IsConnectionSuccess) { Logger.ShowUserError("Unable to open the event log; eventlog server may be disabled"); return; } if (eventLogHandle != null) { _pluginNode.Nodes.Clear(); } } _currentHost = _hn.hostName; } _hn.IsConnectionSuccess = true; } else { _hn.IsConnectionSuccess = false; } }