示例#1
0
        public void AddDevice(DetectedDevice device)
        {
            if (device == null)
            {
                throw new ArgumentNullException("Error: The argument is Null");
            }

            DetectedDeviceCollection.Add(device);
            var diskFileID = device.GPSID;

            //var gps = Entities.GPSViewModel.GetGPSEx(device.SerialNumber);
            if (diskFileID != null)
            {
                var gps = Entities.GPSViewModel.GetGPSEx(diskFileID);
                if (gps != null)
                {
                    device.GPS = gps;
                    //if(gps.PNPDeviceID==null || gps.PNPDeviceID.Length==0)
                    //{
                    //    gps.PNPDeviceID = device.PNPDeviceID;
                    //    gps.VolumeName = device.Disks[0].VolumeName;
                    //    Entities.GPSViewModel.UpdateRecordInRepo(gps);
                    //}
                }
            }
        }
示例#2
0
        public bool DeleteDeviceFromCollection(string deviceID)
        {
            if (deviceID == null)
            {
                throw new Exception("Serial number cannot be null");
            }

            int index = 0;
            int deviceCountBeforeDelete = DetectedDeviceCollection.Count;

            while (index < DetectedDeviceCollection.Count)
            {
                if (DetectedDeviceCollection[index].DeviceID == deviceID)
                {
                    DetectedDeviceCollection.RemoveAt(index);
                    return(deviceCountBeforeDelete > DetectedDeviceCollection.Count);
                }
                index++;
            }
            return(false);
        }