using Radzen; using SystemX.Core.Config.Model; using SystemX.Core.DB; using SystemX.Core.Services; using Web.Operation.Components; using Web.Operation.Services; using WebClient.Library.Config; using WebClient.Library.Model; string configDir = @"../../Config"; string configFileName = "WebClient.Operation.Config.json"; //raed log4net configs if (LogXnet.ReadConfig(@$"{configDir}/LogXnetConfig.json") == true) { LogXnet.WriteLine("LogXnet Init Success"); } else { Console.WriteLine("LogXnet Init Failed"); return; } var builder = WebApplication.CreateBuilder(args); builder.Services.AddRadzenComponents(); //singleton builder.Services.AddSingleton>(); //scoped builder.Services.AddScoped(); builder.Services.AddScoped(); //db builder.Services.AddSingleton(); // Generic µî·Ï // Add services to the container. builder.Services.AddRazorComponents() .AddInteractiveServerComponents(); //config preload, auth set ConfigService preloadConfig = new ConfigService(); if (preloadConfig.OpenConfig($@"{configDir}/{configFileName}") == true) { var config = preloadConfig.GetConfig(); } else { LogXnet.WriteLine("Config Preload Load Error.", LogXLabel.Error); return; } var app = builder.Build(); //read api config and set string serverUrl = string.Empty; var configService = app.Services.GetService>(); bool isIIS = false; if (configService?.OpenConfig($@"{configDir}/{configFileName}") == true) { LogXnet.WriteLine("WebClient Config Success."); var apiConfig = ConfigService.Config; if (apiConfig != null) { serverUrl = $"{apiConfig?.Server?.Address}:{apiConfig?.Server?.Port}"; isIIS = apiConfig!.Server.IIS; } } else { LogXnet.WriteLine("WebClient Config Error."); return; } // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Error", createScopeForErrors: true); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseAntiforgery(); app.MapRazorComponents() .AddInteractiveServerRenderMode(); if (isIIS == true) { app.Run(); } else { LogXnet.WriteLine($"Operation Url: {serverUrl}"); app.Run($"{serverUrl}"); }