提交 d9490624 编写于 作者: X xleili

docs(cloud):C# suppply cloud in/out doc and fix ivavalid path

上级 4d598231
```csharp ```csharp
// {{#include docs/examples/csharp/SubscribeDemo.cs}} {{#include docs/examples/csharp/native-example/SubscribeDemo.cs}}
``` ```
\ No newline at end of file
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16 # Visual Studio Version 16
VisualStudioVersion = 16.0.30114.105 VisualStudioVersion = 16.0.30114.105
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "connect", "connect\connect.csproj", "{4006CF0C-17BE-4508-9682-A85298F8C92D}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "connect", "connect\connect.csproj", "{4006CF0C-17BE-4508-9682-A85298F8C92D}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "usage", "usage\usage.csproj", "{243C420F-FC47-4F21-B81E-83CDE91F2D47}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "usage", "usage\usage.csproj", "{243C420F-FC47-4F21-B81E-83CDE91F2D47}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "stmt", "stmt\stmt.csproj", "{B6907CB6-41CB-4644-AEE1-551456EADE12}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "stmt", "stmt\stmt.csproj", "{B6907CB6-41CB-4644-AEE1-551456EADE12}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "inout", "inout\inout.csproj", "{058C3864-CF33-459D-B1A7-F7E1C6AED452}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "inout", "inout\inout.csproj", "{058C3864-CF33-459D-B1A7-F7E1C6AED452}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4006CF0C-17BE-4508-9682-A85298F8C92D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4006CF0C-17BE-4508-9682-A85298F8C92D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4006CF0C-17BE-4508-9682-A85298F8C92D}.Debug|Any CPU.Build.0 = Debug|Any CPU {4006CF0C-17BE-4508-9682-A85298F8C92D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4006CF0C-17BE-4508-9682-A85298F8C92D}.Release|Any CPU.ActiveCfg = Release|Any CPU {4006CF0C-17BE-4508-9682-A85298F8C92D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4006CF0C-17BE-4508-9682-A85298F8C92D}.Release|Any CPU.Build.0 = Release|Any CPU {4006CF0C-17BE-4508-9682-A85298F8C92D}.Release|Any CPU.Build.0 = Release|Any CPU
{243C420F-FC47-4F21-B81E-83CDE91F2D47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {243C420F-FC47-4F21-B81E-83CDE91F2D47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{243C420F-FC47-4F21-B81E-83CDE91F2D47}.Debug|Any CPU.Build.0 = Debug|Any CPU {243C420F-FC47-4F21-B81E-83CDE91F2D47}.Debug|Any CPU.Build.0 = Debug|Any CPU
{243C420F-FC47-4F21-B81E-83CDE91F2D47}.Release|Any CPU.ActiveCfg = Release|Any CPU {243C420F-FC47-4F21-B81E-83CDE91F2D47}.Release|Any CPU.ActiveCfg = Release|Any CPU
{243C420F-FC47-4F21-B81E-83CDE91F2D47}.Release|Any CPU.Build.0 = Release|Any CPU {243C420F-FC47-4F21-B81E-83CDE91F2D47}.Release|Any CPU.Build.0 = Release|Any CPU
{B6907CB6-41CB-4644-AEE1-551456EADE12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B6907CB6-41CB-4644-AEE1-551456EADE12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B6907CB6-41CB-4644-AEE1-551456EADE12}.Debug|Any CPU.Build.0 = Debug|Any CPU {B6907CB6-41CB-4644-AEE1-551456EADE12}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B6907CB6-41CB-4644-AEE1-551456EADE12}.Release|Any CPU.ActiveCfg = Release|Any CPU {B6907CB6-41CB-4644-AEE1-551456EADE12}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B6907CB6-41CB-4644-AEE1-551456EADE12}.Release|Any CPU.Build.0 = Release|Any CPU {B6907CB6-41CB-4644-AEE1-551456EADE12}.Release|Any CPU.Build.0 = Release|Any CPU
{058C3864-CF33-459D-B1A7-F7E1C6AED452}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {058C3864-CF33-459D-B1A7-F7E1C6AED452}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{058C3864-CF33-459D-B1A7-F7E1C6AED452}.Debug|Any CPU.Build.0 = Debug|Any CPU {058C3864-CF33-459D-B1A7-F7E1C6AED452}.Debug|Any CPU.Build.0 = Debug|Any CPU
{058C3864-CF33-459D-B1A7-F7E1C6AED452}.Release|Any CPU.ActiveCfg = Release|Any CPU {058C3864-CF33-459D-B1A7-F7E1C6AED452}.Release|Any CPU.ActiveCfg = Release|Any CPU
{058C3864-CF33-459D-B1A7-F7E1C6AED452}.Release|Any CPU.Build.0 = Release|Any CPU {058C3864-CF33-459D-B1A7-F7E1C6AED452}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal
using System; using System;
using TDengineDriver; using TDengineDriver;
using TDengineWS.Impl; using TDengineWS.Impl;
using System.Collections.Generic; using System.Collections.Generic;
namespace Cloud.Examples namespace Cloud.Examples
{ {
public class InOutExample public class InOutExample
{ {
static void Main(string[] args) static void Main(string[] args)
{ {
string dsn = Environment.GetEnvironmentVariable("TDENGINE_CLOUD_DSN"); string dsn = Environment.GetEnvironmentVariable("TDENGINE_CLOUD_DSN");
IntPtr conn = LibTaosWS.WSConnectWithDSN(dsn); IntPtr conn = LibTaosWS.WSConnectWithDSN(dsn);
if (conn != IntPtr.Zero) if (conn != IntPtr.Zero)
{ {
try try
{ {
// ANCHOR: insert // ANCHOR: insert
string createTable = "CREATE STABLE if not exists test.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)"; string createTable = "CREATE STABLE if not exists test.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)";
string insertData = "INSERT INTO test.d1001 USING test.meters TAGS('California.SanFrancisco', 1) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000)" + string insertData = "INSERT INTO test.d1001 USING test.meters TAGS('California.SanFrancisco', 1) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000)" +
"test.d1002 USING test.meters TAGS('California.SanFrancisco', 2) VALUES ('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000)" + "test.d1002 USING test.meters TAGS('California.SanFrancisco', 2) VALUES ('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000)" +
"test.d1003 USING test.meters TAGS('California.LosAngeles', 3) VALUES ('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000)" + "test.d1003 USING test.meters TAGS('California.LosAngeles', 3) VALUES ('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000)" +
"test.d1004 USING test.meters TAGS('California.LosAngeles', 4) VALUES ('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000) "; "test.d1004 USING test.meters TAGS('California.LosAngeles', 4) VALUES ('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000) ";
// create database under database named 'test' // create database under database named 'test'
IntPtr res = LibTaosWS.WSQuery(conn, createTable); IntPtr res = LibTaosWS.WSQuery(conn, createTable);
ValidQueryExecution(res); ValidQueryExecution(res);
// Free the query result every time when used up it. // Free the query result every time when used up it.
LibTaosWS.WSFreeResult(res); LibTaosWS.WSFreeResult(res);
// insert data into the table created in previous step. // insert data into the table created in previous step.
res = LibTaosWS.WSQuery(conn, insertData); res = LibTaosWS.WSQuery(conn, insertData);
ValidQueryExecution(res); ValidQueryExecution(res);
// Free the query result every time when used up it. // Free the query result every time when used up it.
LibTaosWS.WSFreeResult(res); LibTaosWS.WSFreeResult(res);
// ANCHOR: query // ANCHOR: query
void ValidQueryExecution(IntPtr res) void ValidQueryExecution(IntPtr res)
{ {
int code = LibTaosWS.WSErrorNo(res); int code = LibTaosWS.WSErrorNo(res);
if (code != 0) if (code != 0)
{ {
throw new Exception($"execute SQL failed: reason: {LibTaosWS.WSErrorStr(res)}, code:{code}"); throw new Exception($"execute SQL failed: reason: {LibTaosWS.WSErrorStr(res)}, code:{code}");
} }
} }
// ANCHOR_END: insert // ANCHOR_END: insert
string selectTable = "select * from test.meters"; string selectTable = "select * from test.meters";
IntPtr res = LibTaosWS.WSQueryTimeout(conn, selectTable, 5000); res = LibTaosWS.WSQueryTimeout(conn, selectTable, 5000);
ValidQueryExecution(res); ValidQueryExecution(res);
// get meta info of the retrieved data as List // get meta info of the retrieved data as List
List<TDengineMeta> metas = LibTaosWS.WSGetFields(res); List<TDengineMeta> metas = LibTaosWS.WSGetFields(res);
// get data of the retrieved data as List. // get data of the retrieved data as List.
List<object> dataSet = LibTaosWS.WSGetData(res); List<object> dataSet = LibTaosWS.WSGetData(res);
// Free the query result every time when used up it. // Free the query result every time when used up it.
LibTaosWS.WSFreeResult(res); LibTaosWS.WSFreeResult(res);
// ANCHOR_END: query // ANCHOR_END: query
} }
finally finally
{ {
// close connect // close connect
LibTaosWS.WSClose(conn); LibTaosWS.WSClose(conn);
} }
} }
else else
{ {
throw new Exception($"get connection failed,reason:{LibTaosWS.WSErrorStr(conn)},code:{LibTaosWS.WSErrorNo(conn)}"); throw new Exception($"get connection failed,reason:{LibTaosWS.WSErrorStr(conn)},code:{LibTaosWS.WSErrorNo(conn)}");
} }
sum(1, 2); }
void sum(int i, int j)
{ }
Console.WriteLine("{0} + {1} = {2}", i, j, i + j);
}
}
}
} }
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net5.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="TDengine.Connector" Version="3.0.1" /> <PackageReference Include="TDengine.Connector" Version="3.0.1" />
</ItemGroup> </ItemGroup>
</Project> </Project>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册