示例#1
0
 public void AddEvent(DateTime date, string title, string location)
 {
     Event newEvent = new Event(date, title, location);
     this.byTitle.Add(title.ToLower(), newEvent);
     this.byDate.Add(newEvent);
     Message.EventAdded();
 }
示例#2
0
        public void TestEventCompareTo()
        {
            Event game = new Event(new DateTime(2013, 10, 10, 15, 50, 0), "Volley", "Beach");
            Event lecture = new Event(new DateTime(2013, 06, 01, 21, 20, 0), "JS", "Telerik");

            Assert.AreEqual(true, game.CompareTo(lecture) > 0);
        }
 private static void AddEvent(string command)
 {
     var currentEvent = new Event(DateTime.Now, "title", "location");
     ///GetParameters(command, "AddEvent", out date, out title, out location);
     var events = new MultiDictionary<string, Event>(true);  ///added that to make it stop crashing too
     events.Add("title", currentEvent);
 }
示例#4
0
        /// <summary>
        /// Returns an Event from the Events table
        /// </summary>
        /// <param name="eventName"> Name of event </param>
        /// <param name="dbConnection"> Reuse dbConnection to save memory </param>
        /// <returns> An Event, passing it the dbconnection for it to fetch all information it needs </returns>
        public Events.Event GetEventByName(string eventName, IDbConnection dbConnection)
        {
            using (IDbCommand dbcmd = dbConnection.CreateCommand()) {
                dbcmd.CommandText = "SELECT * FROM Events WHERE Name = '" + eventName + "'";

                using (IDataReader reader = dbcmd.ExecuteReader()) {
                    Events.Event newEvent            = null;
                    string[]     eventInteractions   = new string[5];
                    string[]     eventSprites        = new string[3];
                    int[]        possibleBackgrounds = new int[4];

                    if (reader.Read())
                    {
                        eventInteractions[0] = reader.GetString(6);
                        eventInteractions[1] = reader.GetString(7);
                        eventInteractions[2] = reader.GetString(8);
                        eventInteractions[3] = reader.GetString(9);
                        eventInteractions[4] = reader.GetString(10);

                        eventSprites[0] = reader.GetString(14);
                        eventSprites[1] = reader.GetString(15);
                        eventSprites[2] = reader.GetString(16);

                        newEvent = new Events.Event(reader.GetString(1), reader.GetString(2), reader.GetInt32(3), reader.GetInt32(4), reader.GetString(5),
                                                    eventInteractions, reader.GetBoolean(11), reader.GetString(12), reader.GetInt32(13), eventSprites, dbConnection);
                    }

                    return(newEvent);
                }
            }
        }
示例#5
0
 /// <summary>
 /// Adds the string representation of the <see cref="Event"/>
 /// to the message log.
 /// </summary>
 /// <param name="eventToAdd">The event which will be added in the log.</param>
 public void AddEvent(Event eventToAdd)
 {
     if (eventToAdd != null)
     {
         this.output.Append(eventToAdd + Environment.NewLine);
     }
 }
示例#6
0
 /// <summary>
 /// If there is a valid event print it to a new line.
 /// </summary>
 /// <param name="eventToPrint">An event given to check.</param>
 public static void PrintEvent(Event eventToPrint)
 {
     if (eventToPrint != null)
     {
         Output.Append(eventToPrint).AppendLine();
     }
 }
示例#7
0
 public void PrintEvent(Event eventToPrint)
 {
     if (eventToPrint != null)
     {
         this.output.AppendLine(eventToPrint.ToString());
     }
 }
示例#8
0
        public void TestEventCompareTo3()
        {
            Event seminar = new Event(new DateTime(2013, 5, 9, 9, 0, 0), "Humanware", "Enterprise Hall");
            Event lecture = new Event(new DateTime(2013, 5, 9, 9, 0, 0), "Humanware", "Telerik Academy");

            Assert.AreEqual(true, seminar.CompareTo(lecture) < 0);
        }
        static void Main(string[] args)
        {
            Bus.Initialize(sbc =>
            {
                sbc.UseMsmq(x => x.UseMulticastSubscriptionClient());
                sbc.UseNLog();
                sbc.ReceiveFrom("msmq://localhost/test.publisher");
            });

            Bus.Instance.Probe();
            Bus.Instance.WriteIntrospectionToFile("publisher.txt");

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("----------WELCOME TO MESSAGE PUBLISHER---------");
            Console.WriteLine("Type your message and press enter (this step will repeat until CTRL+C)");
            while (true)
            {
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.Write("Message: ");
                Console.ForegroundColor = ConsoleColor.Gray;
                var msg = Console.ReadLine();
                var evt = new Event();
                evt.Message = msg;
                evt.EventDateTime = DateTime.Now;
                evt.EventId = Guid.NewGuid();

                Bus.Instance.Publish(evt);
            }
        }
示例#10
0
 public static void PrintEvent(Event eventToPrint)
 {
     if (eventToPrint != null)
     {
         Program.output.Append(eventToPrint + "\n");
     }
 }
 public static void PrintEvent(Event eventToPrint, StringBuilder output)
 {
     if (eventToPrint != null)
     {
         output.Append(eventToPrint + "\n");
     }
 }
示例#12
0
 public static void PrintEvent(Event eventToPrint)
 {
     if (eventToPrint != null)
     {
         output.Append(eventToPrint + Environment.NewLine);
     }
 }
示例#13
0
        public void OnEventRequest(Event externalEvent)
        {
            if (externalEvent == null)
                return;

            Log.Info("Got event " + externalEvent.Name);
            if (OnEvent != null)
                OnEvent(this, externalEvent);
        }
        public void DispatchEvent(Event @event)
        {
            IEnumerable<dynamic> eventHandlers = factory.GetHandlersFor(@event);

            if (eventHandlers != null && eventHandlers.Any())
            {
                Parallel.ForEach(eventHandlers, handler => handler.Handle((dynamic)@event));
            }
        }
示例#15
0
        public void AddEvent(Event @event)
        {
            var snapshot = @event as Events.ParticipantSnapshottedEvent.Version1;

            if (snapshot == null)
                writeRepository.Do("INSERT INTO [Events] ([Id], [AggregateRootId], [Event]) VALUES (@Id, @AggregateRootId, @Event)", Pairs(@event));
            else
                writeRepository.Do("INSERT INTO [Snapshots] ([Id], [AggregateRootId], [Snapshot]) VALUES (@Id, @AggregateRootId, @Event)", Pairs(@snapshot));
        }
示例#16
0
 public static void PrintEvent(Event eventToPrint)
 {
     if (eventToPrint != null)
     {
         Output = eventToPrint + "\n";
     }
     else
     {
         throw new ArgumentNullException("eventToPrint", "Parameter is null!");
     }
 }
示例#17
0
        IEnumerable<KeyValuePair<string, object>> Pairs(Event @event)
        {
            yield return new KeyValuePair<string, object>("@Id", @event.Id);
            yield return new KeyValuePair<string, object>("@AggregateRootId", @event.AggregateRootId);

            var stream = new MemoryStream();
/*
            // this will convert the object to a byte array but there doesnt appear to be a way to convert the byte array back to an object
            var writer = new StreamWriter(stream);
            writer.Write(@event);
            writer.Flush();
            var content = stream.GetBuffer();
*/
            new BinaryFormatter().Serialize(stream, @event);
            var content = stream.ToArray();
            Console.WriteLine("content: " + content.Length + " | " + content);
            yield return new KeyValuePair<string, object>("@Event", content);
        }
示例#18
0
        /// <summary>
        /// Returns an Event from the Events table
        /// </summary>
        /// <param name="eventName"> Name of event </param>
        /// <param name="areaName"> Name of area event occurs in </param>
        /// <param name="eventChance"> Chance of event occuring </param>
        /// <param name="dbConnection"> Reuse dbConnection to save memory </param>
        /// <returns> An Event, passing it the dbconnection for it to fetch all information it needs </returns>
        public Events.Event GetEventByName(string eventName, string areaName, int eventChance, IDbConnection dbConnection)
        {
            using (IDbCommand dbcmd = dbConnection.CreateCommand()) {
                dbcmd.CommandText = "SELECT * FROM Events WHERE Name = '" + eventName + "'";

                using (IDataReader reader = dbcmd.ExecuteReader()) {
                    Events.Event newEvent          = null;
                    string[]     eventInteractions = new string[5];
                    string[]     eventSprites      = new string[3];
                    string       type                = "";
                    string       bgPackName          = "";
                    int[]        possibleBackgrounds = new int[4];
                    int          progressAmount      = 0;
                    int          specificBGSprite    = -1;
                    bool         isLeavePossible     = false;

                    if (reader.Read())
                    {
                        type                 = reader.GetString(3);
                        progressAmount       = reader.GetInt32(4);
                        eventInteractions[0] = reader.GetString(5);
                        eventInteractions[1] = reader.GetString(6);
                        eventInteractions[2] = reader.GetString(7);
                        eventInteractions[3] = reader.GetString(8);
                        eventInteractions[4] = reader.GetString(9);
                        isLeavePossible      = reader.GetBoolean(10);
                        bgPackName           = reader.GetString(11);
                        specificBGSprite     = reader.GetInt32(12);
                        eventSprites[0]      = reader.GetString(13);
                        eventSprites[1]      = reader.GetString(14);
                        eventSprites[2]      = reader.GetString(15);

                        newEvent = new Events.Event(eventName, areaName, type, eventChance, progressAmount,
                                                    eventInteractions, isLeavePossible, bgPackName, specificBGSprite, eventSprites, dbConnection);
                    }
                    else
                    {
                        Debug.LogError("Event " + eventName + " does not exist in the DB");
                    }

                    return(newEvent);
                }
            }
        }
 public HandlerNotRegisteredException(AggregateRoot aggregateRoot, Event @event) : this(aggregateRoot.GetType(), @event.GetType())
 {
 }
示例#20
0
 public void Send(Event iEvent)
 {
     _channel.SendMessageTo(iEvent.Serialize(), _sendingEndPoint);
 }
 public void ReceiveEvent(Event @event)
 {
     dispatcher.DispatchEvent(@event);
 }
示例#22
0
        /// <summary>
        /// This method needs to be integrated into the main actor class.
        /// </summary>
        /// <param name="Event"></param>
        /// <returns>a bool value which tells the EventManager if the Event was successful or not!</returns>
        public virtual bool ProcessEvents(EventType EventType, Event Event) 
        {
            List<string> methods = EventMethods[EventType];
            bool Return = true; 

            foreach (string method in methods)
            {
                object[] arguments = {Event};
                Return = (bool)this.GetType().InvokeMember(method, System.Reflection.BindingFlags.InvokeMethod, null, this, arguments);
            }

            return Return; 
        }
示例#23
0
 void HandleEvent(object sender, Event even)
 {
     Console.WriteLine("\nThis is how the event is handled:\n");
     Console.WriteLine(this.name + " received this message: {0}", even.Message);
 }
示例#24
0
 public void TestEventToString2()
 {
     Event seminar = new Event(new DateTime(2013, 4, 9, 9, 0, 0), "Algorithms & Data Structures", string.Empty);
     Assert.AreEqual("2013-04-09T09:00:00 | Algorithms & Data Structures", seminar.ToString());
 }
示例#25
0
 public void TestEventToString1()
 {
     Event seminar = new Event(new DateTime(2013, 4, 9, 10, 0, 0), "OOP", "Enterprise Hall");
     Assert.AreEqual("2013-04-09T10:00:00 | OOP | Enterprise Hall", seminar.ToString());
 }
示例#26
0
 public void TestEventConstructor3()
 {
     Event seminar = new Event(new DateTime(2013, 4, 9, 10, 0, 0), "JavaScript Part II", "Ultimate Hall");
     Assert.AreEqual("Ultimate Hall", seminar.Location);
 }
示例#27
0
 public void TestEventConstructor2()
 {
     Event seminar = new Event(new DateTime(2013, 4, 9, 10, 0, 0), "Trees & Graphs", "Telerik Academy");
     Assert.AreEqual("Trees & Graphs", seminar.Title);
 }
示例#28
0
 public void TestEventConstructor1()
 {
     Event seminar = new Event(new DateTime(2013, 4, 9, 10, 0, 0), "ASP.NET MVC", "Telerik Academy");
     Assert.AreEqual("2013-04-09T10:00:00", seminar.DateAndTime.ToString("yyyy-MM-ddTHH:mm:ss"));
 }
示例#29
0
 public void TestEventConstructor()
 {
     Event game = new Event(new DateTime(2013, 04, 17, 18, 0, 0), "Football Game", "Stadium");
     Assert.IsTrue(game.Location == "Stadium");
 }
 ////TODO implement PrintEvent
 internal static void PrintEvent(Event eventToShow)
 {
     throw new NotImplementedException();
 }
示例#31
0
        /// <summary>
        /// Hooks an event from any sender to the queue!
        /// </summary>
        /// <param name="EventType"></param>
        /// <param name="Event"></param>
        public void HookEvent(EventType EventType, Event Event)
        {
            if (Queue != null)
            {
                if (!Queue.ContainsKey(EventType))
                    Queue.Add(EventType, new List<Event>());

                if (!Queue[EventType].Contains(Event))
                    Queue[EventType].Add(Event);
            }
            else
            {
                throw new Exception("Queue hasn't been initialized");
            }
        }
 internal void CallApply(Event @event)
 {
     Apply(@event);
 }