Beispiel #1
0
 static async Task UploadResultAsync(IEnumerable <NodeQuality> result)
 {
     using (var conn = new InfluxConnection(InfluxDB))
     {
         var time = DateTime.UtcNow;
         conn.Open();
         var parameters     = new List <InfluxParameter>();
         var row            = 0;
         var commandBuilder = new StringBuilder();
         foreach (var x in result)
         {
             commandBuilder.AppendLine($"INSERT MonTxNodes,host=@p{row}_0 latency=@p{row}_1 @p{row}_2");
             parameters.Add(new InfluxParameter($"p{row}_0", x.Host, InfluxParameterType.Tag));
             parameters.Add(new InfluxParameter($"p{row}_1", x.Latency, InfluxParameterType.Field));
             parameters.Add(new InfluxParameter($"p{row}_2", time, InfluxParameterType.Timestamp));
             ++row;
         }
         using (var cmd = new InfluxCommand(commandBuilder.ToString().TrimEnd('\n').TrimEnd('\r'), conn))
         {
             cmd.Parameters.AddRange(parameters.ToArray());
             await cmd.ExecuteNonQueryAsync();
         }
     }
 }
 public InfluxServiceBase(InfluxConnection connection, string tableName)
 {
     this.Connection = connection;
     this.TableName  = tableName;
 }