public async Task Handle(ProcessFileAddedEvent message, CancellationToken token)
        {
            var caseWorkerTask = ProcessFileAggregate.New(new DomainEvent[] { message });
            await _processFileCommandRepository.Add(caseWorkerTask, token);

            await _processFileCommandRepository.SaveChanges(token);
        }
Esempio n. 2
0
        private void InitializeDatabase(IApplicationBuilder app)
        {
            using (var scope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                using (var context = scope.ServiceProvider.GetService <BPMNDbContext>())
                {
                    context.Database.Migrate();
                    if (context.ProcessFiles.Any())
                    {
                        return;
                    }

                    var pathLst = Directory.EnumerateFiles(Path.Combine(_env.ContentRootPath, "Bpmns"), "*.bpmn").ToList();
                    foreach (var path in pathLst)
                    {
                        var bpmnTxt     = File.ReadAllText(path);
                        var name        = Path.GetFileName(path);
                        var processFile = ProcessFileAggregate.New(name, name, name, 0, bpmnTxt);
                        context.ProcessFiles.Add(processFile);
                    }

                    context.DelegateConfigurations.Add(DelegateConfigurationAggregate.Create("GetWeatherInformationDelegate", typeof(GetWeatherInformationDelegate).FullName));
                    context.SaveChanges();
                }
            }
        }
        public ServerBuilder AddProcessFiles(List <string> lst)
        {
            var processFiles = new ConcurrentBag <ProcessFileAggregate>();

            foreach (var path in lst)
            {
                var bpmnTxt     = File.ReadAllText(path);
                var name        = Path.GetFileName(path);
                var processFile = ProcessFileAggregate.New(name, name, name, 0, bpmnTxt);
                processFiles.Add(processFile);
            }

            _services.AddSingleton <IProcessFileCommandRepository>(new InMemoryProcessFileCommandRepository(processFiles));
            _services.AddSingleton <IProcessFileQueryRepository>(new InMemoryProcessFileQueryRepository(processFiles));
            return(this);
        }
Esempio n. 4
0
        public ServerBuilder AddProcessFiles(List <string> lst)
        {
            var builder = _services.BuildServiceProvider();
            var commitAggregateHelper = (ICommitAggregateHelper)builder.GetService(typeof(ICommitAggregateHelper));
            var processFiles          = new ConcurrentBag <ProcessFileAggregate>();

            foreach (var path in lst)
            {
                var bpmnTxt     = File.ReadAllText(path);
                var name        = Path.GetFileName(path);
                var processFile = ProcessFileAggregate.New(name, name, name, 0, bpmnTxt);
                processFiles.Add(processFile);
                commitAggregateHelper.Commit(processFile, processFile.GetStreamName(), CancellationToken.None).Wait();
            }

            _services.AddSingleton <IProcessFileCommandRepository>(new InMemoryProcessFileCommandRepository(processFiles));
            _services.AddSingleton <IProcessFileQueryRepository>(new InMemoryProcessFileQueryRepository(processFiles));
            return(this);
        }
Esempio n. 5
0
        public async Task <CreateProcessFileResult> Handle(CreateProcessFileCommand request, CancellationToken cancellationToken)
        {
            var payload = request.Payload;

            if (string.IsNullOrWhiteSpace(request.Payload))
            {
                payload = _options.DefaultBPMNFile;
            }

            var processFile = ProcessFileAggregate.New(Guid.NewGuid().ToString(), request.Name, request.Description, 0, payload);
            var streamName  = ProcessFileAggregate.GetStreamName(processFile.AggregateId);
            await _commitAggregateHelper.Commit(processFile, streamName, cancellationToken);

            _logger.LogInformation("Process file has been added");
            return(new CreateProcessFileResult
            {
                Id = processFile.AggregateId
            });
        }
Esempio n. 6
0
        private void InitializeDatabase(IApplicationBuilder app)
        {
            using (var scope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                using (var context = scope.ServiceProvider.GetService <BPMNDbContext>())
                {
                    context.Database.Migrate();
                    if (context.ProcessFiles.Any())
                    {
                        return;
                    }

                    var commitAggregateHelper = scope.ServiceProvider.GetService <ICommitAggregateHelper>();
                    var pathLst = Directory.EnumerateFiles(Path.Combine(_env.ContentRootPath, "Bpmns"), "*.bpmn").ToList();
                    foreach (var path in pathLst)
                    {
                        var bpmnTxt     = File.ReadAllText(path);
                        var name        = Path.GetFileName(path);
                        var processFile = ProcessFileAggregate.New(name, name, name, 0, bpmnTxt);
                        commitAggregateHelper.Commit(processFile, processFile.GetStreamName(), CancellationToken.None).Wait();
                    }
                }
            }
        }