コード例 #1
0
        public List <VersionInfo> GetVersions()
        {
            // запрос версий
            var windows = WmiHelper.First(WmiHelper.QueryInfo("Win32_OperatingSystem"));
            var bdb     = getDbVersion("BaseComplex", "select max(Version) from Db_verson");
            var bdb2    = getDbVersion("BaseComplex2", "select max(Version) from Db_version");
            var aisurt  = getAisurtVersion();

            // запись результата
            return(new List <VersionInfo>
            {
                new VersionInfo("ОС Windows", string.Format("{0} {1}", windows["Caption"], windows["CSDVersion"])),
                new VersionInfo("SQL Server", DatabaseHelper.Instance.GetServerVersion(ConnectionWrapper.CreateLoginPassword(string.Empty, "master", "sa", string.Empty).ConnectionString)),
                new VersionInfo("АС БДБ", prepare(bdb)),
                new VersionInfo("АМ КЗ", prepare(bdb2)),
                new VersionInfo("АИС УРТ", aisurt),
                new VersionInfo("Aux Service", Assembly.GetExecutingAssembly().GetName().Version.ToString())
            });
        }
コード例 #2
0
        public SystemInfo GetSystemInfo()
        {
            var info = new SystemInfo();

            try
            {
                var cpu = WmiHelper.First(WmiHelper.QueryInfo("Win32_Processor"));
                info.Processor = new CPU
                {
                    Name     = (string)cpu["Name"],
                    SpeedMHz = (uint)cpu["CurrentClockSpeed"]
                };

                var memory = WmiHelper.First(WmiHelper.QueryInfo("Win32_LogicalMemoryConfiguration"));
                info.Memory = (uint)memory["TotalPhysicalMemory"] * 1024;

                var motherboard = WmiHelper.First(WmiHelper.QueryInfo("Win32_BaseBoard"));
                info.MotherBoard = new MotherBoard
                {
                    Manufacturer = (string)motherboard["Manufacturer"],
                    Model        = (string)motherboard["Product"]
                };

                foreach (var disk in Environment.GetLogicalDrives())
                {
                    var drive = new DriveInfo(disk);
                    if (drive.IsReady)
                    {
                        info.HDD.Add(new Disk
                        {
                            Name       = drive.Name,
                            Label      = drive.VolumeLabel,
                            TotalSpace = drive.TotalSize,
                            FreeSpace  = drive.AvailableFreeSpace
                        });
                    }
                }

                info.Printers.AddRange(PrintInfo.GetPrinterList());
                foreach (var printer in WmiHelper.QueryInfo("Win32_Printer"))
                {
                    string name        = (string)printer.Properties["Caption"].Value;
                    var    printerInfo = info.Printers.Find(p => p.Caption == name);
                    if (printerInfo != null)
                    {
                        printerInfo.Model = (string)printer.Properties["DriverName"].Value;
                    }
                }

                info.HostName = SystemInformation.ComputerName;

                foreach (var address in Dns.GetHostEntry(info.HostName).AddressList)
                {
                    info.IPAddresses.Add(address.ToString());
                }

                info.UserName = SystemInformation.UserName;                 // можно также через System.Enironment.UserName
            }
            catch
            { }
            return(info);
        }