コード例 #1
0
        private void FireSystemEvent(SystemEventType type)
        {
            var se = Create <SystemEvent>();

            se.Type = type;
            FireNow(se);
        }
コード例 #2
0
        private List <SystemEventSetting> GetQueuesForEvent(SystemEventType eventType)
        {
            var queuesToSend =
                _SystemEventSettings
                .Where(eventSettings => eventSettings.SystemEventType == eventType && eventSettings.IsActive).ToList();

            return(queuesToSend);
        }
コード例 #3
0
        public AutoEvent(OpcServer.OpcList opcName, string opcTag, SystemEventType eventType, string eventText, bool logic)
        {
            _opcName   = opcName;
            _opcTag    = opcTag;
            _eventType = eventType;
            _eventText = eventText;
            _logic     = logic;

            Subscribe();
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 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);
     }
 }
コード例 #7
0
        /// <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);
        }
コード例 #8
0
ファイル: TestAutoSleep.cs プロジェクト: valoni/NextionNET
 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);
     }
 }
コード例 #9
0
 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;
     }
 }
コード例 #10
0
        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);
                }
            }));
        }
コード例 #11
0
        /*
         * 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);
        }
コード例 #12
0
        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));
        }
コード例 #13
0
        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);
        }
コード例 #14
0
 internal void OnSystemEvent(SystemEventType eventType, IQuery systemQuery)
 {
     systemEventHandler(new SystemEvent(eventType, systemQuery));
 }
コード例 #15
0
ファイル: FeatureInfo.cs プロジェクト: deveel/deveeldb
 internal void OnSystemEvent(SystemEventType eventType, IQuery systemQuery)
 {
     systemEventHandler(new SystemEvent(eventType, systemQuery));
 }
コード例 #16
0
        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;
        }
コード例 #17
0
 private static WebBaseEvent CreateDummySystemEvent(SystemEventType systemEventType)
 {
     return NewEventFromSystemEventType(true, systemEventType, null, null, 0, 0, null, null);
 }
コード例 #18
0
ファイル: idEventLoop.cs プロジェクト: iainmckay/idtech4.net
		public SystemEvent(SystemEventType type)
			: base()
		{
			_type = type;
		}
コード例 #19
0
 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;
     }
 }
コード例 #20
0
ファイル: idEventLoop.cs プロジェクト: PEMantis/idtech4.net
 public SystemEvent(SystemEventType type, int value, int value2)
 {
     _type   = type;
     _value  = value;
     _value2 = value2;
 }
コード例 #21
0
        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);
        }
コード例 #22
0
        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;
            }
        }
コード例 #23
0
ファイル: idEventLoop.cs プロジェクト: iainmckay/idtech4.net
		public SystemEvent(SystemEventType type, int value, int value2)
		{
			_type = type;
			_value = value;
			_value2 = value2;
		}
コード例 #24
0
ファイル: systemEvent.cs プロジェクト: dataangel/HDF5-CSharp
 public SystemEventModel(SystemEventType systemEventType, long timeStamp, string eventData)
 {
     SystemEventType = systemEventType;
     TimeStamp       = timeStamp;
     EventData       = eventData;
 }
コード例 #25
0
        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;
        }
コード例 #26
0
 public SystemEvent(SystemEventType eventType, IQuery systemQuery)
 {
     EventType   = eventType;
     SystemQuery = systemQuery;
 }
コード例 #27
0
ファイル: idEventLoop.cs プロジェクト: iainmckay/idtech4.net
		public void Queue(SystemEventType type, int value, int value2)
		{
			_events.Enqueue(new SystemEvent(type, value, value2));
		}
コード例 #28
0
ファイル: idEventLoop.cs プロジェクト: PEMantis/idtech4.net
 public void Queue(SystemEventType type, int value, int value2)
 {
     _events.Enqueue(new SystemEvent(type, value, value2));
 }
コード例 #29
0
ファイル: idEventLoop.cs プロジェクト: PEMantis/idtech4.net
 public SystemEvent(SystemEventType type)
     : base()
 {
     _type = type;
 }
コード例 #30
0
 private static WebBaseEvent CreateDummySystemEvent(SystemEventType systemEventType)
 {
     return(NewEventFromSystemEventType(true, systemEventType, null, null, 0, 0, null, null));
 }
コード例 #31
0
ファイル: SystemEvent.cs プロジェクト: deveel/deveeldb
 public SystemEvent(SystemEventType eventType, IQuery systemQuery)
 {
     EventType = eventType;
     SystemQuery = systemQuery;
 }