public void ConfirmParticipated() { DomainEvent.Publish <GrouponParticipatedEvent>(new GrouponParticipatedEvent(this) { ID = Guid.NewGuid(), TimeStamp = DateTime.Now, ParticipateTime = DateTime.Now }); }
public void ShelvedConfirm() { DomainEvent.Publish(new GoodsShelvedEvent(this) { ID = Guid.NewGuid(), TimeStamp = DateTime.Now, ShelvedTime = DateTime.Now }); }
public void CreatedConfirm() { DomainEvent.Publish <VerificationCreatedEvent>(new VerificationCreatedEvent(this) { CreatedTime = DateTime.Now, ID = Guid.NewGuid(), TimeStamp = DateTime.Now, VerificationCode = this.Code, VerificationTo = this.To, BizCode = this.BizCode }); }
/// <summary> /// 当客户完成收货后,对销售订单进行确认。 /// </summary> public void Confirm() { DomainEvent.Publish <OrderConfirmedEvent>(new OrderConfirmedEvent(this) { ConfirmedDate = DateTime.Now, OrderID = this.ID, UserEmailAddress = this.User.Email }); }
public void NoDispatcher() { DomainEvent.Assign(null); var domainEvent = Substitute.For <IDomainEvent>(); Assert.Throws <InvalidOperationException>(() => DomainEvent.Publish(domainEvent)); }
/// <summary> /// 处理发货。 /// </summary> public void Dispatch() { DomainEvent.Publish <OrderDispatchedEvent>(new OrderDispatchedEvent(this) { DispatchedDate = DateTime.Now, OrderID = this.ID, UserEmailAddress = this.User.Email }); }
public void ConfirmAppoint() { DomainEvent.Publish(new AppointmentConfirmedEvent(this) { ID = Guid.NewGuid(), TimeStamp = DateTime.Now, ConfirmedTime = DateTime.Now }); }
/// <summary> /// Invoke the command /// </summary> /// <param name="command">Command to run</param> public void Invoke(CreateNote command) { var note = new Note(command.Title, command.Body); _storage.Save(note); DomainEvent.Publish(new NoteCreated(note.Id)); }
/// <summary> /// 用户权限更新 /// </summary> public void UpdatePermission(Guid WebID) { DomainEvent.Publish <UserUpdatePermissionEvent>(new UserUpdatePermissionEvent(this) { UserID = this.ID, WebID = WebID, }); }
/// <summary> /// 当客户完成收货后,对销售订单进行确认。 /// </summary> public void ChangeEmail(string email) { Debug.WriteLine("ChangeEmail=>Name:" + Name + " Email:" + Email); DomainEvent.Publish <UserChangeEmailDomainEvent>(new UserChangeEmailDomainEvent(this) { Email = email }); }
/// <summary> /// 取消 /// </summary> public void Cancel() { ReservationCanceledEvent evnt = new ReservationCanceledEvent(this); evnt.CustomerEmailAddress = this.Customer.Email; evnt.CanceledDate = DateTime.Now; DomainEvent.Publish <ReservationCanceledEvent>(evnt); }
/// <summary> /// 用户下线 /// </summary> /// <param name="WebID"></param> public void OffLine(Guid WebID) { DomainEvent.Publish <UserOfflineEvent>(new UserOfflineEvent(this) { UserID = this.ID, WebID = WebID }); }
/// <summary> /// 使用站点更新 /// </summary> public void UpdateWeb() { DomainEvent.Publish <UserWebUpdateEvent>(new UserWebUpdateEvent(this) { UpdateTime = DateTime.Now, Email = this.Email, UserID = this.ID, UserName = this.RealName }); }
public void RegularDispatch() { var innerDispatcher = Substitute.For <IDomainEventDispatcher>(); DomainEvent.Assign(innerDispatcher); var domainEvent = Substitute.For <IDomainEvent>(); DomainEvent.Publish(domainEvent); innerDispatcher.Received().Dispatch(domainEvent); }
/// <summary> /// Invoke the command /// </summary> /// <param name="command">Command to run</param> public void Invoke(RegisterUser command) { Console.WriteLine("I would register the user in the DB etc"); var user = new User(command.DisplayName); // fake data layer user.GetType().GetProperty("Id").SetValue(user, 1, null); // Never include the domain entity, but only info relevant to the actual event. DomainEvent.Publish(new UserRegistered(user.Id, user.DisplayName)); }
public void SoldConfirm() { Stock--; if (Stock <= 0) { DomainEvent.Publish(new GoodsSoldOutEvent(this) { ID = Guid.NewGuid(), TimeStamp = DateTime.Now, SoldOutTime = DateTime.Now }); } }
public Word(string stem) { if (string.IsNullOrWhiteSpace(stem)) { throw new HangerdException("词干不可为空"); } Stem = stem.Trim().ToLower(); Interpretations = new List <WordInterpretation>(); DomainEvent.Publish(new WordCreatedEvent(this)); }
/* * This example will hold all domain events until your transaction have been completed. * That's great since failing transactions won't result in events for stuff that hasn't been persisted. * * To keep the example simple we'll use a fake transaction. * */ static void Main(string[] args) { // configure Griffin.Container var container = ConfigureGriffinContainer(); var dbContext = new FakeDbContext(); // Use a synchronous IoC dispatcher var builder = new EventPipelineBuilder(new ErrorHandler()); var dispatcher = builder .WaitOnTransactions(dbContext) //do not release events if a transaction is active .UseGriffinContainer(container) //use Griffin.Container .Build(); // Build the pipeline dispatcher Console.WriteLine("Step 1. A simple publising"); Console.WriteLine("============================="); DomainEvent.Assign(dispatcher); // Will be published directly DomainEvent.Publish(new UserRegistered("Arne")); Console.WriteLine(); Console.WriteLine("Step 1. Disposed Uow = no events"); Console.WriteLine("============================="); using (var uow = dbContext.CreateUnitOfWork()) { Console.WriteLine("** Nothing should come between this line"); DomainEvent.Publish(new UserRegistered("Arne")); Console.WriteLine("** ...and this line..."); //no save = rollback } Console.WriteLine("* this should come directly after 'And this line...'"); Console.WriteLine(); Console.WriteLine("Step 3. Uow = dispatch after"); Console.WriteLine("============================="); using (var uow = dbContext.CreateUnitOfWork()) { Console.WriteLine("** Nothing should come between this line"); DomainEvent.Publish(new UserRegistered("Arne")); Console.WriteLine("** ...and this line..."); uow.SaveChanges(); } Console.WriteLine("** Two domain messages should have come."); // and wait Console.ReadLine(); }
/* * First sample for domain events. * * As you see below it's increadibly easy to get started with Griffin.Decoupled and Griffin.Container * */ static void Main(string[] args) { // configure Griffin.Container var container = ConfigureGriffinContainer(); // extension method from the "Griffin.Decoupled.Container" nuget package. container.DispatchEvents(); // Publish the event DomainEvent.Publish(new UserRegistered("Arne")); // and wait Console.ReadLine(); }
/// <summary> /// Mark item as completed /// </summary> public void Complete() { // Might look trivial, but it's in fact invalid logic which may // produce other side effects. So throw that exception... if (IsCompleted) { throw new InvalidOperationException("Item has already been marked as completed."); } IsCompleted = true; CompletedAt = DateTime.Now; DomainEvent.Publish(new NoteCompleted(Id)); }
/// <summary> /// Invoke the command /// </summary> /// <param name="command">Command</param> public void Invoke(CreateUser command) { var user = _storage.Create(command.UserName); user.FullName = command.FullName; user.DisplayName = command.DisplayName; _storage.Save(user); // Note that the command and not the repository // generates the event now. // // imho it's poor practice to let non business related classes // to generate events. But I did it for simplicity in the last example project. DomainEvent.Publish(new UserCreated(user.Id)); Console.WriteLine("All done."); }
/// <summary> /// Updates the text. /// </summary> /// <param name="newText">The new text.</param> /// <exception cref="System.ArgumentNullException">newText</exception> /// <exception cref="System.ArgumentOutOfRangeException">newText;Body may max be 500000 bytes.</exception> public void Update(string newText) { if (newText == null) { throw new ArgumentNullException("newText"); } if (newText.Length > 500000) { throw new ArgumentOutOfRangeException("newText", newText, "Body may max be 500000 bytes."); } if (IsCompleted) { throw new InvalidOperationException("Items may not be changed once completed."); } var oldText = Body; Body = newText; UpdatedAt = DateTime.Now; DomainEvent.Publish(new NoteUpdated(Id, oldText, newText)); }
public void TestBusMethod() { var domainevent = new OrderConfirmedEvent(); DomainEvent.Publish <OrderConfirmedEvent>(domainevent); }
public void MyTestMethod() { var domainevent = new OrderDispatchedEvent(); DomainEvent.Publish <OrderDispatchedEvent>(domainevent); }
public void Cancel() { DomainEvent.Publish(new PlatformCancelledEvent(this)); }
public void ConfirmSubmited() => DomainEvent.Publish(new OrderSubmittedEvent(this) { ID = Guid.NewGuid(), TimeStamp = DateTime.Now, SubmittedTime = DateTime.Now });
public void ConfirmPaidFailed() => DomainEvent.Publish(new OrderPaidFailedEvent(this) { ID = Guid.NewGuid(), TimeStamp = DateTime.Now, FailedTime = DateTime.Now });
public void ConfirmRefund() => DomainEvent.Publish(new OrderRefundedEvent(this) { ID = Guid.NewGuid(), TimeStamp = DateTime.Now, RefundTime = DateTime.Now });
/// <summary> /// 下线 /// </summary> public void Offline() { DomainEvent.Publish <UserOfflineEvent>(new UserOfflineEvent(this)); }
public void ConfirmCancelled() => DomainEvent.Publish(new OrderCancelledEvent(this) { ID = Guid.NewGuid(), TimeStamp = DateTime.Now, CancelledTime = DateTime.Now });