public List <DiskShareMountDTOResponse> GetDiskShareMountInfo()
        {
            List <DiskShareMountDTOResponse> mounts = new List <DiskShareMountDTOResponse>();
            FCInfoDetectorSource             fcinfo = new FCInfoDetectorSource();

            try
            {
                SelectQuery query = new SelectQuery(
                    @"select Model, DeviceID, Size 
					  from Win32_DiskDrive 
					  where Model like '3PARdata%'"
                    );
                ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);

                foreach (ManagementObject obj in searcher.Get())
                {
                    SelectQuery snQuery = new SelectQuery(
                        "select SerialNumber from Win32_PhysicalMedia " +
                        "where tag='" + GetValueAsString(obj, "DeviceID").Replace(@"\", @"\\") + "'"
                        );
                    ManagementObjectSearcher snSearcher = new ManagementObjectSearcher(snQuery);

                    foreach (ManagementObject snObj in snSearcher.Get())
                    {
                        string serialNumber = fcinfo.GetShareWWN(
                            GetValueAsString(snObj, "SerialNumber")
                            );
                        if (serialNumber.Length == 0)
                        {
                            continue;
                        }
                        DiskShareMountDTOResponse share = new DiskShareMountDTOResponse();
                        share.Volume       = GetValueAsString(obj, "Model");
                        share.SerialNumber = serialNumber;
                        share.Size         = ConvertSizeToMiB(
                            Int64.Parse(GetValueAsString(obj, "Size")),
                            SizeUnits.B
                            ).ToString();

                        mounts.Add(share);

                        break;
                    }
                }
            }
            catch (ManagementException e)
            {
                Logger.Instance.LogError(e.ToString());
            }

            return(mounts);
        }
Beispiel #2
0
        public List <DiskShareMountDTOResponse> GetDiskShareMountInfo()
        {
            List <DiskShareMountDTOResponse> mounts = new List <DiskShareMountDTOResponse>();

            try
            {
                SelectQuery query = new SelectQuery(
                    @"select Model, DeviceID 
					  from Win32_DiskDrive 
					  where Model like '3PARdata%'"
                    );
                ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);

                foreach (ManagementObject obj in searcher.Get())
                {
                    SelectQuery snQuery = new SelectQuery(
                        "select SerialNumber from Win32_PhysicalMedia " +
                        "where tag='" + GetValueAsString(obj, "DeviceID").Replace(@"\", @"\\") + "'"
                        );
                    ManagementObjectSearcher snSearcher = new ManagementObjectSearcher(snQuery);

                    foreach (ManagementObject snObj in snSearcher.Get())
                    {
                        DiskShareMountDTOResponse share = new DiskShareMountDTOResponse();
                        share.Volume = GetValueAsString(obj, "Model");
                        share.Sn     = GetValueAsString(snObj, "SerialNumber");

                        mounts.Add(share);

                        break;
                    }
                }
            }
            catch (ManagementException e)
            {
                Logger.Instance.LogError(e.ToString());
            }

            return(mounts);
        }