public void Search(DtoInventoryCollection collection) { using (var wmi = new ServiceWmi <DtoComputerSystemInventory>(new DtoComputerSystemInventory())) { collection.ComputerSystem = wmi.Execute(); } }
public void Search(DtoInventoryCollection collection) { using (var wmi = new ServiceWmi <DtoProcessorInventory>(new DtoProcessorInventory())) { collection.Processor = wmi.Execute(); } }
public void Search(DtoInventoryCollection collection) { using (var wmi = new ServiceWmi <DtoBiosInventory>(new DtoBiosInventory())) { collection.Bios = wmi.Execute(); } }
public void Search(DtoInventoryCollection collection) { using (var wmi = new ServiceWmi <DtoComputerSystemInventory>(new DtoComputerSystemInventory())) { collection.ComputerSystem = wmi.Execute(); } using (var wmi = new ServiceWmi <DtoComputerSystemProduct>(new DtoComputerSystemProduct())) { var computerSystemProduct = wmi.Execute(); if (computerSystemProduct != null) { collection.HardwareUUID = computerSystemProduct.UUID; } else { collection.HardwareUUID = string.Empty; } } }
private DtoClientFileHash GetFileForArch() { string osArch; using (var wmi = new ServiceWmi <DtoOsWmi>(new DtoOsWmi())) { var wmiInfo = wmi.Execute(); osArch = wmiInfo.OSArchitecture; } if (osArch.Contains("64")) { foreach (var file in _module.Files) { if (file.FileName.ToLower().Contains("-x64")) { return(file); } } } else if (osArch.Contains("32")) { foreach (var file in _module.Files) { if (file.FileName.ToLower().Contains("-x86")) { return(file); } } } else { Logger.Debug("Could Not Determine Current Os Architecture For Update Selection. Using First File."); return(_module.Files.OrderBy(x => x.FileName).FirstOrDefault()); } Logger.Debug("Could Not Find A File Designated For This Architecture. Using First File."); return(_module.Files.OrderBy(x => x.FileName).FirstOrDefault()); }
public void Search(DtoInventoryCollection collection) { using (var wmi = new ServiceWmi <DtoOsWmi>(new DtoOsWmi())) { var wmiInfo = wmi.Execute(); var osInventory = new DtoOsInventory(); try { osInventory.BuildNumber = wmiInfo.BuildNumber; osInventory.Caption = wmiInfo.Caption; osInventory.OSArchitecture = wmiInfo.OSArchitecture; osInventory.ServicePackMajorVersion = wmiInfo.ServicePackMajorVersion; osInventory.ServicePackMinorVersion = wmiInfo.ServicePackMinorVersion; osInventory.Version = wmiInfo.Version; osInventory.LocalTimeZone = TimeZone.CurrentTimeZone.StandardName; collection.Os = osInventory; } catch (Exception ex) { Logger.Error("Could Not Parse OS Inventory"); Logger.Error(ex.Message); } try { //get release id from registry var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion"); if (key != null) { osInventory.ReleaseId = Convert.ToString(key.GetValue("ReleaseId")); } //get uac status from registry var uacKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"); if (uacKey != null) { var consentPromptBehavior = uacKey.GetValue("ConsentPromptBehaviorAdmin"); var promptOnSecureDesktop = uacKey.GetValue("PromptOnSecureDesktop"); if (consentPromptBehavior != null && promptOnSecureDesktop != null) { var stringConsent = consentPromptBehavior.ToString(); var stringPrompt = promptOnSecureDesktop.ToString(); if (stringConsent.Equals("0") && stringPrompt.Equals("0")) { collection.Os.UacStatus = "Never Notify"; } else if (stringConsent.Equals("5") && stringPrompt.Equals("0")) { collection.Os.UacStatus = "Notify Changes"; } else if (stringConsent.Equals("5") && stringPrompt.Equals("1")) { collection.Os.UacStatus = "Notify Changes (Dim)"; } else if (stringConsent.Equals("2") && stringPrompt.Equals("0")) { collection.Os.UacStatus = "Always Notify"; } else { collection.Os.UacStatus = "Unknown"; } } } //get sus server from registry var susKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate"); if (susKey != null) { osInventory.UpdateServer = Convert.ToString(susKey.GetValue("WUServer")); osInventory.SUStargetGroup = Convert.ToString(susKey.GetValue("TargetGroup")); } collection.Os = osInventory; } catch (Exception ex) { Logger.Error("Could Not Parse OS Inventory"); Logger.Error(ex.Message); } try { GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); watcher.PositionChanged += (sender, e) => { var coordinate = e.Position.Location; collection.Os.Latitude = coordinate.Latitude.ToString(CultureInfo.InvariantCulture); collection.Os.Longitude = coordinate.Longitude.ToString(CultureInfo.InvariantCulture); collection.Os.LastLocationUpdateUtc = e.Position.Timestamp.DateTime; }; watcher.TryStart(true, TimeSpan.FromMilliseconds(10000)); collection.Os.LocationEnabled = watcher.Permission == GeoPositionPermission.Granted; } catch { //ignored } } }