private void FireSystemEvent(SystemEventType type) { var se = Create <SystemEvent>(); se.Type = type; FireNow(se); }
private List <SystemEventSetting> GetQueuesForEvent(SystemEventType eventType) { var queuesToSend = _SystemEventSettings .Where(eventSettings => eventSettings.SystemEventType == eventType && eventSettings.IsActive).ToList(); return(queuesToSend); }
public AutoEvent(OpcServer.OpcList opcName, string opcTag, SystemEventType eventType, string eventText, bool logic) { _opcName = opcName; _opcTag = opcTag; _eventType = eventType; _eventText = eventText; _logic = logic; Subscribe(); }
public FeatureBuilder OnSystemEvent(SystemEventType eventType, Action <IQuery> handler) { Action <IQuery> oldHandler; if (feature.HandledEvents.TryGetValue(eventType, out oldHandler)) { handler = (Action <IQuery>)Delegate.Combine(oldHandler, handler); } feature.HandledEvents[eventType] = handler; return(this); }
public virtual void Send(SystemEventType eventType, object data, string error = null) { _Logger.LogInformation("Send. eventType: {0}, data: {1}", eventType, data); var message = new QueueMessage { Data = GetDataAsString(data), EventType = eventType, Error = error }; Send(message); }
protected virtual void DispatchEvent( SystemEventType evtType, IWebSocketClientConnection connection, JObject json = null) { if (SystemEvent != null) { SystemEventArgs args = new SystemEventArgs(); args.evtType = evtType; args.json = json; SystemEvent(connection, args); } }
/// <summary> /// Create a log entry in the system /// </summary> /// <param name="eventType">The event type</param> /// <param name="msg">The message to log</param> /// <returns>An error collection with anything found</returns> public static ClassGenExceptionCollection CreateLogEntry(SystemEventType eventType, string msg) { ClassGenExceptionCollection errors = new ClassGenExceptionCollection(); // Generate a log entry LogSystem item = new LogSystem(); item.DateLogged = DateTime.Now; item.EventType = eventType.ToString(); item.Message = msg; errors = item.AddUpdate(); return(errors); }
static void display_SystemEvent(object sender, SystemEventType eventType, SystemEventParameter parameter) { if (eventType == SystemEventType.AutomaticSleepMode) { Debug.Print("==> Automatic sleep mode"); } else if (eventType == SystemEventType.AutomaticWakeUp) { Debug.Print("==> Automatic wakeup"); } else { Debug.Print("Unknown system event type: " + eventType); } }
private static void GetSystemEventTypeInfo(int eventCode, int index0, int index1, out SystemEventTypeInfo info, out SystemEventType systemEventType) { systemEventType = s_eventCodeToSystemEventTypeMappings[index0, index1]; if (systemEventType == SystemEventType.Unknown) { systemEventType = SystemEventTypeFromEventCode(eventCode); s_eventCodeToSystemEventTypeMappings[index0, index1] = systemEventType; } info = s_systemEventTypeInfos[(int)systemEventType]; if (info == null) { info = new SystemEventTypeInfo(CreateDummySystemEvent(systemEventType)); s_systemEventTypeInfos[(int)systemEventType] = info; } }
private Task WriteSystemEvents(KamaAcquisitionFile file) { Array values = Enum.GetValues(typeof(SystemEventType)); Random random = new Random(); return(Task.Factory.StartNew(() => { for (int i = 0; i < 100; i++) { SystemEventType set = (SystemEventType)values.GetValue(random.Next(values.Length)); SystemEventModel se = new SystemEventModel(set, DateTimeOffset.Now.ToUnixTimeMilliseconds(), "Empty"); file.AppendSystemEvent(se); } })); }
/* * Logs interserver communication * @param command The user command that is driving the process */ protected void LogServerEvent(UserCommandType command) { SystemEventType sysEvent = new SystemEventType() { timestamp = Unix.TimeStamp.ToString(), server = ServiceDetails.Abbr, transactionNum = command.transactionNum, username = command.username, fundsSpecified = command.fundsSpecified, command = command.command, filename = command.filename, stockSymbol = command.stockSymbol }; if (command.fundsSpecified) { sysEvent.funds = command.funds / 100m; } Auditor.WriteRecord(sysEvent); }
public static IDisposable?TryRegister(SystemEventType type, Action handler) { if (type == SystemEventType.DisplayStateChanged) { return(PowerEvent.TryRegister(PowerEvent.DisplayStateChangedId, handler)); } if (type == SystemEventType.DisplaySettingsChanged) { var adapter = new EventDelegateAdapter(handler); SystemEvents.DisplaySettingsChanging += adapter.HandleEvent; SystemEvents.DisplaySettingsChanged += adapter.HandleEvent; return(Disposable.Create(() => { SystemEvents.DisplaySettingsChanging -= adapter.HandleEvent; SystemEvents.DisplaySettingsChanged -= adapter.HandleEvent; })); } throw new ArgumentOutOfRangeException(nameof(type)); }
private static int GetEventCount(SystemEventType evtType, int timeSpanMs) { ERROR status = ERROR.ERROR_SUCCESS; IntPtr hResult = IntPtr.Zero; IntPtr[] eventBatch = new IntPtr[10]; // these 2 event id's, along with 'USER32' event source, denote requested // shutdown and abort, respectively string shutDownId = "1074"; string abortId = "1075"; // XPath query to get the event id, event source, and timespan in ms from now // back to when the event was posted to the event log. string format = "*[System[(EventID = {0}) and Provider[@Name=\"USER32\"] and TimeCreated[timediff(@SystemTime) <= {1}]]]"; // The "System" event channel string channelPath = "System"; int nEvents = 0; int count = 0; string evtQuery; switch (evtType) { case SystemEventType.Shutdown: evtQuery = string.Format(format, shutDownId, timeSpanMs); break; case SystemEventType.Abort: evtQuery = string.Format(format, abortId, timeSpanMs); break; default: throw new InvalidOperationException(); } hResult = EvtQuery(IntPtr.Zero, channelPath, evtQuery, (int)(EVT_QUERY_FLAGS.EvtQueryChannelPath | EVT_QUERY_FLAGS.EvtQueryReverseDirection)); if (IntPtr.Zero == hResult) { status = (ERROR)GetLastError(); if (status == ERROR.ERROR_EVT_CHANNEL_NOT_FOUND) { // log error return(0); } else if (status == ERROR.ERROR_EVT_INVALID_QUERY) { // log error return(0); } else { // log error return(0); } } while (EvtNext(hResult, 10, eventBatch, 1000, 0, ref nEvents)) { for (int i = 0; i < nEvents; i++) { count++; if (eventBatch[i] != IntPtr.Zero) { EvtClose(eventBatch[i]); } } } status = (ERROR)GetLastError(); if (status != ERROR.ERROR_NO_MORE_ITEMS) { // log error here and cleanup any remaining events for (int i = 0; i < nEvents; i++) { if (eventBatch[i] != IntPtr.Zero) { EvtClose(eventBatch[i]); } } } if (hResult != null) { EvtClose(hResult); } return(count); }
internal void OnSystemEvent(SystemEventType eventType, IQuery systemQuery) { systemEventHandler(new SystemEvent(eventType, systemQuery)); }
static void GetSystemEventTypeInfo(int eventCode, int index0, int index1, out SystemEventTypeInfo info, out SystemEventType systemEventType) { // Figure out what SystemEventType this eventCode maps to. // For each eventCode, we store the result in a cache. systemEventType = s_eventCodeToSystemEventTypeMappings[index0, index1]; if (systemEventType == SystemEventType.Unknown) { systemEventType = SystemEventTypeFromEventCode(eventCode); s_eventCodeToSystemEventTypeMappings[index0, index1] = systemEventType; } // Based on the systemEventType, we read the SystemEventTypeInfo. For each // event type, we also cache the info info = s_systemEventTypeInfos[(int)systemEventType]; if (info != null) { return; } info = new SystemEventTypeInfo(CreateDummySystemEvent(systemEventType)); s_systemEventTypeInfos[(int)systemEventType] = info; }
private static WebBaseEvent CreateDummySystemEvent(SystemEventType systemEventType) { return NewEventFromSystemEventType(true, systemEventType, null, null, 0, 0, null, null); }
public SystemEvent(SystemEventType type) : base() { _type = type; }
private static void GetSystemEventTypeInfo(int eventCode, int index0, int index1, out SystemEventTypeInfo info, out SystemEventType systemEventType) { systemEventType = s_eventCodeToSystemEventTypeMappings[index0, index1]; if (systemEventType == SystemEventType.Unknown) { systemEventType = SystemEventTypeFromEventCode(eventCode); s_eventCodeToSystemEventTypeMappings[index0, index1] = systemEventType; } info = s_systemEventTypeInfos[(int) systemEventType]; if (info == null) { info = new SystemEventTypeInfo(CreateDummySystemEvent(systemEventType)); s_systemEventTypeInfos[(int) systemEventType] = info; } }
public SystemEvent(SystemEventType type, int value, int value2) { _type = type; _value = value; _value2 = value2; }
private static WebBaseEvent NewEventFromSystemEventType(bool createDummy, SystemEventType systemEventType, string message, object source, int eventCode, int eventDetailCode, Exception exception, string nameToAuthenticate) { if (!createDummy && (message == null)) { message = WebEventCodes.MessageFromEventCode(eventCode, eventDetailCode); } switch (systemEventType) { case SystemEventType.WebApplicationLifetimeEvent: if (createDummy) { return(new WebApplicationLifetimeEvent()); } return(new WebApplicationLifetimeEvent(message, source, eventCode, eventDetailCode)); case SystemEventType.WebHeartbeatEvent: if (createDummy) { return(new WebHeartbeatEvent()); } return(new WebHeartbeatEvent(message, eventCode)); case SystemEventType.WebRequestEvent: if (createDummy) { return(new WebRequestEvent()); } return(new WebRequestEvent(message, source, eventCode, eventDetailCode)); case SystemEventType.WebRequestErrorEvent: if (createDummy) { return(new WebRequestErrorEvent()); } return(new WebRequestErrorEvent(message, source, eventCode, eventDetailCode, exception)); case SystemEventType.WebErrorEvent: if (createDummy) { return(new WebErrorEvent()); } return(new WebErrorEvent(message, source, eventCode, eventDetailCode, exception)); case SystemEventType.WebAuthenticationSuccessAuditEvent: if (createDummy) { return(new WebAuthenticationSuccessAuditEvent()); } return(new WebAuthenticationSuccessAuditEvent(message, source, eventCode, eventDetailCode, nameToAuthenticate)); case SystemEventType.WebSuccessAuditEvent: if (createDummy) { return(new WebSuccessAuditEvent()); } return(new WebSuccessAuditEvent(message, source, eventCode, eventDetailCode)); case SystemEventType.WebAuthenticationFailureAuditEvent: if (createDummy) { return(new WebAuthenticationFailureAuditEvent()); } return(new WebAuthenticationFailureAuditEvent(message, source, eventCode, eventDetailCode, nameToAuthenticate)); case SystemEventType.WebFailureAuditEvent: if (createDummy) { return(new WebFailureAuditEvent()); } return(new WebFailureAuditEvent(message, source, eventCode, eventDetailCode)); case SystemEventType.WebViewStateFailureAuditEvent: if (createDummy) { return(new WebViewStateFailureAuditEvent()); } return(new WebViewStateFailureAuditEvent(message, source, eventCode, eventDetailCode, (ViewStateException)exception)); } return(null); }
static WebBaseEvent NewEventFromSystemEventType(bool createDummy, SystemEventType systemEventType, string message, object source,int eventCode, int eventDetailCode, Exception exception, string nameToAuthenticate) { // If createDummy == true, it means we're only creating a dummy event for the sake of using // it to call IncrementPerfCounters() if (!createDummy && message == null) { message = WebEventCodes.MessageFromEventCode(eventCode, eventDetailCode); } // Code view note for the future: // If the number of systemEventType increases tremendoulsy, we may need to // avoid using switch, and change to use a "factory" to create new event. switch(systemEventType) { case SystemEventType.WebApplicationLifetimeEvent: return createDummy ? new WebApplicationLifetimeEvent() : new WebApplicationLifetimeEvent(message, source, eventCode, eventDetailCode); case SystemEventType.WebHeartbeatEvent: return createDummy ? new WebHeartbeatEvent() : new WebHeartbeatEvent(message, eventCode); case SystemEventType.WebRequestEvent: return createDummy ? new WebRequestEvent() : new WebRequestEvent(message, source, eventCode, eventDetailCode); case SystemEventType. WebRequestErrorEvent: return createDummy ? new WebRequestErrorEvent() : new WebRequestErrorEvent(message, source, eventCode, eventDetailCode, exception); case SystemEventType.WebErrorEvent: return createDummy ? new WebErrorEvent() : new WebErrorEvent(message, source, eventCode, eventDetailCode, exception); case SystemEventType.WebAuthenticationSuccessAuditEvent: return createDummy ? new WebAuthenticationSuccessAuditEvent() : new WebAuthenticationSuccessAuditEvent(message, source, eventCode, eventDetailCode, nameToAuthenticate); case SystemEventType.WebSuccessAuditEvent: return createDummy ? new WebSuccessAuditEvent() : new WebSuccessAuditEvent(message, source, eventCode, eventDetailCode); case SystemEventType.WebAuthenticationFailureAuditEvent: return createDummy ? new WebAuthenticationFailureAuditEvent() : new WebAuthenticationFailureAuditEvent(message, source, eventCode, eventDetailCode, nameToAuthenticate); case SystemEventType.WebFailureAuditEvent: return createDummy ? new WebFailureAuditEvent() : new WebFailureAuditEvent(message, source, eventCode, eventDetailCode); case SystemEventType.WebViewStateFailureAuditEvent: return createDummy ? new WebViewStateFailureAuditEvent() : new WebViewStateFailureAuditEvent(message, source, eventCode, eventDetailCode, (System.Web.UI.ViewStateException)exception); default: Debug.Assert(false, "Unexpected event type = " + systemEventType); return null; } }
public SystemEventModel(SystemEventType systemEventType, long timeStamp, string eventData) { SystemEventType = systemEventType; TimeStamp = timeStamp; EventData = eventData; }
private static WebBaseEvent NewEventFromSystemEventType(bool createDummy, SystemEventType systemEventType, string message, object source, int eventCode, int eventDetailCode, Exception exception, string nameToAuthenticate) { if (!createDummy && (message == null)) { message = WebEventCodes.MessageFromEventCode(eventCode, eventDetailCode); } switch (systemEventType) { case SystemEventType.WebApplicationLifetimeEvent: if (createDummy) { return new WebApplicationLifetimeEvent(); } return new WebApplicationLifetimeEvent(message, source, eventCode, eventDetailCode); case SystemEventType.WebHeartbeatEvent: if (createDummy) { return new WebHeartbeatEvent(); } return new WebHeartbeatEvent(message, eventCode); case SystemEventType.WebRequestEvent: if (createDummy) { return new WebRequestEvent(); } return new WebRequestEvent(message, source, eventCode, eventDetailCode); case SystemEventType.WebRequestErrorEvent: if (createDummy) { return new WebRequestErrorEvent(); } return new WebRequestErrorEvent(message, source, eventCode, eventDetailCode, exception); case SystemEventType.WebErrorEvent: if (createDummy) { return new WebErrorEvent(); } return new WebErrorEvent(message, source, eventCode, eventDetailCode, exception); case SystemEventType.WebAuthenticationSuccessAuditEvent: if (createDummy) { return new WebAuthenticationSuccessAuditEvent(); } return new WebAuthenticationSuccessAuditEvent(message, source, eventCode, eventDetailCode, nameToAuthenticate); case SystemEventType.WebSuccessAuditEvent: if (createDummy) { return new WebSuccessAuditEvent(); } return new WebSuccessAuditEvent(message, source, eventCode, eventDetailCode); case SystemEventType.WebAuthenticationFailureAuditEvent: if (createDummy) { return new WebAuthenticationFailureAuditEvent(); } return new WebAuthenticationFailureAuditEvent(message, source, eventCode, eventDetailCode, nameToAuthenticate); case SystemEventType.WebFailureAuditEvent: if (createDummy) { return new WebFailureAuditEvent(); } return new WebFailureAuditEvent(message, source, eventCode, eventDetailCode); case SystemEventType.WebViewStateFailureAuditEvent: if (createDummy) { return new WebViewStateFailureAuditEvent(); } return new WebViewStateFailureAuditEvent(message, source, eventCode, eventDetailCode, (ViewStateException) exception); } return null; }
public SystemEvent(SystemEventType eventType, IQuery systemQuery) { EventType = eventType; SystemQuery = systemQuery; }
public void Queue(SystemEventType type, int value, int value2) { _events.Enqueue(new SystemEvent(type, value, value2)); }
private static WebBaseEvent CreateDummySystemEvent(SystemEventType systemEventType) { return(NewEventFromSystemEventType(true, systemEventType, null, null, 0, 0, null, null)); }