示例#1
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();
                }
            }
        }
示例#2
0
        private static ConcurrentBag <DelegateConfigurationAggregate> GetDelegateConfigurations()
        {
            var credential = JsonConvert.DeserializeObject <CredentialsParameter>(File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory(), "credentials.json")));

            var sendEmailDelegate = DelegateConfigurationAggregate.Create("SendEmailDelegate", typeof(SendEmailDelegate).FullName);

            sendEmailDelegate.AddDisplayName("fr", "Envoyer un email");
            sendEmailDelegate.AddDisplayName("en", "Send email");
            sendEmailDelegate.AddRecord("httpBody", "Please update the password by clicking on the website {{configuration.Get('humanTaskUrl')}}/humantaskinstances/{{messages.Get('humanTaskCreated', 'humanTaskInstance.id')}}?auth=email, the OTP code is {{messages.Get('otp', 'otpCode')}}");
            sendEmailDelegate.AddRecord("subject", "Update password");
            sendEmailDelegate.AddRecord("fromEmail", credential.Login);
            sendEmailDelegate.AddRecord("smtpHost", "smtp.gmail.com");
            sendEmailDelegate.AddRecord("smtpPort", "587");
            sendEmailDelegate.AddRecord("smtpUserName", credential.Login);
            sendEmailDelegate.AddRecord("smtpPassword", credential.Password);
            sendEmailDelegate.AddRecord("humanTaskUrl", "http://localhost:4200");
            sendEmailDelegate.AddRecord("smtpEnableSsl", "true");

            var updateUserPasswordDelegate = DelegateConfigurationAggregate.Create("UpdateUserPasswordDelegate", typeof(UpdateUserPasswordDelegate).FullName);

            updateUserPasswordDelegate.AddDisplayName("fr", "Mettre à jour le mot de passe");
            updateUserPasswordDelegate.AddDisplayName("en", "Update password");
            updateUserPasswordDelegate.AddRecord("clientId", "humanTaskClient");
            updateUserPasswordDelegate.AddRecord("clientSecret", "humanTaskClientSecret");
            updateUserPasswordDelegate.AddRecord("tokenUrl", "https://localhost:60000/token");
            updateUserPasswordDelegate.AddRecord("userUrl", "https://localhost:60000/management/users/{id}/password");
            updateUserPasswordDelegate.AddRecord("scope", "manage_users");

            var generateOTPDelegate = DelegateConfigurationAggregate.Create("GenerateOTPDelegate", typeof(GenerateOTPDelegate).FullName);

            generateOTPDelegate.AddDisplayName("fr", "Générer le code OTP");
            generateOTPDelegate.AddDisplayName("en", "Generate OTP code");
            generateOTPDelegate.AddRecord("clientId", "humanTaskClient");
            generateOTPDelegate.AddRecord("clientSecret", "humanTaskClientSecret");
            generateOTPDelegate.AddRecord("tokenUrl", "https://localhost:60000/token");
            generateOTPDelegate.AddRecord("userUrl", "https://localhost:60000/management/users/{id}/otp");
            generateOTPDelegate.AddRecord("scope", "manage_users");

            var assignHumanTaskInstanceDelegate = DelegateConfigurationAggregate.Create("assignHumanTask", typeof(AssignHumanTaskInstanceDelegate).FullName);

            assignHumanTaskInstanceDelegate.AddDisplayName("fr", "Assigner la tâche humaine");
            assignHumanTaskInstanceDelegate.AddDisplayName("en", "Assign human task");
            assignHumanTaskInstanceDelegate.AddRecord("clientId", "humanTaskClient");
            assignHumanTaskInstanceDelegate.AddRecord("clientSecret", "humanTaskClientSecret");
            assignHumanTaskInstanceDelegate.AddRecord("tokenUrl", "https://localhost:60000/token");
            assignHumanTaskInstanceDelegate.AddRecord("humanTaskInstanceClaimUrl", "http://localhost:60006/humantaskinstances/{id}/force/claim");
            assignHumanTaskInstanceDelegate.AddRecord("humanTaskInstanceStartUrl", "http://localhost:60006/humantaskinstances/{id}/force/start");

            return(new ConcurrentBag <DelegateConfigurationAggregate>
            {
                sendEmailDelegate,
                updateUserPasswordDelegate,
                generateOTPDelegate,
                assignHumanTaskInstanceDelegate
            });
        }
示例#3
0
            private FakeCaseJobServer()
            {
                _factory = new FakeHttpClientFactory();
                var serviceCollection = new ServiceCollection();

                serviceCollection.AddLogging();
                serviceCollection.AddProcessJobServer(callbackServerOpts: o =>
                {
                    o.WSHumanTaskAPI = "http://localhost";
                    o.CallbackUrl    = "http://localhost/{id}/{eltId}";
                }).AddDelegateConfigurations(new ConcurrentBag <DelegateConfigurationAggregate>
                {
                    DelegateConfigurationAggregate.Create("GetWeatherInformationDelegate", typeof(GetWeatherInformationDelegate).FullName)
                });
                serviceCollection.AddSingleton <IHttpClientFactory>(_factory);
                _serviceProvider = serviceCollection.BuildServiceProvider();
                _processInstanceCommandRepository = _serviceProvider.GetRequiredService <IProcessInstanceCommandRepository>();
                _busControl = _serviceProvider.GetRequiredService <IBusControl>();
                _mediator   = _serviceProvider.GetRequiredService <IMediator>();
            }
示例#4
0
        public void ConfigureServices(IServiceCollection services)
        {
            var files             = Directory.EnumerateFiles(Path.Combine(Directory.GetCurrentDirectory(), "Bpmns"), "*.bpmn").ToList();
            var sp                = services.BuildServiceProvider();
            var httpClientFactory = sp.GetRequiredService <CaseManagement.Common.Factories.IHttpClientFactory>();

            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCustomAuthentication(opts => { });
            services.AddAuthorization(_ =>
            {
                _.AddPolicy("Authenticated", p => p.RequireAuthenticatedUser());
                _.AddPolicy(HumanTaskConstants.ScopeNames.ManageHumanTaskInstance, p => p.RequireAssertion(__ => true));
            });
            services
            .AddMvc(opts => opts.EnableEndpointRouting = false)
            .AddApplicationPart(typeof(ProcessFilesController).Assembly)
            .AddApplicationPart(typeof(HumanTaskDefsController).Assembly)
            .AddNewtonsoftJson();
            services.AddLogging();
            var emptyTask = HumanTaskDefBuilder.New("emptyTask")
                            .SetTaskInitiatorUserIdentifiers(new List <string> {
                "thabart"
            })
                            .SetPotentialOwnerUserIdentifiers(new List <string> {
                "thabart"
            })
                            .Build();
            var dressAppropriateForm = HumanTaskDefBuilder.New("dressAppropriateForm")
                                       .SetTaskInitiatorUserIdentifiers(new List <string> {
                "thabart"
            })
                                       .SetPotentialOwnerUserIdentifiers(new List <string> {
                "thabart"
            })
                                       .AddInputOperationParameter("degree", ParameterTypes.STRING, true)
                                       .AddInputOperationParameter("city", ParameterTypes.STRING, true)
                                       .Build();
            var takeTemperatureForm = HumanTaskDefBuilder.New("temperatureForm")
                                      .SetTaskInitiatorUserIdentifiers(new List <string> {
                "thabart"
            })
                                      .SetPotentialOwnerUserIdentifiers(new List <string> {
                "thabart"
            })
                                      .AddOutputOperationParameter("degree", ParameterTypes.INT, true)
                                      .Build();

            services.AddHumanTasksApi();
            services.AddHumanTaskServer()
            .AddHumanTaskDefs(new List <HumanTaskDefinitionAggregate>
            {
                emptyTask,
                dressAppropriateForm,
                takeTemperatureForm
            })
            .AddScheduledJobs(new List <ScheduleJob>
            {
                ScheduleJob.New <ProcessActivationTimerJob>(1 * 1000),
                ScheduleJob.New <ProcessDeadLinesJob>(1 * 1000)
            });
            services.AddProcessJobServer(callbackOpts: o =>
            {
                o.ApplicationAssembly = typeof(ProcessInstanceAggregate).Assembly;
            }, callbackServerOpts: o =>
            {
                o.WSHumanTaskAPI     = "http://localhost";
                o.OAuthTokenEndpoint = "http://localhost/token";
                o.CallbackUrl        = "http://localhost/processinstances/{id}/complete/{eltId}";
            })
            .AddProcessFiles(files)
            .AddDelegateConfigurations(new ConcurrentBag <DelegateConfigurationAggregate>
            {
                DelegateConfigurationAggregate.Create("GetWeatherInformationDelegate", typeof(GetWeatherInformationDelegate).FullName)
            });
            services.AddHostedService <HumanTaskJobServerHostedService>();
            services.AddSingleton <CaseManagement.Common.Factories.IHttpClientFactory>(httpClientFactory);
        }