1
This commit is contained in:
@@ -271,9 +271,9 @@ public class IDIS_DBContext:DbContext
|
||||
SaveChangesAsync();
|
||||
}
|
||||
|
||||
public bool Update(string handle, string format, string value)
|
||||
public bool Update(string handle, string name, string value)
|
||||
{
|
||||
var result = Datas.FirstOrDefault(x => x.Handle == handle && x.Format == format);
|
||||
var result = Datas.FirstOrDefault(x => x.Handle == handle && x.Name == name);
|
||||
if (result is null) return false;
|
||||
result.UpdateTime=DateTime.Now;
|
||||
result.Value = value;
|
||||
@@ -313,5 +313,5 @@ public partial class IDIS_Service:Node
|
||||
public void RegisterReference(string handle,string refenceHandle) => Context.RegisterReference(handle,refenceHandle);
|
||||
public static string GenerateHandle() => $"88.123.99/{Mathf.Abs(Guid.NewGuid().GetHashCode())}";
|
||||
public bool Query(string key, out IDIS_Query query) => Context.Query(key, out query);
|
||||
public bool Update(string handle, string format, string value) => Context.Update(handle, format, value);
|
||||
public bool Update(string handle, string name, string value) => Context.Update(handle, name, value);
|
||||
}
|
@@ -18,6 +18,7 @@ public partial class IDIS_THService : Node
|
||||
None,
|
||||
Update,
|
||||
Insert,
|
||||
UpdateAndInsert,
|
||||
}
|
||||
|
||||
[Export] private UpdateMode currentUpdateMode = UpdateMode.Insert;
|
||||
@@ -104,20 +105,21 @@ public partial class IDIS_THService : Node
|
||||
service.Register(handle, "湿度","float", humidity, "环境");
|
||||
break;
|
||||
case UpdateMode.Update:
|
||||
if (service.Update(handle, "温度",temperature) is false)
|
||||
if (service.Update(handle, "当前温度",temperature) is false)
|
||||
{
|
||||
autoUpdateLabel.SetTextAsync("温度更新失败,未知异常");
|
||||
return;
|
||||
}
|
||||
|
||||
if (service.Update(handle, "湿度",humidity) is false)
|
||||
if (service.Update(handle, "当前湿度",humidity) is false)
|
||||
{
|
||||
autoUpdateLabel.SetTextAsync("湿度更新失败,未知异常");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case UpdateMode.UpdateAndInsert:
|
||||
service.Register(handle,"温度" ,"float", temperature, "环境");
|
||||
service.Register(handle, "湿度","float", humidity, "环境");
|
||||
goto case UpdateMode.Update;
|
||||
}
|
||||
autoUpdateLabel.SetTextAsync($"温湿度已自动更新:{DateTime.Now}");
|
||||
}
|
||||
|
Reference in New Issue
Block a user