/// <summary> /// 添加OpcUa业务数据关联数据点信息 /// </summary> /// <param name="inputDtos">要添加的OpcUa业务数据关联数据点信息DTO信息</param> /// <returns>业务操作结果</returns> public async Task <OperationResult> AddCommOpcUaBusinessNodeMaps(params CommOpcUaBusinessNodeMapInputDto[] inputDtos) { inputDtos.CheckNotNull("inputDtos"); CommOpcUaBusinessNodeMapRepository.UnitOfWork.BeginTransaction(); var result = await CommOpcUaBusinessNodeMapRepository.InsertAsync(inputDtos); CommOpcUaBusinessNodeMapRepository.UnitOfWork.Commit(); return(result); }
/// <summary> /// 设备业务数据点配置 /// </summary> /// <param name="inputDtos"></param> /// <returns></returns> public async Task <OperationResult> Setting(params CommOpcUaBusinessManageInputDto[] inputDtos) { inputDtos.CheckNotNull("inputDtos"); OperationResult result = new OperationResult(); OperationResult result2 = new OperationResult(); foreach (var inputDto in inputDtos) { if (Equals(inputDto.OpcUaBusiness_Id, Guid.Empty)) { return(new OperationResult(OperationResultType.Error, "请选择业务名称!")); } if (Equals(inputDto.EquipmentID, Guid.Empty)) { return(new OperationResult(OperationResultType.Error, "请选择设备名称!")); } int count = inputDto.CommOpcUaNodeInfoList.Count(); if (count >= 0) { CommOpcUaBusinessNodeMapRepository.UnitOfWork.BeginTransaction(); var oldmaplist = CommOpcUaBusinessNodeMapRepository.TrackEntities.Where(x => x.EquipmentID == inputDto.EquipmentID && x.OpcUaBusiness.Id == inputDto.OpcUaBusiness_Id); int count0 = oldmaplist.Count(); if (count0 > 0) { Guid[] mapIds = new Guid[count0]; mapIds = oldmaplist.Select(x => x.Id).ToArray(); result2 = await CommOpcUaBusinessNodeMapRepository.DeleteAsync(mapIds); } if (count == 0 && count0 > 0) { result = result2; } if ((result2.Successed || count0 == 0) && count > 0) { CommOpcUaBusinessNodeMapInputDto[] map_dtos = new CommOpcUaBusinessNodeMapInputDto[count]; for (int i = 0; i < count; i++) { CommOpcUaBusinessNodeMapInputDto edto = new CommOpcUaBusinessNodeMapInputDto(); edto.EquipmentID = inputDto.EquipmentID; var id = inputDto.CommOpcUaNodeInfoList[i].Id; edto.OpcUaNode = CommOpcUaNodeRepository.TrackEntities.Where(m => m.Id == id).FirstOrDefault(); edto.OpcUaBusiness = CommOpcUaBusinessRepository.TrackEntities.Where(m => m.Id == inputDto.OpcUaBusiness_Id).FirstOrDefault(); edto.CreatorUserId = inputDto.CreatorUserId; edto.CreatedTime = inputDto.CreatedTime; edto.LastUpdatedTime = inputDto.LastUpdatedTime; edto.LastUpdatorUserId = inputDto.LastUpdatorUserId; if (Equals(edto.OpcUaBusiness, null)) { return(new OperationResult(OperationResultType.Error, $"对应的通讯业务信息不存在,该组数据不被存储。")); } if (Equals(edto.OpcUaNode, null)) { return(new OperationResult(OperationResultType.Error, $"对应的数据点不存在,该组数据不被存储。")); } map_dtos[i] = edto; } result = await CommOpcUaBusinessNodeMapRepository.InsertAsync(map_dtos); } CommOpcUaBusinessNodeMapRepository.UnitOfWork.Commit(); } else { return(new OperationResult(OperationResultType.Error, $"设备业务数据点配置数据异常,该组数据不被存储。")); } } return(result); }