Ejemplo n.º 1
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
            }
        }
 public void GetOperatingSystemInformation()
 {
     _builder.WriteMessage(OperatingSystemInformation.ToObject());
 }
        private static async Task <Dictionary <String, String> > OSInfoToDico(Dictionary <string, string> returnedInfo, OperatingSystemInformation operatingSystem)
        {
            returnedInfo.Add("OS Edition", operatingSystem.OsEdition);
            returnedInfo.Add("OS Version", operatingSystem.OsVersionString);
            returnedInfo.Add("Platform", operatingSystem.PlatformName);
            returnedInfo.Add("Language", operatingSystem.Language);

            return(returnedInfo);
        }