using HslCommunication.LogNet; using Microsoft.EntityFrameworkCore; using NPOI.SS.Formula.Functions; using ProductionLineMonitor.EntityFramework; namespace ProductionLineMonitor.WebAPI { public class Program { public static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); DBOptions.ConnectionString = builder.Configuration.GetSection("ConnectionStrings")["DefaultConnection"]; builder.Services.AddDbContext( opt => opt.UseSqlite(DBOptions.ConnectionString, b => b.MigrationsAssembly("ProductionLineMonitor.WebAPI"))); var app = builder.Build(); app.UseSwagger(); app.UseSwaggerUI(); app.UseAuthorization(); app.MapControllers(); // Hsl Authorization var rev = HslCommunication.Authorization.SetAuthorizationCode("3e54799d-f65f-4be6-9e34-517ea9ee294c"); if (rev == false) throw new NotImplementedException("hsl ¼¤»îʧ°Ü£¡"); // MQTT Client string ip = builder.Configuration.GetSection("MqttOptions")["IpAddress"]; int port = int.Parse(builder.Configuration.GetSection("MqttOptions")["Port"]); string clientId = builder.Configuration.GetSection("MqttOptions")["ClientId"]; string path = AppContext.BaseDirectory; ILogNet log = new LogNetDateTime($"{path}\\Logs", GenerateMode.ByEveryDay); app.UseHostMqtt(ip, port, clientId, log); app.Run(); } } }