コード例 #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IBackgroundJobClient backgroundJobs, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseStatusCodePages(); //works fine
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }
            app.UseStaticFiles();

            app.UseHangfireDashboard();

            QueueManagerClient.StartQueueManager();

            app.UseRouting();

            app.UseCors("CorsPolicy");
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");

                endpoints.MapHub <DownloadProgressHub>("/DownloadProgressHub");
            });
        }
コード例 #2
0
 internal static void AddNewskiesServices(this IServiceCollection services)
 {
     ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
     services.AddSingleton <IBookingManager>(service =>
     {
         var options = service.GetService(typeof(IOptions <AppSettings>)) as IOptions <AppSettings>;
         var client  = new BookingManagerClient();
         if (!string.IsNullOrEmpty(options.Value.NewskiesSettings.ServiceEndpoints.BookingManagerUrl))
         {
             client.Endpoint.Address              = new EndpointAddress(options.Value.NewskiesSettings.ServiceEndpoints.BookingManagerUrl);
             var timeout                          = options.Value.NewskiesSettings.ServiceTimeoutSeconds;
             client.Endpoint.Binding.OpenTimeout  = TimeSpan.FromSeconds(timeout);
             client.Endpoint.Binding.CloseTimeout = TimeSpan.FromSeconds(timeout);
             client.Endpoint.Binding.SendTimeout  = TimeSpan.FromSeconds(timeout);
         }
         return(client);
     });
     services.AddSingleton <IAgentManager>(service =>
     {
         var options = service.GetService(typeof(IOptions <AppSettings>)) as IOptions <AppSettings>;
         var client  = new AgentManagerClient();
         if (!string.IsNullOrEmpty(options.Value.NewskiesSettings.ServiceEndpoints.AgentManagerUrl))
         {
             client.Endpoint.Address              = new EndpointAddress(options.Value.NewskiesSettings.ServiceEndpoints.AgentManagerUrl);
             var timeout                          = options.Value.NewskiesSettings.ServiceTimeoutSeconds;
             client.Endpoint.Binding.OpenTimeout  = TimeSpan.FromSeconds(timeout);
             client.Endpoint.Binding.CloseTimeout = TimeSpan.FromSeconds(timeout);
             client.Endpoint.Binding.SendTimeout  = TimeSpan.FromSeconds(timeout);
         }
         return(client);
     });
     services.AddSingleton <IPersonManager>(service =>
     {
         var options = service.GetService(typeof(IOptions <AppSettings>)) as IOptions <AppSettings>;
         var client  = new PersonManagerClient();
         if (!string.IsNullOrEmpty(options.Value.NewskiesSettings.ServiceEndpoints.PersonManagerUrl))
         {
             client.Endpoint.Address              = new EndpointAddress(options.Value.NewskiesSettings.ServiceEndpoints.PersonManagerUrl);
             var timeout                          = options.Value.NewskiesSettings.ServiceTimeoutSeconds;
             client.Endpoint.Binding.OpenTimeout  = TimeSpan.FromSeconds(timeout);
             client.Endpoint.Binding.CloseTimeout = TimeSpan.FromSeconds(timeout);
             client.Endpoint.Binding.SendTimeout  = TimeSpan.FromSeconds(timeout);
         }
         return(client);
     });
     services.AddSingleton <IUtilitiesManager>(service =>
     {
         var options = service.GetService(typeof(IOptions <AppSettings>)) as IOptions <AppSettings>;
         var client  = new UtilitiesManagerClient();
         if (!string.IsNullOrEmpty(options.Value.NewskiesSettings.ServiceEndpoints.UtilitiesManagerUrl))
         {
             client.Endpoint.Address              = new EndpointAddress(options.Value.NewskiesSettings.ServiceEndpoints.UtilitiesManagerUrl);
             var timeout                          = options.Value.NewskiesSettings.ServiceTimeoutSeconds;
             client.Endpoint.Binding.OpenTimeout  = TimeSpan.FromSeconds(timeout);
             client.Endpoint.Binding.CloseTimeout = TimeSpan.FromSeconds(timeout);
             client.Endpoint.Binding.SendTimeout  = TimeSpan.FromSeconds(timeout);
         }
         return(client);
     });
     services.AddSingleton <IOperationManager>(service =>
     {
         var options = service.GetService(typeof(IOptions <AppSettings>)) as IOptions <AppSettings>;
         var client  = new OperationManagerClient();
         if (!string.IsNullOrEmpty(options.Value.NewskiesSettings.ServiceEndpoints.OperationManagerUrl))
         {
             client.Endpoint.Address              = new EndpointAddress(options.Value.NewskiesSettings.ServiceEndpoints.OperationManagerUrl);
             var timeout                          = options.Value.NewskiesSettings.ServiceTimeoutSeconds;
             client.Endpoint.Binding.OpenTimeout  = TimeSpan.FromSeconds(timeout);
             client.Endpoint.Binding.CloseTimeout = TimeSpan.FromSeconds(timeout);
             client.Endpoint.Binding.SendTimeout  = TimeSpan.FromSeconds(timeout);
         }
         return(client);
     });
     services.AddSingleton <IQueueManager>(service =>
     {
         var options = service.GetService(typeof(IOptions <AppSettings>)) as IOptions <AppSettings>;
         var client  = new QueueManagerClient();
         if (!string.IsNullOrEmpty(options.Value.NewskiesSettings.ServiceEndpoints.QueueManagerUrl))
         {
             client.Endpoint.Address              = new EndpointAddress(options.Value.NewskiesSettings.ServiceEndpoints.QueueManagerUrl);
             var timeout                          = options.Value.NewskiesSettings.ServiceTimeoutSeconds;
             client.Endpoint.Binding.OpenTimeout  = TimeSpan.FromSeconds(timeout);
             client.Endpoint.Binding.CloseTimeout = TimeSpan.FromSeconds(timeout);
             client.Endpoint.Binding.SendTimeout  = TimeSpan.FromSeconds(timeout);
         }
         return(client);
     });
     services.AddSingleton <IVoucherManager>(service =>
     {
         var options = service.GetService(typeof(IOptions <AppSettings>)) as IOptions <AppSettings>;
         var client  = new VoucherManagerClient();
         if (!string.IsNullOrEmpty(options.Value.NewskiesSettings.ServiceEndpoints.VoucherManagerUrl))
         {
             client.Endpoint.Address              = new EndpointAddress(options.Value.NewskiesSettings.ServiceEndpoints.VoucherManagerUrl);
             var timeout                          = options.Value.NewskiesSettings.ServiceTimeoutSeconds;
             client.Endpoint.Binding.OpenTimeout  = TimeSpan.FromSeconds(timeout);
             client.Endpoint.Binding.CloseTimeout = TimeSpan.FromSeconds(timeout);
             client.Endpoint.Binding.SendTimeout  = TimeSpan.FromSeconds(timeout);
         }
         return(client);
     });
     services.AddSingleton <IAccountManager>(service =>
     {
         var options = service.GetService(typeof(IOptions <AppSettings>)) as IOptions <AppSettings>;
         var client  = new AccountManagerClient();
         if (!string.IsNullOrEmpty(options.Value.NewskiesSettings.ServiceEndpoints.AccountManagerUrl))
         {
             client.Endpoint.Address              = new EndpointAddress(options.Value.NewskiesSettings.ServiceEndpoints.AccountManagerUrl);
             var timeout                          = options.Value.NewskiesSettings.ServiceTimeoutSeconds;
             client.Endpoint.Binding.OpenTimeout  = TimeSpan.FromSeconds(timeout);
             client.Endpoint.Binding.CloseTimeout = TimeSpan.FromSeconds(timeout);
             client.Endpoint.Binding.SendTimeout  = TimeSpan.FromSeconds(timeout);
         }
         return(client);
     });
     services.AddSingleton <ISessionManager>(service =>
     {
         var options = service.GetService(typeof(IOptions <AppSettings>)) as IOptions <AppSettings>;
         var client  = new SessionManagerClient();
         if (!string.IsNullOrEmpty(options.Value.NewskiesSettings.ServiceEndpoints.SessionManagerUrl))
         {
             client.Endpoint.Address              = new EndpointAddress(options.Value.NewskiesSettings.ServiceEndpoints.SessionManagerUrl);
             var timeout                          = options.Value.NewskiesSettings.ServiceTimeoutSeconds;
             client.Endpoint.Binding.OpenTimeout  = TimeSpan.FromSeconds(timeout);
             client.Endpoint.Binding.CloseTimeout = TimeSpan.FromSeconds(timeout);
             client.Endpoint.Binding.SendTimeout  = TimeSpan.FromSeconds(timeout);
         }
         return(client);
     });
 }