public ApplicationController(ApplicationManagementService applicationManagementService, IApplicationService applicationService, ILogger <ApplicationController> logger, ICorrelationContextAccessor correlationContextAccessor)
 {
     _applicationManagementService = applicationManagementService;
     _applicationService           = applicationService;
     _logger = logger;
     _correlationContextAccessor = correlationContextAccessor;
 }
        private void ConfigureRouting(IApplicationBuilder app, ApplicationManagementService applicationManagementService)
        {
            // This isnt ideal...
            var applications = applicationManagementService.GetApplications().Result;

            app.UseMvc(routes =>
            {
                // map any incoming routes for each application
                foreach (var application in applications.Where(w => !string.IsNullOrEmpty(w.MainMenuText)))
                {
                    if (application.RequiresAuthorization)
                    {
                        routes.MapRoute(
                            name: $"application-{application.RouteName}-Index",
                            template: application.RouteName,
                            defaults: new { controller = "Authorized", action = "Index", application.RouteName }
                            );
                    }
                    else
                    {
                        routes.MapRoute(
                            name: $"application-{application.RouteName}-Index",
                            template: application.RouteName,
                            defaults: new { controller = "Application", action = "Index", application.RouteName }
                            );
                    }
                }

                // add the default route
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
        private void AddHealthChecks(IServiceCollection services, ApplicationManagementService applicationManagementService)
        {
            services.AddHealthChecksUI();
            var healthChecks = services.AddHealthChecks().AddCheck("self", () => HealthCheckResult.Healthy());
            var applications = applicationManagementService.GetApplications().Result;

            var canCheck = applications.Where(w => !string.IsNullOrEmpty(w.HealthCheckUrl)).ToList();

            canCheck.ForEach(f => healthChecks.AddUrlGroup(new Uri(f.HealthCheckUrl), name: f.Name, tags: new string[] { $"{f.RouteName}-api" }));

            services.Configure <HealthCheckPublisherOptions>(options =>
            {
                options.Period  = new TimeSpan(0, 0, 4);
                options.Delay   = TimeSpan.FromSeconds(2);
                options.Timeout = new TimeSpan(0, 0, 10);
                //    options.Predicate = (check) => check.Tags.Contains("ready");
            });

            const string HealthCheckServiceAssembly = "Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckPublisherHostedService";

            services.TryAddEnumerable(
                ServiceDescriptor.Singleton(typeof(IHostedService),
                                            typeof(HealthCheckPublisherOptions).Assembly
                                            .GetType(HealthCheckServiceAssembly)));

            services.AddSingleton <IHealthCheckPublisher, ReadinessPublisher>();
        }
 public AuthorizedController(
     ApplicationManagementService applicationManagementService,
     Services.IApplicationService applicationService,
     ILogger <AuthorizedController> logger,
     ICorrelationContextAccessor correlationContextAccessor
     ) : base(applicationManagementService, applicationService, logger, correlationContextAccessor)
 {
 }
コード例 #5
0
        // List the application versions for each environment
        public static void Main(string[] args)
        {
            // Use the AuthenticationService API to get a session token.
            // See its implementation on the Authorization Service API
            String token = AuthenticationExample.getToken();

            // Create an authentication object to send in the WS call and set it with the session token
            WebServiceSimpleAuthentication authentication = new WebServiceSimpleAuthentication();

            authentication.Token = token;

            // Application Management Service WS proxy created by Visual Studio
            ApplicationManagementService service = new ApplicationManagementService();

            // The status of the WS call
            bool      success = false;
            APIStatus status  = null;

            ApplicationInfo[] applicationList = null;

            // Invoke the Application_List web method
            // WS returns a boolean and status code to signal success
            success = service.Application_List(authentication, out status, out applicationList);

            // If the call was successful, print the applications and their versions
            if (success)
            {
                foreach (ApplicationInfo application in applicationList)
                {
                    Console.Write(String.Format("\n{0,-30}", application.Name));
                    foreach (EnvironmentApplicationInfo applicationInEnvironment in application.StatusInEnvironments)
                    {
                        // Print app version or '-' if it is not deployed on the environment
                        Console.Write(String.Format("{0,-20}",
                                                    applicationInEnvironment.ExistsInEnvironment ? applicationInEnvironment.Version : "-"));
                    }
                }
            }
            else
            {
                // Implement error handling by checking the status.ResponseId field
                // See the possible error codes in the APIStatus structure documentation
            }
        }
        // List the application permission levels available
        public static void Main(string[] args)
        {
            // Use the AuthenticationService API to get a session token.
            // See its implementation on the Authorization Service API
            String token = AuthenticationExample.getToken();

            // Create an authentication object to send in the WS call and set it with the session token
            WebServiceSimpleAuthentication authentication = new WebServiceSimpleAuthentication();

            authentication.Token = token;

            // Application Management Service WS proxy created by Visual Studio
            ApplicationManagementService service = new ApplicationManagementService();

            // The status of the WS call
            bool      success = false;
            APIStatus status  = null;

            ApplicationPermissionLevel[] permissionLevels = null;

            // Invoke the ApplicationPermissionLevel_List web method
            // WS returns a boolean and status code to signal success
            success = service.ApplicationPermissionLevel_List(authentication, out status, out permissionLevels);


            // If the call was successful, print the permission levels available
            if (success)
            {
                foreach (ApplicationPermissionLevel permission in permissionLevels)
                {
                    Console.WriteLine(String.Format("{0}", permission.ShortLabel));
                }
            }
            else
            {
                // Implement error handling by checking the status.ResponseId field
                // See the possible error codes in the APIStatus structure documentation
            }
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApplicationManagementService applicationManagementService)
        {
            app.UseCorrelationId(new CorrelationIdOptions
            {
                Header = "X-Correlation-ID",
                UseGuidForCorrelationId = true,
                UpdateTraceIdentifier   = false             // = false is a Core 2.2 workaround - should be fixed in Core 2.2.2
            });

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();
            app.UseAuthentication();

            app.UseHealthChecks("/liveness", new HealthCheckOptions
            {
                Predicate = r => r.Name.Contains("self")
            });
            app.UseHealthChecks("/health", new HealthCheckOptions()
            {
                Predicate      = _ => true,
                ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
            });
            app.UseHealthChecksUI();

            ConfigureRouting(app, applicationManagementService);
        }
コード例 #8
0
        public void SetUp()
        {
            ServiceLocatorInitializer.Init();

            _applicationRepository =
                MockRepository.GenerateMock <IApplicationRepository>();
            _applicationRepository.Stub(r => r.DbContext)
            .Return(MockRepository.GenerateMock <IDbContext>());

            _hostManagementService =
                MockRepository.GenerateMock <IHostManagementService>();

            _supportTeamManagementService =
                MockRepository.GenerateMock <ISupportTeamManagementService>();

            _personManagementService =
                MockRepository.GenerateMock <IPersonManagementService>();


            _applicationManagementService =
                new ApplicationManagementService(_applicationRepository, _supportTeamManagementService, _hostManagementService,
                                                 _personManagementService);
        }
コード例 #9
0
 public HealthController(HealthCheckService healthCheckService, IMemoryCache memoryCache, ApplicationManagementService applicationManagementService)
 {
     _healthCheckService           = healthCheckService;
     _memoryCache                  = memoryCache;
     _applicationManagementService = applicationManagementService;
 }
コード例 #10
0
 public ApplicationNavigationMenuViewComponent(ApplicationManagementService applicationManagementService)
 {
     _applicationManagementService = applicationManagementService;
 }
コード例 #11
0
 public ListApplicationsViewComponent(ApplicationManagementService applicationManagementService)
 {
     _applicationManagementService = applicationManagementService;
 }