// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); var redisConfiguration = Configuration.GetSection("redis").Get <RedisConfiguration>(); services.AddSingleton(redisConfiguration); var mysql_conn = Configuration.GetConnectionString("mysql"); NotifyEventInterval = Configuration.GetSection("NotifyEventInterval").Get <TimeSpan>(); SiteId = Configuration.GetSection("SiteId").Get <int>(); var mqtt_informations = Configuration.GetSection("MQTTBrokers").Get <MqttConfig>(); //services.AddSingleton(mqtt_informations); services.AddSingleton <IRedisConnectionFactory, RedisConnectionFactory>(); LoadMqttConfig(services); LoadConfigModbusMapper(services); #if CONTROL_TEST //services.AddHostedService<ControlLogService>(); #endif IDataAccess mysql_access = new MysqlDataAccess(mysql_conn); services.AddSingleton(mysql_access); //MsSqlAccessManager mssql_access = new MsSqlAccessManager(mssql_conn); //using (DataAccess da = new DataAccess(dam)) //{ // var list = da.Select<ModbusSystem>(); // foreach (var aimap in list) // { // //string tpNAme = aimap.DataType.TypeName; // } //} //MqttDataPacket packet = new MqttDataPacket(); //packet.SetGroupName("FAULT INFO"); //List<MqttRegister> registers = new List<MqttRegister>(); //foreach(SlaveInfoYaml obj in config.slaves) //{ // registers.AddRange(obj.registers.Select(x => x.ConvertRegister(77.1f))); //} //packet.SetDateTime(DateTimeOffset.Now); //packet.registerCnt = registers.Count; //packet.registers = registers.ToArray(); //byte[] buffer = packet.ToByteArray(); services.AddCors(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); //MqttDataPacket copyPacket = MqttDataPacket.Parse(buffer); }
public MongoBackgroundHostService( IBackgroundMongoTaskQueue taskQueue, IConfiguration configuration, MqttSubscribeConfig mqttConfig, ILoggerFactory loggerFactory, MysqlDataAccess da ) { TaskQueue = taskQueue; _mqttConfig = mqttConfig; insertBatchList = new ConcurrentBag <DaegunPacketClass>(); _da = da; BatchInterval = configuration.GetSection("BatchInterval").Get <TimeSpan>(); _logger = loggerFactory.CreateLogger <MongoBackgroundHostService>(); }
public PeiuGridDataContext(IConfiguration configuration) { string mysql_conn = configuration.GetConnectionString("peiudb"); _da = new MysqlDataAccess(mysql_conn); }
public EventRecorder(NLog.ILogger logger, IBackgroundTaskQueue <EventSummary> queue, string ConnectionString) { _logger = logger; _queue = queue; da = new MysqlDataAccess(ConnectionString); }