示例#1
0
        /// <summary>
        /// Waits for the specified event.
        /// </summary>
        /// <param name="desiredEventCode">event code to wait for</param>
        /// <param name="msTimeout">timeout</param>
        /// <param name="actuallyReceivedEventCode">The event actually received, or "0" if no event was received</param>
        /// <param name="param">1st parameter associated with event</param>
        /// <returns>True if the desired event was received. False if timed out, or different event received</returns>
        public bool WaitForEvent(EventCode desiredEventCode, int msTimeout, out EventCode actuallyReceivedEventCode, out int param)
        {
            bool restartTimer = false;

            if (_mediaSeekTimer.Enabled)
            {
                _mediaSeekTimer.Stop();
                restartTimer = true;
            }

            int    hr = 0;
            IntPtr lparam1, lparam2;

            hr = _mediaEvent.GetEvent(out actuallyReceivedEventCode, out lparam1, out lparam2, msTimeout);
            if (DsError.Succeeded(hr))
            {
                Debug.WriteLine("WaitForEvent got " + actuallyReceivedEventCode.ToString() + " 0x" + lparam1.ToString("X") + " 0x" + lparam2.ToString("X"));
                param = lparam1.ToInt32();
                _mediaEvent.FreeEventParams(actuallyReceivedEventCode, lparam1, lparam2);
            }
            else
            {
                actuallyReceivedEventCode = 0;
                param = 0;
            }

            if (restartTimer)
            {
                _mediaSeekTimer.Start();
            }

            return(DsError.Succeeded(hr) && (actuallyReceivedEventCode == desiredEventCode));
        }
示例#2
0
 public void AddDescription(StringBuilder sb)
 {
     sb.AppendFormat("{0:T}.{1:D3}: ", time, time.Millisecond);
     sb.Append(eventcode.ToString());
     sb.AppendFormat(" ({0}), param1={1} (0x{1:X}), param2={2} (0x{2:X})", (int)eventcode, param1, param2);
     sb.AppendLine();
 }
示例#3
0
        public static int?Log(EventCode eventCode, string description, Exception exception, object payload, LogLevel logLevel)
        {
            if (!Config.Support.EnableLogging)
            {
                return(null);
            }

            var systemLogLevel = Config.Support.LogLevel;

            if (systemLogLevel == LogLevel.WARN.ToString() && (logLevel != LogLevel.ERROR || logLevel != LogLevel.WARN))
            {
                return(null);
            }

            if (systemLogLevel == LogLevel.INFO.ToString() && logLevel == LogLevel.DEBUG)
            {
                return(null);
            }

            var db = new DB();

            // Save in DB
            EventLog eventLog = new EventLog();

            eventLog.EventDate   = DateTime.Now;
            eventLog.Login       = Identity.AuditLogin;
            eventLog.LogLevel    = logLevel.ToString();
            eventLog.EventCode   = eventCode.ToString();
            eventLog.Description = description;
            eventLog.Exception   = SerializeException(exception).NullEmptyString();
            eventLog.Context     = GetContext();

            // Log payload
            if (payload != null)
            {
                var t = payload.GetType();

                if (t.IsPrimitive || t == typeof(Decimal) || t == typeof(String))
                {
                    eventLog.Payload = payload.ToString();
                }
                else
                {
                    eventLog.Payload = payload.ToJson();
                }
            }

            db.EventLog.Add(eventLog);
            db.SaveChanges();

            // Output to console as well?
            if (ConsoleOutput)
            {
                Console.WriteLine(eventCode + " - " + description);
            }

            // Return final message
            return(eventLog.EventLogId);
        }
示例#4
0
        public Data AsData(DataCollectorContext context)
        {
            DictionaryData d = new DictionaryData(context);

            d.Data["Message"]       = Message;
            d.Data["TimeGenerated"] = TimeGeneratedAsDateTimeOffset.ToString("o");
            d.Data["Source"]        = SourceName;
            d.Data["RecordNumber"]  = RecordNumber.ToString();
            d.Data["EventCode"]     = EventCode.ToString();
            return(d);
        }
示例#5
0
    public void OnEvent(EventData eventData)
    {
        Debug.Log("触发了事件:" + (EventCode)eventData.Code + " " + eventData.ToStringFull());
        EventCode code = (EventCode)eventData.Code;

        if (EventDataContain.ContainsKey(code) && EventDataContain[code] != null)
        {
            EventDataContain[code](eventData);
        }
        else
        {
            Debug.LogError("未注册事件:" + code.ToString());
        }
    }
示例#6
0
    public void UnRegisterEventCode(EventCode code, EventDataCallback callback)
    {
        if (EventDataContain.ContainsKey(code))
        {
            EventDataContain[code] -= callback;

            if (EventDataContain[code] == null)
            {
                EventDataContain.Remove(code);
            }
        }
        else
        {
            Debug.LogWarning("未注册事件:" + code.ToString());
        }
    }
            public ChannelSettingsMapper(EventCode code, ControlCollection panel)
            {
                Code = code;

                var name = code.ToString();

                switch (code)
                {
                case EventCode.FreeCompany:
                    name = "FC";
                    break;

                case EventCode.TellFrom:
                    name = "Tell";
                    break;
                }
                CheckBoxFilter = (CheckBox)panel.Find($"checkBoxChannelFilter{name}", true)[0];
                ButtonColor    = (Button)panel.Find($"buttonChannelColor{name}", true)[0];
                CheckBoxLabel  = (CheckBox)panel.Find($"checkBoxChannelLabel{name}", true)[0];

                switch (code)
                {
                case EventCode.FreeCompany:
                    ColorSettingKey = "ColorFCompany";
                    break;

                case EventCode.Novice:
                    ColorSettingKey = "ColorBeginner";
                    break;

                case EventCode.NPC:
                    ColorSettingKey = "ColorNpcSay";
                    break;

                case EventCode.CWLS1:
                    ColorSettingKey = "ColorCWLS";
                    break;

                default:
                    ColorSettingKey = $"Color{name}";
                    break;
                }
            }
            public ChannelSettingsMapper(EventCode code, ControlCollection panel)
            {
                Code = code;

                var name = code.ToString();

                switch (name)
                {
                case "FreeCompany":
                    name = "FC";
                    break;

                case "TellFrom":
                    name = "Tell";
                    break;
                }
                CheckBoxFilter = (CheckBox)panel.Find($"checkBoxChannelFilter{name}", true)[0];
                ButtonColor    = (Button)panel.Find($"buttonChannelColor{name}", true)[0];
                CheckBoxLabel  = (CheckBox)panel.Find($"checkBoxChannelLabel{name}", true)[0];
            }
示例#9
0
 /// <summary>
 /// Is ran everytime a new media event occurs on the graph
 /// </summary>
 /// <param name="code">The Event code that occured</param>
 /// <param name="lparam1">The first event parameter sent by the graph</param>
 /// <param name="lparam2">The second event parameter sent by the graph</param>
 protected override void OnMediaEvent(EventCode code, IntPtr lparam1, IntPtr lparam2)
 {
     Console.WriteLine(code.ToString());
     if (Loop)
     {
         switch (code)
         {
         case EventCode.Complete:
             MediaPosition = 0;
             break;
         }
     }
     else
     {
         /* Only run the base when we don't loop
          * otherwise the default behavior is to
          * fire a media ended event */
         base.OnMediaEvent(code, lparam1, lparam2);
     }
 }