Quellcode durchsuchen

增加测试环境配置

td_orm
H Vs vor 1 Jahr
Ursprung
Commit
cead2a8bd8
7 geänderte Dateien mit 333 neuen und 29 gelöschten Zeilen
  1. +205
    -9
      HealthMonitor.Service/Biz/db/TDengineService.cs
  2. +14
    -6
      HealthMonitor.Service/Resolver/BloodpressResolver.cs
  3. +13
    -9
      HealthMonitor.Service/Sub/TDengineDataSubcribe.cs
  4. +5
    -5
      HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressController.cs
  5. +46
    -0
      HealthMonitor.WebApi/Dockerfile
  6. +43
    -0
      HealthMonitor.WebApi/appsettings.test.json
  7. +7
    -0
      nuget.config

+ 205
- 9
HealthMonitor.Service/Biz/db/TDengineService.cs Datei anzeigen

@@ -1,6 +1,8 @@
using HealthMonitor.Common.helper;
using HealthMonitor.Common;
using HealthMonitor.Common.helper;
using HealthMonitor.Model.Config;
using HealthMonitor.Service.Biz.db.Dto;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
@@ -129,8 +131,29 @@ namespace HealthMonitor.Service.Biz.db
}
}

public void ExecuteInsertSQL(IntPtr conn, string sql)
//public void ExecuteInsertSQL(IntPtr conn, string sql)
//{
// try
// {
// //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)";
// IntPtr 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);
// }
//}

public void ExecuteInsertSQL(string sql)
{
var conn = Connection();
try
{
//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) " +
@@ -149,6 +172,179 @@ namespace HealthMonitor.Service.Biz.db
}
}

#region TDengine.Connector async query
public void QueryCallback(IntPtr param, IntPtr taosRes, int code)
{
if (code == 0 && taosRes != IntPtr.Zero)
{
FetchRawBlockAsyncCallback fetchRowAsyncCallback = new FetchRawBlockAsyncCallback(FetchRawBlockCallback);
TDengine.FetchRawBlockAsync(taosRes, fetchRowAsyncCallback, param);
}
else
{
Console.WriteLine($"async query data failed, failed code {code}");
}
}
// Iteratively call this interface until "numOfRows" is no greater than 0.
public void FetchRawBlockCallback(IntPtr param, IntPtr taosRes, int numOfRows)
{
if (numOfRows > 0)
{
Console.WriteLine($"{numOfRows} rows async retrieved");
IntPtr pdata = TDengine.GetRawBlock(taosRes);
List<TDengineMeta> metaList = TDengine.FetchFields(taosRes);
List<object> dataList = LibTaos.ReadRawBlock(pdata, metaList, numOfRows);

for (int i = 0; i < metaList.Count; i++)
{
Console.Write("{0} {1}({2}) \t|", metaList[i].name, metaList[i].type, metaList[i].size);
}
Console.WriteLine();
for (int i = 0; i < dataList.Count; i++)
{
if (i != 0 && i % metaList.Count == 0)
{
Console.WriteLine("{0}\t|", dataList[i]);
}
Console.Write("{0}\t|", dataList[i]);
}
TDengine.FetchRawBlockAsync(taosRes, FetchRawBlockCallback, param);
}
else
{
if (numOfRows == 0)
{
Console.WriteLine("async retrieve complete.");
}
else
{
Console.WriteLine($"FetchRawBlockCallback callback error, error code {numOfRows}");
}
TDengine.FreeResult(taosRes);
}
}

public void ExecuteQueryAsync(string sql)
{
var conn = Connection();
QueryAsyncCallback queryAsyncCallback = new QueryAsyncCallback(QueryCallback);
TDengine.QueryAsync(conn, sql, queryAsyncCallback, IntPtr.Zero);
}

//public void ExecuteQuery(string sql)
//{
// var conn = Connection();
// QueryAsyncCallback queryAsyncCallback = new QueryAsyncCallback(QueryCallback);
// TDengine.QueryAsync(conn, sql, queryAsyncCallback, IntPtr.Zero);
//}



public Aggregate GetAggregateValue(string field, string tbName, string? condition)
{
List<int> data = new();

var sql = $"SELECT MAX({field}), MIN({field}) FROM {_configTDengineService.DB}.{tbName} WHERE {condition}";

var conn = Connection();
try
{
IntPtr res = TDengine.Query(conn, sql);
// Check if query success
if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
{
Console.Write(sql + " failure, ");
// Get error message while Res is a not null pointer.
if (res != IntPtr.Zero)
{
Console.Write("reason:" + TDengine.Error(res));
}
}
else
{
Console.Write(sql + " success, {0} rows affected", TDengine.AffectRows(res));
//... do something with res ...

List<TDengineMeta> resMeta = LibTaos.GetMeta(res);
List<object> resData = LibTaos.GetData(res);

foreach (var meta in resMeta)
{
Console.Write($"\t|{meta.name} {meta.TypeName()} ({meta.size})\t|");
}
resData.ForEach(x => data.Add(SafeType.SafeInt(x)));

// Important: need to free result to avoid memory leak.
TDengine.FreeResult(res);
}
}
finally
{
TDengine.Close(conn);
}

return new Aggregate
{
Max = data.Count.Equals(0) ? 0 : data[0],
Min = data.Count.Equals(0) ? 0 : data[1],
};
}

public int GetAvgExceptMaxMinValue(string field, string tbName, string? condition)
{
List<int> data = new();
var sql = $"SELECT MAX({field}), MIN({field}) FROM {_configTDengineService.DB}.{tbName} WHERE {condition}";

var aggregate= GetAggregateValue(field, tbName, condition);

var sqlAvg = $"SELECT AVG({field}) FROM {_configTDengineService.DB}.{tbName} WHERE {condition} AND {field} < {aggregate.Max} and {field} > {aggregate.Min}";
var conn = Connection();

try
{
IntPtr res = TDengine.Query(conn, sqlAvg);
// Check if query success
if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
{
Console.Write(sqlAvg + " failure, ");
// Get error message while Res is a not null pointer.
if (res != IntPtr.Zero)
{
Console.Write("reason:" + TDengine.Error(res));
}
}
else
{
Console.Write(sqlAvg + " success, {0} rows affected", TDengine.AffectRows(res));
//... do something with res ...

List<TDengineMeta> resMeta = LibTaos.GetMeta(res);
List<object> resData = LibTaos.GetData(res);

foreach (var meta in resMeta)
{
Console.Write($"\t|{meta.name} {meta.TypeName()} ({meta.size})\t|");
}
resData.ForEach(x => data.Add(SafeType.SafeInt(x)));

// Important: need to free result to avoid memory leak.
TDengine.FreeResult(res);
}
}
finally
{
TDengine.Close(conn);
}

return data.Count.Equals(0) ? 0 : data[0];
}
#endregion

#region RestAPI

public async Task<bool> GernalRestSql(string sql)
{

@@ -181,7 +377,7 @@ namespace HealthMonitor.Service.Biz.db
//return res.Code==0;
}

public async Task<string?> GernalRestSqlResText(string sql)
public async Task<string?> GernalRestSqlResTextAsync(string sql)
{
var url = $"http://{_configTDengineService.Host}:{_configTDengineService.RestPort}/rest/sql/{_configTDengineService.DB}";
List<KeyValuePair<string, string>> headers = new()
@@ -192,12 +388,12 @@ namespace HealthMonitor.Service.Biz.db
return result;
}

public async Task<Aggregate> GetAggregateValue(string field,string tbName,string? condition)
public async Task<Aggregate> GetAggregateValueAsync(string field,string tbName,string? condition)
{
var sql = $"SELECT MAX({field}), MIN({field}) FROM {_configTDengineService.DB}.{tbName} WHERE {condition}";

var result = await GernalRestSqlResText(sql);
var result = await GernalRestSqlResTextAsync(sql);
var res = JsonConvert.DeserializeObject<Aggregate>(result!);
List<dynamic> data = res?.Data!;
@@ -208,24 +404,24 @@ namespace HealthMonitor.Service.Biz.db
};
}

public async Task<int> GetAvgExceptMaxMinValue(string field, string tbName, string? condition)
public async Task<int> GetAvgExceptMaxMinValueAsync(string field, string tbName, string? condition)
{

var sql = $"SELECT MAX({field}), MIN({field}) FROM {_configTDengineService.DB}.{tbName} WHERE {condition}";

var result = await GernalRestSqlResText(sql);
var result = await GernalRestSqlResTextAsync(sql);
var res = JsonConvert.DeserializeObject<TDengineRestResBase>(result!);
List<dynamic> data = res?.Data!;

var sqlAvg = $"SELECT AVG({field}) FROM {_configTDengineService.DB}.{tbName} WHERE {condition} AND {field} < { (data.Count.Equals(0)? 0: data[0][0]) } and {field} > {(data.Count.Equals(0) ? 0 : data[0][1])}";
result = await GernalRestSqlResText(sqlAvg);
result = await GernalRestSqlResTextAsync(sqlAvg);
res = JsonConvert.DeserializeObject<TDengineRestResBase>(result!);
data = res?.Data!;

return data.Count.Equals(0)?0:(int)data[0][0];
}

#endregion

}
}

+ 14
- 6
HealthMonitor.Service/Resolver/BloodpressResolver.cs Datei anzeigen

@@ -108,9 +108,11 @@ namespace HealthMonitor.Service.Resolver
DateTime endTime = now;

//
var systolicAggregate = await _serviceTDengine.GetAggregateValue("systolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}'");
var diastolicAggregate = await _serviceTDengine.GetAggregateValue("diastolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}'");

var systolicAggregate = await _serviceTDengine.GetAggregateValueAsync("systolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}'");
var diastolicAggregate = await _serviceTDengine.GetAggregateValueAsync("diastolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}'");
//var systolicAggregate = _serviceTDengine.GetAggregateValue("systolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}'");
//var diastolicAggregate = _serviceTDengine.GetAggregateValue("diastolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}'");
// 最大值
var systolicMax = systolicAggregate.Max;
var diastolicMax = diastolicAggregate.Max;
@@ -120,8 +122,13 @@ namespace HealthMonitor.Service.Resolver


// 计算去除最大值和最小值和异常值的平均值
var systolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValue("systolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}' and systolic_value < {systolicRefValue} ");
var diastolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValue("diastolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}' and diastolic_value < {diastolicRefValue}");
var systolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("systolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}' and systolic_value < {systolicRefValue} ");
var diastolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("diastolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}' and diastolic_value < {diastolicRefValue}");

//var systolicAvg = _serviceTDengine.GetAvgExceptMaxMinValue("systolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}' and systolic_value < {systolicRefValue} ");
//var diastolicAvg = _serviceTDengine.GetAvgExceptMaxMinValue("diastolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}' and diastolic_value < {diastolicRefValue}");



// 偏移参数
var avgOffset = 0.25M;
@@ -165,7 +172,8 @@ namespace HealthMonitor.Service.Resolver
$"'{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}'," +
$"'{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}'," +
$"'{string.Empty}')";
var res = await _serviceTDengine.GernalRestSql(sql);
//var res = await _serviceTDengine.GernalRestSql(sql);
_serviceTDengine.ExecuteInsertSQL(sql);
#endregion
}



+ 13
- 9
HealthMonitor.Service/Sub/TDengineDataSubcribe.cs Datei anzeigen

@@ -1,11 +1,13 @@
using HealthMonitor.Common;
using HealthMonitor.Core.Dal;
using HealthMonitor.Model.Config;
using HealthMonitor.Service.Biz.db;
using HealthMonitor.Service.Cache;
using HealthMonitor.Service.Resolver.Factory;
using HealthMonitor.Service.Resolver.Interface;
using HealthMonitor.Service.Sub.Topic.Model;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using System;
using System.Collections.Concurrent;
@@ -26,6 +28,7 @@ namespace HealthMonitor.Service.Sub
private readonly MsgQueueManager _msgQueueManager;
private readonly TDengineService _serviceTDengine;
private readonly PersonCacheManager _personCacheMgr;
private readonly TDengineServiceConfig _configTDengineService;
private readonly BloodPressReferenceValueCacheManager _bpRefValCacheManager;
private readonly IResolverFactory _resolverFactory;
private CancellationTokenSource? _tokenSource = null;
@@ -38,7 +41,7 @@ namespace HealthMonitor.Service.Sub
PersonCacheManager personCacheMgr,
BloodPressReferenceValueCacheManager bpRefValCacheManager,
IResolverFactory resolverFactory,
IOptions<TDengineServiceConfig> configTDengineService,
MsgQueueManager msgQueueManager,
ILogger<TDengineDataSubcribe> logger
)
@@ -49,7 +52,8 @@ namespace HealthMonitor.Service.Sub
_logger = logger;
_resolverFactory = resolverFactory;
_msgQueueManager = msgQueueManager;
_configTDengineService = configTDengineService.Value;

}
public void BeginListen(CancellationToken stoppingToken)
{
@@ -75,11 +79,11 @@ namespace HealthMonitor.Service.Sub

public void DoTDengineConnect()
{
string host = "47.116.142.20";
string host = _configTDengineService.Host;
short port = 6030;
string username = "root";
string password = "taosdata";
string dbname = "health_monitor";
string username = _configTDengineService.UserName;
string password = _configTDengineService.Password;
string dbname = _configTDengineService.DB;
var conn = TDengine.Connect(host, username, password, dbname, port);
if (conn == IntPtr.Zero)
{
@@ -97,10 +101,10 @@ namespace HealthMonitor.Service.Sub
var cfg = new ConsumerConfig
{
GourpId = "group_1",
TDConnectUser = "root",
TDConnectPasswd = "taosdata",
TDConnectUser = _configTDengineService.UserName,
TDConnectPasswd = _configTDengineService.Password,
MsgWithTableName = "true",
TDConnectIp = "47.116.142.20",
TDConnectIp = _configTDengineService.Host,
};
// string topic = "topic_hm_bp_stats";
string topic = nameof(TopicHmBloodPress).ToLower();


+ 5
- 5
HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressController.cs Datei anzeigen

@@ -86,7 +86,7 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor
// 861281060086380


//var aggregate = await _serviceTDengine.GetAvgExceptMaxMinValue("diastolic_value", "hm_bloodpress", $"ts>='{DateTime.Now.AddDays(-7):yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{DateTime.Now:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='861281060083627' and systolic_value < {120} and diastolic_value >{80}");
//var aggregate = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("diastolic_value", "hm_bloodpress", $"ts>='{DateTime.Now.AddDays(-7):yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{DateTime.Now:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='861281060083627' and systolic_value < {120} and diastolic_value >{80}");

//+++++++++++++++++++++++++++++++

@@ -138,8 +138,8 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor
DateTime endTime = now;

//
var systolicAggregate = await _serviceTDengine.GetAggregateValue("systolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}'");
var diastolicAggregate = await _serviceTDengine.GetAggregateValue("diastolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}'");
var systolicAggregate = await _serviceTDengine.GetAggregateValueAsync("systolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}'");
var diastolicAggregate = await _serviceTDengine.GetAggregateValueAsync("diastolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}'");

// 最大值
var systolicMax = systolicAggregate.Max;
@@ -150,8 +150,8 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor


// 计算去除最大值和最小值和异常值的平均值
var systolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValue("systolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}' and systolic_value < {systolicRefValue} and diastolic_value >{diastolicRefValue}");
var diastolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValue("diastolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}' and systolic_value < {systolicRefValue} and diastolic_value >{diastolicRefValue}");
var systolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("systolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}' and systolic_value < {systolicRefValue} and diastolic_value >{diastolicRefValue}");
var diastolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("diastolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}' and systolic_value < {systolicRefValue} and diastolic_value >{diastolicRefValue}");

// 偏移参数
var avgOffset = 0.25M;


+ 46
- 0
HealthMonitor.WebApi/Dockerfile Datei anzeigen

@@ -0,0 +1,46 @@
# final stage/image

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 6899

RUN sed -i s@/deb.debian.org/@/mirrors.aliyun.com/@g /etc/apt/sources.list
RUN sed -i s@/security.debian.org/@/mirrors.aliyun.com/@g /etc/apt/sources.list

RUN apt-get update --fix-missing\
&& DEBIAN_FRONTEND=noninteractive apt-get install -y net-tools vim \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["nuget.config","."]
COPY ["HealthMonitor.Common/HealthMonitor.Common.csproj", "HealthMonitor.Common/"]
COPY ["HealthMonitor.Core/HealthMonitor.Core.csproj", "HealthMonitor.Core/"]
COPY ["HealthMonitor.Model/HealthMonitor.Model.csproj", "HealthMonitor.Model/"]
COPY ["HealthMonitor.Service/HealthMonitor.Service.csproj", "HealthMonitor.Service/"]
COPY ["HealthMonitor.Util/HealthMonitor.Util.csproj", "HealthMonitor.Util/"]
COPY ["HealthMonitor.WebApi/HealthMonitor.WebApi.csproj", "HealthMonitor.WebApi/"]
RUN dotnet nuget remove source nuget.org
#RUN dotnet nuget add source https://mirrors.cloud.tencent.com/nuget/ -n tencent_nuget
RUN dotnet nuget add source https://repo.huaweicloud.com/repository/nuget/v3/index.json -n huaweicloud_nuget
RUN dotnet restore "HealthMonitor.WebApi/HealthMonitor.WebApi.csproj"
COPY . .
WORKDIR "/src/HealthMonitor.WebApi"
RUN dotnet build "HealthMonitor.WebApi.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "HealthMonitor.WebApi.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
#ENV environment=Development
ENV urls=http://*:6899
ENV TimeZone=Asia/Shanghai
ENV LANG C.UTF-8
RUN ln -snf /usr/share/zoneinfo/$TimeZone /etc/localtime && echo $TimeZone > /etc/timezone
#ENTRYPOINT dotnet HealthMonitor.WebApi.dll --environment=$environment

ENTRYPOINT ["dotnet", "HealthMonitor.WebAapi.dll"]
CMD ["--environment=Development"]

+ 43
- 0
HealthMonitor.WebApi/appsettings.test.json Datei anzeigen

@@ -0,0 +1,43 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"TDengineServiceConfig": {
"Host": "172.19.42.44", // 测试环境内网
//"Host": "47.116.142.20", // 测试环境公网
"UserName": "root",
"Password": "taosdata",
"Token": "cm9vdDp0YW9zZGF0YQ==",
"Port": 6030,
"RestPort": 6041,
"DB": "health_monitor"
},
"Redis": {
"Server": "172.19.42.44:8090", // 测试环境内网
//"Server": "47.116.142.20:8090", // 测试环境公网
"Password": "telpo#1234",
//"Server": "127.0.0.1:6379",
"DefaultDatabase": 2,
"Prefix": "_HM_",
//"DefaultDatabase": 7,
// "Prefix": "TELPO",
"Poolsize": 50,

"ConnectTimeout": 5000,
"IdleTimeout": 20000
},
"ServiceConfig": {
"TelpoDataUrl": "https://id.ssjlai.com/data/"
},
"ConnectionStrings": {
// 测试环境内网
"GpsCard_Connection_String": "server=172.19.42.40;port=3305;database=gps_card;uid=root;pwd=telpo#1234;CharSet=utf8;MinimumPoolSize=10;MaximumPoolSize=1000;SslMode=none",
"HealthMonitor_Connection_String": "server=172.19.42.40;port=3305;database=health_monitor;uid=root;pwd=telpo#1234;CharSet=utf8;MinimumPoolSize=10;MaximumPoolSize=1000;SslMode=none",
// 测试环境公网
//"GpsCard_Connection_String": "server=139.224.254.18;port=3305;database=gps_card;uid=root;pwd=telpo#1234;CharSet=utf8;MinimumPoolSize=10;MaximumPoolSize=1000;SslMode=none",
// "HealthMonitor_Connection_String": "server=139.224.254.18;port=3305;database=health_monitor;uid=root;pwd=telpo#1234;CharSet=utf8;MinimumPoolSize=10;MaximumPoolSize=1000;SslMode=none"
}
}

+ 7
- 0
nuget.config Datei anzeigen

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="company" value="http://139.224.254.18:3344" />
</packageSources>
</configuration>

Laden…
Abbrechen
Speichern