Exemplo n.º 1
0
        public void QueryDeviceCheckpoints(RestServiceRequest request, RestServiceResponse <DeviceCheckpoint[]> response)
        {
            response.Paging = request.Paging;

            response.Body = DeviceCheckpointTransfer.BuildDeviceCheckpoints(_DeviceCheckpointRepository.QueryDeviceCheckpoints(
                                                                                request.Paging,
                                                                                request.GetValue <int>("DeviceCheckpointId", 0),
                                                                                request.GetValue("DeviceNumber")));
        }
Exemplo n.º 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;
        }