提交 aad4bd8e 编写于 作者: W wq1234wq

修正编译错误

上级 a923684c
......@@ -62,8 +62,8 @@
"budgets": [
{
"type": "initial",
"maximumWarning": "4mb",
"maximumError": "7mb"
"maximumWarning": "7mb",
"maximumError": "8mb"
},
{
"type": "anyComponentStyle",
......
......@@ -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",
......
......@@ -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>
......
......@@ -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>
......
......@@ -33,10 +33,10 @@ namespace IoTSharp.Controllers
public class RulesController : ControllerBase
{
private ApplicationDbContext _context;
private readonly FlowRuleProcessor _flowRuleProcessor;
private readonly FlowRuleProcessorV2 _flowRuleProcessor;
private UserManager<IdentityUser> _userManager;
public RulesController(ApplicationDbContext context, UserManager<IdentityUser> userManager, FlowRuleProcessor flowRuleProcessor)
public RulesController(ApplicationDbContext context, UserManager<IdentityUser> userManager, FlowRuleProcessorV2 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).
......
......@@ -17,20 +17,21 @@ namespace IoTSharp.FlowRuleEngine
{
private readonly IServiceProvider _sp;
private readonly ApplicationDbContext _context;
private readonly ILogger<FlowRuleProcessor> _logger;
private readonly ILogger<FlowRuleProcessorV2> _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.TestPurpose,
Type = type,
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;
}
......
......@@ -37,11 +37,11 @@ namespace IoTSharp.Handlers
readonly ILogger _logger;
private readonly IServiceScopeFactory _scopeFactor;
private readonly IStorage _storage;
private readonly FlowRuleProcessor _flowRuleProcessor;
private readonly FlowRuleProcessorV2 _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, FlowRuleProcessorV2 flowRuleProcessor, IEasyCachingProviderFactory factory
)
{
_appSettings = options.Value;
......
......@@ -31,11 +31,11 @@ namespace IoTSharp.Handlers
private readonly IEasyCachingProviderFactory _factory;
readonly IMqttServerEx _serverEx;
private readonly ICapPublisher _queue;
private readonly FlowRuleProcessor _flowRuleProcessor;
private readonly FlowRuleProcessorV2 _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, FlowRuleProcessorV2 flowRuleProcessor
)
{
_mcsetting = options.Value.MqttClient;
......
......@@ -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>
......
......@@ -378,7 +378,7 @@ namespace IoTSharp
configuration.RootPath = "ClientApp/dist";
});
services.AddScriptEngines(Configuration.GetSection("EngineSetting"));
services.AddTransient<FlowRuleProcessor>();
services.AddTransient<FlowRuleProcessorV2>();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册