Exemplo n.º 1
0
        public void when_creating_processor_then_receives_from_specified_subscription()
        {
            this.sut.Initialize();

            var waiter     = new ManualResetEventSlim();
            var handler    = new Mock <IEventHandler <AnEvent> >();
            var serializer = new JsonTextSerializer();
            var ev         = new AnEvent();

            handler.Setup(x => x.Handle(It.IsAny <AnEvent>()))
            .Callback(() => waiter.Set());

            var processor = this.sut.CreateEventProcessor("log", handler.Object, serializer);

            processor.Start();

            var sender = new TopicSender(this.settings, this.settings.Topics.First(t => t.Path.StartsWith("conference/events")).Path);
            var bus    = new EventBus(sender, new StandardMetadataProvider(), serializer);

            bus.Publish(ev);

            waiter.Wait(5000);

            handler.Verify(x => x.Handle(It.Is <AnEvent>(e => e.SourceId == ev.SourceId)));
        }
Exemplo n.º 2
0
        public void Serialize()
        {
            Assert.Ignore("Throwing an error about not finding NUnit.dll - not sure why...");
            var formatter = new JsonEventFormatter(_typeResolver);
            var theEvent  = new AnEvent(
                eventIdentifier: new Guid("402639D5-4106-4AE7-B210-45780C7A08F3"),
                eventSourceId: new Guid("697BAB3C-E122-4C70-85B0-76750BC2D878"),
                eventSequence: 1,
                eventTimeStamp: new DateTime(2001, 4, 12, 12, 52, 21, 425, DateTimeKind.Utc))
            {
                Day   = new DateTime(2000, 01, 01),
                Name  = "Alice",
                Value = 10,
            };

            var result = formatter.Serialize(theEvent);

            result.EventName.Should().Be("bob");
            result.EventIdentifier.Should().Be(theEvent.EventIdentifier);
            result.EventSourceId.Should().Be(theEvent.EventSourceId);
            result.EventSequence.Should().Be(theEvent.EventSequence);
            result.EventTimeStamp.Should().Be(theEvent.EventTimeStamp);
            result.EventVersion.Should().Be(theEvent.EventVersion);

            result.Data.Should().NotBeNull();
            result.Data.Count.Should().Be(3);
            result.Data.Value <string>("Name").Should().Be(theEvent.Name);
            result.Data.Value <int>("Value").Should().Be(theEvent.Value);
            result.Data.Value <DateTime>("Day").Should().Be(theEvent.Day);
        }
Exemplo n.º 3
0
 private void JournalMeasureForm_Load(object sender, EventArgs e)
 {
     start       = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
     end         = DateTime.Now;
     users       = User.getList().Where((x) => x.IsPerson == 1).ToList();
     departments = Department.getList();
     events      = AnEvent.getList();
     UpdateItems();
     foreach (var user in users)
     {
         comboBox1.Items.Add(user.Name);
     }
     foreach (var department in departments)
     {
         comboBox2.Items.Add(department.Name);
     }
     foreach (var anEvent in events)
     {
         comboBox3.Items.Add(anEvent.Id);
     }
     if (EventId != null && EventId != 0)
     {
         AnEvent anEvent = events.First(x => x.Id == this.EventId);
         foreach (int _id in comboBox3.Items)
         {
             if (_id == anEvent.Id)
             {
                 comboBox3.SelectedIndex = comboBox3.Items.IndexOf(_id);
             }
         }
     }
 }
        private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            ProgressAddEventForm addEventForm = new ProgressAddEventForm();

            addEventForm.Ev      = AnEvent.getList()[int.Parse(dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString())];
            addEventForm.Closed += addEventForm_Closed;
            addEventForm.ShowDialog();
        }
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            ProgressAddEventForm addEventForm = new ProgressAddEventForm();
            DataGridViewRow      row          = dataGridView1.Rows[e.RowIndex];
            List <AnEvent>       events       = AnEvent.getList();
            var obj = events.Where((x) => x.Id == int.Parse(row.Cells["Номер"].Value.ToString())).First();

            addEventForm.Ev      = obj;
            addEventForm.Closed += addEventForm_Closed;
            addEventForm.ShowDialog();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            var id     = int.Parse(textBox1.Text);
            var list   = from _event in AnEvent.getList() where _event.Id == id select _event;
            var _Event = list.First();

            ProgressAddEventForm addEventForm = new ProgressAddEventForm();

            addEventForm.Ev      = _Event;
            addEventForm.Closed += addEventForm_Closed;
            addEventForm.ShowDialog();
        }
Exemplo n.º 7
0
        public void Serialize()
        {
            var formatter = new JsonEventFormatter(_typeResolver);
            var theEvent  = new AnEvent {
                Day   = new DateTime(2000, 01, 01),
                Name  = "Alice",
                Value = 10,
            };

            string eventName;
            var    result = formatter.Serialize(theEvent, out eventName);

            eventName.Should().Be("bob");

            result.Should().NotBeNull();
            result.Count.Should().Be(3);
            result.Value <string>("Name").Should().Be(theEvent.Name);
            result.Value <int>("Value").Should().Be(theEvent.Value);
            result.Value <DateTime>("Day").Should().Be(theEvent.Day);
        }
        public void Serialize()
        {
            var formatter = new JsonEventFormatter(_typeResolver);
            var theEvent = new AnEvent {
                Day = new DateTime(2000, 01, 01),
                Name = "Alice",
                Value = 10,
            };

            string eventName;
            var result = formatter.Serialize(theEvent, out eventName);

            eventName.Should().Be("bob");

            result.Should().NotBeNull();
            result.Count.Should().Be(3);
            result.Value<string>("Name").Should().Be(theEvent.Name);
            result.Value<int>("Value").Should().Be(theEvent.Value);
            result.Value<DateTime>("Day").Should().Be(theEvent.Day);
        }
Exemplo n.º 9
0
        public void Handle(IViewContext context, AnEvent domainEvent)
        {
            var value = domainEvent.Meta[Id];

            HeaderValues.Add(value);
        }
            public void Handle(IViewContext context, AnEvent domainEvent)
            {
                var myRoot = context.Load <MyRoot>(domainEvent.GetAggregateRootId());

                Calls.Add(Tuple.Create(myRoot.LastEmittedEventNumber, domainEvent.EventNumber));
            }
Exemplo n.º 11
0
        public void Serialize()
        {
            Assert.Ignore("Throwing an error about not finding NUnit.dll - not sure why...");
            var formatter = new JsonEventFormatter(_typeResolver);
            var theEvent = new AnEvent(
                eventIdentifier: new Guid("402639D5-4106-4AE7-B210-45780C7A08F3"),
                eventSourceId: new Guid("697BAB3C-E122-4C70-85B0-76750BC2D878"),
                eventSequence: 1,
                eventTimeStamp: new DateTime(2001, 4, 12, 12, 52, 21, 425, DateTimeKind.Utc)) {
                Day = new DateTime(2000, 01, 01),
                Name = "Alice",
                Value = 10,
            };

            var result = formatter.Serialize(theEvent);

            result.EventName.Should().Be("bob");
            result.EventIdentifier.Should().Be(theEvent.EventIdentifier);
            result.EventSourceId.Should().Be(theEvent.EventSourceId);
            result.EventSequence.Should().Be(theEvent.EventSequence);
            result.EventTimeStamp.Should().Be(theEvent.EventTimeStamp);
            result.EventVersion.Should().Be(theEvent.EventVersion);

            result.Data.Should().NotBeNull();
            result.Data.Count.Should().Be(3);
            result.Data.Value<string>("Name").Should().Be(theEvent.Name);
            result.Data.Value<int>("Value").Should().Be(theEvent.Value);
            result.Data.Value<DateTime>("Day").Should().Be(theEvent.Day);
        }
Exemplo n.º 12
0
        public void when_creating_processor_then_receives_from_specified_subscription()
        {
            this.sut.Initialize();

            var waiter = new ManualResetEventSlim();
            var handler = new Mock<IEventHandler<AnEvent>>();
            var serializer = new JsonTextSerializer();
            var ev = new AnEvent();
            handler.Setup(x => x.Handle(It.IsAny<AnEvent>()))
                .Callback(() => waiter.Set());

            var processor = this.sut.CreateEventProcessor("log", handler.Object, serializer);

            processor.Start();

            var sender = new TopicSender(this.settings, this.settings.Topics.First(t => t.Path.StartsWith("conference/events")).Path);
            var bus = new EventBus(sender, new StandardMetadataProvider(), serializer);
            bus.Publish(ev);

            waiter.Wait(5000);

            handler.Verify(x => x.Handle(It.Is<AnEvent>(e => e.SourceId == ev.SourceId)));
        }
Exemplo n.º 13
0
    public EventListener()
    {
        var anEvent = new AnEvent();

        anEvent.MyEvent += SomeMethod;
    }
        private void ProgressAddEventForm_Load(object sender, EventArgs e)
        {
            if (Authorizer.Instance.Guest == 1)
            {
                this.ShortDescription.Enabled     = false;
                this.CreateReport.Enabled         = false;
                this.DepartmentComboBox.Enabled   = false;
                this.reg_id.Enabled               = false;
                this.CategoryComboBox.Enabled     = false;
                this.ClassifiedByComboBox.Enabled = false;
                this.RegisteredByComboBox.Enabled = false;
                this.ReportButton.Enabled         = false;
            }
            Boolean new_ev = true;

            if (this.Ev == null)
            {
                Ev = new AnEvent();
            }
            else
            {
                new_ev = false;
            }
            reg_id.Enabled = false;
            users          = User.getList();
            foreach (var user in users)
            {
                RegisteredByComboBox.Items.Add(user.Name);
                ClassifiedByComboBox.Items.Add(user.Name);
            }
            departments = Department.getList();
            foreach (var department in departments)
            {
                DepartmentComboBox.Items.Add(department.Name);
            }
            categories = Category.getList();
            foreach (var category in categories)
            {
                CategoryComboBox.Items.Add(category.Name);
            }
            if (!new_ev)
            {
                User _user = users.Where((x) => x.Id == Ev.RegisteredBy.Value).First();
                foreach (String item in RegisteredByComboBox.Items)
                {
                    if (item == _user.Name)
                    {
                        RegisteredByComboBox.SelectedIndex = RegisteredByComboBox.Items.IndexOf(item);
                    }
                }
                _user = users.Where((x) => x.Id == Ev.ClassifiedBy.Value).First();
                foreach (String item in ClassifiedByComboBox.Items)
                {
                    if (item == _user.Name)
                    {
                        ClassifiedByComboBox.SelectedIndex = ClassifiedByComboBox.Items.IndexOf(item);
                    }
                }
                Department department = departments.Where((x) => x.Id == Ev.DepartmentId).First();
                foreach (String item in DepartmentComboBox.Items)
                {
                    if (item == department.Name)
                    {
                        DepartmentComboBox.SelectedIndex = DepartmentComboBox.Items.IndexOf(item);
                    }
                }
                Category category = categories.Where((x) => x.Id == Ev.EventCategoryId).First();

                foreach (String item in CategoryComboBox.Items)
                {
                    if (item == category.Name)
                    {
                        CategoryComboBox.SelectedIndex = CategoryComboBox.Items.IndexOf(item);
                    }
                }
                this.eventDate.Value       = Ev.EventDateTime;
                this.reg_id.Text           = Ev.Id.Value.ToString();
                this.ShortDescription.Text = Ev.Description;
            }
            else
            {
                this.eventDate.Value = DateTime.Now;
            }
            UpdateReportLabel();
        }
Exemplo n.º 15
0
 public void Handle(IViewContext context, AnEvent domainEvent)
 {
 }
 public void Handle(IViewContext context, AnEvent domainEvent)
 {
     var root = context.Load <MyRoot>("randomid");
 }
            public void Handle(IViewContext context, AnEvent domainEvent)
            {
                var root = context.Load <MyRoot>(domainEvent.GetAggregateRootId());

                root.DoStuff();
            }
 protected void OnEvent(BaseEventArgs e)
 => AnEvent.Invoke(this, e);
        private void ProgressAddEventForm_Load(object sender, EventArgs e)
        {
            if (Authorizer.Instance.Guest == 1)
            {
                this.ShortDescription.Enabled = false;
                this.CreateReport.Enabled = false;
                this.DepartmentComboBox.Enabled = false;
                this.reg_id.Enabled = false;
                this.CategoryComboBox.Enabled = false;
                this.ClassifiedByComboBox.Enabled = false;
                this.RegisteredByComboBox.Enabled = false;
                this.ReportButton.Enabled = false;
            }
            Boolean new_ev = true;
            if (this.Ev == null)
                Ev = new AnEvent();
            else
            {
                new_ev = false;
            }
            reg_id.Enabled = false;
            users = User.getList();
            foreach (var user in users)
            {
                RegisteredByComboBox.Items.Add(user.Name);
                ClassifiedByComboBox.Items.Add(user.Name);
            }
            departments = Department.getList();
            foreach (var department in departments)
            {
                DepartmentComboBox.Items.Add(department.Name);
            }
            categories = Category.getList();
            foreach (var category in categories)
            {
                CategoryComboBox.Items.Add(category.Name);
            }
            if (!new_ev)
            {

                User _user = users.Where((x) => x.Id == Ev.RegisteredBy.Value).First();
                foreach (String item in RegisteredByComboBox.Items)
                {
                    if (item == _user.Name)
                    {
                        RegisteredByComboBox.SelectedIndex = RegisteredByComboBox.Items.IndexOf(item);
                    }
                }
                _user = users.Where((x) => x.Id == Ev.ClassifiedBy.Value).First();
                foreach (String item in ClassifiedByComboBox.Items)
                {
                    if (item == _user.Name)
                    {
                        ClassifiedByComboBox.SelectedIndex = ClassifiedByComboBox.Items.IndexOf(item);
                    }
                }
                Department department = departments.Where((x) => x.Id == Ev.DepartmentId).First();
                foreach (String item in DepartmentComboBox.Items)
                {
                    if (item == department.Name)
                    {
                        DepartmentComboBox.SelectedIndex = DepartmentComboBox.Items.IndexOf(item);
                    }
                }
                Category category = categories.Where((x) => x.Id == Ev.EventCategoryId).First();

                foreach (String item in CategoryComboBox.Items)
                {
                    if (item == category.Name)
                    {
                        CategoryComboBox.SelectedIndex = CategoryComboBox.Items.IndexOf(item);
                    }
                }
                this.eventDate.Value = Ev.EventDateTime;
                this.reg_id.Text = Ev.Id.Value.ToString();
                this.ShortDescription.Text = Ev.Description;
            }
            else
            {
                this.eventDate.Value = DateTime.Now;
            }
            UpdateReportLabel();
        }