Exemplo n.º 1
0
        private void SendScore(String type, Int32 count)
        {
            var ds  = _DS;
            var cfg = Setting.Current;

            var nvs = new Dictionary <String, Object>();

            nvs[nameof(type)] = type;
            nvs["score"]      = ds.Score;
            //nvs["name"] = "{0}/{1}".F(Environment.UserName, Environment.MachineName);
            nvs["name"] = cfg.Name;

            nvs["OS"] = Runtime.OSName;

            using (var reg = Registry.LocalMachine.OpenSubKey(@"HARDWARE\DESCRIPTION\System\CentralProcessor\0"))
            {
                nvs["Processor"] = (reg.GetValue("ProcessorNameString") + "").Trim();
                nvs["Frequency"] = reg.GetValue("~MHz").ToInt() + "";
            }
            nvs["Memory"] = Runtime.PhysicalMemory;

            nvs["Config"] = new { count, ds.Threads, ds.BatchSize, ds.UseSql }.ToJson();

            XTrace.WriteLine(nvs.ToJson(true));

            var url = Setting.Current.Address.EnsureEnd("/add");

            var client = new WebClientX(true, true);

            client.Log = XTrace.Log;
            client.UploadJsonAsync(url, nvs);
        }