From 3993f8dc022e36dbfd3d5cbbdc939b8dfcf671a6 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 3 Sep 2021 11:49:34 +0200 Subject: [PATCH] Update progetto e main layout --- .gitignore | 89 +-------------- MP-PROG.sln | 16 +-- MP.Prog/Components/CmpTop.razor | 32 +++--- MP.Prog/Shared/MainLayout.razor | 62 ++++++++-- MP.Prog/Startup.cs | 194 ++++++++++++++++++++++++++++++-- Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 8 files changed, 264 insertions(+), 135 deletions(-) diff --git a/.gitignore b/.gitignore index 53ab3379..90ec6acf 100644 --- a/.gitignore +++ b/.gitignore @@ -7,8 +7,8 @@ #-------------------------------- # area MP.Stats #-------------------------------- -/Mp.Stats/temp/*.csv - +/Mp.FileData/temp/*.csv +*.bak #-------------------------------- # Area VersGen @@ -16,90 +16,6 @@ /VersGen/bin/* /VersGen/obj/* -#-------------------------------- -# area MapoDb -#-------------------------------- -/MapoDb/bin/* -/MapoDb/obj/* - - -#-------------------------------- -# area MP -#-------------------------------- -/MP/bin/* -/MP/obj/* -MP/logs/*.txt -MP/logs/*.zip -MP-LAND/logs/ - -#-------------------------------- -# Area MP-MON (MoonPro-MONitor) -#-------------------------------- -/MP-MON/logs/*.zip -/MP-MON/logs/*.txt -/MP-MON/bin/* -/MP-MON/obj/* -/MP-MON/WebCharts/*.png - -#-------------------------------- -# Area MP-IO (MoonPro-IO) -#-------------------------------- -/MP-IO/logs/*.zip -/MP-IO/logs/*.txt -/MP-IO/bin/* -/MP-IO/obj/* -/MP-IO/fileUpload/ -!/MP-IO/fileUpload/.PlaceHolder.file - -#-------------------------------- -# Area MP-Admin -#-------------------------------- -/MP-Admin/logs/*.zip -/MP-Admin/logs/*.txt -/MP-Admin/bin/* -/MP-Admin/obj/* -/MP-ADM/logs/*.zip -/MP-ADM/logs/*.txt -/MP-ADM/bin/* -/MP-ADM/obj/* - - -#-------------------------------- -# Area ES3 -#-------------------------------- -/ES3/logs/*.zip -/ES3/logs/*.txt -/ES3/bin/* -/ES3/obj/* - -#-------------------------------- -# Area MoonProTablet -#-------------------------------- -/MP-TAB/logs/*.zip -/MP-TAB/logs/*.txt -/MP-TAB/bin/* -/MP-TAB/obj/* -/MP-TAB/WebCharts/*.png -/MP-TAB/images/macchine/*.* -!/MP-TAB/images/macchine/Steamware.png -/MP-TAB/Files/Disegni/*.pdf -!/MP-TAB/Files/Disegni/ND.pdf -MP-TAB/logs/ - - -#-------------------------------- -# Area MoonPro -#-------------------------------- -/MP-Site/logs/*.zip -/MP-Site/logs/*.txt -/MP-Site/bin/* -/MP-Site/obj/* -/MP-Site/WebCharts/*.png -/MP-Site/images/macchine/*.* -!/MP-Site/images/macchine/Steamware.png - - - # ---> VisualStudio ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. @@ -429,3 +345,4 @@ _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML +MP.Prog/Shared/MainLayout.razor diff --git a/MP-PROG.sln b/MP-PROG.sln index 5f434b0f..a75cf2d1 100644 --- a/MP-PROG.sln +++ b/MP-PROG.sln @@ -3,13 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.31229.75 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MP.Stats", "MP.Stats\MP.Stats.csproj", "{D9901B50-E61C-400C-B62C-FA060CF72C29}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MP.Prog", "MP.Prog\MP.Prog.csproj", "{3223DDE4-564E-4D58-8A94-E368B9778C67}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MP.Data", "MP.Data\MP.Data.csproj", "{10BA8450-301D-49C7-8E1E-21B7469C225C}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MP.Prog", "MP.Prog\MP.Prog.csproj", "{3223DDE4-564E-4D58-8A94-E368B9778C67}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MP.FileData", "MP.FileData\MP.FileData.csproj", "{48693321-1FA6-4DBB-A730-B8EF3E0B68D2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MP.FileData", "MP.FileData\MP.FileData.csproj", "{48693321-1FA6-4DBB-A730-B8EF3E0B68D2}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -17,14 +13,6 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D9901B50-E61C-400C-B62C-FA060CF72C29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D9901B50-E61C-400C-B62C-FA060CF72C29}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D9901B50-E61C-400C-B62C-FA060CF72C29}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D9901B50-E61C-400C-B62C-FA060CF72C29}.Release|Any CPU.Build.0 = Release|Any CPU - {10BA8450-301D-49C7-8E1E-21B7469C225C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {10BA8450-301D-49C7-8E1E-21B7469C225C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {10BA8450-301D-49C7-8E1E-21B7469C225C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {10BA8450-301D-49C7-8E1E-21B7469C225C}.Release|Any CPU.Build.0 = Release|Any CPU {3223DDE4-564E-4D58-8A94-E368B9778C67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3223DDE4-564E-4D58-8A94-E368B9778C67}.Debug|Any CPU.Build.0 = Debug|Any CPU {3223DDE4-564E-4D58-8A94-E368B9778C67}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/MP.Prog/Components/CmpTop.razor b/MP.Prog/Components/CmpTop.razor index a6ac5aea..3107aeaa 100644 --- a/MP.Prog/Components/CmpTop.razor +++ b/MP.Prog/Components/CmpTop.razor @@ -1,14 +1,14 @@ @using MP.Prog.Components @using System.Security.Claims -@using Microsoft.AspNetCore.Components.Authorization +@*@using Microsoft.AspNetCore.Components.Authorization*@ @using MP.Prog.Data @inject MessageService AppMessages -@inject AuthenticationStateProvider AuthenticationStateProvider +@*@inject AuthenticationStateProvider AuthenticationStateProvider*@
- + @**@
@PageName @@ -23,8 +23,8 @@ @code { - [CascadingParameter] - private Task AuthenticationStateTask { get; set; } + //[CascadingParameter] + //private Task AuthenticationStateTask { get; set; } [CascadingParameter(Name = "ShowSearch")] private bool ShowSearch { get; set; } @@ -61,17 +61,19 @@ private async Task forceReload() { - var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - var user = authState.User; +#if false +var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); +var user = authState.User; - if (user.Identity.IsAuthenticated) - { - userName = $"{user.Identity.Name}"; - } - else - { - userName = "N.A."; - } +if (user.Identity.IsAuthenticated) +{ + userName = $"{user.Identity.Name}"; +} +else +{ + userName = "N.A."; +} +#endif } } diff --git a/MP.Prog/Shared/MainLayout.razor b/MP.Prog/Shared/MainLayout.razor index 2281c4f7..98bd8d15 100644 --- a/MP.Prog/Shared/MainLayout.razor +++ b/MP.Prog/Shared/MainLayout.razor @@ -1,17 +1,63 @@ @inherits LayoutComponentBase + +@using MP.Prog.Data +@using MP.Prog.Components + +@inject MessageService AppMService +@implements IDisposable +
-
-
- About + +
+
+ +
+
+ @Body +
+
+ +
- -
- @Body -
-
+
+ + +@code { + bool ShowSearch { get; set; } = false; + + protected override void OnInitialized() + { + AppMService.EA_ShowSearch += OnShowSearch; + AppMService.EA_HideSearch += OnHideSearch; + } + public void OnShowSearch() + { + ShowSearch = true; + InvokeAsync(() => + { + StateHasChanged(); + }); + } + public void OnHideSearch() + { + ShowSearch = false; + InvokeAsync(() => + { + StateHasChanged(); + }); + } + + public void Dispose() + { + AppMService.EA_ShowSearch -= OnShowSearch; + AppMService.EA_ShowSearch -= OnHideSearch; + } + + +} \ No newline at end of file diff --git a/MP.Prog/Startup.cs b/MP.Prog/Startup.cs index 3e7175d2..d8f24e2e 100644 --- a/MP.Prog/Startup.cs +++ b/MP.Prog/Startup.cs @@ -1,13 +1,16 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.HttpsPolicy; +using Microsoft.AspNetCore.Localization; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using MP.Prog.Data; using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Threading.Tasks; @@ -15,21 +18,22 @@ namespace MP.Prog { public class Startup { + #region Public Constructors + public Startup(IConfiguration configuration) { Configuration = configuration; } + #endregion Public Constructors + + #region Public Properties + public IConfiguration Configuration { get; } - // This method gets called by the runtime. Use this method to add services to the container. - // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 - public void ConfigureServices(IServiceCollection services) - { - services.AddRazorPages(); - services.AddServerSideBlazor(); - services.AddSingleton(); - } + #endregion Public Properties + + #region Public Methods // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) @@ -37,6 +41,7 @@ namespace MP.Prog if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); + //app.UseMigrationsEndPoint(); } else { @@ -45,16 +50,187 @@ namespace MP.Prog app.UseHsts(); } + // cultura IT... + var supportedCultures = new[]{ + new CultureInfo("it-IT") + }; + app.UseRequestLocalization(new RequestLocalizationOptions + { + DefaultRequestCulture = new RequestCulture("it-IT"), + SupportedCultures = supportedCultures, + FallBackToParentCultures = false + }); + CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CreateSpecificCulture("it-IT"); + + //// Registrazione Elmah: + //// https://github.com/ElmahCore/ElmahCore + //app.UseElmah(); + + // fix forwarders + app.UseForwardedHeaders(new ForwardedHeadersOptions + { + ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto + }); + + //app.UseAuthentication(); + app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); + //app.UseAuthentication(); + //app.UseAuthorization(); + app.UseEndpoints(endpoints => { + //endpoints.MapControllers(); endpoints.MapBlazorHub(); + //endpoints.MapHealthChecksUI(); + //endpoints.MapHealthChecks("/health", new HealthCheckOptions + //{ + // Predicate = _ => true, + // ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse + //}); endpoints.MapFallbackToPage("/_Host"); }); } + + // This method gets called by the runtime. Use this method to add services to the container. + // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 + public void ConfigureServices(IServiceCollection services) + { +#if false + // init info x DB + string dbServerAddr = Configuration["DbConfig:Server"]; + string nKey = Configuration["DbConfig:nKey"]; + string sKey = Configuration["DbConfig:sKey"]; + DbConfig.InitDb(dbServerAddr, nKey, sKey); + // inizializzo il DB e creo (se necessario) l'utente + DbConfig.CheckUser(nKey, sKey); + // verifico se serve applicazione migrazioni + //DbConfig.ExecMigrationMain(); + //DbConfig.ExecMigrationIdentity(); + + // altri parametri per check vari + string connStringDB = DbConfig.CONNECTION_STRING; + string connStringRedis = Configuration.GetConnectionString("Redis"); + string redisSrvAddr = connStringRedis.Substring(0, connStringRedis.IndexOf(":")); + //var qrCodeUri = new Uri(Configuration["ZCodeUrl"]); + //string qrCodeAddr = qrCodeUri.Host; +#endif + +#if false + // healthchecks + services.AddHealthChecks() + .AddMySql(connStringDB, "MySql instance") + .AddAsyncCheck($"DB PING ({dbServerAddr})", () => Health.Checks.PingCheck(dbServerAddr)) + .AddAsyncCheck($"Redis PING ({redisSrvAddr})", () => Health.Checks.PingCheck(redisSrvAddr)) + //.AddAsyncCheck($"QrCode PING ({qrCodeAddr})", () => Health.Checks.PingCheck(qrCodeAddr)) + .AddProcessAllocatedMemoryHealthCheck(512, "Max Process memory (<512MB)", failureStatus: HealthStatus.Degraded) // 512 MB max allocated memory + .AddRedis(Configuration.GetConnectionString("Redis"), "Redis", failureStatus: HealthStatus.Degraded) + //.AddUrlGroup(new Uri(Configuration["ZCodeUrl"]), name: $"QrCode Gen ({Configuration["ZCodeUrl"]})", failureStatus: HealthStatus.Degraded) + .AddAsyncCheck($"MySql Root User", () => Health.Checks.DbUserRoot("MySql")) + .AddAsyncCheck($"MySql App Users", () => Health.Checks.DbUserApp(DbConfig.DATABASE_NAME)) + .AddAsyncCheck($"MySql Identity", () => Health.Checks.DbIdentity(DbConfig.DATABASE_NAME)) + .AddAsyncCheck($"MySql PlantLog", () => Health.Checks.DbPlantLogTable(DbConfig.DATABASE_NAME)) + ; + //.AddDiskStorageHealthCheck(s => s.AddDrive("C:\\", 1024)) // 1024 MB (1 GB) free minimum + //.AddProcessHealthCheck("ProcessName", p => p.Length > 0) // check if process is running + //.AddWindowsServiceHealthCheck("someservice", s => s.Status == ServiceControllerStatus.Running); + + services + .AddHealthChecksUI(s => + { + s.AddHealthCheckEndpoint("GWMS_Services", "health"); + s.SetEvaluationTimeInSeconds(60); + s.SetMinimumSecondsBetweenFailureNotifications(120); + s.SetApiMaxActiveRequests(5); + s.SetHeaderText("GWMS Health Check Status"); + }) + .AddInMemoryStorage(); + + // abilitazione x email management con MailKit + services.AddTransient(); + services.Configure(options => + { + options.Host_Address = Configuration["ExternalProviders:MailKit:SMTP:Address"]; + options.Host_Port = Convert.ToInt32(Configuration["ExternalProviders:MailKit:SMTP:Port"]); + options.Host_Username = Configuration["ExternalProviders:MailKit:SMTP:Account"]; + options.Host_Password = Configuration["ExternalProviders:MailKit:SMTP:Password"]; + options.Sender_EMail = Configuration["ExternalProviders:MailKit:SMTP:SenderEmail"]; + options.Sender_Name = Configuration["ExternalProviders:MailKit:SMTP:SenderName"]; + }); +#endif + + // cookie applicazione da 14 gg (defaul) a 30 + services.ConfigureApplicationCookie(o => + { + o.ExpireTimeSpan = TimeSpan.FromDays(30); + o.SlidingExpiration = true; + }); +#if false + // token di sicurezza dati a 3h + services.Configure(o => + o.TokenLifespan = TimeSpan.FromHours(3)); +#endif + +#if false + // setup MySql + //string connString = Configuration.GetConnectionString("AdminConnection"); + var serverVersion = DbConfig.MysqlServerVersion(connStringDB); + services.AddDbContext(options => + options.UseMySql(connStringDB, serverVersion)); + + // identity management + services.AddDefaultIdentity(options => options.SignIn.RequireConfirmedAccount = true) + .AddRoles() + .AddEntityFrameworkStores(); +#endif + +#if false + services.AddBlazorise(options => + { + options.ChangeTextOnKeyPress = true; // optional + }) + .AddBootstrapProviders() + .AddFontAwesomeIcons(); +#endif + //// Elmah + //services.AddElmah(); + //string elmaConn = "Data Source=SQL2016DEV;Initial Catalog=Elmah;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=SHERPA.BBM;"; + //services.AddElmah(options => + //{ + // options.ConnectionString = elmaConn; + //}); + + services.AddStackExchangeRedisCache(options => + { + //options.Configuration = "localhost:6379"; + options.ConfigurationOptions = new StackExchange.Redis.ConfigurationOptions() { KeepAlive = 180, DefaultDatabase = 12, EndPoints = { { "localhost", 6379 } } }; + options.InstanceName = "GWMS:"; + }); + + services.AddLocalization(); + + services.AddRazorPages(); + services.AddServerSideBlazor(); + services.AddSingleton(); + +#if false + services.AddScoped>(); + services.AddDatabaseDeveloperPageExceptionFilter(); +#endif + services.AddSingleton(Configuration); + //services.AddTransient(); + +#if false + //services.AddSingleton(); + services.AddScoped(); +#endif + services.AddScoped(); + } + + #endregion Public Methods } -} +} \ No newline at end of file diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index e7ebcf95..8309cc7a 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo statistiche MAPO -

Versione: 1.0.2109.0218

+

Versione: 1.0.2109.0309


Note di rilascio:
    diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index 42817866..d790cb28 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.0.2109.0218 +1.0.2109.0309 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 53b173ec..3ec95204 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.0.2109.0218 + 1.0.2109.0309 http://nexus.steamware.net/repository/SWS/MP-STATS/stable/0/MP.Stats.zip http://nexus.steamware.net/repository/SWS/MP-STATS/stable/0/ChangeLog.html false