예제 #1
0
        private static async Task DequeueAndSendWebHooks(CancellationToken cancellationToken)
        {
            // Create the dequeue manager
            string  connectionString           = ConfigurationManager.ConnectionStrings[QueueConnectionString].ConnectionString;
            ILogger logger                     = CommonServices.GetLogger();
            AzureWebHookDequeueManager manager = new AzureWebHookDequeueManager(connectionString, logger);

            // Start the dequeue manager
            await manager.Start(cancellationToken);
        }
예제 #2
0
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services

            var controllerType = typeof(WebHookReceiversController);

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new
            {
                id = RouteParameter.Optional
            }
                );

            // Load Azure Storage or SQL for persisting subscriptions
            // config.InitializeCustomWebHooksAzureStorage();
            // config.InitializeCustomWebHooksSqlStorage();

            // Load Azure Queued Sender for enqueueing outgoing WebHooks to an Azure Storage Queue
            // config.InitializeCustomWebHooksAzureQueueSender();

            // Uncomment the following to set a custom WebHook sender where you can control how you want
            // the outgoing WebHook request to look.
            ILogger        logger = CommonServices.GetLogger();
            IWebHookSender sender = new TestWebhookSender(logger);

            CustomServices.SetSender(sender);

            // Load basic support for sending WebHooks
            config.InitializeCustomWebHooks();

            // Load Web API controllers for managing subscriptions
            config.InitializeCustomWebHooksApis();

            config.InitializeReceiveCustomWebHooks();

            config.EnsureInitialized();

            var webhookRoutes = config.Routes;

            config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/octet-stream"));
        }
        /// <summary>
        /// Gets an <see cref="ILogger"/> implementation registered with the Dependency Injection engine
        /// or a default <see cref="System.Diagnostics.Trace"/> implementation if none are registered.
        /// </summary>
        /// <param name="services">The <see cref="IDependencyScope"/> implementation.</param>
        /// <returns>The registered <see cref="ILogger"/> instance or a default implementation if none are registered.</returns>
        public static ILogger GetLogger(this IDependencyScope services)
        {
            ILogger logger = services.GetService <ILogger>();

            return(logger ?? CommonServices.GetLogger());
        }