public CoreDataContext CreateDbContext(string[] args) { var dbContextOptionsBuilder = new DbContextOptionsBuilder <CoreDataContext>(); dbContextOptionsBuilder.UseSqlite(CoordinatorConfiguration.GetDatabasesFolderPath(OpenA3XXDatabase.Core)); return(new CoreDataContext(dbContextOptionsBuilder.Options)); }
public CoordinatorContext(CoordinatorParameters parameters, CoordinatorDependencies dependencies, CoordinatorHooks hooks, CoordinatorConfiguration configuration) { this.parameters = parameters; this.dependencies = dependencies; this.hooks = hooks; this.configuration = configuration; collection = new CoordinatorCollection(); facts = new CoordinatorFacts(); }
private static void Main(string[] args) { var dbContextOptionsBuilder = new DbContextOptionsBuilder <CoreDataContext>(); dbContextOptionsBuilder.UseSqlite( CoordinatorConfiguration.GetDatabasesFolderPath(OpenA3XXDatabase.Core)); /* * var repo = new ManufacturerRepository(new CoreDataContext(dbContextOptionsBuilder.Options)); * * var data = repo.GetAllManufacturers(); * * * var adata = JsonConvert.SerializeObject(data, Formatting.None, * new JsonSerializerSettings() * { * ReferenceLoopHandling = ReferenceLoopHandling.Ignore * }); */ /* * var hardwareBoard = new HardwareBoard * { * Name = "MCDU1", * Buses = new List<IOExtenderBus> * { * new() * { * HardwareBus = HardwareBus.Bus0, * Bits = new List<IOExtenderBit> * { * new() * { * ExtenderBusBitType = ExtenderBusBitType.Input, HardwareInputId = 13 * }, * new() * { * ExtenderBusBitType = ExtenderBusBitType.Input, HardwareInputId = 14 * }, * new() * { * ExtenderBusBitType = ExtenderBusBitType.Input, HardwareInputId = 15 * }, * new() * { * ExtenderBusBitType = ExtenderBusBitType.Input, HardwareInputId = 16 * } * } * } * } * }; */ var factory = new ConnectionFactory { UserName = "******", Password = "******", VirtualHost = "/", HostName = "192.168.50.22", ClientProvidedName = "app:opena3xx.processors component:cockpitevents" }; var conn = factory.CreateConnection(); var channel = conn.CreateModel(); channel.QueueDeclare("hardware_events", false, false, false, null); var consumer = new EventingBasicConsumer(channel); consumer.Received += (ch, ea) => { channel.BasicAck(ea.DeliveryTag, false); var result = Encoding.UTF8.GetString(ea.Body.ToArray()); var hardwareSignalDto = JsonConvert.DeserializeObject <HardwareSignalDto>(result); var hardwareBoardRepository = new HardwareBoardRepository(new CoreDataContext(dbContextOptionsBuilder.Options)); var response = hardwareBoardRepository.GetByHardwareBoard(hardwareSignalDto.HardwareBoardId); }; var consumerTag = channel.BasicConsume("hardware_events", false, consumer); Console.ReadLine(); }
protected override void OnConfiguring(DbContextOptionsBuilder options) { options.UseSqlite(CoordinatorConfiguration.GetDatabasesFolderPath(OpenA3XXDatabase.Core)); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers().AddNewtonsoftJson(options => { options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; }); services.AddSignalR(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "OpenA3XX.Peripheral.WebApi", Version = "v1", Description = "OpenA3XX Peripheral API to integrate Hardware Panel Cockpits with OpenA3XX Coordinator", License = new OpenApiLicense { Url = new Uri("https://www.gnu.org/licenses/gpl-3.0.en.html") }, Contact = new OpenApiContact { Name = "David Bonnici", Email = "*****@*****.**", Url = new Uri("https://opena3xx.dev") } }); }); services.AddDbContext <CoreDataContext>(options => { options.UseSqlite(CoordinatorConfiguration.GetDatabasesFolderPath(OpenA3XXDatabase.Core)); }); // DI Configuration services.AddScoped <DbContext, CoreDataContext>(); services.AddTransient <ISystemConfigurationRepository, SystemConfigurationRepository>(); services.AddTransient <IHardwarePanelTokensRepository, HardwarePanelTokensRepository>(); services.AddTransient <IHardwareInputTypesRepository, HardwareInputTypesRepository>(); services.AddTransient <IHardwareInputSelectorRepository, HardwareInputSelectorRepository>(); services.AddTransient <IHardwareOutputSelectorRepository, HardwareOutputSelectorRepository>(); services.AddTransient <IHardwareOutputTypesRepository, HardwareOutputTypesRepository>(); services.AddTransient <IHardwarePanelRepository, HardwarePanelRepository>(); services.AddTransient <IHardwareBoardRepository, HardwareBoardRepository>(); services.AddTransient <IAircraftModelRepository, AircraftModelRepository>(); services.AddTransient <ISimulatorEventRepository, SimulatorEventRepository>(); services.AddTransient <ISimulatorEventService, SimulatorEventService>(); services.AddTransient <IHardwarePanelService, HardwarePanelService>(); services.AddTransient <IHardwareBoardService, HardwareBoardService>(); services.AddTransient <IHardwareInputTypeService, HardwareInputTypeService>(); services.AddTransient <IHardwareInputSelectorService, HardwareInputSelectorService>(); services.AddTransient <IHardwareOutputSelectorService, HardwareOutputSelectorService>(); services.AddTransient <IHardwareOutputTypeService, HardwareOutputTypeService>(); services.AddTransient <IFormService, FormsService>(); services.AddTransient <IFlightIntegrationService, FlightIntegrationService>(); services.AddTransient <ISimulatorEventingService, SimulatorEventingService>(); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddAutoMapper(Assembly.GetAssembly(typeof(HardwarePanelToken))); services.AddHostedService <ConsumeRabbitMqHostedService>(); services.AddEasyCaching(option => { option.UseInMemory("m1"); }); }