/// <summary> /// Initializes a new instance of <see cref="ILogger"/> /// </summary> /// <param name="logger"><see cref="ILogger"/> for logging</param> public ExecutionContextManager(ILogger logger) { _logger = logger; _application = Application.NotSet; _boundedContext = BoundedContext.NotSet; _environment = Environment.Undetermined; }
public async Task <Response> Handle(Request request) { var entity = await _context.BoundedContexts .Include(x => x.Tenant) .SingleOrDefaultAsync(x => x.Id == request.BoundedContext.Id && x.Tenant.UniqueId == request.TenantUniqueId); if (entity == null) { var tenant = await _context.Tenants.SingleAsync(x => x.UniqueId == request.TenantUniqueId); _context.BoundedContexts.Add(entity = new BoundedContext() { TenantId = tenant.Id }); } entity.Name = request.BoundedContext.Name; entity.Description = request.BoundedContext.Description; entity.ImageUrl = request.BoundedContext.ImageUrl; await _context.SaveChangesAsync(); _bus.Publish(new AddedOrUpdatedBoundedContextMessage(entity, request.CorrelationId, request.TenantUniqueId)); return(new Response()); }
/// <summary> /// 保存附件信息 /// </summary> /// <param name="delIDs">需要删除的附件ids</param> /// <param name="infos">附件信息</param> /// <returns>是否保存成功</returns> public virtual bool Save(string delIDs, params SYSAttach[] infos) { var result = false; delIDs = (delIDs ?? string.Empty).Trim(','); if (infos == null || !infos.Any()) goto End; using (var dbContext = BoundedContext.Create()) { var bo = dbContext.Resolve<STDAttachBO>();//dbContext.Repository<STDAttachInfo>(); result = true; var arr = ALConvert.ToList<long>(delIDs); if (arr.Any()) result = bo.Remove(item => arr.Contains(item.ID.Value)); if (result) { foreach (var info in infos) { if (info == null || !(info.ID > 0 ? bo.Modify(info) : bo.Add(info))) { result = false; break; } SaveFile(dbContext, info); } } if (result) dbContext.Commit(); } End: return result; }
public TextMessageListener(IConsumer consumer, ITextMessageProcessors processors, ISerializer serializer, BoundedContext boundedContext) { _consumer = consumer; _processors = processors; _serializer = serializer; _boundedContext = boundedContext; }
/// <inheritdoc/> public void Provide(IBindingProviderBuilder builder) { builder.Bind <IEventStore>().To <NullEventStore>().Singleton(); builder.Bind <IEventSourceVersions>().To <NullEventSourceVersions>().Singleton(); builder.Bind <IEventEnvelopes>().To <EventEnvelopes>(); builder.Bind <IEventSequenceNumbers>().To <NullEventSequenceNumbers>(); builder.Bind <IEventProcessors>().To <EventProcessors>(); builder.Bind <IEventProcessorLog>().To <NullEventProcessorLog>(); builder.Bind <IEventProcessorStates>().To <NullEventProcessorStates>(); //builder.Bind<ICanSendCommittedEventStream>().To<NullCommittedEventStreamSender>().Singleton(); var bridge = new CommittedEventStreamBridge(); builder.Bind <ICommittedEventStreamBridge>().To(bridge); builder.Bind <ICanSendCommittedEventStream>().To <Infrastructure.Kafka.BoundedContexts.CommittedEventStreamSender>().Singleton(); var receiver = new CommittedEventStreamReceiver(bridge, new NullLogger()); builder.Bind <ICanReceiveCommittedEventStream>().To(receiver); builder.Bind <ExecutionContextPopulator>().To((ExecutionContext, details) => { }); builder.Bind <ClaimsPrincipal>().To(() => new ClaimsPrincipal(new ClaimsIdentity())); builder.Bind <CultureInfo>().To(() => CultureInfo.InvariantCulture); builder.Bind <ICallContext>().To(new DefaultCallContext()); builder.Bind <ICanResolvePrincipal>().To(new DefaultPrincipalResolver()); var boundedContext = new BoundedContext("visualization"); builder.Bind <BoundedContext>().To(boundedContext); var applicationConfigurationBuilder = new ApplicationConfigurationBuilder("OCFEV") .Application(applicationBuilder => applicationBuilder .PrefixLocationsWith(boundedContext) .WithStructureStartingWith <BoundedContext>(_ => _ .Required.WithChild <Feature>(f => f .WithChild <SubFeature>(c => c.Recursive) ) ) ) .StructureMappedTo(_ => _ .Domain("Infrastructure.Events.-^{Feature}.-^{SubFeature}*") .Domain("Domain.-^{Feature}.-^{SubFeature}*") .Domain("Domain.-^{Module}.-^{Feature}.-^{SubFeature}*") .Events("Events.-^{Feature}.-^{SubFeature}*") .Events("Events.-^{Module}.-^{Feature}.-^{SubFeature}*") .Events("ExternalEvents.-^{Feature}.-^{SubFeature}*") .Events("ExternalEvents.-^{Module}.-^{Feature}.-^{SubFeature}*") .Read("Read.-^{Feature}.-^{SubFeature}*") .Read("Read.-^{Module}.-^{Feature}.-^{SubFeature}*") .Frontend("Web.-^{Feature}.-^{SubFeature}*") .Frontend("Web.-^{Module}.-^{Feature}.-^{SubFeature}*") ); (IApplication application, IApplicationStructureMap structureMap)applicationConfiguration = applicationConfigurationBuilder.Build(); builder.Bind <IApplication>().To(applicationConfiguration.application); builder.Bind <IApplicationStructureMap>().To(applicationConfiguration.structureMap); }
private static BoundedContext LoadBoundedContext() { //string projectFile = TransformationContext.Current.GetPropertyValue("MSBuildProjectFullPath"); string projectDir = "../..";//System.IO.Path.GetDirectoryName(projectFile); var excludedFiles = new List <string>(); excludedFiles.Add("Audience.yaml"); excludedFiles.Add("IdentityManagement.yaml"); excludedFiles.Add("AccessManagement.yaml"); string filePath1 = System.IO.Path.Combine(projectDir, "../Dddml.Wms.Metadata/AttributeSetInstanceDddml.yaml"); string filePath2 = System.IO.Path.Combine(projectDir, "../Dddml.Wms.Metadata/AttributeSetInstanceExtensionFieldGroupDddml.yaml"); var additionalFiles = new List <string>(); additionalFiles.Add(filePath1); additionalFiles.Add(filePath2); var dddmlDir = System.IO.Path.Combine(projectDir, "..\\dddml"); BoundedContext boundedContext = BoundedContextUtils.LoadFromDirectory(dddmlDir, "*.yaml", excludedFiles, additionalFiles); boundedContext.Refresh(); boundedContext.GenerateAllEntityMViewObjectsAndRefresh(); return(boundedContext); }
/// <summary> /// /// </summary> /// <param name="infos"></param> /// <returns></returns> public virtual bool Save(params SYSMenu[] infos) { if (infos == null || !infos.Any()) { throw new ArgumentNullException("参数不能为空!"); } var result = true; using (var dbContext = BoundedContext.Create()) { var bo = dbContext.Repository <SYSMenu>(); foreach (var info in infos) { result = Save(bo, info); if (!result) { break; } } if (result) { dbContext.Commit(); } } return(result); }
public void MergeFrom(OpenTunnel other) { if (other == null) { return; } if (other.application_ != null) { if (application_ == null) { application_ = new global::System.Protobuf.guid(); } Application.MergeFrom(other.Application); } if (other.boundedContext_ != null) { if (boundedContext_ == null) { boundedContext_ = new global::System.Protobuf.guid(); } BoundedContext.MergeFrom(other.BoundedContext); } if (other.clientId_ != null) { if (clientId_ == null) { clientId_ = new global::System.Protobuf.guid(); } ClientId.MergeFrom(other.ClientId); } offsets_.Add(other.offsets_); events_.Add(other.events_); }
public ApplicationService() { this.OnInject(); this.DependOn(BoundedContext.Create(new UnitOfWorkOptions { IsTransactional = false })); }
public override int GetHashCode() { int hash = 1; if (application_ != null) { hash ^= Application.GetHashCode(); } if (boundedContext_ != null) { hash ^= BoundedContext.GetHashCode(); } if (tenant_ != null) { hash ^= Tenant.GetHashCode(); } if (correlationId_ != null) { hash ^= CorrelationId.GetHashCode(); } if (Environment.Length != 0) { hash ^= Environment.GetHashCode(); } hash ^= claims_.GetHashCode(); if (Culture.Length != 0) { hash ^= Culture.GetHashCode(); } return(hash); }
public override int GetHashCode() { int hash = 1; if (application_ != null) { hash ^= Application.GetHashCode(); } if (boundedContext_ != null) { hash ^= BoundedContext.GetHashCode(); } if (tenant_ != null) { hash ^= Tenant.GetHashCode(); } if (Environment.Length != 0) { hash ^= Environment.GetHashCode(); } hash ^= claims_.GetHashCode(); if (CommitInOrigin != 0UL) { hash ^= CommitInOrigin.GetHashCode(); } return(hash); }
public QueueingBasicConsumerWithManagedConnection(IConnectionFactory connectionFactory, ISubscriberCollection <T> subscriberCollection, BoundedContext boundedContext) { this.connectionFactory = connectionFactory; this.subscriberCollection = subscriberCollection; this.boundedContext = boundedContext; queueName = $"{boundedContext}.{typeof(T).Name}"; }
public RabbitMqContinuousConsumer(BoundedContext boundedContext, ISerializer serializer, IConnectionFactory connectionFactory, ISubscriberCollection <T> subscriberCollection) : base(subscriberCollection) { this.deliveryTags = new Dictionary <Guid, ulong>(); this.serializer = serializer; this.consumer = new QueueingBasicConsumerWithManagedConnection(connectionFactory, subscriberCollection, boundedContext); }
/// <summary> /// Instantiates a new instance of <see cref="BootProcedure" /> /// </summary> /// <param name="systemsThatKnowAboutEventProcessors">Provides <see cref="IEventProcessor">Event Processors</see></param> /// <param name="tenants">A collection of all <see cref="ITenants">tenants</see></param> /// <param name="processingHub">An instance of <see cref="IScopedEventProcessingHub" /> for processing <see cref="CommittedEventStream">Committed Event Streams</see></param> /// <param name="getOffsetRepository">A factory function to return a correctly scoped instance of <see cref="IEventProcessorOffsetRepository" /></param> /// <param name="getUnprocessedEventsFetcher">A factory function to return a correctly scoped instance of <see cref="IFetchUnprocessedEvents" /></param> /// <param name="executionContextManager">The <see cref="ExecutionContextManager" /> for setting the correct execution context for the Event Processors </param> /// <param name="resourceConfiguration"><see cref="IResourceConfiguration"/> for resources</param> /// <param name="environment">Current <see cref="Execution.Environment">execution environment</see></param> /// <param name="scheduler"><see cref="IScheduler"/> to use for scheduling</param> /// <param name="application">Current <see cref="Application"/></param> /// <param name="boundedContext">Current <see cref="BoundedContext"/></param> /// <param name="logger">An instance of <see cref="ILogger" /> for logging</param> public BootProcedure( IInstancesOf <IKnowAboutEventProcessors> systemsThatKnowAboutEventProcessors, ITenants tenants, IScopedEventProcessingHub processingHub, FactoryFor <IEventProcessorOffsetRepository> getOffsetRepository, FactoryFor <IFetchUnprocessedEvents> getUnprocessedEventsFetcher, IExecutionContextManager executionContextManager, IResourceConfiguration resourceConfiguration, IScheduler scheduler, Application application, BoundedContext boundedContext, Execution.Environment environment, ILogger logger) { _processingHub = processingHub; _scheduler = scheduler; _logger = logger; _tenants = tenants; _systemsThatKnowAboutEventProcessors = systemsThatKnowAboutEventProcessors; _getOffsetRepository = getOffsetRepository; _getUnprocessedEventsFetcher = getUnprocessedEventsFetcher; _executionContextManager = executionContextManager; _resourceConfiguration = resourceConfiguration; _logger = logger; _scheduler = scheduler; _executionContextManager.SetConstants(application, boundedContext, environment); }
public CronusHeartbeat(IPublisher <ISignal> publisher, IOptionsMonitor <BoundedContext> boundedContext, IOptionsMonitor <HeartbeatOptions> HeartbeatOptions, IOptions <TenantsOptions> tenantsOptions, ILogger <CronusHeartbeat> logger) { this.publisher = publisher; this.boundedContext = boundedContext.CurrentValue; tenants = tenantsOptions.Value.Tenants.ToList(); options = HeartbeatOptions.CurrentValue; this.logger = logger; }
public BootStrapper SetExternalDataSources() { _boundedContext = _boundedContext .WithInvokerAsync <CurrenciesDto>(new Service().RetrieveCurrenciesAsync) .WithInvoker <CurrenciesDto>(new Service().RetrieveCurrencies); return(this); }
/// <summary> /// Initializes a new instance of <see cref="Singularity"/> /// </summary> /// <param name="subscriptions"><see cref="IEnumerable{ParticleSubscription}">Subscriptions</see></param> /// <param name="application"><see cref="Application">Application</see> representing the singularity</param> /// <param name="boundedContext"><see cref="BoundedContext"/> representing the bounded context of the singularity</param> public Singularity( IEnumerable <EventParticleSubscription> subscriptions, Application application, BoundedContext boundedContext) { Subscriptions = subscriptions; Application = application; BoundedContext = boundedContext; }
/// <inheritdoc/> public void SetConstants( Application application, BoundedContext boundedContext, Environment environment) { _application = application; _boundedContext = boundedContext; _environment = environment; }
public EventStoreIndexExplorer(IEventStore eventStore, IOptionsMonitor <BoundedContext> boundedContextMonitor) { if (ReferenceEquals(null, eventStore) == true) { throw new ArgumentNullException(nameof(eventStore)); } this.eventStore = eventStore; this.boundedContext = boundedContextMonitor.CurrentValue; }
/// <summary> /// Initializes a new instance of <see cref="Singularity"/> /// </summary> /// <param name="application"><see cref="Application">Application</see> representing the singularity</param> /// <param name="boundedContext"><see cref="BoundedContext"/> representing the bounded context of the singularity</param> /// <param name="tunnel"><see cref="IQuantumTunnel"/> used to pass through to <see cref="Singularity"/></param> /// <param name="subscription"><see cref="EventParticleSubscription"/></param> public Singularity( Application application, BoundedContext boundedContext, IQuantumTunnel tunnel, EventParticleSubscription subscription) { _subscription = subscription; _tunnel = tunnel; Application = application; BoundedContext = boundedContext; }
public static TModel FromBoundedContext <TModel>(BoundedContext boundedContext) where TModel : BoundedContextApiModel, new() { var model = new TModel(); model.Id = boundedContext.Id; model.TenantId = boundedContext.TenantId; model.Name = boundedContext.Name; model.ImageUrl = boundedContext.ImageUrl; model.Description = boundedContext.Description; return(model); }
public void Send(BoundedContext boundedContext) { // ReSharper disable once UnusedVariable foreach (var @event in _eventUids.Invoke(boundedContext)) { if (_acknowledgement) { // Retrieve from database... // Send } } }
/// <summary> /// Initializes a new instance of <see cref="ExecutionContextFactory"/> /// </summary> /// <param name="principalResolver"><see cref="ICanResolvePrincipal"/> for resolving the identity</param> /// <param name="detailsPopulator">A <see cref="IExecutionContextDetailsPopulator"/> to use for populating any <see cref="IExecutionContext"/> being created</param> /// <param name="application">The current <see cref="Application"/></param> /// <param name="boundedContext">The current <see cref="BoundedContext"/></param> /// <param name="container">The <see cref="IContainer">IOC container</see> to resolve runtime dependencies</param> public ExecutionContextFactory( ICanResolvePrincipal principalResolver, IExecutionContextDetailsPopulator detailsPopulator, Application application, BoundedContext boundedContext, IContainer container) { _principalResolver = principalResolver; _detailsPopulator = detailsPopulator; _application = application; _boundedContext = boundedContext; _container = container; }
/// <summary> /// Initializes a new instance of <see cref="BoundedContextConfiguration"/> /// </summary> /// <param name="application"></param> /// <param name="boundedContext"></param> /// <param name="boundedContextName"></param> /// <param name="core"></param> /// <param name="interaction"></param> /// <param name="resources"></param> public BoundedContextConfiguration( Application application, BoundedContext boundedContext, BoundedContextName boundedContextName, CoreConfiguration core, IEnumerable <InteractionLayerConfiguration> interaction, IDictionary <ResourceType, ResourceTypeImplementationConfiguration> resources) { Application = application; BoundedContext = boundedContext; BoundedContextName = boundedContextName; Core = core; Interaction = interaction; Resources = resources; }
public override int GetHashCode() { unchecked { int hashCode = 3301; int multiplier = 79043; hashCode = (hashCode * multiplier) ^ Name.GetHashCode(); hashCode = (hashCode * multiplier) ^ BoundedContext.GetHashCode(); hashCode = (hashCode * multiplier) ^ Url.GetHashCode(); hashCode = (hashCode * multiplier) ^ Version.GetHashCode(); return(hashCode); } }
/// <summary> /// Initializes an instance of <see cref="ExecutionContext"/> /// </summary> /// <param name="principal"><see cref="ClaimsPrincipal"/> to populate with</param> /// <param name="cultureInfo"><see cref="CultureInfo"/> for the <see cref="ExecutionContext"/></param> /// <param name="detailsPopulator">Callback that gets called for populating the details of the <see cref="ExecutionContext"/></param> /// <param name="application"><see cref="Application"/> that is currently executing</param> /// <param name="boundedContext"><see cref="BoundedContext"/> that is currently executing</param> /// <param name="tenant"><see cref="ITenant"/> that is currently part of the <see cref="IExecutionContext"/></param> public ExecutionContext( ClaimsPrincipal principal, CultureInfo cultureInfo, ExecutionContextPopulator detailsPopulator, Application application, BoundedContext boundedContext, ITenant tenant) { Principal = principal; Culture = cultureInfo; Application = application; BoundedContext = boundedContext; Tenant = tenant; Details = new WriteOnceExpandoObject(d => detailsPopulator(this, d)); }
/// <summary> /// 保存应用信息 /// </summary> /// <param name="dto">应用信息</param> /// <returns>是否成功</returns> public virtual bool SaveApp(SYSAppRegistDTO dto) { using (var dbContext = BoundedContext.Create()) { if (!(SaveApp(dbContext, dto) && SaveMenu(dbContext, dto) && SaveAppAccess(dbContext, dto))) { return(false); } dbContext.Commit(); return(true); } }
/// <summary> /// Initializes an instance of <see cref="OriginalContext"/> /// </summary> /// <param name="application"><see cref="Application"/> that is the source of the event</param> /// <param name="boundedContext"><see cref="BoundedContext"/> that is the source of the event</param> /// <param name="tenant"><see cref="TenantId"/> that is related to the source of the event</param> /// <param name="environment"><see cref="Dolittle.Execution.Environment"/> for the original <see cref="ExecutionContext"/></param> /// <param name="claims"><see cref="Claims"/> for the user who initiated the event</param> /// <param name="commitSequenceNumber"><see cref="CommitSequenceNumber"/> for the commit of which this event is part. May not be populated in the source Bounded Context.</param> public OriginalContext( Application application, BoundedContext boundedContext, TenantId tenant, Dolittle.Execution.Environment environment, Claims claims, CommitSequenceNumber commitSequenceNumber = null) { Application = application; BoundedContext = boundedContext; Tenant = tenant; Environment = environment; Claims = claims; CommitInOrigin = commitSequenceNumber ?? 0; }
/// <summary> /// Initializes a new instance of the <see cref="BootProcedure"/> class. /// </summary> /// <param name="eventHorizons"><see cref="EventHorizonsConfiguration">Event horizons configuration</see>.</param> /// <param name="barrier"><see cref="IBarrier">Barrier</see> to penetrate towards an <see cref="IEventHorizon"/>.</param> /// <param name="resourceConfiguration"><see cref="IResourceConfiguration"/> for resources.</param> /// <param name="executionContextManager"><see cref="IExecutionContextManager"/> for working with <see cref="ExecutionContext"/>.</param> /// <param name="application">The running <see cref="Application"/>.</param> /// <param name="boundedContext">The running <see cref="BoundedContext"/>.</param> /// <param name="environment">The running environment.</param> public BootProcedure( EventHorizonsConfiguration eventHorizons, IBarrier barrier, IResourceConfiguration resourceConfiguration, IExecutionContextManager executionContextManager, Application application, BoundedContext boundedContext, Environment environment) { _eventHorizons = eventHorizons; _barrier = barrier; _resourceConfiguration = resourceConfiguration; executionContextManager.SetConstants(application, boundedContext, environment); }
public void MergeFrom(ExecutionContext other) { if (other == null) { return; } if (other.application_ != null) { if (application_ == null) { application_ = new global::System.Protobuf.guid(); } Application.MergeFrom(other.Application); } if (other.boundedContext_ != null) { if (boundedContext_ == null) { boundedContext_ = new global::System.Protobuf.guid(); } BoundedContext.MergeFrom(other.BoundedContext); } if (other.tenant_ != null) { if (tenant_ == null) { tenant_ = new global::System.Protobuf.guid(); } Tenant.MergeFrom(other.Tenant); } if (other.correlationId_ != null) { if (correlationId_ == null) { correlationId_ = new global::System.Protobuf.guid(); } CorrelationId.MergeFrom(other.CorrelationId); } if (other.Environment.Length != 0) { Environment = other.Environment; } claims_.Add(other.claims_); if (other.Culture.Length != 0) { Culture = other.Culture; } }