修复bug和计算表达式问题

This commit is contained in:
liushoushan_notebook 2022-06-13 16:41:17 +08:00
parent 25d13b4790
commit 6030f63100
5 changed files with 19 additions and 5 deletions

View File

@ -50,6 +50,9 @@ namespace IoTGateway.Controllers
[ActionDescription("Sys.Create")]
public ActionResult Create(DeviceVariableVM vm)
{
if (vm.FC.ContainsKey("Entity.Expressions"))
vm.Entity.Expressions = vm.FC["Entity.Expressions"].ToString();
if (!ModelState.IsValid)
{
return PartialView(vm);
@ -83,6 +86,8 @@ namespace IoTGateway.Controllers
[ValidateFormItemOnly]
public ActionResult Edit(DeviceVariableVM vm)
{
if (vm.FC.ContainsKey("Entity.Expressions"))
vm.Entity.Expressions = vm.FC["Entity.Expressions"].ToString();
if (!ModelState.IsValid)
{
return PartialView(vm);

View File

@ -82,11 +82,16 @@ namespace Plugin
{
try
{
_logger.LogInformation($"CreateDeviceThread Start:{Device.DeviceName}");
_logger.LogInformation($"CreateDeviceThread Start:{Device.DeviceName},Driver:{Device.Driver}");
if (Device.Driver == null)
return;
using (var DC = new DataContext(connnectSetting, DBType))
{
var systemManage = DC.Set<SystemConfig>().FirstOrDefault();
var driver = _DrvierManager.DriverInfos.Where(x => x.Type.FullName == Device.Driver.AssembleName).SingleOrDefault();
if (driver == null)
return;
var settings = DC.Set<DeviceConfig>().Where(x => x.DeviceId == Device.ID).AsNoTracking().ToList();
Type[] types = new Type[1] { typeof(Guid) };
object[] param = new object[1] { Device.ID };

View File

@ -274,7 +274,7 @@ namespace Plugin
//mysql会把一些符号转义没找到原因先临时处理下
private string DealMysqlStr(string Expression)
{
return Expression.Replace("&lt;", ">").Replace("&gt;", "<").Replace("&amp;", "&");
return Expression.Replace("&lt;", "<").Replace("&gt;", ">").Replace("&amp;", "&");
}
}

View File

@ -344,6 +344,7 @@ namespace WalkingTec.Mvvm.Core
/// <param name="updateAllFields">为true时框架会更新当前Entity的全部值为false时框架会检查Request.Form里的key只更新表单提交的字段</param>
public virtual void DoEdit(bool updateAllFields = false)
{
DoEditPrepare(updateAllFields);
try
@ -629,10 +630,11 @@ namespace WalkingTec.Mvvm.Core
string name = f.Replace("entity.", "");
try
{
DC.UpdateProperty(Entity, pros.Where(x => x.Name.ToLower() == name).Select(x => x.Name).FirstOrDefault());
DC.UpdateProperty(Entity, pros.Where(x => name!="id" && x.Name.ToLower() == name).Select(x => x.Name).FirstOrDefault());//id字段不可修改
}
catch (Exception)
catch (Exception ex)
{
MSD.AddModelError("", CoreProgram._localizer?["Sys.EditPrepare"]);
}
}
}

View File

@ -508,6 +508,8 @@ namespace WalkingTec.Mvvm.Core
public void UpdateProperty<T>(T entity, string fieldName)
where T : TopBasePoco
{
if (string.IsNullOrEmpty(fieldName))
return;
var set = this.Set<T>();
if (set.Local.AsQueryable().CheckID(entity.GetID()).FirstOrDefault() == null)
{