fix: mqtt脚本检查功能中的类型转换错误

This commit is contained in:
Diego
2024-08-21 20:44:52 +08:00
parent 5d42a1247a
commit 5072d9f7ad
2 changed files with 11 additions and 2 deletions

View File

@@ -4,7 +4,7 @@
@using ThingsGateway.Gateway.Application
<div class="col-12 col-md-12">
<Textarea Value=@Script ValueChanged=@ScriptChanged ValueExpression="()=>Script" ShowLabelTooltip="true"
<Textarea Value=@Script ValueChanged=@Change ValueExpression="()=>Script" ShowLabelTooltip="true"
rows="10" ShowLabel="true" />
</div>
<div class="col-12 col-md-12">

View File

@@ -24,10 +24,19 @@ public partial class ScriptCheck
public string Script { get; set; }
[Parameter, EditorRequired]
public EventCallback<string> ScriptChanged { get; set; }
private async Task Change(string script)
{
Script = script;
if (ScriptChanged.HasDelegate)
await ScriptChanged.InvokeAsync(script);
}
private Type type;
protected override void OnInitialized()
{
Input = Data.ToJsonNetString();
type = Data.GetType();
base.OnInitialized();
}
@@ -35,7 +44,7 @@ public partial class ScriptCheck
{
try
{
Data = Input.FromJsonNetString<IEnumerable<object>>();
Data = (IEnumerable<object>)Newtonsoft.Json.JsonConvert.DeserializeObject(Input, type);
var value = Data.GetDynamicModel(Script);
Output = value.ToJsonNetString();
}