public void Configuration(IAppBuilder appBuilder) { var config = new HttpConfiguration(); // enable windows auth credentials var listener = (Microsoft.Owin.Host.HttpListener.OwinHttpListener)appBuilder.Properties["Microsoft.Owin.Host.HttpListener.OwinHttpListener"]; listener.Listener.AuthenticationSchemes = AuthenticationSchemes.IntegratedWindowsAuthentication; // inject single CertifyManager for service to use _container = new ServiceContainer(); _container.RegisterApiControllers(); _container.EnableWebApi(config); _container.Register <Management.ICertifyManager, Management.CertifyManager>(new PerContainerLifetime()); config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); #if DEBUG config .EnableSwagger(c => c.SingleApiVersion("v1", "Service API for local install of Certify SSL Manager")) .EnableSwaggerUi(); #endif // appBuilder.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll); appBuilder.MapSignalR("/api/status", new HubConfiguration()); appBuilder.UseWebApi(config); var currentCertifyManager = _container.GetInstance <Management.ICertifyManager>(); currentCertifyManager.OnRequestProgressStateUpdated += (Models.RequestProgressState obj) => { // notify client(s) of status updates StatusHub.SendRequestProgressState(obj); }; currentCertifyManager.OnManagedCertificateUpdated += (Models.ManagedCertificate obj) => { // notify client(s) of update to a managed site StatusHub.SendManagedCertificateUpdate(obj); }; // use a timer to poll for periodic jobs (cleanup, renewal etc) _timer = new System.Timers.Timer(60 * 60 * 1000);// every 60 minutes _timer.Elapsed += _timer_Elapsed; _timer.Start(); // use a timer to poll for periodic jobs (cleanup, renewal etc) _dailyTimer = new System.Timers.Timer(24 * 60 * 60 * 1000);// every 24 hrs _dailyTimer.Elapsed += _dailyTimer_Elapsed; _dailyTimer.Start(); }
public async Task ReportManagedCertificateUpdated(ManagedCertificate item) { System.Diagnostics.Debug.WriteLine($"Sending updated managed cert message to UI: {item.Name}"); StatusHub.SendManagedCertificateUpdate(item); }
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously public async Task ReportRequestProgress(RequestProgressState state) { System.Diagnostics.Debug.WriteLine($"Sending progress update message to UI: {state.Message}"); StatusHub.SendProgressState(state); }