Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
IoTSharp
IoTSharp
提交
0fecf0ab
IoTSharp
项目概览
IoTSharp
/
IoTSharp
10 个月 前同步成功
通知
15
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
IoTSharp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
0fecf0ab
编写于
2月 15, 2021
作者:
麦壳饼
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add to IoTSharp.Data.MySQL
上级
baaff3dc
变更
14
展开全部
隐藏空白更改
内联
并排
Showing
14 changed file
with
2306 addition
and
56 deletion
+2306
-56
IoTSharp.ClientApp/IoTSharp.ClientApp.csproj
IoTSharp.ClientApp/IoTSharp.ClientApp.csproj
+1
-1
IoTSharp.Data.MySQL/IoTSharp.Data.MySQL.csproj
IoTSharp.Data.MySQL/IoTSharp.Data.MySQL.csproj
+23
-0
IoTSharp.Data.MySQL/IoTSharpDataBuilderExtensions.cs
IoTSharp.Data.MySQL/IoTSharpDataBuilderExtensions.cs
+30
-0
IoTSharp.Data.MySQL/Migrations/20210214185821_MySQLFirstSchema.Designer.cs
...QL/Migrations/20210214185821_MySQLFirstSchema.Designer.cs
+769
-0
IoTSharp.Data.MySQL/Migrations/20210214185821_MySQLFirstSchema.cs
....Data.MySQL/Migrations/20210214185821_MySQLFirstSchema.cs
+592
-0
IoTSharp.Data.MySQL/Migrations/ApplicationDbContextModelSnapshot.cs
...ata.MySQL/Migrations/ApplicationDbContextModelSnapshot.cs
+767
-0
IoTSharp.Data.PostgreSQL/IoTSharp.Data.PostgreSQL.csproj
IoTSharp.Data.PostgreSQL/IoTSharp.Data.PostgreSQL.csproj
+18
-13
IoTSharp.Data.PostgreSQL/IoTSharpDataBuilderExtensions.cs
IoTSharp.Data.PostgreSQL/IoTSharpDataBuilderExtensions.cs
+30
-0
IoTSharp.Data/IoTSharp.Data.csproj
IoTSharp.Data/IoTSharp.Data.csproj
+2
-0
IoTSharp.sln
IoTSharp.sln
+24
-2
IoTSharp/AppSettings.cs
IoTSharp/AppSettings.cs
+0
-2
IoTSharp/IoTSharp.csproj
IoTSharp/IoTSharp.csproj
+6
-6
IoTSharp/Startup.cs
IoTSharp/Startup.cs
+40
-30
IoTSharp/appsettings.Development.json
IoTSharp/appsettings.Development.json
+4
-2
未找到文件。
IoTSharp.ClientApp/IoTSharp.ClientApp.csproj
浏览文件 @
0fecf0ab
...
...
@@ -9,7 +9,7 @@
<ItemGroup>
<PackageReference Include="AntDesign" Version="0.6.0" />
<PackageReference Include="AntDesign.Charts" Version="0.2.0-*" />
<PackageReference Include="AntDesign.Pro.Layout" Version="0.1.0-nightly-2
01127071242
" />
<PackageReference Include="AntDesign.Pro.Layout" Version="0.1.0-nightly-2
10129055145
" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.3" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="5.0.3" />
...
...
IoTSharp.Data.MySQL/IoTSharp.Data.MySQL.csproj
0 → 100644
浏览文件 @
0fecf0ab
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.MySql" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.UI.MySql.Storage" Version="5.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="5.0.3" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.0-alpha.2" />
<PackageReference Include="EFCore.Sharding.MySql" Version="5.0.0.6" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\IoTSharp.Data\IoTSharp.Data.csproj" />
</ItemGroup>
</Project>
IoTSharp.Data.MySQL/IoTSharpDataBuilderExtensions.cs
0 → 100644
浏览文件 @
0fecf0ab
using
EFCore.Sharding
;
using
IoTSharp.Data
;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.Extensions.DependencyInjection
;
using
System
;
namespace
Microsoft.Extensions.DependencyInjection
{
public
static
class
IoTSharpDataBuilderExtensions
{
public
static
void
ConfigureMySql
(
this
IServiceCollection
services
,
string
connectionString
,
int
poolSize
,
IHealthChecksBuilder
checksBuilder
,
HealthChecksUIBuilder
healthChecksUI
)
{
services
.
AddDbContextPool
<
ApplicationDbContext
>(
builder
=>
{
builder
.
UseMySql
(
connectionString
,
ServerVersion
.
AutoDetect
(
connectionString
),
s
=>
s
.
MigrationsAssembly
(
"IoTSharp.Data.MySQL"
));
}
,
poolSize
);
checksBuilder
.
AddMySql
(
connectionString
,
"IoTSharp.Data.MySQL"
);
healthChecksUI
.
AddMySqlStorage
(
connectionString
);
}
public
static
void
UseMySqlToSharding
(
this
IShardingBuilder
builder
,
string
connectionString
,
ExpandByDateMode
expandBy
)
{
builder
.
AddDataSource
(
connectionString
,
ReadWriteType
.
Read
|
ReadWriteType
.
Write
,
DatabaseType
.
MySql
);
builder
.
SetDateSharding
<
TelemetryData
>(
nameof
(
TelemetryData
.
DateTime
),
expandBy
,
DateTime
.
Now
);
}
}
}
IoTSharp.Data.MySQL/Migrations/20210214185821_MySQLFirstSchema.Designer.cs
0 → 100644
浏览文件 @
0fecf0ab
此差异已折叠。
点击以展开。
IoTSharp.Data.MySQL/Migrations/20210214185821_MySQLFirstSchema.cs
0 → 100644
浏览文件 @
0fecf0ab
此差异已折叠。
点击以展开。
IoTSharp.Data.MySQL/Migrations/ApplicationDbContextModelSnapshot.cs
0 → 100644
浏览文件 @
0fecf0ab
此差异已折叠。
点击以展开。
IoTSharp.Data.PostgreSQL/IoTSharp.Data.PostgreSQL.csproj
浏览文件 @
0fecf0ab
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.2" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.NpgSql" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.UI.PostgreSQL.Storage" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Core" Version="5.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="5.0.3" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.2" />
<PackageReference Include="EFCore.Sharding.PostgreSql" Version="5.0.0.6" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\IoTSharp.Data\IoTSharp.Data.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\IoTSharp.Data\IoTSharp.Data.csproj" />
</ItemGroup>
</Project>
IoTSharp.Data.PostgreSQL/IoTSharpDataBuilderExtensions.cs
0 → 100644
浏览文件 @
0fecf0ab
using
EFCore.Sharding
;
using
IoTSharp.Data
;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.Extensions.DependencyInjection
;
using
System
;
namespace
Microsoft.Extensions.DependencyInjection
{
public
static
class
IoTSharpDataBuilderExtensions
{
public
static
void
ConfigureNpgsql
(
this
IServiceCollection
services
,
string
connectionString
,
int
poolSize
,
IHealthChecksBuilder
checksBuilder
,
HealthChecksUIBuilder
healthChecksUI
)
{
services
.
AddDbContextPool
<
ApplicationDbContext
>(
builder
=>
{
builder
.
UseNpgsql
(
connectionString
,
s
=>
s
.
MigrationsAssembly
(
"IoTSharp.Data.PostgreSQL"
));
}
,
poolSize
);
checksBuilder
.
AddNpgSql
(
connectionString
);
healthChecksUI
.
AddPostgreSqlStorage
(
connectionString
);
}
public
static
void
UseNpgsqlToSharding
(
this
IShardingBuilder
builder
,
string
connectionString
,
ExpandByDateMode
expandBy
)
{
builder
.
AddDataSource
(
connectionString
,
ReadWriteType
.
Read
|
ReadWriteType
.
Write
,
DatabaseType
.
PostgreSql
);
builder
.
SetDateSharding
<
TelemetryData
>(
nameof
(
TelemetryData
.
DateTime
),
expandBy
,
DateTime
.
Now
);
}
}
}
IoTSharp.Data/IoTSharp.Data.csproj
浏览文件 @
0fecf0ab
...
...
@@ -9,6 +9,8 @@
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="EFCore.Sharding" Version="5.0.0.6" />
</ItemGroup>
</Project>
IoTSharp.sln
浏览文件 @
0fecf0ab
...
...
@@ -43,9 +43,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTSharp.Sdk.Http", "IoTSha
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTSharp.Sdk.MQTT", "IoTSharp.SDKs\IoTSharp.Sdk.MQTT\IoTSharp.Sdk.MQTT.csproj", "{A2A1191C-32ED-482B-AACE-4091EE518CEC}"
EndProject
Project("{
FAE04EC0-301F-11D3-BF4B-00C04F79EFBC
}") = "IoTSharp.Data.PostgreSQL", "IoTSharp.Data.PostgreSQL\IoTSharp.Data.PostgreSQL.csproj", "{0A6EAEEC-79A3-406B-9897-C3DA17F06BB9}"
Project("{
9A19103F-16F7-4668-BE54-9A1E7A4F7556
}") = "IoTSharp.Data.PostgreSQL", "IoTSharp.Data.PostgreSQL\IoTSharp.Data.PostgreSQL.csproj", "{0A6EAEEC-79A3-406B-9897-C3DA17F06BB9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IoTSharp.Data", "IoTSharp.Data\IoTSharp.Data.csproj", "{522B2676-EB0E-4191-ACBC-EDC86DD2351D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTSharp.Data", "IoTSharp.Data\IoTSharp.Data.csproj", "{522B2676-EB0E-4191-ACBC-EDC86DD2351D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IoTSharp.Data.MySQL", "IoTSharp.Data.MySQL\IoTSharp.Data.MySQL.csproj", "{233F2C8D-DD4C-49B7-99A2-F3DB5620DEFB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
...
...
@@ -276,6 +278,26 @@ Global
{522B2676-EB0E-4191-ACBC-EDC86DD2351D}.Release|x64.Build.0 = Release|Any CPU
{522B2676-EB0E-4191-ACBC-EDC86DD2351D}.Release|x86.ActiveCfg = Release|Any CPU
{522B2676-EB0E-4191-ACBC-EDC86DD2351D}.Release|x86.Build.0 = Release|Any CPU
{233F2C8D-DD4C-49B7-99A2-F3DB5620DEFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{233F2C8D-DD4C-49B7-99A2-F3DB5620DEFB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{233F2C8D-DD4C-49B7-99A2-F3DB5620DEFB}.Debug|ARM.ActiveCfg = Debug|Any CPU
{233F2C8D-DD4C-49B7-99A2-F3DB5620DEFB}.Debug|ARM.Build.0 = Debug|Any CPU
{233F2C8D-DD4C-49B7-99A2-F3DB5620DEFB}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{233F2C8D-DD4C-49B7-99A2-F3DB5620DEFB}.Debug|ARM64.Build.0 = Debug|Any CPU
{233F2C8D-DD4C-49B7-99A2-F3DB5620DEFB}.Debug|x64.ActiveCfg = Debug|Any CPU
{233F2C8D-DD4C-49B7-99A2-F3DB5620DEFB}.Debug|x64.Build.0 = Debug|Any CPU
{233F2C8D-DD4C-49B7-99A2-F3DB5620DEFB}.Debug|x86.ActiveCfg = Debug|Any CPU
{233F2C8D-DD4C-49B7-99A2-F3DB5620DEFB}.Debug|x86.Build.0 = Debug|Any CPU
{233F2C8D-DD4C-49B7-99A2-F3DB5620DEFB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{233F2C8D-DD4C-49B7-99A2-F3DB5620DEFB}.Release|Any CPU.Build.0 = Release|Any CPU
{233F2C8D-DD4C-49B7-99A2-F3DB5620DEFB}.Release|ARM.ActiveCfg = Release|Any CPU
{233F2C8D-DD4C-49B7-99A2-F3DB5620DEFB}.Release|ARM.Build.0 = Release|Any CPU
{233F2C8D-DD4C-49B7-99A2-F3DB5620DEFB}.Release|ARM64.ActiveCfg = Release|Any CPU
{233F2C8D-DD4C-49B7-99A2-F3DB5620DEFB}.Release|ARM64.Build.0 = Release|Any CPU
{233F2C8D-DD4C-49B7-99A2-F3DB5620DEFB}.Release|x64.ActiveCfg = Release|Any CPU
{233F2C8D-DD4C-49B7-99A2-F3DB5620DEFB}.Release|x64.Build.0 = Release|Any CPU
{233F2C8D-DD4C-49B7-99A2-F3DB5620DEFB}.Release|x86.ActiveCfg = Release|Any CPU
{233F2C8D-DD4C-49B7-99A2-F3DB5620DEFB}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
...
...
IoTSharp/AppSettings.cs
浏览文件 @
0fecf0ab
using
CoAP
;
using
CoAP.Server
;
using
DotNetCore.CAP.Dashboard.NodeDiscovery
;
using
EFCore.Sharding
;
using
IoTSharp.Data
;
using
MaiKeBing.CAP
;
using
MaiKeBing.HostedService.ZeroMQ
;
using
Newtonsoft.Json
;
using
Newtonsoft.Json.Converters
;
...
...
IoTSharp/IoTSharp.csproj
浏览文件 @
0fecf0ab
...
...
@@ -40,18 +40,18 @@
<PackageReference Include="AspNetCore.HealthChecks.Kafka" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.MongoDb" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.Network" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.NpgSql" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.Redis" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.System" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.UI" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.UI.InMemory.Storage" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.UI.PostgreSQL.Storage" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.UI.SQLite.Storage" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.Network" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.NpgSql" Version="5.0.1" />
<PackageReference Include="CAP.Extensions" Version="1.0.31" />
<PackageReference Include="DotNetCore.CAP" Version="3.1.2" />
<PackageReference Include="DotNetCore.CAP.Dashboard" Version="3.1.2" />
...
...
@@ -64,8 +64,7 @@
<PackageReference Include="EasyCaching.InMemory" Version="1.2.0" />
<PackageReference Include="EasyCaching.LiteDB" Version="1.2.0" />
<PackageReference Include="EasyCaching.Redis" Version="1.2.1" />
<PackageReference Include="EFCore.Sharding" Version="5.0.0.6" />
<PackageReference Include="EFCore.Sharding.PostgreSql" Version="5.0.0.6" />
<PackageReference Include="GitVersionTask" Version="5.5.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
...
...
@@ -91,6 +90,7 @@
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" />
<PackageReference Include="MQTTnet" Version="3.0.14" />
<PackageReference Include="MQTTnet.AspNetCore" Version="3.0.14" />
<PackageReference Include="MQTTnet.AspNetCoreEx" Version="3.0.14" />
<PackageReference Include="MQTTnet.Extensions.Rpc" Version="3.0.14" />
<PackageReference Include="NetMQ" Version="4.0.1.6" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.2" />
...
...
@@ -114,7 +114,6 @@
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
<PackageReference Include="MQTTnet.AspNetCoreEx" Version="3.0.13" />
<PackageReference Include="MQTTnet.Extensions.ManagedClient" Version="3.0.14" />
</ItemGroup>
<ItemGroup>
...
...
@@ -139,6 +138,7 @@
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\IoTSharp.Data.MySQL\IoTSharp.Data.MySQL.csproj" />
<ProjectReference Include="..\IoTSharp.Data.PostgreSQL\IoTSharp.Data.PostgreSQL.csproj" />
<ProjectReference Include="..\IoTSharp.Data\IoTSharp.Data.csproj" />
</ItemGroup>
...
...
IoTSharp/Startup.cs
浏览文件 @
0fecf0ab
...
...
@@ -72,18 +72,35 @@ namespace IoTSharp
{
Configuration
.
Bind
(
setting
);
}));
services
.
AddDbContextPool
<
ApplicationDbContext
>(
options
=>
var
healthChecksUI
=
services
.
AddHealthChecksUI
(
setup
=>
{
switch
(
settings
.
DataBase
)
{
case
DataBaseType
.
PostgreSql
:
default
:
options
.
UseNpgsql
(
Configuration
.
GetConnectionString
(
"IoTSharp"
),
s
=>
s
.
MigrationsAssembly
(
"IoTSharp.Data.PostgreSQL"
));
break
;
}
setup
.
SetHeaderText
(
"IoTSharp HealthChecks"
);
//Maximum history entries by endpoint
setup
.
MaximumHistoryEntriesPerEndpoint
(
50
);
setup
.
AddIoTSharpHealthCheckEndpoint
();
});
var
healthChecks
=
services
.
AddHealthChecks
()
.
AddDiskStorageHealthCheck
(
dso
=>
{
System
.
IO
.
DriveInfo
.
GetDrives
()
.
Where
(
d
=>
d
.
DriveType
!=
System
.
IO
.
DriveType
.
CDRom
&&
d
.
DriveType
!=
System
.
IO
.
DriveType
.
Ram
)
.
Select
(
f
=>
f
.
Name
).
Distinct
().
ToList
()
.
ForEach
(
f
=>
dso
.
AddDrive
(
f
,
1024
));
},
name
:
"Disk Storage"
);
switch
(
settings
.
DataBase
)
{
case
DataBaseType
.
MySql
:
services
.
ConfigureMySql
(
Configuration
.
GetConnectionString
(
"IoTSharp"
),
settings
.
DbContextPoolSize
,
healthChecks
,
healthChecksUI
);
break
;
case
DataBaseType
.
PostgreSql
:
default
:
services
.
ConfigureNpgsql
(
Configuration
.
GetConnectionString
(
"IoTSharp"
),
settings
.
DbContextPoolSize
,
healthChecks
,
healthChecksUI
);
break
;
}
,
poolSize
:
settings
.
DbContextPoolSize
);
services
.
AddIdentity
<
IdentityUser
,
IdentityRole
>()
.
AddRoles
<
IdentityRole
>()
.
AddRoleManager
<
RoleManager
<
IdentityRole
>>()
...
...
@@ -128,24 +145,8 @@ namespace IoTSharp
services
.
AddMqttClient
(
settings
.
MqttClient
);
services
.
AddSingleton
<
RetainedMessageHandler
>();
var
healthChecks
=
services
.
AddHealthChecks
()
.
AddNpgSql
(
Configuration
.
GetConnectionString
(
"IoTSharp"
),
name
:
"PostgreSQL"
)
.
AddDiskStorageHealthCheck
(
dso
=>
{
System
.
IO
.
DriveInfo
.
GetDrives
()
.
Where
(
d
=>
d
.
DriveType
!=
System
.
IO
.
DriveType
.
CDRom
&&
d
.
DriveType
!=
System
.
IO
.
DriveType
.
Ram
)
.
Select
(
f
=>
f
.
Name
).
Distinct
().
ToList
()
.
ForEach
(
f
=>
dso
.
AddDrive
(
f
,
1024
));
},
name
:
"Disk Storage"
);
services
.
AddHealthChecksUI
(
setup
=>
{
setup
.
SetHeaderText
(
"IoTSharp HealthChecks"
);
//Maximum history entries by endpoint
setup
.
MaximumHistoryEntriesPerEndpoint
(
50
);
setup
.
AddIoTSharpHealthCheckEndpoint
();
}).
AddPostgreSqlStorage
(
Configuration
.
GetConnectionString
(
"IoTSharp"
));
services
.
AddSilkierQuartz
(
opt
=>
{
...
...
@@ -194,8 +195,17 @@ namespace IoTSharp
case
TelemetryStorage
.
Sharding
:
services
.
AddEFCoreSharding
(
config
=>
{
config
.
AddDataSource
(
Configuration
.
GetConnectionString
(
"TelemetryStorage"
),
ReadWriteType
.
Read
|
ReadWriteType
.
Write
,
settings
.
Sharding
.
DatabaseType
);
config
.
SetDateSharding
<
TelemetryData
>(
nameof
(
TelemetryData
.
DateTime
),
settings
.
Sharding
.
ExpandByDateMode
,
DateTime
.
Now
);
switch
(
settings
.
DataBase
)
{
case
DataBaseType
.
MySql
:
config
.
UseMySqlToSharding
(
Configuration
.
GetConnectionString
(
"TelemetryStorage"
),
settings
.
Sharding
.
ExpandByDateMode
);
break
;
case
DataBaseType
.
PostgreSql
:
default
:
config
.
UseNpgsqlToSharding
(
Configuration
.
GetConnectionString
(
"TelemetryStorage"
),
settings
.
Sharding
.
ExpandByDateMode
);
break
;
}
});
services
.
AddSingleton
<
IStorage
,
ShardingStorage
>();
break
;
...
...
IoTSharp/appsettings.Development.json
浏览文件 @
0fecf0ab
...
...
@@ -6,8 +6,10 @@
"Microsoft"
:
"Information"
}
},
"DataBase"
:
"MySql"
,
"ConnectionStrings"
:
{
"IoTSharp"
:
"Server=localhost;Database=IoTSharp;Username=postgres;Password=future;"
,
//pgsql
"IoTSharp"
:
"Server=localhost;Database=IoTSharp;Username=postgres;Password=future;"
,
"IoTSharp"
:
"server=localhost;user=root;password=kissme;database=IoTSharp"
,
"EventBusStore"
:
"mongodb://root:kissme@mongodb:27017"
,
"TelemetryStorage"
:
"DataSource=taos;DataBase=IoTSharp;Username=root;Password=taosdata;Port=6030"
,
"EventBusMQ"
:
"amqp://root:kissme@rabbitmq:5672"
...
...
@@ -19,7 +21,7 @@
"JwtAudience"
:
"IoTSharp.Net"
,
"EventBusStore"
:
"InMemory"
,
"EventBusMQ"
:
"InMemory"
,
"TelemetryStorage"
:
"
Taos
"
"TelemetryStorage"
:
"
Sharding
"
//
"Discovery"
:
{
//
"DiscoveryServerHostName"
:
"iotsharp"
,
//
"DiscoveryServerPort"
:
8500
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录