/// <summary> /// 添加设备数据点信息 /// </summary> /// <param name="inputDtos">要添加的设备数据点信息DTO信息</param> /// <returns>业务操作结果</returns> public async Task <OperationResult> AddDeviceNodes(params DeviceNodeInputDto[] inputDtos) { inputDtos.CheckNotNull("inputDtos"); foreach (var dtoData in inputDtos) { if (string.IsNullOrEmpty(dtoData.NodeName)) { return(new OperationResult(OperationResultType.Error, "请正确填写点表名称,不能为空。")); } if (string.IsNullOrEmpty(dtoData.NodeUrl)) { return(new OperationResult(OperationResultType.Error, "请正确填写通讯点Url,不能为空。")); } dtoData.DeviceServerInfo = DeviceServerInfoRepository.TrackEntities.FirstOrDefault(m => m.Id == dtoData.DeviceServerInfo_Id); if (Equals(dtoData.DeviceServerInfo, null)) { return(new OperationResult(OperationResultType.Error, $"对应的设备通讯服务器不存在,数据添加失败。")); } if (DeviceNodeRepository.CheckExists(x => x.NodeUrl == dtoData.NodeUrl && x.DeviceServerInfo.Id == dtoData.DeviceServerInfo_Id)) { return(new OperationResult(OperationResultType.Error, $"设备通讯服务器:{dtoData.DeviceServerInfo.DeviceServerName},数据点URL:{dtoData.NodeUrl} 的数据已存在,请使用其他Url或选择其他设备服务器。")); } } var result = await DeviceNodeRepository.InsertAsync(inputDtos); return(result); }
/// <summary> /// 检查设备数据点信息是否存在 /// </summary> /// <param name="predicate">检查谓语表达式</param> /// <param name="id">更新的设备数据点信息编号</param> /// <returns>设备数据点信息是否存在</returns> public bool CheckDeviceNodeExists(Expression <Func <DeviceNode, bool> > predicate, Guid id) => DeviceNodeRepository.CheckExists(predicate, id);