Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
IoTSharp
提交
7adda40d
I
IoTSharp
项目概览
jobily
/
IoTSharp
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
IoTSharp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
7adda40d
编写于
10月 28, 2021
作者:
麦壳饼
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改规则链和解析器器相关。
上级
549f3a80
变更
13
展开全部
隐藏空白更改
内联
并排
Showing
13 changed file
with
399 addition
and
251 deletion
+399
-251
IoTSharp.SDKs/IoTSharp.Sdk.CSharp/IoT.Sharp.Hub.nswag
IoTSharp.SDKs/IoTSharp.Sdk.CSharp/IoT.Sharp.Hub.nswag
+1
-1
IoTSharp.TaskExecutor/Air720Sx.cs
IoTSharp.TaskExecutor/Air720Sx.cs
+33
-0
IoTSharp.TaskExecutor/ITaskExecutor.cs
IoTSharp.TaskExecutor/ITaskExecutor.cs
+4
-2
IoTSharp.TaskExecutor/IoTSharp.TaskExecutor.csproj
IoTSharp.TaskExecutor/IoTSharp.TaskExecutor.csproj
+11
-0
IoTSharp.TaskExecutor/MessagePullExcutor.cs
IoTSharp.TaskExecutor/MessagePullExcutor.cs
+3
-4
IoTSharp.sln
IoTSharp.sln
+23
-1
IoTSharp/Controllers/RulesController.cs
IoTSharp/Controllers/RulesController.cs
+10
-8
IoTSharp/Extensions/ExecutorExtensions.cs
IoTSharp/Extensions/ExecutorExtensions.cs
+14
-0
IoTSharp/FlowRuleEngine/FlowRuleProcessor.cs
IoTSharp/FlowRuleEngine/FlowRuleProcessor.cs
+225
-233
IoTSharp/FlowRuleEngine/TaskExecutorHelper.cs
IoTSharp/FlowRuleEngine/TaskExecutorHelper.cs
+72
-0
IoTSharp/Handlers/MQTTServerHandler.cs
IoTSharp/Handlers/MQTTServerHandler.cs
+1
-2
IoTSharp/IoTSharp.csproj
IoTSharp/IoTSharp.csproj
+1
-0
IoTSharp/Startup.cs
IoTSharp/Startup.cs
+1
-0
未找到文件。
IoTSharp.SDKs/IoTSharp.Sdk.CSharp/IoT.Sharp.Hub.nswag
浏览文件 @
7adda40d
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
IoTSharp.TaskExecutor/Air720Sx.cs
0 → 100644
浏览文件 @
7adda40d
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.Dynamic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
IoTSharp.Data
;
using
IoTSharp.TaskExecutor
;
using
Newtonsoft.Json
;
using
Newtonsoft.Json.Linq
;
namespace
IoTSharp.TaskExecutor
{
[
DisplayName
(
"Air720S解析器"
)]
public
class
Air720Sx
:
ITaskExecutor
{
public
Air720Sx
()
{
}
public
TaskExecutorResult
Execute
(
TaskExecutorParam
param
)
{
var
msg
=
JsonConvert
.
DeserializeObject
<(
string
Topic
,
string
Payload
,
string
ClientId
)>(
param
.
Param
);
var
playload
=
Convert
.
FromBase64String
(
msg
.
Payload
);
return
new
TaskExecutorResult
();
}
}
}
IoTSharp
/FlowRuleEngine
/ITaskExecutor.cs
→
IoTSharp
.TaskExecutor
/ITaskExecutor.cs
浏览文件 @
7adda40d
...
...
@@ -4,7 +4,7 @@ using System.Dynamic;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
IoTSharp.
FlowRuleEngine
namespace
IoTSharp.
TaskExecutor
{
public
interface
ITaskExecutor
{
...
...
@@ -25,7 +25,7 @@ namespace IoTSharp.FlowRuleEngine
public
class
TaskExecutorResult
{
public
dynamic
Result
{
get
;
set
;
}
}
...
...
@@ -35,4 +35,6 @@ namespace IoTSharp.FlowRuleEngine
public
string
Param
{
get
;
set
;
}
}
}
IoTSharp.TaskExecutor/IoTSharp.TaskExecutor.csproj
0 → 100644
浏览文件 @
7adda40d
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\IoTSharp.Data\IoTSharp.Data.csproj" />
</ItemGroup>
</Project>
IoTSharp
/FlowRuleEngine/TaskEx
cutor/MessagePullExcutor.cs
→
IoTSharp
.TaskExe
cutor/MessagePullExcutor.cs
浏览文件 @
7adda40d
...
...
@@ -5,16 +5,16 @@ using System.Dynamic;
using
System.Linq
;
using
System.Threading.Tasks
;
using
IoTSharp.Data
;
using
IoTSharp.TaskExecutor
;
using
Newtonsoft.Json
;
using
Newtonsoft.Json.Linq
;
namespace
IoTSharp.
FlowRuleEngine.TaskEx
cutor
namespace
IoTSharp.
TaskExe
cutor
{
[
DisplayName
(
"用于消息推送的执行器"
)]
public
class
MessagePullExecutor
:
ITaskExecutor
{
private
readonly
ApplicationDbContext
_context
;
public
MessagePullExecutor
()
{
...
...
@@ -28,9 +28,8 @@ namespace IoTSharp.FlowRuleEngine.TaskExcutor
var
d
=
o
.
Property
(
"temperature"
);
d
.
Value
=
new
JValue
(
d
.
Value
.
Value
<
double
>()
+
100
);
return
new
TaskExecutorResult
()
{
Result
=
o
.
ToObject
(
typeof
(
ExpandoObject
))
};
var
p
=
JsonConvert
.
DeserializeObject
<
MessagePullParam
>(
param
.
Param
);
p
.
temperature
=
p
.
temperature
+
120
;
p
.
temperature
+=
120
;
return
new
TaskExecutorResult
()
{
Result
=
p
};
}
...
...
IoTSharp.sln
浏览文件 @
7adda40d
...
...
@@ -55,7 +55,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTSharp.Data.Oracle", "IoT
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTSharp.Data.Sqlite", "IoTSharp.Data.Sqlite\IoTSharp.Data.Sqlite.csproj", "{C4450C7C-DD38-47A2-90C7-3F774B09CD69}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IoTSharp.Interpreter", "IoTSharp.Interpreter\IoTSharp.Interpreter.csproj", "{01210118-0A41-4A6D-9B4A-06F5540B139A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTSharp.Interpreter", "IoTSharp.Interpreter\IoTSharp.Interpreter.csproj", "{01210118-0A41-4A6D-9B4A-06F5540B139A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IoTSharp.TaskExecutor", "IoTSharp.TaskExecutor\IoTSharp.TaskExecutor.csproj", "{01671BDE-398D-423C-B3E4-A05FF0AB7B4F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
...
...
@@ -366,6 +368,26 @@ Global
{01210118-0A41-4A6D-9B4A-06F5540B139A}.Release|x64.Build.0 = Release|Any CPU
{01210118-0A41-4A6D-9B4A-06F5540B139A}.Release|x86.ActiveCfg = Release|Any CPU
{01210118-0A41-4A6D-9B4A-06F5540B139A}.Release|x86.Build.0 = Release|Any CPU
{01671BDE-398D-423C-B3E4-A05FF0AB7B4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{01671BDE-398D-423C-B3E4-A05FF0AB7B4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{01671BDE-398D-423C-B3E4-A05FF0AB7B4F}.Debug|ARM.ActiveCfg = Debug|Any CPU
{01671BDE-398D-423C-B3E4-A05FF0AB7B4F}.Debug|ARM.Build.0 = Debug|Any CPU
{01671BDE-398D-423C-B3E4-A05FF0AB7B4F}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{01671BDE-398D-423C-B3E4-A05FF0AB7B4F}.Debug|ARM64.Build.0 = Debug|Any CPU
{01671BDE-398D-423C-B3E4-A05FF0AB7B4F}.Debug|x64.ActiveCfg = Debug|Any CPU
{01671BDE-398D-423C-B3E4-A05FF0AB7B4F}.Debug|x64.Build.0 = Debug|Any CPU
{01671BDE-398D-423C-B3E4-A05FF0AB7B4F}.Debug|x86.ActiveCfg = Debug|Any CPU
{01671BDE-398D-423C-B3E4-A05FF0AB7B4F}.Debug|x86.Build.0 = Debug|Any CPU
{01671BDE-398D-423C-B3E4-A05FF0AB7B4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{01671BDE-398D-423C-B3E4-A05FF0AB7B4F}.Release|Any CPU.Build.0 = Release|Any CPU
{01671BDE-398D-423C-B3E4-A05FF0AB7B4F}.Release|ARM.ActiveCfg = Release|Any CPU
{01671BDE-398D-423C-B3E4-A05FF0AB7B4F}.Release|ARM.Build.0 = Release|Any CPU
{01671BDE-398D-423C-B3E4-A05FF0AB7B4F}.Release|ARM64.ActiveCfg = Release|Any CPU
{01671BDE-398D-423C-B3E4-A05FF0AB7B4F}.Release|ARM64.Build.0 = Release|Any CPU
{01671BDE-398D-423C-B3E4-A05FF0AB7B4F}.Release|x64.ActiveCfg = Release|Any CPU
{01671BDE-398D-423C-B3E4-A05FF0AB7B4F}.Release|x64.Build.0 = Release|Any CPU
{01671BDE-398D-423C-B3E4-A05FF0AB7B4F}.Release|x86.ActiveCfg = Release|Any CPU
{01671BDE-398D-423C-B3E4-A05FF0AB7B4F}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
...
...
IoTSharp/Controllers/RulesController.cs
浏览文件 @
7adda40d
...
...
@@ -24,6 +24,7 @@ using System.Reflection;
using
System.Threading.Tasks
;
using
Dynamitey.DynamicObjects
;
using
Namotion.Reflection
;
using
IoTSharp.TaskExecutor
;
namespace
IoTSharp.Controllers
{
...
...
@@ -34,13 +35,15 @@ namespace IoTSharp.Controllers
{
private
ApplicationDbContext
_context
;
private
readonly
FlowRuleProcessor
_flowRuleProcessor
;
private
readonly
TaskExecutorHelper
_helper
;
private
UserManager
<
IdentityUser
>
_userManager
;
public
RulesController
(
ApplicationDbContext
context
,
UserManager
<
IdentityUser
>
userManager
,
FlowRuleProcessor
flowRuleProcessor
)
public
RulesController
(
ApplicationDbContext
context
,
UserManager
<
IdentityUser
>
userManager
,
FlowRuleProcessor
flowRuleProcessor
,
TaskExecutorHelper
helper
)
{
this
.
_userManager
=
userManager
;
this
.
_context
=
context
;
_flowRuleProcessor
=
flowRuleProcessor
;
_helper
=
helper
;
}
[
HttpPost
(
"[action]"
)]
...
...
@@ -1013,7 +1016,7 @@ namespace IoTSharp.Controllers
}
else
{
return
(
await
this
.
_userManager
.
FindByIdAsync
(
dto
.
Creator
.
ToString
()))?.
UserName
;
return
(
await
_userManager
.
FindByIdAsync
(
dto
.
Creator
.
ToString
()))?.
UserName
;
}
}
...
...
@@ -1021,9 +1024,9 @@ namespace IoTSharp.Controllers
[
HttpGet
(
"[action]"
)]
public
ApiResult
<
dynamic
>
GetFlowOperstions
(
Guid
eventId
)
public
ApiResult
<
dynamic
>
GetFlowOperstions
(
Guid
eventId
)
{
return
new
ApiResult
<
dynamic
>(
ApiCode
.
Success
,
"OK"
,
_context
.
FlowOperations
.
Where
(
c
=>
c
.
BaseEvent
.
EventId
==
eventId
).
ToList
().
OrderBy
(
c
=>
c
.
Step
).
return
new
ApiResult
<
dynamic
>(
ApiCode
.
Success
,
"OK"
,
_context
.
FlowOperations
.
Where
(
c
=>
c
.
BaseEvent
.
EventId
==
eventId
).
ToList
().
OrderBy
(
c
=>
c
.
Step
).
ToList
()
.
GroupBy
(
c
=>
c
.
Step
).
Select
(
c
=>
new
{
...
...
@@ -1038,9 +1041,8 @@ namespace IoTSharp.Controllers
[
HttpGet
(
"[action]"
)]
public
ApiResult
<
dynamic
>
GetExecutor
()
{
return
new
ApiResult
<
dynamic
>
(
ApiCode
.
Success
,
"OK"
,
Assembly
.
GetExecutingAssembly
().
GetTypes
().
Where
(
c
=>
c
.
GetInterfaces
().
Contains
(
typeof
(
ITaskExecutor
))).
Select
(
c
=>
new
{
label
=
c
.
GetCustomAttribute
<
DisplayNameAttribute
>()?.
DisplayName
??
c
.
FullName
,
value
=
c
.
FullName
}).
ToList
());
return
new
ApiResult
<
dynamic
>(
ApiCode
.
Success
,
"OK"
,
_helper
.
GetTaskExecutorList
().
Select
(
c
=>
new
{
label
=
c
.
Key
,
value
=
c
.
Value
.
FullName
}).
ToList
());
}
}
}
}
\ No newline at end of file
IoTSharp/Extensions/ExecutorExtensions.cs
0 → 100644
浏览文件 @
7adda40d
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
IoTSharp.Extensions
{
public
static
class
ExecutorExtensions
{
}
}
IoTSharp/FlowRuleEngine/FlowRuleProcessor.cs
浏览文件 @
7adda40d
此差异已折叠。
点击以展开。
IoTSharp/FlowRuleEngine/TaskExecutorHelper.cs
0 → 100644
浏览文件 @
7adda40d
using
IoTSharp.Data
;
using
IoTSharp.TaskExecutor
;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Options
;
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.Linq
;
using
System.Reflection
;
using
System.Threading.Tasks
;
namespace
IoTSharp.FlowRuleEngine
{
public
class
TaskExecutorHelper
{
Dictionary
<
string
,
Type
>
pairs
=
null
;
Dictionary
<
string
,
Type
>
pairstypename
=
null
;
private
IServiceProvider
_sp
;
private
ApplicationDbContext
_context
;
public
TaskExecutorHelper
(
ILogger
<
TaskExecutorHelper
>
logger
,
IServiceScopeFactory
scopeFactor
,
IOptions
<
AppSettings
>
options
)
{
_sp
=
scopeFactor
.
CreateScope
().
ServiceProvider
;
_context
=
_sp
.
GetRequiredService
<
ApplicationDbContext
>();
}
public
Dictionary
<
string
,
Type
>
GetTaskExecutorList
()
{
if
(
pairs
==
null
)
{
LoadTypesInfo
();
}
return
pairs
;
}
public
object
CreateInstance
(
string
name
)
{
if
(
pairs
==
null
)
{
LoadTypesInfo
();
}
return
Activator
.
CreateInstance
(
pairs
[
name
]);
}
public
object
CreateInstanceByTypeName
(
string
typename
)
{
if
(
pairs
==
null
)
{
LoadTypesInfo
();
}
return
Activator
.
CreateInstance
(
pairstypename
[
typename
]);
}
private
void
LoadTypesInfo
()
{
pairs
=
new
Dictionary
<
string
,
Type
>();
Assembly
.
GetEntryAssembly
().
GetTypes
().
Where
(
c
=>
c
.
GetInterfaces
().
Contains
(
typeof
(
ITaskExecutor
))).
ToList
().
ForEach
(
c
=>
{
pairs
.
Add
(
c
.
GetCustomAttribute
<
DisplayNameAttribute
>()?.
DisplayName
??
c
.
FullName
,
c
);
});
typeof
(
ITaskExecutor
).
Assembly
.
GetTypes
().
Where
(
c
=>
c
.
GetInterfaces
().
Contains
(
typeof
(
ITaskExecutor
))).
ToList
().
ForEach
(
c
=>
{
pairs
.
Add
(
c
.
GetCustomAttribute
<
DisplayNameAttribute
>()?.
DisplayName
??
c
.
FullName
,
c
);
});
pairstypename
=
new
Dictionary
<
string
,
Type
>();
pairs
.
Values
.
ToList
().
ForEach
(
t
=>
{
pairstypename
.
Add
(
t
.
FullName
,
t
);
});
}
}
}
IoTSharp/Handlers/MQTTServerHandler.cs
浏览文件 @
7adda40d
...
...
@@ -166,8 +166,7 @@ namespace IoTSharp.Handlers
,
TimeSpan
.
FromMinutes
(
5
));
if
(
rules
.
HasValue
)
{
var
obj
=
new
{
e
.
ApplicationMessage
.
Topic
,
Payload
=
e
.
ApplicationMessage
.
ConvertPayloadToString
()
};
var
obj
=
new
{
e
.
ApplicationMessage
.
Topic
,
Payload
=
Convert
.
ToBase64String
(
e
.
ApplicationMessage
.
Payload
),
e
.
ClientId
};
rules
.
Value
.
ToList
().
ForEach
(
async
g
=>
{
_logger
.
LogInformation
(
$"
{
e
.
ClientId
}
的数据
{
e
.
ApplicationMessage
.
Topic
}
通过规则链
{
g
}
进行处理。"
);
...
...
IoTSharp/IoTSharp.csproj
浏览文件 @
7adda40d
...
...
@@ -201,6 +201,7 @@
<ProjectReference Include="..\IoTSharp.Data.SqlServer\IoTSharp.Data.SqlServer.csproj" />
<ProjectReference Include="..\IoTSharp.Data\IoTSharp.Data.csproj" />
<ProjectReference Include="..\IoTSharp.Interpreter\IoTSharp.Interpreter.csproj" />
<ProjectReference Include="..\IoTSharp.TaskExecutor\IoTSharp.TaskExecutor.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="ClientApp\" />
...
...
IoTSharp/Startup.cs
浏览文件 @
7adda40d
...
...
@@ -370,6 +370,7 @@ namespace IoTSharp
});
services
.
AddScriptEngines
(
Configuration
.
GetSection
(
"EngineSetting"
));
services
.
AddTransient
<
FlowRuleProcessor
>();
services
.
AddSingleton
<
TaskExecutorHelper
>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录