test(docs):change docs-example file structure and update reference (#16987)

* test(docs):update docs-example file structure

* test(docs):update docs-example references under zh and en
This commit is contained in:
xiaolei li 2022-09-22 09:58:31 +08:00 committed by GitHub
parent 14e1e47062
commit c577897c1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
45 changed files with 416 additions and 333 deletions

View File

@ -1,5 +1,5 @@
```csharp title="Native Connection" ```csharp title="Native Connection"
{{#include docs/examples/csharp/ConnectExample.cs}} {{#include docs/examples/csharp/connect/Program.cs}}
``` ```
:::info :::info

View File

@ -1,3 +1,3 @@
```csharp ```csharp
{{#include docs/examples/csharp/InfluxDBLineExample.cs}} {{#include docs/examples/csharp/influxdbLine/Program.cs}}
``` ```

View File

@ -1,3 +1,3 @@
```csharp ```csharp
{{#include docs/examples/csharp/OptsJsonExample.cs}} {{#include docs/examples/csharp/optsJSON/Program.cs}}
``` ```

View File

@ -1,3 +1,3 @@
```csharp ```csharp
{{#include docs/examples/csharp/OptsTelnetExample.cs}} {{#include docs/examples/csharp/optsTelnet/Program.cs}}
``` ```

View File

@ -1,3 +1,3 @@
```csharp ```csharp
{{#include docs/examples/csharp/SQLInsertExample.cs}} {{#include docs/examples/csharp/sqlInsert/Program.cs}}
``` ```

View File

@ -1,3 +1,3 @@
```csharp ```csharp
{{#include docs/examples/csharp/StmtInsertExample.cs}} {{#include docs/examples/csharp/stmtInsert/Program.cs}}
``` ```

View File

@ -1,3 +1,3 @@
```csharp ```csharp
{{#include docs/examples/csharp/QueryExample.cs}} {{#include docs/examples/csharp/query/Program.cs}}
``` ```

View File

@ -1,3 +1,3 @@
```csharp ```csharp
{{#include docs/examples/csharp/AsyncQueryExample.cs}} {{#include docs/examples/csharp/asyncQuery/Program.cs}}
``` ```

View File

@ -1,3 +1,3 @@
```csharp ```csharp
{{#include docs/examples/csharp/SubscribeDemo.cs}} {{#include docs/examples/csharp/subscribe/Program.cs}}
``` ```

View File

@ -79,7 +79,7 @@ dotnet add exmaple.csproj reference src/TDengine.csproj
## Establish a Connection ## Establish a Connection
``` C# ``` csharp
using TDengineDriver; using TDengineDriver;
namespace TDengineExample namespace TDengineExample

View File

@ -1,12 +1,27 @@
bin
obj
.vs .vs
*.sln asyncQuery/bin
wsConnect/obj connect/bin
wsInsert/obj influxdbLine/bin
wsQuery/obj optsJSON/bin
wsStmt/obj optsTelnet/bin
query/bin
sqlInsert/bin
stmtInsert/bin
subscribe/bin
wsConnect/bin wsConnect/bin
wsInsert/bin wsInsert/bin
wsQuery/bin wsQuery/bin
wsStmt/bin wsStmt/bin
asyncQuery/obj
connect/obj
influxdbLine/obj
optsJSON/obj
optsTelnet/obj
query/obj
sqlInsert/obj
stmtInsert/obj
subscribe/obj
wsConnect/obj
wsInsert/obj
wsQuery/obj
wsStmt/obj

View File

@ -1,82 +0,0 @@
using TDengineDriver;
using TDengineDriver.Impl;
using System.Runtime.InteropServices;
namespace TDengineExample
{
internal class QueryExample
{
static void Main()
{
IntPtr conn = GetConnection();
// run query
IntPtr res = TDengine.Query(conn, "SELECT * FROM meters LIMIT 2");
if (TDengine.ErrorNo(res) != 0)
{
Console.WriteLine("Failed to query since: " + TDengine.Error(res));
TDengine.Close(conn);
TDengine.Cleanup();
return;
}
// get filed count
int fieldCount = TDengine.FieldCount(res);
Console.WriteLine("fieldCount=" + fieldCount);
// print column names
List<TDengineMeta> metas = LibTaos.GetMeta(res);
for (int i = 0; i < metas.Count; i++)
{
Console.Write(metas[i].name + "\t");
}
Console.WriteLine();
// print values
List<Object> resData = LibTaos.GetData(res);
for (int i = 0; i < resData.Count; i++)
{
Console.Write($"|{resData[i].ToString()} \t");
if (((i + 1) % metas.Count == 0))
{
Console.WriteLine("");
}
}
Console.WriteLine();
if (TDengine.ErrorNo(res) != 0)
{
Console.WriteLine($"Query is not complete, Error {TDengine.ErrorNo(res)} {TDengine.Error(res)}");
}
// exit
TDengine.FreeResult(res);
TDengine.Close(conn);
TDengine.Cleanup();
}
static IntPtr GetConnection()
{
string host = "localhost";
short port = 6030;
string username = "root";
string password = "taosdata";
string dbname = "power";
var conn = TDengine.Connect(host, username, password, dbname, port);
if (conn == IntPtr.Zero)
{
Console.WriteLine("Connect to TDengine failed");
System.Environment.Exit(0);
}
else
{
Console.WriteLine("Connect to TDengine success");
}
return conn;
}
}
}
// output:
// Connect to TDengine success
// fieldCount=6
// ts current voltage phase location groupid
// 1648432611249 10.3 219 0.31 California.SanFrancisco 2
// 1648432611749 12.6 218 0.33 California.SanFrancisco 2

View File

@ -1,70 +0,0 @@
using TDengineDriver;
namespace TDengineExample
{
internal class SQLInsertExample
{
static void Main()
{
IntPtr conn = GetConnection();
IntPtr res = TDengine.Query(conn, "CREATE DATABASE power");
CheckRes(conn, res, "failed to create database");
res = TDengine.Query(conn, "USE power");
CheckRes(conn, res, "failed to change database");
res = TDengine.Query(conn, "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)");
CheckRes(conn, res, "failed to create stable");
var sql = "INSERT INTO d1001 USING meters TAGS('California.SanFrancisco', 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000) " +
"d1002 USING power.meters TAGS('California.SanFrancisco', 3) VALUES('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000) " +
"d1003 USING power.meters TAGS('California.LosAngeles', 2) VALUES('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000)('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000) " +
"d1004 USING power.meters TAGS('California.LosAngeles', 3) VALUES('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000)('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000)";
res = TDengine.Query(conn, sql);
CheckRes(conn, res, "failed to insert data");
int affectedRows = TDengine.AffectRows(res);
Console.WriteLine("affectedRows " + affectedRows);
TDengine.FreeResult(res);
ExitProgram(conn, 0);
}
static IntPtr GetConnection()
{
string host = "localhost";
short port = 6030;
string username = "root";
string password = "taosdata";
string dbname = "";
var conn = TDengine.Connect(host, username, password, dbname, port);
if (conn == IntPtr.Zero)
{
Console.WriteLine("Connect to TDengine failed");
Environment.Exit(0);
}
else
{
Console.WriteLine("Connect to TDengine success");
}
return conn;
}
static void CheckRes(IntPtr conn, IntPtr res, String errorMsg)
{
if (TDengine.ErrorNo(res) != 0)
{
Console.Write(errorMsg + " since: " + TDengine.Error(res));
ExitProgram(conn, 1);
}
}
static void ExitProgram(IntPtr conn, int exitCode)
{
TDengine.Close(conn);
TDengine.Cleanup();
Environment.Exit(exitCode);
}
}
}
// output:
// Connect to TDengine success
// affectedRows 8

View File

@ -11,11 +11,17 @@ namespace TDengineExample
static void Main() static void Main()
{ {
IntPtr conn = GetConnection(); IntPtr conn = GetConnection();
QueryAsyncCallback queryAsyncCallback = new QueryAsyncCallback(QueryCallback); try
TDengine.QueryAsync(conn, "select * from meters", queryAsyncCallback, IntPtr.Zero); {
Thread.Sleep(2000); QueryAsyncCallback queryAsyncCallback = new QueryAsyncCallback(QueryCallback);
TDengine.Close(conn); TDengine.QueryAsync(conn, "select * from meters", queryAsyncCallback, IntPtr.Zero);
TDengine.Cleanup(); Thread.Sleep(2000);
}
finally
{
TDengine.Close(conn);
}
} }
static void QueryCallback(IntPtr param, IntPtr taosRes, int code) static void QueryCallback(IntPtr param, IntPtr taosRes, int code)
@ -27,11 +33,11 @@ namespace TDengineExample
} }
else else
{ {
Console.WriteLine($"async query data failed, failed code {code}"); throw new Exception($"async query data failed,code:{code},reason:{TDengine.Error(taosRes)}");
} }
} }
// Iteratively call this interface until "numOfRows" is no greater than 0. // Iteratively call this interface until "numOfRows" is no greater than 0.
static void FetchRawBlockCallback(IntPtr param, IntPtr taosRes, int numOfRows) static void FetchRawBlockCallback(IntPtr param, IntPtr taosRes, int numOfRows)
{ {
if (numOfRows > 0) if (numOfRows > 0)
@ -43,7 +49,7 @@ namespace TDengineExample
for (int i = 0; i < dataList.Count; i++) for (int i = 0; i < dataList.Count; i++)
{ {
if (i != 0 && (i+1) % metaList.Count == 0) if (i != 0 && (i + 1) % metaList.Count == 0)
{ {
Console.WriteLine("{0}\t|", dataList[i]); Console.WriteLine("{0}\t|", dataList[i]);
} }
@ -63,7 +69,7 @@ namespace TDengineExample
} }
else else
{ {
Console.WriteLine($"FetchRawBlockCallback callback error, error code {numOfRows}"); throw new Exception($"FetchRawBlockCallback callback error, error code {numOfRows}");
} }
TDengine.FreeResult(taosRes); TDengine.FreeResult(taosRes);
} }
@ -79,8 +85,7 @@ namespace TDengineExample
var conn = TDengine.Connect(host, username, password, dbname, port); var conn = TDengine.Connect(host, username, password, dbname, port);
if (conn == IntPtr.Zero) if (conn == IntPtr.Zero)
{ {
Console.WriteLine("Connect to TDengine failed"); throw new Exception("Connect to TDengine failed");
Environment.Exit(0);
} }
else else
{ {

View File

@ -9,7 +9,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="TDengine.Connector" Version="3.0.0" /> <PackageReference Include="TDengine.Connector" Version="3.0.1" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -16,7 +16,7 @@ namespace TDengineExample
var conn = TDengine.Connect(host, username, password, dbname, port); var conn = TDengine.Connect(host, username, password, dbname, port);
if (conn == IntPtr.Zero) if (conn == IntPtr.Zero)
{ {
Console.WriteLine("Connect to TDengine failed"); throw new Exception("Connect to TDengine failed");
} }
else else
{ {

View File

@ -0,0 +1,94 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30114.105
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "asyncquery", "asyncQuery\asyncquery.csproj", "{E2A5F00C-14E7-40E1-A2DE-6AB2975616D3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "connect", "connect\connect.csproj", "{CCC5042D-93FC-4AE0-B2F6-7E692FD476B7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "influxdbline", "influxdbLine\influxdbline.csproj", "{6A24FB80-1E3C-4E2D-A5AB-914FA583874D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "optsJSON", "optsJSON\optsJSON.csproj", "{6725A961-0C66-4196-AC98-8D3F3D757D6C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "optstelnet", "optsTelnet\optstelnet.csproj", "{B3B50D25-688B-44D4-8683-482ABC52FFCA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "query", "query\query.csproj", "{F2B7D13B-FE04-4C5C-BB6D-C12E0A9D9970}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "stmtinsert", "stmtInsert\stmtinsert.csproj", "{B40D6BED-BE3C-4B44-9B12-28BE441311BA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "subscribe", "subscribe\subscribe.csproj", "{C3D45A8E-AFC0-4547-9F3C-467B0B583DED}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wsConnect", "wsConnect\wsConnect.csproj", "{51E19494-845E-49ED-97C7-749AE63111BD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wsInsert", "wsInsert\wsInsert.csproj", "{13E2233B-4AFF-40D9-AF42-AB3F01617540}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wsQuery", "wsQuery\wsQuery.csproj", "{0F394169-C456-442C-929D-C2D43A0EEC7B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wsStmt", "wsStmt\wsStmt.csproj", "{27B9C9AB-9055-4BF2-8A14-4E59F09D5985}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sqlinsert", "sqlInsert\sqlinsert.csproj", "{CD24BD12-8550-4627-A11D-707B446F48C3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E2A5F00C-14E7-40E1-A2DE-6AB2975616D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E2A5F00C-14E7-40E1-A2DE-6AB2975616D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E2A5F00C-14E7-40E1-A2DE-6AB2975616D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E2A5F00C-14E7-40E1-A2DE-6AB2975616D3}.Release|Any CPU.Build.0 = Release|Any CPU
{CCC5042D-93FC-4AE0-B2F6-7E692FD476B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CCC5042D-93FC-4AE0-B2F6-7E692FD476B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CCC5042D-93FC-4AE0-B2F6-7E692FD476B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CCC5042D-93FC-4AE0-B2F6-7E692FD476B7}.Release|Any CPU.Build.0 = Release|Any CPU
{6A24FB80-1E3C-4E2D-A5AB-914FA583874D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6A24FB80-1E3C-4E2D-A5AB-914FA583874D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6A24FB80-1E3C-4E2D-A5AB-914FA583874D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6A24FB80-1E3C-4E2D-A5AB-914FA583874D}.Release|Any CPU.Build.0 = Release|Any CPU
{6725A961-0C66-4196-AC98-8D3F3D757D6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6725A961-0C66-4196-AC98-8D3F3D757D6C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6725A961-0C66-4196-AC98-8D3F3D757D6C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6725A961-0C66-4196-AC98-8D3F3D757D6C}.Release|Any CPU.Build.0 = Release|Any CPU
{B3B50D25-688B-44D4-8683-482ABC52FFCA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B3B50D25-688B-44D4-8683-482ABC52FFCA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B3B50D25-688B-44D4-8683-482ABC52FFCA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B3B50D25-688B-44D4-8683-482ABC52FFCA}.Release|Any CPU.Build.0 = Release|Any CPU
{F2B7D13B-FE04-4C5C-BB6D-C12E0A9D9970}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F2B7D13B-FE04-4C5C-BB6D-C12E0A9D9970}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2B7D13B-FE04-4C5C-BB6D-C12E0A9D9970}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2B7D13B-FE04-4C5C-BB6D-C12E0A9D9970}.Release|Any CPU.Build.0 = Release|Any CPU
{B40D6BED-BE3C-4B44-9B12-28BE441311BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B40D6BED-BE3C-4B44-9B12-28BE441311BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B40D6BED-BE3C-4B44-9B12-28BE441311BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B40D6BED-BE3C-4B44-9B12-28BE441311BA}.Release|Any CPU.Build.0 = Release|Any CPU
{C3D45A8E-AFC0-4547-9F3C-467B0B583DED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C3D45A8E-AFC0-4547-9F3C-467B0B583DED}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C3D45A8E-AFC0-4547-9F3C-467B0B583DED}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C3D45A8E-AFC0-4547-9F3C-467B0B583DED}.Release|Any CPU.Build.0 = Release|Any CPU
{51E19494-845E-49ED-97C7-749AE63111BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{51E19494-845E-49ED-97C7-749AE63111BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{51E19494-845E-49ED-97C7-749AE63111BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{51E19494-845E-49ED-97C7-749AE63111BD}.Release|Any CPU.Build.0 = Release|Any CPU
{13E2233B-4AFF-40D9-AF42-AB3F01617540}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{13E2233B-4AFF-40D9-AF42-AB3F01617540}.Debug|Any CPU.Build.0 = Debug|Any CPU
{13E2233B-4AFF-40D9-AF42-AB3F01617540}.Release|Any CPU.ActiveCfg = Release|Any CPU
{13E2233B-4AFF-40D9-AF42-AB3F01617540}.Release|Any CPU.Build.0 = Release|Any CPU
{0F394169-C456-442C-929D-C2D43A0EEC7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0F394169-C456-442C-929D-C2D43A0EEC7B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0F394169-C456-442C-929D-C2D43A0EEC7B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0F394169-C456-442C-929D-C2D43A0EEC7B}.Release|Any CPU.Build.0 = Release|Any CPU
{27B9C9AB-9055-4BF2-8A14-4E59F09D5985}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{27B9C9AB-9055-4BF2-8A14-4E59F09D5985}.Debug|Any CPU.Build.0 = Debug|Any CPU
{27B9C9AB-9055-4BF2-8A14-4E59F09D5985}.Release|Any CPU.ActiveCfg = Release|Any CPU
{27B9C9AB-9055-4BF2-8A14-4E59F09D5985}.Release|Any CPU.Build.0 = Release|Any CPU
{CD24BD12-8550-4627-A11D-707B446F48C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CD24BD12-8550-4627-A11D-707B446F48C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CD24BD12-8550-4627-A11D-707B446F48C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CD24BD12-8550-4627-A11D-707B446F48C3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

View File

@ -17,8 +17,7 @@ namespace TDengineExample
IntPtr res = TDengine.SchemalessInsert(conn, lines, lines.Length, (int)TDengineSchemalessProtocol.TSDB_SML_LINE_PROTOCOL, (int)TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_MILLI_SECONDS); IntPtr res = TDengine.SchemalessInsert(conn, lines, lines.Length, (int)TDengineSchemalessProtocol.TSDB_SML_LINE_PROTOCOL, (int)TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_MILLI_SECONDS);
if (TDengine.ErrorNo(res) != 0) if (TDengine.ErrorNo(res) != 0)
{ {
Console.WriteLine("SchemalessInsert failed since " + TDengine.Error(res)); throw new Exception("SchemalessInsert failed since " + TDengine.Error(res));
ExitProgram(conn, 1);
} }
else else
{ {
@ -26,7 +25,6 @@ namespace TDengineExample
Console.WriteLine($"SchemalessInsert success, affected {affectedRows} rows"); Console.WriteLine($"SchemalessInsert success, affected {affectedRows} rows");
} }
TDengine.FreeResult(res); TDengine.FreeResult(res);
ExitProgram(conn, 0);
} }
static IntPtr GetConnection() static IntPtr GetConnection()
@ -39,9 +37,7 @@ namespace TDengineExample
var conn = TDengine.Connect(host, username, password, dbname, port); var conn = TDengine.Connect(host, username, password, dbname, port);
if (conn == IntPtr.Zero) if (conn == IntPtr.Zero)
{ {
Console.WriteLine("Connect to TDengine failed"); throw new Exception("Connect to TDengine failed");
TDengine.Cleanup();
Environment.Exit(1);
} }
else else
{ {
@ -55,23 +51,15 @@ namespace TDengineExample
IntPtr res = TDengine.Query(conn, "CREATE DATABASE test"); IntPtr res = TDengine.Query(conn, "CREATE DATABASE test");
if (TDengine.ErrorNo(res) != 0) if (TDengine.ErrorNo(res) != 0)
{ {
Console.WriteLine("failed to create database, reason: " + TDengine.Error(res)); throw new Exception("failed to create database, reason: " + TDengine.Error(res));
ExitProgram(conn, 1);
} }
res = TDengine.Query(conn, "USE test"); res = TDengine.Query(conn, "USE test");
if (TDengine.ErrorNo(res) != 0) if (TDengine.ErrorNo(res) != 0)
{ {
Console.WriteLine("failed to change database, reason: " + TDengine.Error(res)); throw new Exception("failed to change database, reason: " + TDengine.Error(res));
ExitProgram(conn, 1);
} }
} }
static void ExitProgram(IntPtr conn, int exitCode)
{
TDengine.Close(conn);
TDengine.Cleanup();
Environment.Exit(exitCode);
}
} }
} }

View File

@ -7,27 +7,31 @@ namespace TDengineExample
static void Main() static void Main()
{ {
IntPtr conn = GetConnection(); IntPtr conn = GetConnection();
PrepareDatabase(conn); try
string[] lines = { "[{\"metric\": \"meters.current\", \"timestamp\": 1648432611249, \"value\": 10.3, \"tags\": {\"location\": \"California.SanFrancisco\", \"groupid\": 2}}," + {
PrepareDatabase(conn);
string[] lines = { "[{\"metric\": \"meters.current\", \"timestamp\": 1648432611249, \"value\": 10.3, \"tags\": {\"location\": \"California.SanFrancisco\", \"groupid\": 2}}," +
" {\"metric\": \"meters.voltage\", \"timestamp\": 1648432611249, \"value\": 219, \"tags\": {\"location\": \"California.LosAngeles\", \"groupid\": 1}}, " + " {\"metric\": \"meters.voltage\", \"timestamp\": 1648432611249, \"value\": 219, \"tags\": {\"location\": \"California.LosAngeles\", \"groupid\": 1}}, " +
"{\"metric\": \"meters.current\", \"timestamp\": 1648432611250, \"value\": 12.6, \"tags\": {\"location\": \"California.SanFrancisco\", \"groupid\": 2}}," + "{\"metric\": \"meters.current\", \"timestamp\": 1648432611250, \"value\": 12.6, \"tags\": {\"location\": \"California.SanFrancisco\", \"groupid\": 2}}," +
" {\"metric\": \"meters.voltage\", \"timestamp\": 1648432611250, \"value\": 221, \"tags\": {\"location\": \"California.LosAngeles\", \"groupid\": 1}}]" " {\"metric\": \"meters.voltage\", \"timestamp\": 1648432611250, \"value\": 221, \"tags\": {\"location\": \"California.LosAngeles\", \"groupid\": 1}}]"
}; };
IntPtr res = TDengine.SchemalessInsert(conn, lines, 1, (int)TDengineSchemalessProtocol.TSDB_SML_JSON_PROTOCOL, (int)TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_NOT_CONFIGURED); IntPtr res = TDengine.SchemalessInsert(conn, lines, 1, (int)TDengineSchemalessProtocol.TSDB_SML_JSON_PROTOCOL, (int)TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
if (TDengine.ErrorNo(res) != 0) if (TDengine.ErrorNo(res) != 0)
{ {
Console.WriteLine("SchemalessInsert failed since " + TDengine.Error(res)); throw new Exception("SchemalessInsert failed since " + TDengine.Error(res));
ExitProgram(conn, 1); }
else
{
int affectedRows = TDengine.AffectRows(res);
Console.WriteLine($"SchemalessInsert success, affected {affectedRows} rows");
}
TDengine.FreeResult(res);
} }
else finally
{ {
int affectedRows = TDengine.AffectRows(res); TDengine.Close(conn);
Console.WriteLine($"SchemalessInsert success, affected {affectedRows} rows");
} }
TDengine.FreeResult(res);
ExitProgram(conn, 0);
} }
static IntPtr GetConnection() static IntPtr GetConnection()
{ {
@ -39,9 +43,7 @@ namespace TDengineExample
var conn = TDengine.Connect(host, username, password, dbname, port); var conn = TDengine.Connect(host, username, password, dbname, port);
if (conn == IntPtr.Zero) if (conn == IntPtr.Zero)
{ {
Console.WriteLine("Connect to TDengine failed"); throw new Exception("Connect to TDengine failed");
TDengine.Cleanup();
Environment.Exit(1);
} }
else else
{ {
@ -55,22 +57,13 @@ namespace TDengineExample
IntPtr res = TDengine.Query(conn, "CREATE DATABASE test"); IntPtr res = TDengine.Query(conn, "CREATE DATABASE test");
if (TDengine.ErrorNo(res) != 0) if (TDengine.ErrorNo(res) != 0)
{ {
Console.WriteLine("failed to create database, reason: " + TDengine.Error(res)); throw new Exception("failed to create database, reason: " + TDengine.Error(res));
ExitProgram(conn, 1);
} }
res = TDengine.Query(conn, "USE test"); res = TDengine.Query(conn, "USE test");
if (TDengine.ErrorNo(res) != 0) if (TDengine.ErrorNo(res) != 0)
{ {
Console.WriteLine("failed to change database, reason: " + TDengine.Error(res)); throw new Exception("failed to change database, reason: " + TDengine.Error(res));
ExitProgram(conn, 1);
} }
} }
static void ExitProgram(IntPtr conn, int exitCode)
{
TDengine.Close(conn);
TDengine.Cleanup();
Environment.Exit(exitCode);
}
} }
} }

View File

@ -7,8 +7,10 @@ namespace TDengineExample
static void Main() static void Main()
{ {
IntPtr conn = GetConnection(); IntPtr conn = GetConnection();
PrepareDatabase(conn); try
string[] lines = { {
PrepareDatabase(conn);
string[] lines = {
"meters.current 1648432611249 10.3 location=California.SanFrancisco groupid=2", "meters.current 1648432611249 10.3 location=California.SanFrancisco groupid=2",
"meters.current 1648432611250 12.6 location=California.SanFrancisco groupid=2", "meters.current 1648432611250 12.6 location=California.SanFrancisco groupid=2",
"meters.current 1648432611249 10.8 location=California.LosAngeles groupid=3", "meters.current 1648432611249 10.8 location=California.LosAngeles groupid=3",
@ -18,20 +20,22 @@ namespace TDengineExample
"meters.voltage 1648432611249 221 location=California.LosAngeles groupid=3", "meters.voltage 1648432611249 221 location=California.LosAngeles groupid=3",
"meters.voltage 1648432611250 217 location=California.LosAngeles groupid=3", "meters.voltage 1648432611250 217 location=California.LosAngeles groupid=3",
}; };
IntPtr res = TDengine.SchemalessInsert(conn, lines, lines.Length, (int)TDengineSchemalessProtocol.TSDB_SML_TELNET_PROTOCOL, (int)TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_NOT_CONFIGURED); IntPtr res = TDengine.SchemalessInsert(conn, lines, lines.Length, (int)TDengineSchemalessProtocol.TSDB_SML_TELNET_PROTOCOL, (int)TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
if (TDengine.ErrorNo(res) != 0) if (TDengine.ErrorNo(res) != 0)
{ {
Console.WriteLine("SchemalessInsert failed since " + TDengine.Error(res)); throw new Exception("SchemalessInsert failed since " + TDengine.Error(res));
ExitProgram(conn, 1); }
else
{
int affectedRows = TDengine.AffectRows(res);
Console.WriteLine($"SchemalessInsert success, affected {affectedRows} rows");
}
TDengine.FreeResult(res);
} }
else catch
{ {
int affectedRows = TDengine.AffectRows(res); TDengine.Close(conn);
Console.WriteLine($"SchemalessInsert success, affected {affectedRows} rows");
} }
TDengine.FreeResult(res);
ExitProgram(conn, 0);
} }
static IntPtr GetConnection() static IntPtr GetConnection()
{ {
@ -43,9 +47,7 @@ namespace TDengineExample
var conn = TDengine.Connect(host, username, password, dbname, port); var conn = TDengine.Connect(host, username, password, dbname, port);
if (conn == IntPtr.Zero) if (conn == IntPtr.Zero)
{ {
Console.WriteLine("Connect to TDengine failed"); throw new Exception("Connect to TDengine failed");
TDengine.Cleanup();
Environment.Exit(1);
} }
else else
{ {
@ -59,22 +61,13 @@ namespace TDengineExample
IntPtr res = TDengine.Query(conn, "CREATE DATABASE test"); IntPtr res = TDengine.Query(conn, "CREATE DATABASE test");
if (TDengine.ErrorNo(res) != 0) if (TDengine.ErrorNo(res) != 0)
{ {
Console.WriteLine("failed to create database, reason: " + TDengine.Error(res)); throw new Exception("failed to create database, reason: " + TDengine.Error(res));
ExitProgram(conn, 1);
} }
res = TDengine.Query(conn, "USE test"); res = TDengine.Query(conn, "USE test");
if (TDengine.ErrorNo(res) != 0) if (TDengine.ErrorNo(res) != 0)
{ {
Console.WriteLine("failed to change database, reason: " + TDengine.Error(res)); throw new Exception("failed to change database, reason: " + TDengine.Error(res));
ExitProgram(conn, 1);
} }
} }
static void ExitProgram(IntPtr conn, int exitCode)
{
TDengine.Close(conn);
TDengine.Cleanup();
Environment.Exit(exitCode);
}
} }
} }

View File

@ -0,0 +1,80 @@
using TDengineDriver;
using TDengineDriver.Impl;
using System.Runtime.InteropServices;
namespace TDengineExample
{
internal class QueryExample
{
static void Main()
{
IntPtr conn = GetConnection();
try
{
// run query
IntPtr res = TDengine.Query(conn, "SELECT * FROM meters LIMIT 2");
if (TDengine.ErrorNo(res) != 0)
{
throw new Exception("Failed to query since: " + TDengine.Error(res));
}
// get filed count
int fieldCount = TDengine.FieldCount(res);
Console.WriteLine("fieldCount=" + fieldCount);
// print column names
List<TDengineMeta> metas = LibTaos.GetMeta(res);
for (int i = 0; i < metas.Count; i++)
{
Console.Write(metas[i].name + "\t");
}
Console.WriteLine();
// print values
List<Object> resData = LibTaos.GetData(res);
for (int i = 0; i < resData.Count; i++)
{
Console.Write($"|{resData[i].ToString()} \t");
if (((i + 1) % metas.Count == 0))
{
Console.WriteLine("");
}
}
Console.WriteLine();
// Free result after use
TDengine.FreeResult(res);
}
finally
{
TDengine.Close(conn);
}
}
static IntPtr GetConnection()
{
string host = "localhost";
short port = 6030;
string username = "root";
string password = "taosdata";
string dbname = "power";
var conn = TDengine.Connect(host, username, password, dbname, port);
if (conn == IntPtr.Zero)
{
throw new Exception("Connect to TDengine failed");
}
else
{
Console.WriteLine("Connect to TDengine success");
}
return conn;
}
}
}
// output:
// Connect to TDengine success
// fieldCount=6
// ts current voltage phase location groupid
// 1648432611249 10.3 219 0.31 California.SanFrancisco 2
// 1648432611749 12.6 218 0.33 California.SanFrancisco 2

View File

@ -9,7 +9,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="TDengine.Connector" Version="3.0.0" /> <PackageReference Include="TDengine.Connector" Version="3.0.1" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,69 @@
using TDengineDriver;
namespace TDengineExample
{
internal class SQLInsertExample
{
static void Main()
{
IntPtr conn = GetConnection();
try
{
IntPtr res = TDengine.Query(conn, "CREATE DATABASE power");
CheckRes(conn, res, "failed to create database");
res = TDengine.Query(conn, "USE power");
CheckRes(conn, res, "failed to change database");
res = TDengine.Query(conn, "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)");
CheckRes(conn, res, "failed to create stable");
var sql = "INSERT INTO d1001 USING meters TAGS('California.SanFrancisco', 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000) " +
"d1002 USING power.meters TAGS('California.SanFrancisco', 3) VALUES('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000) " +
"d1003 USING power.meters TAGS('California.LosAngeles', 2) VALUES('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000)('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000) " +
"d1004 USING power.meters TAGS('California.LosAngeles', 3) VALUES('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000)('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000)";
res = TDengine.Query(conn, sql);
CheckRes(conn, res, "failed to insert data");
int affectedRows = TDengine.AffectRows(res);
Console.WriteLine("affectedRows " + affectedRows);
TDengine.FreeResult(res);
}
finally
{
TDengine.Close(conn);
}
}
static IntPtr GetConnection()
{
string host = "localhost";
short port = 6030;
string username = "root";
string password = "taosdata";
string dbname = "";
var conn = TDengine.Connect(host, username, password, dbname, port);
if (conn == IntPtr.Zero)
{
throw new Exception("Connect to TDengine failed");
}
else
{
Console.WriteLine("Connect to TDengine success");
}
return conn;
}
static void CheckRes(IntPtr conn, IntPtr res, String errorMsg)
{
if (TDengine.ErrorNo(res) != 0)
{
throw new Exception($"{errorMsg} since: {TDengine.Error(res)}");
}
}
}
}
// output:
// Connect to TDengine success
// affectedRows 8

View File

@ -9,45 +9,50 @@ namespace TDengineExample
static void Main() static void Main()
{ {
conn = GetConnection(); conn = GetConnection();
PrepareSTable(); try
// 1. init and prepare
stmt = TDengine.StmtInit(conn);
if (stmt == IntPtr.Zero)
{ {
Console.WriteLine("failed to init stmt, " + TDengine.Error(stmt)); PrepareSTable();
ExitProgram(); // 1. init and prepare
} stmt = TDengine.StmtInit(conn);
int res = TDengine.StmtPrepare(stmt, "INSERT INTO ? USING meters TAGS(?, ?) VALUES(?, ?, ?, ?)"); if (stmt == IntPtr.Zero)
CheckStmtRes(res, "failed to prepare stmt"); {
throw new Exception("failed to init stmt.");
}
int res = TDengine.StmtPrepare(stmt, "INSERT INTO ? USING meters TAGS(?, ?) VALUES(?, ?, ?, ?)");
CheckStmtRes(res, "failed to prepare stmt");
// 2. bind table name and tags // 2. bind table name and tags
TAOS_MULTI_BIND[] tags = new TAOS_MULTI_BIND[2] { TaosMultiBind.MultiBindBinary(new string[]{"California.SanFrancisco"}), TaosMultiBind.MultiBindInt(new int?[] {2}) }; TAOS_MULTI_BIND[] tags = new TAOS_MULTI_BIND[2] { TaosMultiBind.MultiBindBinary(new string[] { "California.SanFrancisco" }), TaosMultiBind.MultiBindInt(new int?[] { 2 }) };
res = TDengine.StmtSetTbnameTags(stmt, "d1001", tags); res = TDengine.StmtSetTbnameTags(stmt, "d1001", tags);
CheckStmtRes(res, "failed to bind table name and tags"); CheckStmtRes(res, "failed to bind table name and tags");
// 3. bind values // 3. bind values
TAOS_MULTI_BIND[] values = new TAOS_MULTI_BIND[4] { TAOS_MULTI_BIND[] values = new TAOS_MULTI_BIND[4] {
TaosMultiBind.MultiBindTimestamp(new long[2] { 1648432611249, 1648432611749}), TaosMultiBind.MultiBindTimestamp(new long[2] { 1648432611249, 1648432611749}),
TaosMultiBind.MultiBindFloat(new float?[2] { 10.3f, 12.6f}), TaosMultiBind.MultiBindFloat(new float?[2] { 10.3f, 12.6f}),
TaosMultiBind.MultiBindInt(new int?[2] { 219, 218}), TaosMultiBind.MultiBindInt(new int?[2] { 219, 218}),
TaosMultiBind.MultiBindFloat(new float?[2]{ 0.31f, 0.33f}) TaosMultiBind.MultiBindFloat(new float?[2]{ 0.31f, 0.33f})
}; };
res = TDengine.StmtBindParamBatch(stmt, values); res = TDengine.StmtBindParamBatch(stmt, values);
CheckStmtRes(res, "failed to bind params"); CheckStmtRes(res, "failed to bind params");
// 4. add batch // 4. add batch
res = TDengine.StmtAddBatch(stmt); res = TDengine.StmtAddBatch(stmt);
CheckStmtRes(res, "failed to add batch"); CheckStmtRes(res, "failed to add batch");
// 5. execute // 5. execute
res = TDengine.StmtExecute(stmt); res = TDengine.StmtExecute(stmt);
CheckStmtRes(res, "faild to execute"); CheckStmtRes(res, "faild to execute");
// 6. free
TaosMultiBind.FreeTaosBind(tags);
TaosMultiBind.FreeTaosBind(values);
}
finally
{
TDengine.Close(conn);
}
// 6. free
TaosMultiBind.FreeTaosBind(tags);
TaosMultiBind.FreeTaosBind(values);
TDengine.Close(conn);
TDengine.Cleanup();
} }
static IntPtr GetConnection() static IntPtr GetConnection()
@ -60,8 +65,7 @@ namespace TDengineExample
var conn = TDengine.Connect(host, username, password, dbname, port); var conn = TDengine.Connect(host, username, password, dbname, port);
if (conn == IntPtr.Zero) if (conn == IntPtr.Zero)
{ {
Console.WriteLine("Connect to TDengine failed"); throw new Exception("Connect to TDengine failed");
Environment.Exit(0);
} }
else else
{ {
@ -70,8 +74,6 @@ namespace TDengineExample
return conn; return conn;
} }
static void PrepareSTable() static void PrepareSTable()
{ {
IntPtr res = TDengine.Query(conn, "CREATE DATABASE power"); IntPtr res = TDengine.Query(conn, "CREATE DATABASE power");
@ -90,9 +92,8 @@ namespace TDengineExample
int code = TDengine.StmtClose(stmt); int code = TDengine.StmtClose(stmt);
if (code != 0) if (code != 0)
{ {
Console.WriteLine($"falied to close stmt, {code} reason: {TDengine.StmtErrorStr(stmt)} "); throw new Exception($"falied to close stmt, {code} reason: {TDengine.StmtErrorStr(stmt)} ");
} }
ExitProgram();
} }
} }
@ -100,16 +101,9 @@ namespace TDengineExample
{ {
if (TDengine.ErrorNo(res) != 0) if (TDengine.ErrorNo(res) != 0)
{ {
Console.WriteLine(errorMsg + " since:" + TDengine.Error(res)); throw new Exception(errorMsg + " since:" + TDengine.Error(res));
ExitProgram();
} }
} }
static void ExitProgram()
{
TDengine.Close(conn);
TDengine.Cleanup();
Environment.Exit(1);
}
} }
} }

View File

@ -11,11 +11,10 @@ namespace TMQExample
{ {
IntPtr conn = GetConnection(); IntPtr conn = GetConnection();
string topic = "topic_example"; string topic = "topic_example";
Console.WriteLine($"create topic if not exist {topic} as select * from meters");
//create topic //create topic
IntPtr res = TDengine.Query(conn, $"create topic if not exists {topic} as select * from meters"); IntPtr res = TDengine.Query(conn, $"create topic if not exists {topic} as select * from meters");
if (res == IntPtr.Zero) if (TDengine.ErrorNo(res) != 0 )
{ {
throw new Exception($"create topic failed, reason:{TDengine.Error(res)}"); throw new Exception($"create topic failed, reason:{TDengine.Error(res)}");
} }
@ -26,7 +25,7 @@ namespace TMQExample
TDConnectUser = "root", TDConnectUser = "root",
TDConnectPasswd = "taosdata", TDConnectPasswd = "taosdata",
MsgWithTableName = "true", MsgWithTableName = "true",
TDConnectIp = "127.0.0.1", TDConnectIp = "127.0.0.1",
}; };
// create consumer // create consumer
@ -65,7 +64,6 @@ namespace TMQExample
List<string> topics = consumer.Subscription(); List<string> topics = consumer.Subscription();
topics.ForEach(t => Console.WriteLine("topic name:{0}", t)); topics.ForEach(t => Console.WriteLine("topic name:{0}", t));
// unsubscribe // unsubscribe
consumer.Unsubscribe(); consumer.Unsubscribe();
@ -73,7 +71,6 @@ namespace TMQExample
consumer.Close(); consumer.Close();
TDengine.Close(conn); TDengine.Close(conn);
} }
static IntPtr GetConnection() static IntPtr GetConnection()
@ -86,8 +83,7 @@ namespace TMQExample
var conn = TDengine.Connect(host, username, password, dbname, port); var conn = TDengine.Connect(host, username, password, dbname, port);
if (conn == IntPtr.Zero) if (conn == IntPtr.Zero)
{ {
Console.WriteLine("Connect to TDengine failed"); throw new Exception("Connect to TDengine failed");
System.Environment.Exit(0);
} }
else else
{ {

View File

@ -9,7 +9,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="TDengine.Connector" Version="3.0.0" /> <PackageReference Include="TDengine.Connector" Version="3.0.1" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -47,7 +47,7 @@ namespace Examples
} }
else else
{ {
Console.WriteLine("{0} success affect {2} rows, cost {1} nanoseconds", desc, LibTaosWS.WSTakeTiming(wsRes),LibTaosWS.WSAffectRows(wsRes)); Console.WriteLine("{0} success affect {2} rows, cost {1} nanoseconds", desc, LibTaosWS.WSTakeTiming(wsRes), LibTaosWS.WSAffectRows(wsRes));
} }
} }
} }

View File

@ -55,7 +55,7 @@ namespace Examples
// Free result after use. // Free result after use.
LibTaosWS.WSFreeResult(wsRes); LibTaosWS.WSFreeResult(wsRes);
// close connection. // close connection.
LibTaosWS.WSClose(wsConn); LibTaosWS.WSClose(wsConn);
} }

View File

@ -1,5 +1,5 @@
```csharp title="原生连接" ```csharp title="原生连接"
{{#include docs/examples/csharp/ConnectExample.cs}} {{#include docs/examples/csharp/connect/Program.cs}}
``` ```
```csharp title="WebSocket 连接" ```csharp title="WebSocket 连接"

View File

@ -1,3 +1,3 @@
```csharp ```csharp
{{#include docs/examples/csharp/InfluxDBLineExample.cs}} {{#include docs/examples/csharp/influxdbLine/Program.cs}}
``` ```

View File

@ -1,3 +1,3 @@
```csharp ```csharp
{{#include docs/examples/csharp/OptsJsonExample.cs}} {{#include docs/examples/csharp/optsJSON/Program.cs}}
``` ```

View File

@ -1,3 +1,3 @@
```csharp ```csharp
{{#include docs/examples/csharp/OptsTelnetExample.cs}} {{#include docs/examples/csharp/optsTelnet/Program.cs}}
``` ```

View File

@ -1,3 +1,3 @@
```csharp ```csharp
{{#include docs/examples/csharp/SQLInsertExample.cs}} {{#include docs/examples/csharp/sqlInsert/Program.cs}}
``` ```

View File

@ -1,3 +1,3 @@
```csharp ```csharp
{{#include docs/examples/csharp/StmtInsertExample.cs}} {{#include docs/examples/csharp/stmtInsert/Program.cs}}
``` ```

View File

@ -1,3 +1,3 @@
```csharp ```csharp
{{#include docs/examples/csharp/QueryExample.cs}} {{#include docs/examples/csharp/query/Program.cs}}
``` ```

View File

@ -1,3 +1,3 @@
```csharp ```csharp
{{#include docs/examples/csharp/AsyncQueryExample.cs}} {{#include docs/examples/csharp/asyncQuery/Program.cs}}
``` ```

View File

@ -1,3 +1,3 @@
```csharp ```csharp
{{#include docs/examples/csharp/SubscribeDemo.cs}} {{#include docs/examples/csharp/subscribe/Program.cs}}
``` ```

View File

@ -208,7 +208,7 @@ namespace TDengineExample
<TabItem value="native" label="原生连接"> <TabItem value="native" label="原生连接">
``` csharp ``` csharp
{{#include docs/examples/csharp/StmtInsertExample.cs}} {{#include docs/examples/csharp/stmtInsert/Program.cs}}
``` ```
</TabItem> </TabItem>

View File

@ -6,24 +6,32 @@ pgrep taosd || taosd >> /dev/null 2>&1 &
pgrep taosadapter || taosadapter >> /dev/null 2>&1 & pgrep taosadapter || taosadapter >> /dev/null 2>&1 &
cd ../../docs/examples/csharp cd ../../docs/examples/csharp
#dotnet run --project connect.csproj dotnet run --project connect/connect.csproj
#taos -s "drop database if exists power" taos -s "drop database if exists power"
#dotnet run --project sqlinsert.csproj dotnet run --project sqlInsert/sqlinsert.csproj
#dotnet run --project query.csproj dotnet run --project query/query.csproj
#dotnet run --project asyncquery.csproj dotnet run --project asyncQuery/asyncquery.csproj
#dotnet run --project subscribe.csproj dotnet run --project subscribe/subscribe.csproj
#taos -s "drop topic if exists topic_example" taos -s "drop topic if exists topic_example"
#taos -s "drop database if exists power" taos -s "drop database if exists power"
#dotnet run --project stmtinsert.csproj dotnet run --project stmtInsert/stmtinsert.csproj
#taos -s "drop database if exists test" taos -s "drop database if exists test"
#dotnet run --project influxdbline.csproj dotnet run --project influxdbLine/influxdbline.csproj
#taos -s "drop database if exists test" taos -s "drop database if exists test"
#dotnet run --project optstelnet.csproj dotnet run --project optsTelnet/optstelnet.csproj
#taos -s "drop database if exists test" taos -s "drop database if exists test"
#dotnet run --project optsjson.csproji dotnet run --project optsJSON/optsJSON.csproj
echo "uncomment temporily"
taos -s "create database if exists test"
dotnet run --project wsConnect/wsConnect.csproj
dotnet run --project wsInsert/wsInsert.csproj
dotnet run --project wsStmt/wsStmt.csproj
dotnet run --project wsQuery/wsQuery.csproj
taos -s "drop database if exists test"
taos -s "drop database if exists power"