@@ -19,7 +19,8 @@ public enum TimePrecision
1919 Seconds = 3 ,
2020 Milliseconds = 4 ,
2121 Microseconds = 5 ,
22- Nanoseconds = 6
22+ Nanoseconds = 6 ,
23+ H = 1
2324 }
2425
2526 public class InfluxDBClient : IInfluxDBClient
@@ -253,7 +254,7 @@ public async Task<bool> PostValueAsync(string dbName, string measurement, long t
253254 new KeyValuePair < string , string > ( "precision" , precisionLiterals [ ( int ) precision ] )
254255 } ) . ReadAsStringAsync ( ) ;
255256
256- var content = String . Format ( "{0},{1} {2}={3:0.00 } {4}" , measurement , tags , field , value , timestamp ) ;
257+ var content = String . Format ( "{0},{1} {2}={3} {4}" , measurement , tags , field , value , timestamp ) ;
257258 ByteArrayContent requestContent = new ByteArrayContent ( Encoding . UTF8 . GetBytes ( content ) ) ;
258259 HttpResponseMessage response = await PostAsync ( builder , requestContent ) ;
259260
@@ -280,7 +281,7 @@ public async Task<bool> PostValueAsync(string dbName, string measurement, long t
280281 /// <returns>True:Success, False:Failure</returns>
281282 ///<exception cref="UnauthorizedAccessException">When Influx needs authentication, and no user name password is supplied or auth fails</exception>
282283 ///<exception cref="HttpRequestException">all other HTTP exceptions</exception>
283- public async Task < bool > PostValuesAsync ( string dbName , string measurement , long timestamp , TimePrecision precision , string tags , IEnumerable < string > values )
284+ public async Task < bool > PostValuesAsync ( string dbName , string measurement , long timestamp , TimePrecision precision , string tags , IDictionary < string , double > values )
284285 {
285286 var influxAddress = new Uri ( String . Format ( "{0}/write?" , InfluxUrl ) ) ;
286287 var builder = new UriBuilder ( influxAddress ) ;
@@ -289,11 +290,13 @@ public async Task<bool> PostValuesAsync(string dbName, string measurement, long
289290 new KeyValuePair < string , string > ( "precision" , precisionLiterals [ ( int ) precision ] )
290291 } ) . ReadAsStringAsync ( ) ;
291292
292- var content = new StringBuilder ( ) ;
293- foreach ( var value in values )
294- content . AppendFormat ( "{0},{1} {2} {3}\n " , measurement , tags , value , timestamp ) ;
295- //remove last \n
296- content . Remove ( content . Length - 1 , 1 ) ;
293+ //var content = new StringBuilder ();
294+ //foreach ( var value in values )
295+ // content.AppendFormat ("{0},{1} {2} {3}\n", measurement, tags, value, timestamp);
296+ ////remove last \n
297+ //content.Remove (content.Length - 1, 1);
298+ var valuesTxt = String . Join ( "," , values . Select ( v => String . Format ( "{0}={1}" , v . Key , v . Value ) ) ) ;
299+ var content = String . Format ( "{0},{1} {2} {3}" , measurement , tags , valuesTxt , timestamp ) ;
297300
298301 ByteArrayContent requestContent = new ByteArrayContent ( Encoding . UTF8 . GetBytes ( content . ToString ( ) ) ) ;
299302 HttpResponseMessage response = await PostAsync ( builder , requestContent ) ;
@@ -337,6 +340,8 @@ public async Task<bool> PostRawValueAsync(string dbName, TimePrecision precision
337340 else
338341 return false ;
339342 }
343+
344+
340345 }
341346
342347}
0 commit comments