Beispiel #1
0
        /// <summary>
        /// Appends an event onto the end of the objects to stream next sync
        /// </summary>
        /// <param name="item">The event to append</param>
        public void Append(IGenericEvent item) {
            if (this.EventsStream != null) {
                lock (this.EventsStream) {
                    if (this.InclusiveNames.Contains(item.Name) == true) {
                        item.Disposed += GenericEventArgs_Disposed;

                        this.EventsStream.Add(item);
                    }
                }
            }
        }
        protected String FormatEvent(IGenericEvent item) {
            String text = null;

            switch (item.Name) {
                case "TextCommandRegistered":
                    TextCommandModel firstTextCommand = item.Now.TextCommands.FirstOrDefault();
                    ConnectionModel firstConnection = item.Scope.Connections.FirstOrDefault();

                    if (firstTextCommand != null && firstConnection != null) {
                        text = String.Format(@"Registed command(s) ""{0}"" to plugin {1} on connection {2}.", String.Join(", ", firstTextCommand.Commands.ToArray()), this.FormatGuid(firstTextCommand.PluginGuid), this.FormatGuid(firstConnection.ConnectionGuid));
                    }

                    break;
                case "ConnectionDisconnected":
                case "ConnectionDisconnecting":
                case "ConnectionConnecting":
                case "ConnectionConnected":
                case "ConnectionListening":
                case "ConnectionReady":
                case "ConnectionLoggedIn":
                    text = this.FormatGuid(item.Scope.Connections.First().ConnectionGuid);
                    break;
                default:
                    if (String.IsNullOrEmpty(item.Message.Trim()) == false) {
                        text = item.Message;
                    }
                    
                    break;
            }

            if (String.IsNullOrEmpty(text) == false) {
                text = String.Format("[{0}] {1}: {2}", DateTime.Now.ToString("HH:mm:ss"), item.Name, text);
            }

            return text;
        }
Beispiel #3
0
 /// <summary>
 /// Builds a command to send a EventsLog
 /// </summary>
 /// <returns>The built command to dispatch</returns>
 public static ICommand EventsLog(IGenericEvent e) {
     return new Command() {
         CommandType = CommandType.EventsLog,
         Parameters = new List<ICommandParameter>() {
             new CommandParameter() {
                 Data = {
                     Events = new List<IGenericEvent>() {
                         e
                     }
                 }
             }
         }
     };
 }
        protected void Events_EventLogged(object sender, IGenericEvent e) {
            String text = this.FormatEvent(e);

            if (String.IsNullOrEmpty(text) == false) Console.WriteLine(text);
        }
Beispiel #5
0
 /// <summary>
 /// Called whenever an event is logged.
 /// </summary>
 protected void MasterEvents_EventLogged(object sender, IGenericEvent e) {
     foreach (var endPoint in this.EndPoints) {
         endPoint.Value.Append(e);
     }
 }
Beispiel #6
0
        /// <summary>
        /// Log an item to the events list
        /// </summary>
        /// <param name="item"></param>
        public void Log(IGenericEvent item) {
            // Can be null after disposal.
            if (this.LoggedEvents != null) {
                item.Id = this.AcquireEventId;

                lock (this.LoggedEvents) {
                    this.LoggedEvents.Add(item);
                }

                this.OnEventLogged(item);
            }
        }
Beispiel #7
0
        protected virtual void OnEventLogged(IGenericEvent e) {
            EventLoggedHandler handler = this.EventLogged;

            if (handler != null) {
                handler(this, e);
            }
        }