驱动程序集自动获取不可修改

This commit is contained in:
iioter 2024-06-02 16:12:03 +08:00
parent 71390bc3a6
commit f218dfc738
3 changed files with 10 additions and 3 deletions

View File

@ -36,6 +36,13 @@ namespace IoTGateway.ViewModel.BasicData.DriverVMs
public override void DoEdit(bool updateAllFields = false) public override void DoEdit(bool updateAllFields = false)
{ {
var DriverService = Wtm.ServiceProvider.GetService(typeof(DriverService)) as DriverService;
Entity.AssembleName = DriverService.GetAssembleNameByFileName(Entity.FileName);
if (string.IsNullOrEmpty(Entity.AssembleName))
{
MSD.AddModelError("", "程序集获取失败");
return;
}
base.DoEdit(updateAllFields); base.DoEdit(updateAllFields);
} }

View File

@ -5,7 +5,7 @@
<wt:row items-per-row="ItemsPerRowEnum.Two"> <wt:row items-per-row="ItemsPerRowEnum.Two">
<wt:textbox field="Entity.DriverName" /> <wt:textbox field="Entity.DriverName" />
<wt:textbox field="Entity.FileName" /> <wt:textbox field="Entity.FileName" />
<wt:textbox field="Entity.AssembleName" /> <wt:display field="Entity.AssembleName" />
<wt:textbox field="Entity.AuthorizesNum" /> <wt:textbox field="Entity.AuthorizesNum" />
</wt:row> </wt:row>
<wt:hidden field="Entity.ID" /> <wt:hidden field="Entity.ID" />

View File

@ -82,9 +82,9 @@ namespace Plugin
{ {
var systemManage = dc.Set<SystemConfig>().FirstOrDefault(); var systemManage = dc.Set<SystemConfig>().FirstOrDefault();
var driver = DrvierManager.DriverInfos var driver = DrvierManager.DriverInfos
.SingleOrDefault(x => x.Type.FullName == device.Driver.AssembleName); .SingleOrDefault(x => x.Type.FullName == device.Driver?.AssembleName);
if (driver == null) if (driver == null)
_logger.LogError($"找不到设备:[{device.DeviceName}]的驱动:[{device.Driver.AssembleName}]"); _logger.LogError($"找不到设备:[{device.DeviceName}]的驱动:[{device.Driver?.AssembleName}]");
else else
{ {
var settings = dc.Set<DeviceConfig>().Where(x => x.DeviceId == device.ID).AsNoTracking() var settings = dc.Set<DeviceConfig>().Where(x => x.DeviceId == device.ID).AsNoTracking()