|
|
@ -227,41 +227,38 @@ namespace IoTCenter.Services
|
|
|
|
|
|
|
|
|
|
|
|
private void TiggerHandle(BaseEvent<Data> message)
|
|
|
|
private void TiggerHandle(BaseEvent<Data> message)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var data = message.Data;
|
|
|
|
try
|
|
|
|
using var scope = this._sp.CreateScope();
|
|
|
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
using var scope = this._sp.CreateScope();
|
|
|
|
|
|
|
|
var job = scope.ServiceProvider.GetService<IoTCenterJob>();
|
|
|
|
|
|
|
|
foreach (var item in Tiggers)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
foreach (var item in Tiggers)
|
|
|
|
var data = message.Data;
|
|
|
|
|
|
|
|
var tigger = item.Value;
|
|
|
|
|
|
|
|
if (tigger.DataId == data.Id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var tigger = item.Value;
|
|
|
|
var methodText = $"bool Valid(string name,string key,{data.Type.ToString().ToLower()} value,string description){{ return {tigger.Condition};}}";
|
|
|
|
if (tigger.DataId == data.Id)
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var methodText = $"bool Valid(string name,string key,{data.Type.ToString().ToLower()} value,string description){{ return {tigger.Condition};}}";
|
|
|
|
dynamic method = CSScript.Evaluator.LoadMethod(methodText);
|
|
|
|
try
|
|
|
|
dynamic value = data.GetValue();
|
|
|
|
{
|
|
|
|
var result = method.Valid(data.Name, data.Key, value, data.Description);
|
|
|
|
dynamic method = CSScript.Evaluator.LoadMethod(methodText);
|
|
|
|
if (result)
|
|
|
|
dynamic value = data.GetValue();
|
|
|
|
|
|
|
|
var result = method.Valid(data.Name, data.Key, value, data.Description);
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var job = scope.ServiceProvider.GetService<IoTCenterJob>();
|
|
|
|
|
|
|
|
job.TiggerHandle(tigger.Id);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ex.PrintStack();
|
|
|
|
job.TiggerHandle(tigger.Id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ex.PrintStack();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
}
|
|
|
|
{
|
|
|
|
catch (Exception ex)
|
|
|
|
ex.PrintStack();
|
|
|
|
{
|
|
|
|
}
|
|
|
|
ex.PrintStack();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Notify<T>(BaseEvent<T> message)
|
|
|
|
private void Notify<T>(BaseEvent<T> message)
|
|
|
|