Example #1
0
        public void GetCpuInformation()
        {
            if (string.IsNullOrEmpty(CpuInformation.Name))
            {
                var cpu =
                    new ManagementObjectSearcher("select * from Win32_Processor")
                    .Get()
                    .Cast <ManagementObject>()
                    .First();

                CpuInformation.Id           = (string)cpu["ProcessorId"];
                CpuInformation.Socket       = (string)cpu["SocketDesignation"];
                CpuInformation.Name         = (string)cpu["Name"];
                CpuInformation.Description  = (string)cpu["Caption"];
                CpuInformation.AddressWidth = (ushort)cpu["AddressWidth"];
                CpuInformation.DataWidth    = (ushort)cpu["DataWidth"];
                CpuInformation.Architecture = Environment.Is64BitOperatingSystem ? "x64" : "x86";
                CpuInformation.SpeedMHz     = (uint)cpu["MaxClockSpeed"];
                CpuInformation.BusSpeedMHz  = (uint)cpu["ExtClock"];
                CpuInformation.L2Cache      = (uint)cpu["L2CacheSize"] * (ulong)1024;
                CpuInformation.L3Cache      = (uint)cpu["L3CacheSize"] * (ulong)1024;
                CpuInformation.Cores        = (uint)cpu["NumberOfCores"];
                CpuInformation.Threads      = (uint)cpu["NumberOfLogicalProcessors"];

                CpuInformation.Name =
                    CpuInformation.Name
                    .Replace("(TM)", "™")
                    .Replace("(tm)", "™")
                    .Replace("(R)", "®")
                    .Replace("(r)", "®")
                    .Replace("(C)", "©")
                    .Replace("(c)", "©")
                    .Replace("    ", " ")
                    .Replace("  ", " ");
            }
            serializator.Serialize(_client, packet.endpoint, packet.syncKey, CpuInformation.ToObject());
        }
Example #2
0
        private async void SendData()
        {
            try
            {
                var data = new
                {
                    ServerInfo         = OperatingSystemInformation.ToObject(),
                    SystemInfo         = SystemInformation.ToObject(),
                    UlteriusVersion    = Assembly.GetExecutingAssembly().GetName().Version,
                    GpuInfo            = GetGpuInformation(),
                    NetworkInformation = NetworkInformation.ToObject(),
                    CpuInfo            = CpuInformation.ToObject()
                };
                var json    = JsonConvert.SerializeObject(data);
                var content = new FormUrlEncodedContent(new[]
                {
                    new KeyValuePair <string, string>("guid", GetMachineGuid()),
                    new KeyValuePair <string, string>("results", json)
                });
                using (var client = new HttpClient())
                {
                    client.Timeout = new TimeSpan(0, 0, 0, 5);
                    var result = await client.PostAsync("https://api.ulterius.io/hardware/", content);

                    if (result.IsSuccessStatusCode)
                    {
                        Console.WriteLine("Hardware Survery Completed");
                        File.WriteAllText(results, "true");
                    }
                }
            }
            catch (Exception)
            {
                //just fail
            }
        }
Example #3
0
 public void GetCpuInformation()
 {
     _builder.WriteMessage(CpuInformation.ToObject());
 }