using Microsoft.EntityFrameworkCore; using Microsoft.IdentityModel.Tokens; using System.Text; using FaKrosnoApi.Models; using FaKrosnoApi.Services; using FaKrosnoEfDataModel; using FaKrosnoEfDataModel.Services; using Hangfire; using Hangfire.SqlServer; using Microsoft.AspNetCore.Authentication.JwtBearer; using OrdersManagementDataModel; using OrdersManagementDataModel.Services; using SytelineSaAppEfDataModel; using SytelineSaAppEfDataModel.Services; using NSwag; using NSwag.Generation.Processors.Security; using FaKrosnoMappingProfile = FaKrosnoEfDataModel.MappingProfile; using SytelineSaAppMappingProfile = SytelineSaAppEfDataModel.MappingProfile; using OrdersManagementMappingProfile = OrdersManagementDataModel.MappingProfile; var builder = WebApplication.CreateBuilder(args); builder.Services.AddDbContext(options => options.UseSqlServer(builder.Configuration.GetConnectionString("FaKrosnoConnection"))); builder.Services.AddDbContext(options => options.UseSqlServer(builder.Configuration.GetConnectionString("SytelineSaAppConnection"))); builder.Services.AddDbContext(options => options.UseSqlServer(builder.Configuration.GetConnectionString("OrdersManagementConnection"))); builder.Services.Configure(builder.Configuration.GetSection("EmailSettings")); builder.Services.Configure(builder.Configuration.GetSection("JobSettings")); builder.WebHost.UseUrls("http://*:5001"); // builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) // .AddJwtBearer(options => // { // options.TokenValidationParameters = new TokenValidationParameters // { // ValidateIssuer = true, // ValidateAudience = true, // ValidateLifetime = true, // ValidateIssuerSigningKey = true, // ValidIssuer = builder.Configuration["Jwt:Issuer"], // ValidAudience = builder.Configuration["Jwt:Audience"], // IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(builder.Configuration["Jwt:Key"] ?? string.Empty)), // NameClaimType = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier" // }; // }); builder.Services.AddControllers(); builder.Services.AddEndpointsApiExplorer(); builder.Services.AddOpenApiDocument(config => { config.Title = "FaKrosnoApi"; config.Version = "v1"; config.AddSecurity("Bearer", new OpenApiSecurityScheme { Name = "Authorization", Type = OpenApiSecuritySchemeType.Http, Scheme = "Bearer", BearerFormat = "JWT", In = OpenApiSecurityApiKeyLocation.Header, Description = "Wprowadź token JWT w formacie: Bearer {token}" }); config.OperationProcessors.Add(new OperationSecurityScopeProcessor("Bearer")); }); // builder.Services.AddHangfire(config => config // .SetDataCompatibilityLevel(CompatibilityLevel.Version_170) // .UseSimpleAssemblyNameTypeSerializer() // .UseRecommendedSerializerSettings() // .UseSqlServerStorage(builder.Configuration.GetConnectionString("OrdersManagementConnection"), new SqlServerStorageOptions // { // CommandBatchMaxTimeout = TimeSpan.FromMinutes(5), // SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5), // QueuePollInterval = TimeSpan.Zero, // UseRecommendedIsolationLevel = true, // DisableGlobalLocks = true // })); // builder.Services.AddHangfireServer(); builder.Services.AddAutoMapper(typeof(FaKrosnoMappingProfile), typeof(SytelineSaAppMappingProfile), typeof(OrdersManagementMappingProfile)); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddHostedService(); Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("NRAiBiAaIQQuGjN/V09+XU9HdVRDX3xKf0x/TGpQb19xflBPallYVBYiSV9jS3tTckVgWHldc3ZUR2lfVE90Vg=="); var app = builder.Build(); app.UseOpenApi(); app.UseSwaggerUi(); app.UseHttpsRedirection(); app.UseAuthentication(); app.UseAuthorization(); app.MapControllers(); // app.UseHangfireDashboard(); app.Run();