Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
IoTSharp
IoTSharp
提交
aad4bd8e
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 搜索 >>
提交
aad4bd8e
编写于
10月 25, 2021
作者:
W
wq1234wq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修正编译错误
上级
a923684c
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
181 addition
and
55 deletion
+181
-55
IoTSharp/ClientApp/angular.json
IoTSharp/ClientApp/angular.json
+2
-2
IoTSharp/ClientApp/package.json
IoTSharp/ClientApp/package.json
+1
-0
IoTSharp/ClientApp/src/app/layout/basic/basic.component.ts
IoTSharp/ClientApp/src/app/layout/basic/basic.component.ts
+1
-1
IoTSharp/ClientApp/src/app/routes/device/devicecertificate/devicecertificate.component.html
...device/devicecertificate/devicecertificate.component.html
+0
-1
IoTSharp/ClientApp/src/app/routes/flow/diagram/diagram.component.html
...entApp/src/app/routes/flow/diagram/diagram.component.html
+6
-5
IoTSharp/Controllers/RulesController.cs
IoTSharp/Controllers/RulesController.cs
+4
-4
IoTSharp/FlowRuleEngine/FlowRuleProcessorV2.cs
IoTSharp/FlowRuleEngine/FlowRuleProcessorV2.cs
+161
-36
IoTSharp/Handlers/EventBusHandler.cs
IoTSharp/Handlers/EventBusHandler.cs
+2
-2
IoTSharp/Handlers/MQTTServerHandler.cs
IoTSharp/Handlers/MQTTServerHandler.cs
+2
-2
IoTSharp/IoTSharp.xml
IoTSharp/IoTSharp.xml
+1
-1
IoTSharp/Startup.cs
IoTSharp/Startup.cs
+1
-1
未找到文件。
IoTSharp/ClientApp/angular.json
浏览文件 @
aad4bd8e
...
...
@@ -62,8 +62,8 @@
"budgets"
:
[
{
"type"
:
"initial"
,
"maximumWarning"
:
"
4
mb"
,
"maximumError"
:
"
7
mb"
"maximumWarning"
:
"
7
mb"
,
"maximumError"
:
"
8
mb"
},
{
"type"
:
"anyComponentStyle"
,
...
...
IoTSharp/ClientApp/package.json
浏览文件 @
aad4bd8e
...
...
@@ -68,6 +68,7 @@
"ajv"
:
"^8.1.0"
,
"angular-baidu-maps"
:
"^11.1.0"
,
"angular-draggable-droppable"
:
"^4.6.0"
,
"babel-loader"
:
"^7.1.5"
,
"bpmn-js"
:
"^8.1.0"
,
"file-saver"
:
"^2.0.5"
,
"grapesjs"
:
"^0.17.26"
,
...
...
IoTSharp/ClientApp/src/app/layout/basic/basic.component.ts
浏览文件 @
aad4bd8e
...
...
@@ -6,7 +6,7 @@ import { environment } from '@env/environment';
@
Component
({
selector
:
'
layout-basic
'
,
template
:
`
<layout-default [options]="options" [
asideUser]="asideUserTpl" [
content]="contentTpl">
<layout-default [options]="options" [content]="contentTpl">
<layout-default-header-item direction="left">
<a layout-default-header-item-trigger href="//github.com/IoTSharp/IoTSharp" target="_blank">
<i nz-icon nzType="github"></i>
...
...
IoTSharp/ClientApp/src/app/routes/device/devicecertificate/devicecertificate.component.html
浏览文件 @
aad4bd8e
<p>
devicecertificate works!
</p>
IoTSharp/ClientApp/src/app/routes/flow/diagram/diagram.component.html
浏览文件 @
aad4bd8e
...
...
@@ -62,14 +62,15 @@
[ngModelOptions]=
"{ standalone: true }"
(ngModelChange)=
"flowscripttypeChange($event)"
>
<nz-option
nzValue=
"csharp"
nzLabel=
"csharp"
></nz-option>
<nz-option
nzValue=
"javascript"
nzLabel=
"javascript"
></nz-option>
<nz-option
nzValue=
"python"
nzLabel=
"python"
></nz-option>
<nz-option
nzValue=
"bat"
nzLabel=
"bat"
></nz-option>
<nz-option
nzValue=
"xml"
nzLabel=
"xml"
></nz-option>
<nz-option
nzValue=
"sql"
nzLabel=
"sql"
></nz-option>
<nz-option
nzValue=
"json"
nzLabel=
"json"
></nz-option>
<nz-option
nzValue=
"lua"
nzLabel=
"lua"
></nz-option>
<nz-option
nzValue=
"csharp"
nzLabel=
"csharp"
[nzDisabled]=
"true"
></nz-option>
<nz-option
nzValue=
"json"
nzLabel=
"json"
[nzDisabled]=
"true"
></nz-option>
<nz-option
nzValue=
"bat"
nzLabel=
"bat"
[nzDisabled]=
"true"
></nz-option>
<nz-option
nzValue=
"xml"
nzLabel=
"xml"
[nzDisabled]=
"true"
></nz-option>
</nz-select>
</se>
...
...
IoTSharp/Controllers/RulesController.cs
浏览文件 @
aad4bd8e
...
...
@@ -33,10 +33,10 @@ namespace IoTSharp.Controllers
public
class
RulesController
:
ControllerBase
{
private
ApplicationDbContext
_context
;
private
readonly
FlowRuleProcessor
_flowRuleProcessor
;
private
readonly
FlowRuleProcessor
V2
_flowRuleProcessor
;
private
UserManager
<
IdentityUser
>
_userManager
;
public
RulesController
(
ApplicationDbContext
context
,
UserManager
<
IdentityUser
>
userManager
,
FlowRuleProcessor
flowRuleProcessor
)
public
RulesController
(
ApplicationDbContext
context
,
UserManager
<
IdentityUser
>
userManager
,
FlowRuleProcessor
V2
flowRuleProcessor
)
{
this
.
_userManager
=
userManager
;
this
.
_context
=
context
;
...
...
@@ -874,8 +874,8 @@ namespace IoTSharp.Controllers
var
testabizId
=
Guid
.
NewGuid
().
ToString
();
//根据业务保存起来,用来查询执行事件和步骤
// await _flowRuleProcessor.RunFlowRules(ruleid, d, profile.Id, EventType.TestPurpose, testabizId);
FlowRuleProcessorV2
ruleProcessorV2
=
new
FlowRuleProcessorV2
(
this
.
_context
);
var
result
=
await
ruleProcessorV2
.
RunFlowRules
(
ruleid
,
d
,
profile
.
Id
,
EventType
.
TestPurpose
,
testabizId
);
//
FlowRuleProcessorV2 ruleProcessorV2 = new FlowRuleProcessorV2(this._context);
var
result
=
await
_flowRuleProcessor
.
RunFlowRules
(
ruleid
,
d
,
profile
.
Id
,
EventType
.
TestPurpose
,
testabizId
);
//应该由事件总线去通知
return
new
ApiResult
<
dynamic
>(
ApiCode
.
Success
,
"test complete"
,
result
.
OrderBy
(
c
=>
c
.
Step
).
...
...
IoTSharp/FlowRuleEngine/FlowRuleProcessorV2.cs
浏览文件 @
aad4bd8e
...
...
@@ -17,20 +17,21 @@ namespace IoTSharp.FlowRuleEngine
{
private
readonly
IServiceProvider
_sp
;
private
readonly
ApplicationDbContext
_context
;
private
readonly
ILogger
<
FlowRuleProcessor
>
_logger
;
private
readonly
ILogger
<
FlowRuleProcessor
V2
>
_logger
;
private
readonly
AppSettings
_setting
;
private
List
<
Flow
>
_allFlows
=
new
List
<
Flow
>();
private
List
<
FlowOperation
>
_allflowoperation
=
new
List
<
FlowOperation
>();
public
FlowRuleProcessorV2
(
ApplicationDbContext
context
)
ApplicationDbContext
context
,
ILogger
<
FlowRuleProcessorV2
>
logger
,
IServiceScopeFactory
scopeFactor
,
IOptions
<
AppSettings
>
options
)
{
_sp
=
scopeFactor
.
CreateScope
().
ServiceProvider
;
_context
=
context
;
_logger
=
logger
;
_setting
=
options
.
Value
;
}
/// <summary>
///
...
...
@@ -40,7 +41,7 @@ namespace IoTSharp.FlowRuleEngine
/// <param name="creator">创建者(可以是模拟器(测试),可以是设备,在EventType中区分一下)</param>
/// <param name="type">类型</param>
/// <param name="BizId">业务Id(第三方唯一Id,用于取回事件以及记录的标识)</param>
/// <returns></returns>
/// <returns>
返回所有节点的记录信息,需要保存则保存
</returns>
public
async
Task
<
List
<
FlowOperation
>>
RunFlowRules
(
Guid
ruleid
,
object
data
,
Guid
creator
,
EventType
type
,
string
BizId
)
{
...
...
@@ -56,7 +57,7 @@ namespace IoTSharp.FlowRuleEngine
MataData
=
JsonConvert
.
SerializeObject
(
data
),
FlowRule
=
rule
,
Bizid
=
BizId
,
Type
=
EventType
.
TestPurpos
e
,
Type
=
typ
e
,
EventStaus
=
1
};
_context
.
BaseEvents
.
Add
(
_event
);
...
...
@@ -67,7 +68,7 @@ namespace IoTSharp.FlowRuleEngine
var
startoperation
=
new
FlowOperation
()
{
OperationId
=
Guid
.
NewGuid
(),
OperationId
=
Guid
.
NewGuid
(),
bpmnid
=
start
.
bpmnid
,
AddDate
=
DateTime
.
Now
,
FlowRule
=
start
.
FlowRule
,
...
...
@@ -86,7 +87,8 @@ namespace IoTSharp.FlowRuleEngine
foreach
(
var
item
in
nextflows
)
{
var
flowOperation
=
new
FlowOperation
()
{
OperationId
=
Guid
.
NewGuid
(),
{
OperationId
=
Guid
.
NewGuid
(),
AddDate
=
DateTime
.
Now
,
FlowRule
=
item
.
FlowRule
,
Flow
=
item
,
...
...
@@ -161,7 +163,7 @@ namespace IoTSharp.FlowRuleEngine
BaseEvent
=
peroperation
.
BaseEvent
};
_allflowoperation
.
Add
(
taskoperation
);
//脚本处理
if
(!
string
.
IsNullOrEmpty
(
flow
.
NodeProcessScriptType
)
&&
!
string
.
IsNullOrEmpty
(
flow
.
NodeProcessScript
))
...
...
@@ -175,11 +177,111 @@ namespace IoTSharp.FlowRuleEngine
break
;
case
"python"
:
{
dynamic
obj
=
null
;
using
(
var
pse
=
_sp
.
GetRequiredService
<
PythonScriptEngine
>())
{
obj
=
pse
.
Do
(
scriptsrc
,
taskoperation
.
Data
);
}
if
(
obj
!=
null
)
{
var
next
=
await
ProcessCondition
(
taskoperation
.
Flow
.
FlowId
,
obj
);
foreach
(
var
item
in
next
)
{
var
flowOperation
=
new
FlowOperation
()
{
OperationId
=
Guid
.
NewGuid
(),
AddDate
=
DateTime
.
Now
,
FlowRule
=
item
.
FlowRule
,
Flow
=
item
,
Data
=
JsonConvert
.
SerializeObject
(
data
),
NodeStatus
=
1
,
OperationDesc
=
"执行条件("
+
(
string
.
IsNullOrEmpty
(
item
.
Conditionexpression
)
?
"空条件"
:
item
.
Conditionexpression
)
+
")"
,
Step
=
taskoperation
.
Step
++,
bpmnid
=
item
.
bpmnid
,
BaseEvent
=
taskoperation
.
BaseEvent
};
_allflowoperation
.
Add
(
flowOperation
);
await
Process
(
flowOperation
.
OperationId
,
obj
);
}
}
else
{
taskoperation
.
OperationDesc
=
"脚本执行异常"
;
taskoperation
.
NodeStatus
=
2
;
}
}
break
;
case
"sql"
:
{
dynamic
obj
=
null
;
using
(
var
pse
=
_sp
.
GetRequiredService
<
SQLEngine
>())
{
obj
=
pse
.
Do
(
scriptsrc
,
taskoperation
.
Data
);
}
var
next
=
await
ProcessCondition
(
taskoperation
.
Flow
.
FlowId
,
obj
);
if
(
obj
!=
null
)
{
foreach
(
var
item
in
next
)
{
var
flowOperation
=
new
FlowOperation
()
{
OperationId
=
Guid
.
NewGuid
(),
AddDate
=
DateTime
.
Now
,
FlowRule
=
item
.
FlowRule
,
Flow
=
item
,
Data
=
JsonConvert
.
SerializeObject
(
data
),
NodeStatus
=
1
,
OperationDesc
=
"执行条件("
+
(
string
.
IsNullOrEmpty
(
item
.
Conditionexpression
)
?
"空条件"
:
item
.
Conditionexpression
)
+
")"
,
Step
=
taskoperation
.
Step
++,
bpmnid
=
item
.
bpmnid
,
BaseEvent
=
taskoperation
.
BaseEvent
};
_allflowoperation
.
Add
(
flowOperation
);
await
Process
(
flowOperation
.
OperationId
,
obj
);
}
}
else
{
taskoperation
.
OperationDesc
=
"脚本执行异常"
;
taskoperation
.
NodeStatus
=
2
;
}
}
break
;
case
"lua"
:
{
dynamic
obj
=
null
;
using
(
var
lua
=
_sp
.
GetRequiredService
<
LuaScriptEngine
>())
{
obj
=
lua
.
Do
(
scriptsrc
,
taskoperation
.
Data
);
}
if
(
obj
!=
null
)
{
var
next
=
await
ProcessCondition
(
taskoperation
.
Flow
.
FlowId
,
obj
);
foreach
(
var
item
in
next
)
{
...
...
@@ -203,42 +305,65 @@ namespace IoTSharp.FlowRuleEngine
await
Process
(
flowOperation
.
OperationId
,
obj
);
}
}
else
{
taskoperation
.
OperationDesc
=
"脚本执行异常"
;
taskoperation
.
NodeStatus
=
2
;
}
}
break
;
case
"sql"
:
break
;
case
"javascript"
:
{
ExpandoObject
obj
=
null
;
using
(
var
js
=
_sp
.
GetRequiredService
<
JavaScriptEngine
>())
{
string
result
=
js
.
Do
(
@"var output=input.Temperature;output = output + 100; return { Temperature:output};"
,
taskoperation
.
Data
);
string
result
=
js
.
Do
(
scriptsrc
,
taskoperation
.
Data
);
obj
=
JsonConvert
.
DeserializeObject
<
ExpandoObject
>(
result
);
}
var
next
=
await
ProcessCondition
(
taskoperation
.
Flow
.
FlowId
,
obj
);
foreach
(
var
item
in
next
)
if
(
obj
!=
null
)
{
var
flowOperation
=
new
FlowOperation
()
var
next
=
await
ProcessCondition
(
taskoperation
.
Flow
.
FlowId
,
obj
);
foreach
(
var
item
in
next
)
{
OperationId
=
Guid
.
NewGuid
(),
AddDate
=
DateTime
.
Now
,
FlowRule
=
item
.
FlowRule
,
Flow
=
item
,
Data
=
JsonConvert
.
SerializeObject
(
obj
),
NodeStatus
=
1
,
OperationDesc
=
"执行条件("
+
(
string
.
IsNullOrEmpty
(
item
.
Conditionexpression
)
?
"空条件"
:
item
.
Conditionexpression
)
+
")"
,
Step
=
++
taskoperation
.
Step
,
bpmnid
=
item
.
bpmnid
,
BaseEvent
=
taskoperation
.
BaseEvent
};
_allflowoperation
.
Add
(
flowOperation
);
await
Process
(
flowOperation
.
OperationId
,
obj
);
var
flowOperation
=
new
FlowOperation
()
{
OperationId
=
Guid
.
NewGuid
(),
AddDate
=
DateTime
.
Now
,
FlowRule
=
item
.
FlowRule
,
Flow
=
item
,
Data
=
JsonConvert
.
SerializeObject
(
obj
),
NodeStatus
=
1
,
OperationDesc
=
"执行条件("
+
(
string
.
IsNullOrEmpty
(
item
.
Conditionexpression
)
?
"空条件"
:
item
.
Conditionexpression
)
+
")"
,
Step
=
++
taskoperation
.
Step
,
bpmnid
=
item
.
bpmnid
,
BaseEvent
=
taskoperation
.
BaseEvent
};
_allflowoperation
.
Add
(
flowOperation
);
await
Process
(
flowOperation
.
OperationId
,
obj
);
}
}
else
{
taskoperation
.
OperationDesc
=
"脚本执行异常"
;
taskoperation
.
NodeStatus
=
2
;
}
}
break
;
...
...
@@ -266,7 +391,7 @@ namespace IoTSharp.FlowRuleEngine
BaseEvent
=
taskoperation
.
BaseEvent
};
_allflowoperation
.
Add
(
flowOperation
);
...
...
@@ -362,7 +487,7 @@ namespace IoTSharp.FlowRuleEngine
end
.
BaseEvent
=
peroperation
.
BaseEvent
;
_allflowoperation
.
Add
(
end
);
}
break
;
//case "bpmn:StartEvent":
...
...
@@ -434,7 +559,7 @@ namespace IoTSharp.FlowRuleEngine
// break;
// //
//没有终结点的节点必须
//没有终结点的节点必须
留个空标签
case
"label"
:
break
;
...
...
@@ -457,7 +582,7 @@ namespace IoTSharp.FlowRuleEngine
default
:
{
break
;
}
...
...
IoTSharp/Handlers/EventBusHandler.cs
浏览文件 @
aad4bd8e
...
...
@@ -37,11 +37,11 @@ namespace IoTSharp.Handlers
readonly
ILogger
_logger
;
private
readonly
IServiceScopeFactory
_scopeFactor
;
private
readonly
IStorage
_storage
;
private
readonly
FlowRuleProcessor
_flowRuleProcessor
;
private
readonly
FlowRuleProcessor
V2
_flowRuleProcessor
;
private
readonly
IEasyCachingProvider
_caching
;
public
EventBusHandler
(
ILogger
<
EventBusHandler
>
logger
,
IServiceScopeFactory
scopeFactor
,
IOptions
<
AppSettings
>
options
,
IStorage
storage
,
FlowRuleProcessor
flowRuleProcessor
,
IEasyCachingProviderFactory
factory
,
IOptions
<
AppSettings
>
options
,
IStorage
storage
,
FlowRuleProcessor
V2
flowRuleProcessor
,
IEasyCachingProviderFactory
factory
)
{
_appSettings
=
options
.
Value
;
...
...
IoTSharp/Handlers/MQTTServerHandler.cs
浏览文件 @
aad4bd8e
...
...
@@ -31,11 +31,11 @@ namespace IoTSharp.Handlers
private
readonly
IEasyCachingProviderFactory
_factory
;
readonly
IMqttServerEx
_serverEx
;
private
readonly
ICapPublisher
_queue
;
private
readonly
FlowRuleProcessor
_flowRuleProcessor
;
private
readonly
FlowRuleProcessor
V2
_flowRuleProcessor
;
private
readonly
IEasyCachingProvider
_caching
;
readonly
MqttClientSetting
_mcsetting
;
public
MQTTServerHandler
(
ILogger
<
MQTTServerHandler
>
logger
,
IServiceScopeFactory
scopeFactor
,
IMqttServerEx
serverEx
,
IOptions
<
AppSettings
>
options
,
ICapPublisher
queue
,
IEasyCachingProviderFactory
factory
,
FlowRuleProcessor
flowRuleProcessor
,
IOptions
<
AppSettings
>
options
,
ICapPublisher
queue
,
IEasyCachingProviderFactory
factory
,
FlowRuleProcessor
V2
flowRuleProcessor
)
{
_mcsetting
=
options
.
Value
.
MqttClient
;
...
...
IoTSharp/IoTSharp.xml
浏览文件 @
aad4bd8e
...
...
@@ -595,7 +595,7 @@
<param
name=
"creator"
>
创建者(可以是模拟器(测试),可以是设备,在EventType中区分一下)
</param>
<param
name=
"type"
>
类型
</param>
<param
name=
"BizId"
>
业务Id(第三方唯一Id,用于取回事件以及记录的标识)
</param>
<returns></returns>
<returns>
返回所有节点的记录信息,需要保存则保存
</returns>
</member>
<member
name=
"T:IoTSharp.Handlers.EventBusHandler"
>
<summary>
...
...
IoTSharp/Startup.cs
浏览文件 @
aad4bd8e
...
...
@@ -378,7 +378,7 @@ namespace IoTSharp
configuration
.
RootPath
=
"ClientApp/dist"
;
});
services
.
AddScriptEngines
(
Configuration
.
GetSection
(
"EngineSetting"
));
services
.
AddTransient
<
FlowRuleProcessor
>();
services
.
AddTransient
<
FlowRuleProcessor
V2
>();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录