Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
IoTSharp
IoTSharp
提交
9350745e
IoTSharp
项目概览
IoTSharp
/
IoTSharp
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
9350745e
编写于
2月 15, 2021
作者:
麦壳饼
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
针对sqlserver测试完成
上级
fed32198
变更
14
展开全部
隐藏空白更改
内联
并排
Showing
14 changed file
with
2372 addition
and
5 deletion
+2372
-5
IoTSharp.Data.SqlServer/IoTSharp.Data.SqlServer.csproj
IoTSharp.Data.SqlServer/IoTSharp.Data.SqlServer.csproj
+19
-0
IoTSharp.Data.SqlServer/IoTSharpDataBuilderExtensions.cs
IoTSharp.Data.SqlServer/IoTSharpDataBuilderExtensions.cs
+36
-0
IoTSharp.Data.SqlServer/Migrations/20210215110232_SQLServerFirstSchema.Designer.cs
...igrations/20210215110232_SQLServerFirstSchema.Designer.cs
+775
-0
IoTSharp.Data.SqlServer/Migrations/20210215110232_SQLServerFirstSchema.cs
...lServer/Migrations/20210215110232_SQLServerFirstSchema.cs
+593
-0
IoTSharp.Data.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs
...SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs
+773
-0
IoTSharp.Data.SqlServer/MsSqlModelBuilderOptions.cs
IoTSharp.Data.SqlServer/MsSqlModelBuilderOptions.cs
+72
-0
IoTSharp.sln
IoTSharp.sln
+23
-1
IoTSharp/IoTSharp.csproj
IoTSharp/IoTSharp.csproj
+1
-0
IoTSharp/Startup.cs
IoTSharp/Startup.cs
+6
-0
IoTSharp/appsettings.Development.json
IoTSharp/appsettings.Development.json
+0
-2
IoTSharp/appsettings.MySql.json
IoTSharp/appsettings.MySql.json
+23
-0
IoTSharp/appsettings.PostgreSql.json
IoTSharp/appsettings.PostgreSql.json
+24
-0
IoTSharp/appsettings.SQLServer.json
IoTSharp/appsettings.SQLServer.json
+23
-0
tools/ef_mg_add.cmd
tools/ef_mg_add.cmd
+4
-2
未找到文件。
IoTSharp.Data.SqlServer/IoTSharp.Data.SqlServer.csproj
0 → 100644
浏览文件 @
9350745e
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="5.0.2" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Core" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.UI.SqlServer.Storage" Version="5.0.1" />
<PackageReference Include="EFCore.Sharding.SqlServer" Version="5.0.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\IoTSharp.Data\IoTSharp.Data.csproj" />
</ItemGroup>
</Project>
IoTSharp.Data.SqlServer/IoTSharpDataBuilderExtensions.cs
0 → 100644
浏览文件 @
9350745e
using
EFCore.Sharding
;
using
IoTSharp.Data
;
using
IoTSharp.Data.SqlServer
;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.Extensions.DependencyInjection
;
using
System
;
namespace
Microsoft.Extensions.DependencyInjection
{
public
static
class
IoTSharpDataBuilderExtensions
{
public
static
void
ConfigureSqlServer
(
this
IServiceCollection
services
,
string
connectionString
,
int
poolSize
,
IHealthChecksBuilder
checksBuilder
,
HealthChecksUIBuilder
healthChecksUI
)
{
services
.
AddEntityFrameworkSqlServer
();
services
.
AddSingleton
<
IDataBaseModelBuilderOptions
>(
c
=>
new
MsSqlModelBuilderOptions
());
services
.
AddDbContextPool
<
ApplicationDbContext
>(
builder
=>
{
builder
.
UseSqlServer
(
connectionString
,
s
=>
s
.
MigrationsAssembly
(
"IoTSharp.Data.SqlServer"
));
builder
.
UseInternalServiceProvider
(
services
.
BuildServiceProvider
());
}
,
poolSize
);
checksBuilder
.
AddSqlServer
(
connectionString
);
healthChecksUI
.
AddSqlServerStorage
(
connectionString
);
}
public
static
void
UseSqlServerToSharding
(
this
IShardingBuilder
builder
,
string
connectionString
,
ExpandByDateMode
expandBy
)
{
builder
.
AddDataSource
(
connectionString
,
ReadWriteType
.
Read
|
ReadWriteType
.
Write
,
DatabaseType
.
SqlServer
);
builder
.
SetDateSharding
<
TelemetryData
>(
nameof
(
TelemetryData
.
DateTime
),
expandBy
,
DateTime
.
Now
);
}
}
}
IoTSharp.Data.SqlServer/Migrations/20210215110232_SQLServerFirstSchema.Designer.cs
0 → 100644
浏览文件 @
9350745e
此差异已折叠。
点击以展开。
IoTSharp.Data.SqlServer/Migrations/20210215110232_SQLServerFirstSchema.cs
0 → 100644
浏览文件 @
9350745e
此差异已折叠。
点击以展开。
IoTSharp.Data.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs
0 → 100644
浏览文件 @
9350745e
此差异已折叠。
点击以展开。
IoTSharp.Data.SqlServer/MsSqlModelBuilderOptions.cs
0 → 100644
浏览文件 @
9350745e
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Infrastructure
;
using
System
;
namespace
IoTSharp.Data.SqlServer
{
public
class
MsSqlModelBuilderOptions
:
IDataBaseModelBuilderOptions
{
public
MsSqlModelBuilderOptions
()
{
}
public
IInfrastructure
<
IServiceProvider
>
Infrastructure
{
get
;
set
;
}
public
void
OnModelCreating
(
ModelBuilder
modelBuilder
)
{
//modelBuilder.Entity<TelemetryData>()
//.Property(b => b.DateTime)
//.HasColumnType("timestamp with time zone");
//modelBuilder.Entity<TelemetryData>()
//.Property(b => b.Value_DateTime)
//.HasColumnType("timestamp with time zone");
//modelBuilder.Entity<TelemetryLatest>()
//.Property(b => b.DateTime)
//.HasColumnType("timestamp with time zone");
//modelBuilder.Entity<TelemetryLatest>()
//.Property(b => b.Value_DateTime)
//.HasColumnType("timestamp with time zone");
//modelBuilder.Entity<AttributeLatest>()
//.Property(b => b.DateTime)
//.HasColumnType("timestamp with time zone");
//modelBuilder.Entity<AttributeLatest>()
//.Property(b => b.Value_DateTime)
//.HasColumnType("timestamp with time zone");
//modelBuilder.Entity<TelemetryData>()
//.Property(b => b.Value_Json)
//.HasColumnType("jsonb");
//modelBuilder.Entity<TelemetryData>()
//.Property(b => b.Value_XML)
//.HasColumnType("xml");
//modelBuilder.Entity<AttributeLatest>()
//.Property(b => b.Value_Json)
//.HasColumnType("jsonb");
//modelBuilder.Entity<AttributeLatest>()
//.Property(b => b.Value_XML)
//.HasColumnType("xml");
//modelBuilder.Entity<TelemetryLatest>()
//.Property(b => b.Value_Json)
//.HasColumnType("jsonb");
//modelBuilder.Entity<TelemetryLatest>()
//.Property(b => b.Value_XML)
//.HasColumnType("xml");
//modelBuilder.Entity<AuditLog>()
//.Property(b => b.ActionData)
//.HasColumnType("jsonb");
//modelBuilder.Entity<AuditLog>()
//.Property(b => b.ActionResult)
//.HasColumnType("jsonb");
}
}
}
\ No newline at end of file
IoTSharp.sln
浏览文件 @
9350745e
...
...
@@ -47,7 +47,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTSharp.Data.PostgreSQL",
EndProject
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}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTSharp.Data.MySQL", "IoTSharp.Data.MySQL\IoTSharp.Data.MySQL.csproj", "{233F2C8D-DD4C-49B7-99A2-F3DB5620DEFB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IoTSharp.Data.SqlServer", "IoTSharp.Data.SqlServer\IoTSharp.Data.SqlServer.csproj", "{1B3287BE-4FC5-45C7-BA45-D6A3A92D30C8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
...
...
@@ -298,6 +300,26 @@ Global
{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
{1B3287BE-4FC5-45C7-BA45-D6A3A92D30C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B3287BE-4FC5-45C7-BA45-D6A3A92D30C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B3287BE-4FC5-45C7-BA45-D6A3A92D30C8}.Debug|ARM.ActiveCfg = Debug|Any CPU
{1B3287BE-4FC5-45C7-BA45-D6A3A92D30C8}.Debug|ARM.Build.0 = Debug|Any CPU
{1B3287BE-4FC5-45C7-BA45-D6A3A92D30C8}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{1B3287BE-4FC5-45C7-BA45-D6A3A92D30C8}.Debug|ARM64.Build.0 = Debug|Any CPU
{1B3287BE-4FC5-45C7-BA45-D6A3A92D30C8}.Debug|x64.ActiveCfg = Debug|Any CPU
{1B3287BE-4FC5-45C7-BA45-D6A3A92D30C8}.Debug|x64.Build.0 = Debug|Any CPU
{1B3287BE-4FC5-45C7-BA45-D6A3A92D30C8}.Debug|x86.ActiveCfg = Debug|Any CPU
{1B3287BE-4FC5-45C7-BA45-D6A3A92D30C8}.Debug|x86.Build.0 = Debug|Any CPU
{1B3287BE-4FC5-45C7-BA45-D6A3A92D30C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B3287BE-4FC5-45C7-BA45-D6A3A92D30C8}.Release|Any CPU.Build.0 = Release|Any CPU
{1B3287BE-4FC5-45C7-BA45-D6A3A92D30C8}.Release|ARM.ActiveCfg = Release|Any CPU
{1B3287BE-4FC5-45C7-BA45-D6A3A92D30C8}.Release|ARM.Build.0 = Release|Any CPU
{1B3287BE-4FC5-45C7-BA45-D6A3A92D30C8}.Release|ARM64.ActiveCfg = Release|Any CPU
{1B3287BE-4FC5-45C7-BA45-D6A3A92D30C8}.Release|ARM64.Build.0 = Release|Any CPU
{1B3287BE-4FC5-45C7-BA45-D6A3A92D30C8}.Release|x64.ActiveCfg = Release|Any CPU
{1B3287BE-4FC5-45C7-BA45-D6A3A92D30C8}.Release|x64.Build.0 = Release|Any CPU
{1B3287BE-4FC5-45C7-BA45-D6A3A92D30C8}.Release|x86.ActiveCfg = Release|Any CPU
{1B3287BE-4FC5-45C7-BA45-D6A3A92D30C8}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
...
...
IoTSharp/IoTSharp.csproj
浏览文件 @
9350745e
...
...
@@ -140,6 +140,7 @@
<ItemGroup>
<ProjectReference Include="..\IoTSharp.Data.MySQL\IoTSharp.Data.MySQL.csproj" />
<ProjectReference Include="..\IoTSharp.Data.PostgreSQL\IoTSharp.Data.PostgreSQL.csproj" />
<ProjectReference Include="..\IoTSharp.Data.SqlServer\IoTSharp.Data.SqlServer.csproj" />
<ProjectReference Include="..\IoTSharp.Data\IoTSharp.Data.csproj" />
</ItemGroup>
</Project>
\ No newline at end of file
IoTSharp/Startup.cs
浏览文件 @
9350745e
...
...
@@ -95,6 +95,9 @@ namespace IoTSharp
case
DataBaseType
.
MySql
:
services
.
ConfigureMySql
(
Configuration
.
GetConnectionString
(
"IoTSharp"
),
settings
.
DbContextPoolSize
,
healthChecks
,
healthChecksUI
);
break
;
case
DataBaseType
.
SqlServer
:
services
.
ConfigureSqlServer
(
Configuration
.
GetConnectionString
(
"IoTSharp"
),
settings
.
DbContextPoolSize
,
healthChecks
,
healthChecksUI
);
break
;
case
DataBaseType
.
PostgreSql
:
default
:
services
.
ConfigureNpgsql
(
Configuration
.
GetConnectionString
(
"IoTSharp"
),
settings
.
DbContextPoolSize
,
healthChecks
,
healthChecksUI
);
...
...
@@ -200,6 +203,9 @@ namespace IoTSharp
case
DataBaseType
.
MySql
:
config
.
UseMySqlToSharding
(
Configuration
.
GetConnectionString
(
"TelemetryStorage"
),
settings
.
Sharding
.
ExpandByDateMode
);
break
;
case
DataBaseType
.
SqlServer
:
config
.
UseSqlServerToSharding
(
Configuration
.
GetConnectionString
(
"TelemetryStorage"
),
settings
.
Sharding
.
ExpandByDateMode
);
break
;
case
DataBaseType
.
PostgreSql
:
default
:
config
.
UseNpgsqlToSharding
(
Configuration
.
GetConnectionString
(
"TelemetryStorage"
),
settings
.
Sharding
.
ExpandByDateMode
);
...
...
IoTSharp/appsettings.Development.json
浏览文件 @
9350745e
...
...
@@ -8,12 +8,10 @@
},
"DataBase"
:
"MySql"
,
"ConnectionStrings"
:
{
//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"
//
"TelemetryStorage"
:
"http://localhost:8086/?org=iotsharp&bucket=iotsharp-bucket&token=iotsharp-token&&latest=-72h"
},
"JwtKey"
:
"kissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissme"
,
"JwtExpireHours"
:
24
,
...
...
IoTSharp/appsettings.MySql.json
0 → 100644
浏览文件 @
9350745e
{
"Logging"
:
{
"LogLevel"
:
{
"Default"
:
"Debug"
,
"System"
:
"Information"
,
"Microsoft"
:
"Information"
}
},
"DataBase"
:
"MySql"
,
"ConnectionStrings"
:
{
"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"
},
"JwtKey"
:
"kissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissme"
,
"JwtExpireHours"
:
24
,
"JwtIssuer"
:
"IoTSharp.Net"
,
"JwtAudience"
:
"IoTSharp.Net"
,
"EventBusStore"
:
"InMemory"
,
"EventBusMQ"
:
"InMemory"
,
"TelemetryStorage"
:
"Sharding"
}
\ No newline at end of file
IoTSharp/appsettings.PostgreSql.json
0 → 100644
浏览文件 @
9350745e
{
"Logging"
:
{
"LogLevel"
:
{
"Default"
:
"Debug"
,
"System"
:
"Information"
,
"Microsoft"
:
"Information"
}
},
"DataBase"
:
"PostgreSql"
,
"ConnectionStrings"
:
{
"IoTSharp"
:
"Server=localhost;Database=IoTSharp;Username=postgres;Password=future;"
,
"EventBusStore"
:
"mongodb://root:kissme@mongodb:27017"
,
"TelemetryStorage"
:
"DataSource=taos;DataBase=IoTSharp;Username=root;Password=taosdata;Port=6030"
,
"EventBusMQ"
:
"amqp://root:kissme@rabbitmq:5672"
},
"JwtKey"
:
"kissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissme"
,
"JwtExpireHours"
:
24
,
"JwtIssuer"
:
"IoTSharp.Net"
,
"JwtAudience"
:
"IoTSharp.Net"
,
"EventBusStore"
:
"InMemory"
,
"EventBusMQ"
:
"InMemory"
,
"TelemetryStorage"
:
"Sharding"
}
\ No newline at end of file
IoTSharp/appsettings.SQLServer.json
0 → 100644
浏览文件 @
9350745e
{
"Logging"
:
{
"LogLevel"
:
{
"Default"
:
"Debug"
,
"System"
:
"Information"
,
"Microsoft"
:
"Information"
}
},
"DataBase"
:
"SQLServer"
,
"ConnectionStrings"
:
{
"IoTSharp"
:
"Data Source=.;Initial Catalog=IoTSharp;Persist Security Info=True;User ID=sa;Password=future"
,
"EventBusStore"
:
"mongodb://root:kissme@mongodb:27017"
,
"TelemetryStorage"
:
"Data Source=.;Initial Catalog=IoTSharp;Persist Security Info=True;User ID=sa;Password=future"
,
"EventBusMQ"
:
"amqp://root:kissme@rabbitmq:5672"
},
"JwtKey"
:
"kissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissme"
,
"JwtExpireHours"
:
24
,
"JwtIssuer"
:
"IoTSharp.Net"
,
"JwtAudience"
:
"IoTSharp.Net"
,
"EventBusStore"
:
"InMemory"
,
"EventBusMQ"
:
"InMemory"
,
"TelemetryStorage"
:
"Sharding"
}
\ No newline at end of file
tools/ef_mg_add.cmd
浏览文件 @
9350745e
cd
IoTSharp
.Data.PostgreSQL
dotnet
ef
migrations
add
%
1
--context
IoTSharp
.Data.ApplicationDbContext
--startup-project
..\IoTSharp\IoTSharp.csproj
\ No newline at end of file
echo
Add
a
migration
name
is
%
2
to
IoTSharp
.Data.
%
1
cd
IoTSharp
.Data.
%
1
set
ASPNETCORE_ENVIRONMENT
=
%
1
dotnet
ef
migrations
add
%
2
--context
IoTSharp
.Data.ApplicationDbContext
--startup-project
..\IoTSharp\IoTSharp.csproj
--project
..\IoTSharp.Data.
%
1
\IoTSharp.Data.
%
1
.csproj
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录