예제 #1
0
        public void QueryBriefDevices(RestServiceRequest request, RestServiceResponse <DeviceInfo[]> response)
        {
            response.Paging = request.Paging;

            response.Body = DeviceInfoTransfer.BuildDeviceInfos(_DeviceInfoRepository.QueryDeviceInfos(
                                                                    request.Paging,
                                                                    request.GetValue("DeviceNumber"),
                                                                    request.GetValue("DeviceName")));
        }
예제 #2
0
        public void QueryDetailDevices(RestServiceRequest request, RestServiceResponse <DeviceInfo[]> response)
        {
            response.Paging = request.Paging;

            var deviceInfos = DeviceInfoTransfer.BuildDeviceInfos(_DeviceInfoRepository.QueryDeviceInfos(
                                                                      request.Paging,
                                                                      request.GetValue("DeviceNumber"),
                                                                      request.GetValue("DeviceName")));

            var deviceCheckpoints = DeviceCheckpointTransfer.BuildDeviceCheckpoints(
                _DeviceCheckpointRepository.QueryDeviceCheckpoints(deviceInfos.Select(x => x.DeviceNumber).ToArray()));

            var deviceSparePartDeviceInfoMappings = DeviceSparePartDeviceInfoMappingTransfer.BuildDeviceSparePartDeviceInfoMappings(
                _DeviceSparePartRepository.QueryDeviceSpareParts(deviceInfos.Select(x => x.DeviceNumber).ToArray()));

            foreach (var deviceInfo in deviceInfos)
            {
                deviceInfo.DeviceCheckpoints = deviceCheckpoints.Where(x => x.DeviceInfo != null && x.DeviceInfo.DeviceNumber == deviceInfo.DeviceNumber).ToArray();
                deviceInfo.DeviceSpareParts  = deviceSparePartDeviceInfoMappings.Where(x => x.DeviceInfo != null && x.DeviceInfo.DeviceNumber == deviceInfo.DeviceNumber)
                                               .Select(x => x.DeviceSparePart).ToArray();
            }

            response.Body = deviceInfos;
        }