public void LoadEventsTest() { var aggregateRootId = Guid.NewGuid(); var employee = new Employee(aggregateRootId); var event1 = new NameChangedEvent("daxnet"); var event2 = new TitleChangedEvent("title"); var event3 = new RegisteredEvent(); event1.AttachTo(employee); event2.AttachTo(employee); event3.AttachTo(employee); var storeConfig = new AdoNetEventStoreConfiguration(PostgreSQLFixture.ConnectionString, new GuidKeyGenerator()); var payloadSerializer = new ObjectJsonSerializer(); var store = new PostgreSqlEventStore(storeConfig, payloadSerializer); store.Save(new List <DomainEvent> { event1, event2, event3 }); var events = store.Load <Guid>(typeof(Employee).AssemblyQualifiedName, aggregateRootId); Assert.Equal(3, events.Count()); }
// ReSharper disable once ParameterOnlyUsedForPreconditionCheck.Local private void AssertEventFound(IRegisteredEventsPlugin plugin, RegisteredEvent @event, string message) { if (@event == null) { throw new Exception($"Plugin {plugin.GetType().FullName} {message} Unable to set the registered event of the context."); } }
/// <summary> /// Sets the registered event for the context. /// </summary> /// <param name="event">The event.</param> /// <returns></returns> public TDerived WithRegisteredEvent(RegisteredEvent @event) { Context.Stage = (int)@event.Stage; Context.MessageName = @event.MessageName; Context.PrimaryEntityName = @event.EntityLogicalName; return(This); }
public void SaveEventsTest1() { var aggregateRootId = Guid.NewGuid(); var employee = new Employee(aggregateRootId); var event1 = new NameChangedEvent("daxnet"); var event2 = new TitleChangedEvent("title"); var event3 = new RegisteredEvent(); event1.AttachTo(employee); event2.AttachTo(employee); event3.AttachTo(employee); var store = new DictionaryEventStore(); store.Save(new List <DomainEvent> { event1, event2, event3 }); var events = store.Load <Guid>(typeof(Employee).AssemblyQualifiedName, aggregateRootId); Assert.Equal(3, events.Count()); Assert.NotEqual(Guid.Empty, event1.Id); Assert.NotEqual(Guid.Empty, event2.Id); Assert.NotEqual(Guid.Empty, event3.Id); }
public void SaveEventsTest() { var aggregateRootId = Guid.NewGuid(); var employee = new Employee { Id = aggregateRootId }; var event1 = new NameChangedEvent("daxnet"); var event2 = new TitleChangedEvent("title"); var event3 = new RegisteredEvent(); event1.AttachTo(employee); event2.AttachTo(employee); event3.AttachTo(employee); var storeConfig = new AdoNetEventStoreConfiguration(PostgreSQLFixture.ConnectionString, new GuidKeyGenerator()); var payloadSerializer = new ObjectJsonSerializer(); var store = new PostgreSqlEventStore(storeConfig, payloadSerializer); store.Save(new List <DomainEvent> { event1, event2, event3 }); }
public ActionResult Register(int id) { // Action called by a user to Register to an event. try { var userId = User.Identity.GetUserId(); var userAccount = db.UserAccounts.Where(c => c.ApplicationUserId == userId).First(); // Checking if the user has already registered. if (db.RegisteredEvents.Where(i => i.UserAccountId == userAccount.Id && i.EventId == id).Count() == 0) { var registeredEvent = new RegisteredEvent() { UserAccountId = userAccount.Id, EventId = id }; db.RegisteredEvents.Add(registeredEvent); db.SaveChanges(); } return(RedirectToAction("Index", "Event")); } catch { return(RedirectToAction("Index", "Event")); } }
/// <summary> /// 注册 /// </summary> /// <returns></returns> public void Registered() { //业务 if (!CheckHelper.CheckPhone(this.Phone)) { throw new Exception("手机号格式不正确"); } RegisteredEvent registeredEvent = new RegisteredEvent(this.Id, this.Account, this.Password, this.Name, this.Phone, this.Email); //添加注册完成领域事件 AddNotificationEventHandler(registeredEvent); }
public ActionResult Remove(int eventId, int userId) { // Removes a registered event by the user. try { RegisteredEvent registeredEvent = db.RegisteredEvents.Where ( i => (i.UserAccountId == userId && i.EventId == eventId) ).Single(); db.RegisteredEvents.Remove(registeredEvent); db.SaveChanges(); return(RedirectToAction("Index", "RegisteredEvent")); } catch { return(RedirectToAction("Index", "RegisteredEvent")); } }
public void LoadEventsWithMinMaxSequenceTest() { var aggregateRootId = Guid.NewGuid(); var employee = new Employee(aggregateRootId); var event1 = new NameChangedEvent("daxnet") { Sequence = 1 }; var event2 = new TitleChangedEvent("title") { Sequence = 2 }; var event3 = new RegisteredEvent() { Sequence = 3 }; event1.AttachTo(employee); event2.AttachTo(employee); event3.AttachTo(employee); var storeConfig = new AdoNetEventStoreConfiguration(SQLServerFixture.ConnectionString, new GuidKeyGenerator()); var payloadSerializer = new ObjectJsonSerializer(); var store = new SqlServerEventStore(storeConfig, payloadSerializer); store.Save(new List <DomainEvent> { event1, event2, event3 }); var events = store.Load <Guid>(typeof(Employee).AssemblyQualifiedName, aggregateRootId, 1, 3).ToList(); Assert.Equal(3, events.Count); Assert.IsType <NameChangedEvent>(events[0]); Assert.IsType <TitleChangedEvent>(events[1]); Assert.IsType <RegisteredEvent>(events[2]); }
/// <summary> /// Initializes the plugin properties. /// </summary> /// <param name="plugin">The plugin.</param> private void InitializePluginProperties(IRegisteredEventsPlugin plugin) { Event = PluginExecutionContext.GetEvent(plugin.RegisteredEvents); if (Event == null) { var message = $"No RegisteredEvent found for the current context of Stage: {this.GetPipelineStage()}, Message: {MessageName}, Entity: {PrimaryEntityName}. Either Unregister the plugin for this event, or include this as a RegisteredEvent in the Plugin's RegisteredEvents."; try { TracingService.Trace(message); TracingService.Trace(this.GetContextInfo()); } finally { throw new InvalidPluginExecutionException(message); } } if (Event.Message == RegisteredEvent.Any) { Event = new RegisteredEvent(Event.Stage, PluginExecutionContext.GetMessageType(), Event.Execute); } PluginTypeName = plugin.GetType().FullName; }
/// <summary> /// Sets the registered event for the context. /// </summary> /// <param name="event">The event.</param> /// <returns></returns> public TDerived WithRegisteredEvent(RegisteredEvent @event) { return(WithRegisteredEvent((int)@event.Stage, @event.MessageName, @event.EntityLogicalName)); }
/// <summary> /// Returns true if the current plugin maps to the Registered Event, or the current plugin has been triggered by the given registered event /// </summary> /// <param name="context">The context.</param> /// <param name="event">The event.</param> /// <returns></returns> public static bool CalledFrom(this IPluginExecutionContext context, RegisteredEvent @event) { return(context.GetContexts().Any(c => c.MessageName == @event.MessageName && c.PrimaryEntityName == @event.EntityLogicalName && c.Stage == (int)@event.Stage)); }
/// <summary> /// Adds a shared Variable to the context that is checked by the GenericPluginBase to determine if it should be skipped * NOTE * The Plugin has to finish executing for the Shared Variable to be passed to a new plugin /// </summary> /// <param name="context">The context.</param> /// <param name="pluginTypeFullName">The Full Type Name of the Plugin to Prevent</param> /// <param name="event">Type of the event.</param> /// <exception cref="ArgumentNullException"></exception> public static void PreventPluginExecution(this IPluginExecutionContext context, string pluginTypeFullName, RegisteredEvent @event) { if (@event == null) { throw new ArgumentNullException(nameof(@event)); } context.PreventPluginExecution(pluginTypeFullName, @event.MessageName, @event.EntityLogicalName, @event.Stage); }
/// <summary> /// Adds a shared Variable to the context that is checked by the GenericPluginBase to determine if it should be skipped * NOTE * The Plugin has to finish executing for the Shared Variable to be passed to a new plugin /// </summary> /// <typeparam name="T">The type of the plugin.</typeparam> /// <param name="context">The context.</param> /// <param name="event">Type of the event.</param> public static void PreventPluginExecution <T>(this IPluginExecutionContext context, RegisteredEvent @event) where T : IRegisteredEventsPlugin { context.PreventPluginExecution(typeof(T).FullName, @event); }
private void detach_RegisteredEvents(RegisteredEvent entity) { this.SendPropertyChanging(); entity.Event = null; }
partial void DeleteRegisteredEvent(RegisteredEvent instance);
partial void UpdateRegisteredEvent(RegisteredEvent instance);
partial void InsertRegisteredEvent(RegisteredEvent instance);
public IDisposable Register(int pid, uint eventMin, uint eventMax, WinEventDelegate proc) { var e = new RegisteredEvent(context, pid, eventMin, eventMax, proc); return(e); }
/// <summary> /// Determines whether a shared variable exists that specifies that the plugin or the plugin and specifc message type should be prevented from executing. /// This is used in conjunction with PreventPluginExecution /// </summary> /// <typeparam name="T">The type of the plugin.</typeparam> /// <returns></returns> public static bool HasPluginExecutionBeenPrevented <T>(this IPluginExecutionContext context, RegisteredEvent @event) where T : IRegisteredEventsPlugin { var preventionName = GetPreventPluginSharedVariableName(typeof(T).FullName); return(context.HasPluginExecutionBeenPreventedInternal(@event, preventionName)); }
private static bool HasPluginExecutionBeenPreventedInternal(this IPluginExecutionContext context, RegisteredEvent @event, string preventionName) { var value = context.GetFirstSharedVariable(preventionName); if (value == null) { return(false); } var hash = ((Entity)value).Attributes; return(hash.Contains(string.Empty) || hash.Contains(GetPreventionRule(@event.MessageName)) || hash.Contains(GetPreventionRule(@event.MessageName, @event.EntityLogicalName)) || hash.Contains(GetPreventionRule(@event.MessageName, stage: @event.Stage)) || hash.Contains(GetPreventionRule(@event.MessageName, @event.EntityLogicalName, @event.Stage)) || hash.Contains(GetPreventionRule(logicalName: @event.EntityLogicalName)) || hash.Contains(GetPreventionRule(logicalName: @event.EntityLogicalName, stage: @event.Stage)) || hash.Contains(GetPreventionRule(stage: @event.Stage))); }
/// <summary> /// Sets the registered event for the context. /// </summary> /// <param name="event"></param> /// <returns></returns> public PluginExecutionContextBuilder WithRegisteredEvent(RegisteredEvent @event) { return(WithRegisteredEvent((int)@event.Stage, @event.MessageName, @event.EntityLogicalName)); }
//get selected event and user info and add to database //if the user is not logged in then they will be redirected to the login page protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (userCanRegister()) { if (HttpContext.Current.User.Identity.IsAuthenticated == true) //if the user is logged in { Int16 num = Convert.ToInt16(e.CommandArgument); //get row number DataClassesDataContext dc = new DataClassesDataContext(); //get reference to databases RegisteredEvent re = new RegisteredEvent(); re.EventId = getEventId(GridView1.Rows[num].Cells[0].Text); //gets the text of the gridview cell selected re.FirstName = Profile.FirstName; re.LastName = Profile.LastName; re.EmailAddress = Profile.EmailAddress; re.Won = false; dc.RegisteredEvents.InsertOnSubmit(re); dc.SubmitChanges(); Profile.NumberOfTickets--; Response.Write("<script>alert('You have now been registered');</script>"); } else { Response.Redirect("~/Login.aspx"); //else send to login page } } else { Response.Write("<script>alert('You have registered for the maximum number of events');</script>"); } }
private void HandlesRegisteredEvent(RegisteredEvent evnt) { this.DateRegistered = DateTime.UtcNow; }
public void Handle(RegisteredEvent message) { ActivateItem(_loginVm); }