Exemplo n.º 1
0
        /// <summary>
        ///     Return the processor ID of device.
        /// </summary>
        /// <returns>Processor ID of device.</returns>
        public static string GetProcessorId()
        {
            IDeviceIdComponent comp;

            if (OS.IsWindows)
            {
                comp = new WmiDeviceIdComponent("ProcessorId", "Win32_Processor", "ProcessorId");
            }
            else if (OS.IsLinux)
            {
                comp = new FileDeviceIdComponent("ProcessorId", "/proc/cpuinfo", true);
            }
            else
            {
                comp = new UnsupportedDeviceIdComponent("ProcessorId");
            }

            return(comp.GetValue());
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Return the motherboard serial number of device. On Linux, this requires root privilege.
        /// </summary>
        /// <returns>The motherboard serial number of devicee.</returns>
        public static string GetMotherboardSerialNumber()
        {
            IDeviceIdComponent comp;

            if (OS.IsWindows)
            {
                comp = new WmiDeviceIdComponent("MotherboardSerialNumber", "Win32_BaseBoard", "SerialNumber");
            }
            else if (OS.IsLinux)
            {
                comp = new FileDeviceIdComponent("MotherboardSerialNumber", "/sys/class/dmi/id/board_serial");
            }
            else
            {
                comp = new UnsupportedDeviceIdComponent("MotherboardSerialNumber");
            }

            return(comp.GetValue());
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Return the system UUID of device. On Linux, this requires root privilege.
        /// </summary>
        /// <returns>The system UUID of device.</returns>
        public static string GetSystemUUID()
        {
            IDeviceIdComponent comp;

            if (OS.IsWindows)
            {
                comp = new WmiDeviceIdComponent("SystemUUID", "Win32_ComputerSystemProduct", "UUID");
            }
            else if (OS.IsLinux)
            {
                comp = new FileDeviceIdComponent("SystemUUID", "/sys/class/dmi/id/product_uuid");
            }
            else
            {
                comp = new UnsupportedDeviceIdComponent("SystemUUID");
            }

            return(comp.GetValue());
        }
Exemplo n.º 4
0
        public SRClient GetClientDevice()
        {
            DeviceIdBuilder cDeviceId = new DeviceIdBuilder();

            cDeviceId.AddProcessorId();
            cDeviceId.AddMachineName();
            cDeviceId.AddOSVersion();
            cDeviceId.AddSystemUUID();
            cDeviceId.AddUserName();

            // DeviceIdComponent dc = new DeviceIdComponent("test", );
            var wmi = new ManagementObjectSearcher("select * from Win32_OperatingSystem")
                      .Get()
                      .Cast <ManagementObject>()
                      .First();
            var cpu = new ManagementObjectSearcher("select * from Win32_Processor")
                      .Get()
                      .Cast <ManagementObject>()
                      .First();

            var cMachineName    = Environment.MachineName;
            var cExePath        = Environment.CommandLine;
            var cOSVersion      = Environment.OSVersion;
            var cProcessorID    = new WmiDeviceIdComponent("ProcessorId", "Win32_Processor", "ProcessorId").GetValue();
            var cProcessorCount = System.Environment.ProcessorCount;
            var cUUID           = new WmiDeviceIdComponent("SystemUUID", "Win32_ComputerSystemProduct", "UUID").GetValue();
            var cNetwork        = new NetworkAdapterDeviceIdComponent(false, false).GetValue();

            var c = new SRClient();

            c.MachineName = cMachineName;
            c.DeviceID    = cDeviceId.ToString();
            c.FirstRun    = DateTime.Now;
            c.LastActive  = DateTime.Now;
            c.ExePath     = cExePath;
            c.UUID        = cUUID;

            var cOS = new ClientOS();

            cOS.Name            = ((string)wmi["Caption"]).Trim();;
            cOS.Build           = ((string)wmi["BuildNumber"]).StrToInt();
            cOS.Version         = (string)wmi["Version"];
            cOS.SerialNumber    = (string)wmi["SerialNumber"];
            cOS.Architecture    = (string)wmi["OSArchitecture"];
            cOS.MaxProcessCount = (uint)wmi["MaxNumberOfProcesses"];
            cOS.MaxProcessRAM   = (ulong)wmi["MaxProcessMemorySize"];
            c.OS = new List <ClientOS>()
            {
                cOS
            };

            var cCPU = new ClientCPU();

            cCPU.ID          = (string)cpu["ProcessorId"];
            cCPU.Name        = (string)cpu["Name"];
            cCPU.Description = (string)cpu["Caption"];
            // cCPU.Socket = (string)cpu["SocketDesignation"];
            // cCPU.AddressWidth = (ushort)cpu["AddressWidth"];
            // cCPU.DataWidth = (ushort)cpu["DataWidth"];
            // cCPU.Architecture = (ushort)cpu["Architecture"];
            // cCPU.SpeedMHz = (uint)cpu["MaxClockSpeed"];
            // cCPU.BusSpeedMHz = (uint)cpu["ExtClock"];
            // cCPU.L2Cache = (uint)cpu["L2CacheSize"] * (ulong)1024;
            // cCPU.L3Cache = (uint)cpu["L3CacheSize"] * (ulong)1024;
            // cCPU.Cores = (uint)cpu["NumberOfCores"];
            // cCPU.Threads = (uint)cpu["NumberOfLogicalProcessors"];
            c.CPU = new List <ClientCPU>()
            {
                cCPU
            };

            // var js = JsonConvert.SerializeObject(c);
            // Debug.WriteLine(js);
            return(c);
        }