C# 调用influx 数据库
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace DataTest
{
class Program
{
static void Main(string[] args)
{
string a = "name':'hist','columns':['time','status','tagname','value'],'values':[['2020-11-25T02:04:27Z',10,'PALL',0],['2020-11-25T02:06:27Z',1,'PALL',0],";
List<string> arrayList = new List<string>();
ArrayList list = new ArrayList();
Regex re = new Regex("[0-9]{4}-[0-9]{2}-[0-9]{2}[A-Z]\\d*:\\d*:\\d*[A-Z]\',[0-9]*,\'[A-Z]*\',[0-9]*", RegexOptions.Singleline);
MatchCollection mc = re.Matches(a);
foreach (var item in mc)
{
arrayList.Add((item.ToString().Replace("T"," ")).Replace("Z",""));
}
foreach (var item in arrayList)
{
MatchCollection matches = Regex.Matches(item, @",[0-9]*");
var res = new
{
time = Regex.Match(item, "[0-9]{4}-[0-9]{2}-[0-9]{2} \\d*:\\d*:\\d*"),
status = (Regex.Match(item, ",[0-9]*,")).ToString().Replace(",", ""),
tagname = Regex.Match(item, "\'[A-Z]*\'").ToString().Replace("\'", ""),
value = matches[2].Value.Replace(",", "")
};
list.Add(res);
}
foreach (var item in list)
{
Console.WriteLine(item);
}
Console.WriteLine();
Console.ReadLine();
}
}
}