public void CreateInfluxDBSender(int DBProcessorCount) { Console.WriteLine("creating if"); // for (int i = 0; i < DBProcessorCount; i++) // { //InfluxSender influxSender= new InfluxSender(); //DBSenders.Add(DBSender); influxSender = new InfluxSender(InfluxData[0], InfluxData[1]); Thread th = new Thread(() => { while (true) { influxSender.SendPing(); Thread.Sleep(10000); } // DBSender.StartSender(InfluxQueue); }); th.Name = "Inlfux_Sender" + (DBSenders.Count); Console.WriteLine(th.Name + " created"); th.Start(); // } }
public VirtualRobot(int port, ConcurrentQueue <DBQueueObject> VCQueue, HttpServer server, string BPAPrefix, InfluxSender influxSender) { this.port = port; this.id = Guid.NewGuid().ToString(); this.token = null; this.VCQueue = VCQueue; this.server = server; this.UseBPAQueue = false; this.dbready = false; this.influxSender = influxSender; this.BPAPrefix = BPAPrefix; DBQueueObject DBQueueObject = new DBQueueObject(this); //DBQueueObject.needupdate = true; DBQueueObject.Query = DBQueries.UpdateBPAResource(port, 2, 0, BPAPrefix); VCQueue.Enqueue(DBQueueObject); // this.DBQueueObject = new DBQueueObject(this); // this.DBQueueObject.needupdate = true; // VCQueue.Enqueue(DBQueries.CreateBPAResource(id, port)); Console.WriteLine("VirtualRobot created on " + port); }
public DBSender(string[] DBData, InfluxSender influxSender) { this.influxSender = influxSender; isStopped = false; try { SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(); builder.DataSource = DBData[0]; builder.UserID = DBData[1]; builder.Password = DBData[2]; builder.InitialCatalog = DBData[3]; connection = new SqlConnection(builder.ConnectionString); connection.Open(); // Console.WriteLine(Thread.CurrentThread.Name + " created"); } catch (SqlException e) { Console.ForegroundColor = ConsoleColor.Red; DisplaySqlErrors(e); } Thread.Sleep(1); }