From b150f5bcfe68ba635bed89265964cd43e28eba2c Mon Sep 17 00:00:00 2001 From: paolo Date: Tue, 30 Jun 2020 16:35:24 +0200 Subject: [PATCH] fix fonts --- .gitignore | 1 + Thermo.Active/App_Start/Startup.cs | 214 +++++++++++++++-------------- 2 files changed, 109 insertions(+), 106 deletions(-) diff --git a/.gitignore b/.gitignore index 70bd785a..99305d6d 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ Output/ *.ntvs* *.njsproj /ConsoleApp1 +/WindowsFormsApp1 diff --git a/Thermo.Active/App_Start/Startup.cs b/Thermo.Active/App_Start/Startup.cs index c984c618..0cf2f226 100644 --- a/Thermo.Active/App_Start/Startup.cs +++ b/Thermo.Active/App_Start/Startup.cs @@ -23,136 +23,138 @@ using static Thermo.Active.Model.Constants; namespace Thermo.Active.App_Start { - public class Startup - { - public static OAuthAuthorizationServerOptions OAuthOptions; + public class Startup + { + public static OAuthAuthorizationServerOptions OAuthOptions; - public void Configuration(IAppBuilder app) - { - if (NcConfig.NcVendor.ToUpper() == NC_VENDOR.SIEMENS && NcConfig.ShowNcHMI) - ThreadSiemensHmi.InitWindow(); + public void Configuration(IAppBuilder app) + { + if (NcConfig.NcVendor.ToUpper() == NC_VENDOR.SIEMENS && NcConfig.ShowNcHMI) + ThreadSiemensHmi.InitWindow(); - // aggiunto x CORSe accesso remote al progetto - app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll); + // aggiunto x CORSe accesso remote al progetto + app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll); - // Configure HTTP - HttpConfiguration config = new HttpConfiguration(); + // Configure HTTP + HttpConfiguration config = new HttpConfiguration(); - // Register Web API config - WebApiConfig.Register(config); + // Register Web API config + WebApiConfig.Register(config); - // Register Swagger config - SwaggerConfig.Register(config); + // Register Swagger config + SwaggerConfig.Register(config); - // Configure api authentication - ConfigureWebApiOAuth(app); + // Configure api authentication + ConfigureWebApiOAuth(app); - app.UseWebApi(config); + app.UseWebApi(config); - // SignalR config & startup - SignalRConfig(app); + // SignalR config & startup + SignalRConfig(app); - var directoryBrowsing = ConfigurationManager.AppSettings["enableDirectoryBrowsing"] == "true"; + var directoryBrowsing = ConfigurationManager.AppSettings["enableDirectoryBrowsing"] == "true"; - // Check if web site directory exists - if (!Directory.Exists(WEBSITE_DIRECTORY)) - ExceptionManager.ManageError(ERROR_LEVEL.FATAL, "Main window directory not found!"); + // Check if web site directory exists + if (!Directory.Exists(WEBSITE_DIRECTORY)) + ExceptionManager.ManageError(ERROR_LEVEL.FATAL, "Main window directory not found!"); - var options = new FileServerOptions() - { - EnableDefaultFiles = !directoryBrowsing, - EnableDirectoryBrowsing = directoryBrowsing, - RequestPath = PathString.Empty, - FileSystem = new PhysicalFileSystem(WEBSITE_DIRECTORY), - - }; + var options = new FileServerOptions() + { + EnableDefaultFiles = !directoryBrowsing, + EnableDirectoryBrowsing = directoryBrowsing, + RequestPath = PathString.Empty, + FileSystem = new PhysicalFileSystem(WEBSITE_DIRECTORY), - options.StaticFileOptions.ServeUnknownFileTypes = true; - options.StaticFileOptions.ContentTypeProvider = new FileExtensionContentTypeProvider(); - ((FileExtensionContentTypeProvider)options.StaticFileOptions.ContentTypeProvider).Mappings.Add("json", "application/json"); - ((FileExtensionContentTypeProvider)options.StaticFileOptions.ContentTypeProvider).Mappings.Add("ttf", "font/truetype"); + }; + + options.StaticFileOptions.ServeUnknownFileTypes = true; + options.StaticFileOptions.ContentTypeProvider = new FileExtensionContentTypeProvider(); + ((FileExtensionContentTypeProvider)options.StaticFileOptions.ContentTypeProvider).Mappings.Remove(".json"); + ((FileExtensionContentTypeProvider)options.StaticFileOptions.ContentTypeProvider).Mappings.Add("json", "application/json"); + ((FileExtensionContentTypeProvider)options.StaticFileOptions.ContentTypeProvider).Mappings.Remove(".ttf"); + ((FileExtensionContentTypeProvider)options.StaticFileOptions.ContentTypeProvider).Mappings.Add(".ttf", "font/ttf"); - //// Setup configuration sources. - //Configuration = new Configuration().AddJsonFile("config.json").AddEnvironmentVariables(); - //contentProvider.Mappings.Add(".woff2", "application/font-woff2"); + //// Setup configuration sources. + //Configuration = new Configuration().AddJsonFile("config.json").AddEnvironmentVariables(); + //contentProvider.Mappings.Add(".woff2", "application/font-woff2"); - app.UseFileServer(options); - if (!ServerPortIsAvailable(ServerStartupConfig.ServerPort)) - { - ExceptionManager.ManageError(ERROR_LEVEL.FATAL, "Server port is already in use by another process"); - } - } + app.UseFileServer(options); + if (!ServerPortIsAvailable(ServerStartupConfig.ServerPort)) + { + ExceptionManager.ManageError(ERROR_LEVEL.FATAL, "Server port is already in use by another process"); + } + } - private void ConfigureWebApiOAuth(IAppBuilder app) - { - // Create new authorization options - OAuthOptions = new OAuthAuthorizationServerOptions - { - // Login and Token generation end point - TokenEndpointPath = new PathString("/Token"), - Provider = new ApplicationOAuthProvider(), - // Bearer token expiration time - AccessTokenExpireTimeSpan = TimeSpan.FromDays(365), - //TODO: In modalit� di produzione impostare AllowInsecureHttp = false - AllowInsecureHttp = true - }; - // Set authorization options - app.UseOAuthAuthorizationServer(OAuthOptions); - // Set bearer oAuth as authentication method - app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions() { AuthenticationType = AUTHENTICATION_TYPE }); - } + private void ConfigureWebApiOAuth(IAppBuilder app) + { + // Create new authorization options + OAuthOptions = new OAuthAuthorizationServerOptions + { + // Login and Token generation end point + TokenEndpointPath = new PathString("/Token"), + Provider = new ApplicationOAuthProvider(), + // Bearer token expiration time + AccessTokenExpireTimeSpan = TimeSpan.FromDays(365), + //TODO: In modalit� di produzione impostare AllowInsecureHttp = false + AllowInsecureHttp = true + }; + // Set authorization options + app.UseOAuthAuthorizationServer(OAuthOptions); + // Set bearer oAuth as authentication method + app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions() { AuthenticationType = AUTHENTICATION_TYPE }); + } - public void SignalRConfig(IAppBuilder app) - { - // Set CamelCase json configuration - var settings = new JsonSerializerSettings - { - ContractResolver = new SignalRContractResolver() - }; + public void SignalRConfig(IAppBuilder app) + { + // Set CamelCase json configuration + var settings = new JsonSerializerSettings + { + ContractResolver = new SignalRContractResolver() + }; - var serializer = JsonSerializer.Create(settings); - GlobalHost.DependencyResolver.Register(typeof(JsonSerializer), () => serializer); + var serializer = JsonSerializer.Create(settings); + GlobalHost.DependencyResolver.Register(typeof(JsonSerializer), () => serializer); - // Set up signalR config - app.Map("/signalr", map => - { - map.UseCors(CorsOptions.AllowAll); + // Set up signalR config + app.Map("/signalr", map => + { + map.UseCors(CorsOptions.AllowAll); - map.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions() - { - Provider = new SignalROAuthBearerProvider(), - AuthenticationType = AUTHENTICATION_TYPE - }); - var hubConfiguration = new HubConfiguration - { - Resolver = GlobalHost.DependencyResolver, - EnableDetailedErrors = true - }; - map.RunSignalR(hubConfiguration); - }); - //app.MapSignalR(); - } + map.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions() + { + Provider = new SignalROAuthBearerProvider(), + AuthenticationType = AUTHENTICATION_TYPE + }); + var hubConfiguration = new HubConfiguration + { + Resolver = GlobalHost.DependencyResolver, + EnableDetailedErrors = true + }; + map.RunSignalR(hubConfiguration); + }); + //app.MapSignalR(); + } - private bool ServerPortIsAvailable(int port) - { - bool isAvailable = true; + private bool ServerPortIsAvailable(int port) + { + bool isAvailable = true; - IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties(); - IPEndPoint[] ipEndPoints = ipProperties.GetActiveTcpListeners(); + IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties(); + IPEndPoint[] ipEndPoints = ipProperties.GetActiveTcpListeners(); - foreach (IPEndPoint endPoint in ipEndPoints) - { - if (endPoint.Port == port) - { - isAvailable = false; - break; - } - } + foreach (IPEndPoint endPoint in ipEndPoints) + { + if (endPoint.Port == port) + { + isAvailable = false; + break; + } + } - return isAvailable; - } - } + return isAvailable; + } + } } //app.Map("/signalr", map => //{