示例#1
0
        public async Task <ICollection <DiskDrive> > Update()
        {
            ICollection <DiskDrive> disks = new List <DiskDrive>();

            IDiskDriveService service = new DiskDriveService(new LabSystemsContextFactory());

            ManagementObjectCollection drives = _driveClass.GetInstances();

            string firmware    = "FirmwareRevision";
            string model       = "Model";
            string serial      = "SerialNumber";
            string PNPDeviceId = "PNPDeviceID";

            foreach (ManagementObject drive in drives)
            {
                DiskDrive driveModel = new DiskDrive();

                foreach (PropertyData property in drive.Properties)
                {
                    if (property.Name == firmware)
                    {
                        driveModel.Firmware = property.Value.ToString();
                        continue;
                    }
                    if (property.Name == model)
                    {
                        driveModel.ModelNumber = property.Value.ToString();
                        continue;
                    }
                    if (property.Name == serial)
                    {
                        driveModel.SerialNumber = property.Value.ToString();

                        DiskDrive existingDisk = await service.Get(property.Value.ToString());

                        if (existingDisk != null)
                        {
                            driveModel.LabSystemId = existingDisk.LabSystemId;
                            driveModel.Id          = existingDisk.Id;
                        }

                        continue;
                    }
                    if (property.Name == PNPDeviceId)
                    {
                        AddDriverInfo(driveModel, property.Value.ToString());
                        continue;
                    }
                }

                disks.Add(driveModel);
            }

            return(disks);
        }
 public HardwareSystemInformationController(
     MotherBoardService motherBoardService,
     DiskDriveService diskDriveService,
     PhysicalMemoryService physicalMemoryService,
     ProcessorService processorService,
     VideoCardService videoCardService
     )
 {
     _motherBoardService    = motherBoardService;
     _diskDriveService      = diskDriveService;
     _physicalMemoryService = physicalMemoryService;
     _processorService      = processorService;
     _videoCardService      = videoCardService;
 }