Esempio n. 1
0
        void lampDimmer_LoadStateChange(LightingBase lightingObject, LoadEventArgs args)
        {
            if (EventIds.ContainsKey(args.EventId))
            {
                CrestronConsole.PrintLine("Lamp dimmer: {0}", EventIds[args.EventId]);
            }

            // use this structure to react to the different events
            switch (args.EventId)
            {
            case LoadEventIds.IsOnEventId:
                xp.BooleanInput[1].BoolValue = !lampDimmer.DimmingLoads[1].IsOn;
                xp.BooleanInput[2].BoolValue = lampDimmer.DimmingLoads[1].IsOn;
                break;

            case LoadEventIds.LevelChangeEventId:
                xp.UShortInput[1].UShortValue = lampDimmer.DimmingLoads[1].LevelFeedback.UShortValue;
                break;

            case LoadEventIds.LevelInputChangedEventId:
                xp.UShortInput[1].CreateRamp(lampDimmer.DimmingLoads[1].Level.RampingInformation);
                break;

            default:
                break;
            }
        }
Esempio n. 2
0
 private void SingleTarget()
 {
     FromCard.SetTargetedBy(Who);
     Program.GameEngine.EventProxy.OnTargetCard(Who, FromCard, true);
     Program.Trace.TraceEvent(TraceEventType.Information, EventIds.Event | EventIds.PlayerFlag(Who),
                              "{0} targets '{1}'", Who, FromCard);
 }
Esempio n. 3
0
        public IEnumerable <HistoryEvent> TimerCancelledGraph(Identity timerId, TimeSpan startToFireTimeout, bool isARescheduleTimer = false)
        {
            var historyEvents = new List <HistoryEvent>();
            var eventIds      = EventIds.TimerCancelledIds(ref _currentEventId);

            historyEvents.Add(new HistoryEvent()
            {
                EventType = EventType.TimerCanceled,
                EventId   = eventIds.EventId(EventIds.Cancelled),
                TimerCanceledEventAttributes = new TimerCanceledEventAttributes()
                {
                    StartedEventId = eventIds.EventId(EventIds.Started),
                    TimerId        = timerId.Id,
                },
            });

            historyEvents.Add(new HistoryEvent()
            {
                EventType = EventType.TimerStarted,
                EventId   = eventIds.EventId(EventIds.Started),
                TimerStartedEventAttributes = new TimerStartedEventAttributes()
                {
                    TimerId            = timerId.Id,
                    StartToFireTimeout = ((long)startToFireTimeout.TotalSeconds).ToString(),
                    Control            = (new TimerScheduleData()
                    {
                        TimerName = timerId.Name, IsARescheduleTimer = isARescheduleTimer
                    }).ToJson()
                }
            });

            return(historyEvents);
        }
Esempio n. 4
0
 public override void Do()
 {
     base.Do();
     _card.SetOrientation(_rot);
     Program.Trace.TraceEvent(TraceEventType.Information, EventIds.Event | EventIds.PlayerFlag(_who),
                              "{0} sets '{1}' orientation to {2}", _who, _card, _rot);
 }
Esempio n. 5
0
        //internal List<EventLogEntryEx> GetMatchingEventLogEntries()
        //{
        //    List<EventLogEntryEx> list = new List<EventLogEntryEx>();
        //    using (diag.EventLog log = new diag.EventLog(EventLog, Computer))
        //    {
        //        DateTime currentTime = DateTime.Now;
        //        int counter = 0;
        //        int listSize = log.Entries.Count - 1;

        //        for (int i = listSize; i >= 0; i--)
        //        {
        //            try
        //            {
        //                diag.EventLogEntry entry = log.Entries[i];
        //                if (WithInLastXEntries > 0 && WithInLastXEntries <= counter)
        //                    break;
        //                if (WithInLastXMinutes > 0 && entry.TimeGenerated.AddMinutes(WithInLastXMinutes) < currentTime)
        //                    break;

        //                EventLogEntryEx newentry = new EventLogEntryEx();
        //                newentry.Category = entry.Category;
        //                newentry.EntryType = entry.EntryType;
        //                newentry.EventId = (int)(entry.InstanceId & 65535);
        //                newentry.MachineName = entry.MachineName;
        //                newentry.LogName = EventLog;
        //                newentry.Message = entry.Message;
        //                newentry.MessageSummary = newentry.Message.Length > 80 ? newentry.Message.Substring(0, 80) : newentry.Message;
        //                newentry.Source = entry.Source;
        //                newentry.TimeGenerated = entry.TimeGenerated;
        //                newentry.UserName = entry.UserName;

        //                if (MatchEntry(newentry))
        //                    list.Add(newentry);
        //                counter++;
        //            }
        //            catch (Exception ex)
        //            {
        //                if (!ex.ToString().Contains("is out of bounds"))
        //                {
        //                    throw;
        //                }
        //            }
        //        }
        //    }
        //    return list;
        //}
        private bool MatchEntry(EventLogEntryEx entry)
        {
            bool match = true;

            if (!EventEntryTypeMatch(entry))
            {
                match = false;
            }
            else if (Sources.Count > 0 && !Sources.Contains(entry.Source))
            {
                match = false;
            }
            else if (EventIds.Count > 0 && !EventIds.Contains(entry.EventId))
            {
                match = false;
            }
            else if (TextFilter.Length > 0 && UseRegEx)
            {
                System.Text.RegularExpressions.Match regMatch = System.Text.RegularExpressions.Regex.Match(entry.Message, TextFilter, System.Text.RegularExpressions.RegexOptions.Multiline);
                match = regMatch.Success;
            }
            else if (TextFilter.Length > 0 && !ContainsText && (!entry.Message.StartsWith(TextFilter, StringComparison.CurrentCultureIgnoreCase)))
            {
                match = false;
            }
            else if (TextFilter.Length > 0 && ContainsText && (!entry.Message.ToLower().Contains(TextFilter.ToLower())))
            {
                match = false;
            }
            return(match);
        }
Esempio n. 6
0
        public static R LogStartEndAndElapsedTime <T, R>(this ILogger <T> logger,
                                                         EventIds startEventId,
                                                         EventIds completedEventId,
                                                         string messageFormat,
                                                         Func <R> func,
                                                         params object[] messageArguments)
        {
            logger.LogInformation(startEventId.ToEventId(), messageFormat, messageArguments);

            var stopwatch = new Stopwatch();

            stopwatch.Start();

            try
            {
                return(func());
            }
            finally
            {
                stopwatch.Stop();
                logger.LogInformation(completedEventId.ToEventId(),
                                      messageFormat + " Elapsed {Elapsed}",
                                      messageArguments.Concat(new object[] { stopwatch.Elapsed }).ToArray());
            }
        }
Esempio n. 7
0
        private bool MatchEntry(EventLogEntryEx entry)
        {
            bool match = true;

            if (!EventEntryTypeMatch(entry))
            {
                match = false;
            }
            else if (Sources.Count > 0 && !Sources.Contains(entry.Source))
            {
                match = false;
            }
            else if (EventIds.Count > 0 && !EventIds.Contains(entry.EventId))
            {
                match = false;
            }
            else if (TextFilter.Length > 0 && ContainsText && (!entry.Message.ToLower().Contains(TextFilter.ToLower())))
            {
                match = false;
            }
            else if (TextFilter.Length > 0 && !ContainsText && (!entry.Message.StartsWith(TextFilter, StringComparison.CurrentCultureIgnoreCase)))
            {
                match = false;
            }
            return(match);
        }
Esempio n. 8
0
        public IEnumerable <HistoryEvent> ActivityStartedGraph(Identity activityIdentity, string identity)
        {
            var historyEvents = new List <HistoryEvent>();
            var eventIds      = EventIds.ActivityStartedIds(ref _currentEventId);

            historyEvents.Add(new HistoryEvent()
            {
                EventType = EventType.ActivityTaskStarted,
                EventId   = eventIds.EventId(EventIds.Started),
                ActivityTaskStartedEventAttributes = new ActivityTaskStartedEventAttributes()
                {
                    Identity         = identity,
                    ScheduledEventId = eventIds.EventId(EventIds.Scheduled)
                }
            });
            historyEvents.Add(new HistoryEvent()
            {
                EventType = EventType.ActivityTaskScheduled,
                EventId   = eventIds.EventId(EventIds.Scheduled),
                ActivityTaskScheduledEventAttributes = new ActivityTaskScheduledEventAttributes()
                {
                    ActivityType = new ActivityType()
                    {
                        Name = activityIdentity.Name, Version = activityIdentity.Version
                    },
                    Control    = (new ActivityScheduleData()
                    {
                        PN = activityIdentity.PositionalName
                    }).ToJson(),
                    ActivityId = activityIdentity.Id
                }
            });
            return(historyEvents);
        }
Esempio n. 9
0
        public IEnumerable <HistoryEvent> TimerCancellationFailedGraph(Identity timerId, string cause)
        {
            var historyEvents = new List <HistoryEvent>();
            var eventIds      = EventIds.CancellationFailedIds(ref _currentEventId);

            historyEvents.Add(new HistoryEvent()
            {
                EventType = EventType.CancelTimerFailed,
                EventId   = eventIds.EventId(EventIds.Failed),
                CancelTimerFailedEventAttributes = new CancelTimerFailedEventAttributes()
                {
                    TimerId = timerId.Id,
                    Cause   = cause
                }
            });

            historyEvents.Add(new HistoryEvent()
            {
                EventType = EventType.TimerStarted,
                EventId   = eventIds.EventId(EventIds.Started),
                TimerStartedEventAttributes = new TimerStartedEventAttributes()
                {
                    TimerId            = timerId.Id,
                    StartToFireTimeout = ((long)20).ToString(),
                    Control            = (new TimerScheduleData()
                    {
                        TimerName = timerId.Name, IsARescheduleTimer = false
                    }).ToJson()
                }
            });
            return(historyEvents);
        }
Esempio n. 10
0
    /// <summary>
    /// Failed event is added to dictionary for scorekeeping
    /// </summary>
    /// <param name="eventId">Event's ID</param>
    public void NotifyEventFailier(int eventId)
    {
        EventIds eid = (EventIds)eventId;

        _failedEvents.Add(eid.ToString(), eventId);
        _pastEventsList.Add(eventId);
        _isEventInProgress = false;
    }
Esempio n. 11
0
 public void StopTurn(Player player)
 {
     if (player == Player.LocalPlayer)
     {
         Program.Game.StopTurn = false;
     }
     Program.Trace.TraceEvent(TraceEventType.Information, EventIds.Event | EventIds.PlayerFlag(player), "{0} wants to play before end of turn.", player);
 }
Esempio n. 12
0
    /// <summary>
    /// Successful events are added to dictionary for scorekeeping
    /// </summary>
    /// <param name="eventId"></param>
    public void NotifyEventSuccess(int eventId)
    {
        EventIds eid = (EventIds)eventId;

        _finishedEvents.Add(eid.ToString(), eventId);
        _pastEventsList.Add(eventId);
        _isEventInProgress = false;
    }
Esempio n. 13
0
        void wallDimmer_LoadStateChange(LightingBase lightingObject, LoadEventArgs args)
        {
            if (EventIds.ContainsKey(args.EventId))
            {
                CrestronConsole.PrintLine("Wall dimmer: {0}", EventIds[args.EventId]);
            }

            // see below
        }
Esempio n. 14
0
 private void ArrowTarget()
 {
     if (CreatingArrow != null)
     {
         CreatingArrow(this, EventArgs.Empty);
     }
     Program.Trace.TraceEvent(TraceEventType.Information, EventIds.Event | EventIds.PlayerFlag(Who),
                              "{0} targets '{2}' with '{1}'", Who, FromCard, ToCard);
 }
Esempio n. 15
0
        /// <summary>
        /// Logs an event to the Windows Application log..
        /// </summary>
        /// <param name="message">The text of the log message.</param>
        /// <param name="type">Event type (Info/Warning/Error)</param>
        /// <param name="id">The numeric identifier from the EventIds enumeration.</param>
        public static void LogE(string message, EventLogEntryType type, EventIds id)
        {
            if (eventLog == null)
            {
                SetupEventLog();
            }

            ////eventLog.WriteEntry(message, type, (int)Id);
        }
Esempio n. 16
0
 public void GroupVisRemove(Player player, Group group, Player whom)
 {
     // Ignore messages sent by myself
     if (player != Player.LocalPlayer)
     {
         group.RemoveViewer(whom, false);
     }
     Program.Trace.TraceEvent(TraceEventType.Information, EventIds.Event | EventIds.PlayerFlag(player), "{0} hides {1} from {2}.", player, group, whom);
 }
        /// <summary>
        ///     Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            // credit: http://stackoverflow.com/a/263416/677735
            unchecked // Overflow is fine, just wrap
            {
                var hash = 41;
                // Suitable nullity checks etc, of course :)

                if (CountryCodes != null)
                {
                    hash = hash * 59 + CountryCodes.GetHashCode();
                }

                if (BettingTypes != null)
                {
                    hash = hash * 59 + BettingTypes.GetHashCode();
                }

                if (TurnInPlayEnabled != null)
                {
                    hash = hash * 59 + TurnInPlayEnabled.GetHashCode();
                }

                if (MarketTypes != null)
                {
                    hash = hash * 59 + MarketTypes.GetHashCode();
                }

                if (Venues != null)
                {
                    hash = hash * 59 + Venues.GetHashCode();
                }

                if (MarketIds != null)
                {
                    hash = hash * 59 + MarketIds.GetHashCode();
                }

                if (EventTypeIds != null)
                {
                    hash = hash * 59 + EventTypeIds.GetHashCode();
                }

                if (EventIds != null)
                {
                    hash = hash * 59 + EventIds.GetHashCode();
                }

                if (BspMarket != null)
                {
                    hash = hash * 59 + BspMarket.GetHashCode();
                }

                return(hash);
            }
        }
Esempio n. 18
0
        internal static void TracePlayerEvent(Player player, string message, params object[] args)
        {
            var args1 = new List <object>(args)
            {
                player
            };

            Trace.TraceEvent(TraceEventType.Information, EventIds.Event | EventIds.PlayerFlag(player), message,
                             args1.ToArray());
        }
Esempio n. 19
0
        private List <EventModel> InitEventCollection()
        {
            var collection = collectionInitializer.Initialize <Event, EventModel>(e => e.MeetId == MeetId && EventIds.Contains(e.Id));

            var sorted = collection
                         .Select(e => new { Event = e, Rank = EventIds.IndexOf(e.Id) })
                         .OrderBy(a => a.Rank)
                         .Select(a => a.Event)
                         .ToList();

            return(sorted);
        }
Esempio n. 20
0
    public void TriggerEvent(GameEventsList.PlayerEvents EventType, PlayerEventParams playerEventParams)
    {
        EventIds eventIds = m_EventIdMapper.Find(x => x._eventType == EventType);

        if (eventIds != null)
        {
            InvokeRelevantListeners(eventIds._ids, GameEventHandlers.GetInvocationList(), playerEventParams);
        }
        else
        {
            //Debug.Log("Key Not Found!");
        }
    }
Esempio n. 21
0
        public HistoryEvent WorkflowCancellationFailedEvent(string cause)
        {
            var eventIds = EventIds.GenericEventIds(ref _currentEventId);

            return(new HistoryEvent
            {
                EventId = eventIds.EventId(EventIds.Generic),
                EventType = EventType.CancelWorkflowExecutionFailed,
                CancelWorkflowExecutionFailedEventAttributes = new CancelWorkflowExecutionFailedEventAttributes()
                {
                    Cause = cause,
                }
            });
        }
Esempio n. 22
0
        public HistoryEvent WorkflowSignaledEvent(string signalName, string input)
        {
            var eventIds = EventIds.GenericEventIds(ref _currentEventId);

            return(new HistoryEvent
            {
                EventId = eventIds.EventId(EventIds.Generic),
                EventType = EventType.WorkflowExecutionSignaled,
                WorkflowExecutionSignaledEventAttributes = new WorkflowExecutionSignaledEventAttributes()
                {
                    SignalName = signalName,
                    Input = input,
                }
            });
        }
Esempio n. 23
0
        public HistoryEvent MarkerRecordedEvent(string markerName, string detail1)
        {
            var eventIds = EventIds.GenericEventIds(ref _currentEventId);

            return(new HistoryEvent
            {
                EventId = eventIds.EventId(EventIds.Generic),
                EventType = EventType.MarkerRecorded,
                MarkerRecordedEventAttributes = new MarkerRecordedEventAttributes()
                {
                    MarkerName = markerName,
                    Details = detail1
                }
            });
        }
Esempio n. 24
0
        public HistoryEvent RecordMarkerFailedEvent(string markerName, string cause)
        {
            var eventIds = EventIds.GenericEventIds(ref _currentEventId);

            return(new HistoryEvent
            {
                EventId = eventIds.EventId(EventIds.Generic),
                EventType = EventType.RecordMarkerFailed,
                RecordMarkerFailedEventAttributes = new RecordMarkerFailedEventAttributes()
                {
                    MarkerName = markerName,
                    Cause = cause
                }
            });
        }
Esempio n. 25
0
        public HistoryEvent WorkflowSignalFailedEvent(string cause, string workflowId, string runId)
        {
            var eventIds = EventIds.GenericEventIds(ref _currentEventId);

            return(new HistoryEvent
            {
                EventId = eventIds.EventId(EventIds.Generic),
                EventType = EventType.SignalExternalWorkflowExecutionFailed,
                SignalExternalWorkflowExecutionFailedEventAttributes = new SignalExternalWorkflowExecutionFailedEventAttributes()
                {
                    Cause = cause,
                    WorkflowId = workflowId,
                    RunId = runId
                }
            });
        }
Esempio n. 26
0
    public void UnsubscribeEvent(GameEventsList.PlayerEvents EventType, System.Action <PlayerEventParams> eventHandler)
    {
        if (eventHandler == null)
        {
            return;
        }

        GameEventHandlers -= eventHandler;

        EventIds eventIds = m_EventIdMapper.Find(x => x._eventType == EventType);

        if (eventIds != null)
        {
            eventIds._ids.Remove(eventHandler.GetHashCode());
        }
    }
Esempio n. 27
0
        internal static void Print(Player player, string text)
        {
            string finalText = text;
            int    i         = 0;
            var    args      = new List <object>(2);
            Match  match     = Regex.Match(text, "{([^}]*)}");

            while (match.Success)
            {
                string token = match.Groups[1].Value;
                finalText = finalText.Replace(match.Groups[0].Value, "##$$%%^^LEFTBRACKET^^%%$$##" + i + "##$$%%^^RIGHTBRACKET^^%%$$##");
                i++;
                object tokenValue = token;
                switch (token)
                {
                case "me":
                    tokenValue = player;
                    break;

                default:
                    if (token.StartsWith("#"))
                    {
                        int id;
                        if (!int.TryParse(token.Substring(1), out id))
                        {
                            break;
                        }
                        ControllableObject obj = ControllableObject.Find(id);
                        if (obj == null)
                        {
                            break;
                        }
                        tokenValue = obj;
                        break;
                    }
                    break;
                }
                args.Add(tokenValue);
                match = match.NextMatch();
            }
            args.Add(player);
            finalText = finalText.Replace("{", "").Replace("}", "");
            finalText = finalText.Replace("##$$%%^^LEFTBRACKET^^%%$$##", "{").Replace(
                "##$$%%^^RIGHTBRACKET^^%%$$##", "}");
            Trace.TraceEvent(TraceEventType.Information,
                             EventIds.Event | EventIds.PlayerFlag(player) | EventIds.Explicit, finalText, args.ToArray());
        }
Esempio n. 28
0
        public IEnumerable <HistoryEvent> ActivityCancellationFailedGraph(Identity activityId, string cause)
        {
            var historyEvents = new List <HistoryEvent>();
            var eventIds      = EventIds.CompletedIds(ref _currentEventId);


            historyEvents.Add(new HistoryEvent()
            {
                EventType = EventType.RequestCancelActivityTaskFailed,
                EventId   = eventIds.EventId(EventIds.Completion),
                RequestCancelActivityTaskFailedEventAttributes = new RequestCancelActivityTaskFailedEventAttributes()
                {
                    ActivityId = activityId.Id,
                    Cause      = cause
                }
            });

            historyEvents.Add(new HistoryEvent()
            {
                EventType = EventType.ActivityTaskStarted,
                EventId   = eventIds.EventId(EventIds.Started),
                ActivityTaskStartedEventAttributes = new ActivityTaskStartedEventAttributes()
                {
                    Identity         = "someid",
                    ScheduledEventId = eventIds.EventId(EventIds.Scheduled)
                }
            });

            historyEvents.Add(new HistoryEvent()
            {
                EventType = EventType.ActivityTaskScheduled,
                EventId   = eventIds.EventId(EventIds.Scheduled),
                ActivityTaskScheduledEventAttributes = new ActivityTaskScheduledEventAttributes()
                {
                    ActivityType = new ActivityType()
                    {
                        Name = activityId.Name, Version = activityId.Version
                    },
                    ActivityId = activityId.Id,
                    Control    = (new ActivityScheduleData()
                    {
                        PN = activityId.PositionalName
                    }).ToJson(),
                }
            });
            return(historyEvents);
        }
Esempio n. 29
0
    public void SubscribeEvent(GameEventsList.PlayerEvents EventType, System.Action <PlayerEventParams> eventHandler)
    {
        GameEventHandlers += eventHandler;
        EventIds eventIds = m_EventIdMapper.Find(x => x._eventType == EventType);

        if (eventIds == null)
        {
            eventIds            = new EventIds();
            eventIds._eventType = EventType;
            eventIds._ids.Add(eventHandler.GetHashCode());
            m_EventIdMapper.Add(eventIds);
        }
        else
        {
            eventIds._ids.Add(eventHandler.GetHashCode());
        }
    }
Esempio n. 30
0
        public override void Do()
        {
            base.Do();
            _card.SetFaceUp(_up);
            if (_up)
            {
                _card.Reveal();
            }
            Program.Trace.TraceEvent(TraceEventType.Information, EventIds.Event | EventIds.PlayerFlag(_who),
                                     "{0} turns '{1}' face {2}", _who, _card, _up ? "up" : "down");

            // Turning an aliased card face up will change its id,
            // which can create bugs if one tries to execute other actions using its current id.
            // That's why scripts have to be suspended until the card is revealed.
            //if (up && card.Type.alias && Script.ScriptEngine.CurrentScript != null)
            //   card.Type.revealSuspendedScript = Script.ScriptEngine.Suspend();
        }
        /// <summary>
        ///     Returns true if MarketFilter instances are equal
        /// </summary>
        /// <param name="other">Instance of MarketFilter to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(MarketFilter other)
        {
            // credit: http://stackoverflow.com/a/10454552/677735
            if (other == null)
            {
                return(false);
            }

            return((CountryCodes == other.CountryCodes || CountryCodes != null && CountryCodes.SequenceEqual(other.CountryCodes)) &&
                   (BettingTypes == other.BettingTypes || BettingTypes != null && BettingTypes.SequenceEqual(other.BettingTypes)) &&
                   (TurnInPlayEnabled == other.TurnInPlayEnabled || TurnInPlayEnabled != null && TurnInPlayEnabled.Equals(other.TurnInPlayEnabled)) &&
                   (MarketTypes == other.MarketTypes || MarketTypes != null && MarketTypes.SequenceEqual(other.MarketTypes)) &&
                   (Venues == other.Venues || Venues != null && Venues.SequenceEqual(other.Venues)) &&
                   (MarketIds == other.MarketIds || MarketIds != null && MarketIds.SequenceEqual(other.MarketIds)) &&
                   (EventTypeIds == other.EventTypeIds || EventTypeIds != null && EventTypeIds.SequenceEqual(other.EventTypeIds)) &&
                   (EventIds == other.EventIds || EventIds != null && EventIds.SequenceEqual(other.EventIds)) &&
                   (BspMarket == other.BspMarket || BspMarket != null && BspMarket.Equals(other.BspMarket)));
        }