コード例 #1
0
ファイル: ComputerSystem.cs プロジェクト: cocoon/Toec
 public void Search(DtoInventoryCollection collection)
 {
     using (var wmi = new ServiceWmi <DtoComputerSystemInventory>(new DtoComputerSystemInventory()))
     {
         collection.ComputerSystem = wmi.Execute();
     }
 }
コード例 #2
0
ファイル: Processor.cs プロジェクト: theopenem/Toec
 public void Search(DtoInventoryCollection collection)
 {
     using (var wmi = new ServiceWmi <DtoProcessorInventory>(new DtoProcessorInventory()))
     {
         collection.Processor = wmi.Execute();
     }
 }
コード例 #3
0
 public void Search(DtoInventoryCollection collection)
 {
     using (var wmi = new ServiceWmi <DtoBiosInventory>(new DtoBiosInventory()))
     {
         collection.Bios = wmi.Execute();
     }
 }
コード例 #4
0
        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;
                }
            }
        }
コード例 #5
0
ファイル: ModuleWuManager.cs プロジェクト: theopenem/Toec
        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());
        }
コード例 #6
0
ファイル: OS.cs プロジェクト: theopenem/Toec
        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
                }
            }
        }