Browse Source

Added initial mongodb boxing services

pull/10008/head
Halil İbrahim Kalkan 5 years ago
parent
commit
3b7d1514a9
  1. 3
      framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs
  2. 11
      framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/AbpMongoDbModule.cs
  3. 36
      framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/DbContextEventInbox.cs
  4. 27
      framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/DbContextEventOutbox.cs
  5. 10
      framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/IDbContextEventInbox.cs
  6. 10
      framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/IDbContextEventOutbox.cs
  7. 9
      framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/IHasEventInbox.cs
  8. 9
      framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/IHasEventOutbox.cs
  9. 66
      framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/IncomingEventRecord.cs
  10. 52
      framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/OutgoingEventRecord.cs

3
framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs

@ -570,12 +570,13 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
);
}
protected virtual async Task ApplyAbpConceptsForAddedEntityAsync(TEntity entity)
protected virtual Task ApplyAbpConceptsForAddedEntityAsync(TEntity entity)
{
CheckAndSetId(entity);
SetCreationAuditProperties(entity);
TriggerEntityCreateEvents(entity);
TriggerDomainEvents(entity);
return Task.CompletedTask;
}
private void TriggerEntityCreateEvents(TEntity entity)

11
framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/AbpMongoDbModule.cs

@ -5,6 +5,7 @@ using Volo.Abp.Domain.Repositories.MongoDB;
using Volo.Abp.Modularity;
using Volo.Abp.MongoDB.DependencyInjection;
using Volo.Abp.Uow.MongoDB;
using Volo.Abp.MongoDB.DistributedEvents;
namespace Volo.Abp.MongoDB
{
@ -32,6 +33,16 @@ namespace Volo.Abp.MongoDB
typeof(IMongoDbRepositoryFilterer<,>),
typeof(MongoDbRepositoryFilterer<,>)
);
context.Services.AddTransient(
typeof(IDbContextEventOutbox<>),
typeof(DbContextEventOutbox<>)
);
context.Services.AddTransient(
typeof(IDbContextEventInbox<>),
typeof(DbContextEventInbox<>)
);
}
}
}

36
framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/DbContextEventInbox.cs

@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.EventBus.Distributed;
namespace Volo.Abp.MongoDB.DistributedEvents
{
public class DbContextEventInbox<TDbContext> : IDbContextEventInbox<TDbContext>
where TDbContext : IHasEventInbox
{
public Task EnqueueAsync(IncomingEventInfo incomingEvent)
{
throw new NotImplementedException();
}
public Task<List<IncomingEventInfo>> GetWaitingEventsAsync(int maxCount)
{
throw new NotImplementedException();
}
public Task MarkAsProcessedAsync(Guid id)
{
throw new NotImplementedException();
}
public Task<bool> ExistsByMessageIdAsync(string messageId)
{
throw new NotImplementedException();
}
public Task DeleteOldEventsAsync()
{
throw new NotImplementedException();
}
}
}

27
framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/DbContextEventOutbox.cs

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.Uow;
namespace Volo.Abp.MongoDB.DistributedEvents
{
public class DbContextEventOutbox<TDbContext> : IDbContextEventOutbox<TDbContext>
where TDbContext : IHasEventOutbox
{
public Task EnqueueAsync(OutgoingEventInfo outgoingEvent)
{
throw new NotImplementedException();
}
public Task<List<OutgoingEventInfo>> GetWaitingEventsAsync(int maxCount)
{
throw new NotImplementedException();
}
public Task DeleteAsync(Guid id)
{
throw new NotImplementedException();
}
}
}

10
framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/IDbContextEventInbox.cs

@ -0,0 +1,10 @@
using Volo.Abp.EventBus.Distributed;
namespace Volo.Abp.MongoDB.DistributedEvents
{
public interface IDbContextEventInbox<TDbContext> : IEventInbox
where TDbContext : IHasEventInbox
{
}
}

10
framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/IDbContextEventOutbox.cs

@ -0,0 +1,10 @@
using Volo.Abp.EventBus.Distributed;
namespace Volo.Abp.MongoDB.DistributedEvents
{
public interface IDbContextEventOutbox<TDbContext> : IEventOutbox
where TDbContext : IHasEventOutbox
{
}
}

9
framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/IHasEventInbox.cs

@ -0,0 +1,9 @@
using MongoDB.Driver;
namespace Volo.Abp.MongoDB.DistributedEvents
{
public interface IHasEventInbox : IAbpMongoDbContext
{
IMongoCollection<IncomingEventRecord> IncomingEvents { get; set; }
}
}

9
framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/IHasEventOutbox.cs

@ -0,0 +1,9 @@
using MongoDB.Driver;
namespace Volo.Abp.MongoDB.DistributedEvents
{
public interface IHasEventOutbox : IAbpMongoDbContext
{
IMongoCollection<OutgoingEventRecord> OutgoingEvents { get; set; }
}
}

66
framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/IncomingEventRecord.cs

@ -0,0 +1,66 @@
using System;
using Volo.Abp.Auditing;
using Volo.Abp.Data;
using Volo.Abp.Domain.Entities;
using Volo.Abp.EventBus.Distributed;
namespace Volo.Abp.MongoDB.DistributedEvents
{
public class IncomingEventRecord :
BasicAggregateRoot<Guid>,
IHasExtraProperties,
IHasCreationTime
{
public static int MaxEventNameLength { get; set; } = 256;
public ExtraPropertyDictionary ExtraProperties { get; private set; }
public string MessageId { get; private set; }
public string EventName { get; private set; }
public byte[] EventData { get; private set; }
public DateTime CreationTime { get; private set; }
public bool Processed { get; set; }
public DateTime? ProcessedTime { get; set; }
protected IncomingEventRecord()
{
ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties();
}
public IncomingEventRecord(
IncomingEventInfo eventInfo)
: base(eventInfo.Id)
{
MessageId = eventInfo.MessageId;
EventName = eventInfo.EventName;
EventData = eventInfo.EventData;
CreationTime = eventInfo.CreationTime;
ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties();
}
public IncomingEventInfo ToIncomingEventInfo()
{
return new IncomingEventInfo(
Id,
MessageId,
EventName,
EventData,
CreationTime
);
}
public void MarkAsProcessed(DateTime processedTime)
{
Processed = true;
ProcessedTime = processedTime;
}
}
}

52
framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/OutgoingEventRecord.cs

@ -0,0 +1,52 @@
using System;
using Volo.Abp.Auditing;
using Volo.Abp.Data;
using Volo.Abp.Domain.Entities;
using Volo.Abp.EventBus.Distributed;
namespace Volo.Abp.MongoDB.DistributedEvents
{
public class OutgoingEventRecord :
BasicAggregateRoot<Guid>,
IHasExtraProperties,
IHasCreationTime
{
public static int MaxEventNameLength { get; set; } = 256;
public ExtraPropertyDictionary ExtraProperties { get; private set; }
public string EventName { get; private set; }
public byte[] EventData { get; private set; }
public DateTime CreationTime { get; private set; }
protected OutgoingEventRecord()
{
ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties();
}
public OutgoingEventRecord(
OutgoingEventInfo eventInfo)
: base(eventInfo.Id)
{
EventName = eventInfo.EventName;
EventData = eventInfo.EventData;
CreationTime = eventInfo.CreationTime;
ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties();
}
public OutgoingEventInfo ToOutgoingEventInfo()
{
return new OutgoingEventInfo(
Id,
EventName,
EventData,
CreationTime
);
}
}
}
Loading…
Cancel
Save