private void button1_Click(object sender, EventArgs e) { MachineData mdata = new MachineData(); Name = tvstools.GetMachineName(); mdata.disks = tvstools.ReadSmart(); mdata.ethernets = tvstools.GetNetworkDevices(); mdata.mounts = tvstools.GetMountPoints(); mdata.UpTime = tvstools.GetUpTime(); mdata.Processor = tvstools.GetProcessorName(); mdata.OS = tvstools.GetOSName(); mdata.FreeMemory = tvstools.GetFreeMemory(); mdata.FreeSwap = tvstools.GetFreeSwapMemory(); mdata.TotalMemory = tvstools.GetTotalMemory(); mdata.TotalSwap = tvstools.GetTotalSwapMemory(); mdata.Name = Name; //API.SessionKey = "f42a8580-24b7-11e4-b30f-3b79ab91660d"; //textBox1.Text += "\r\n" + API._CallAPI("loadmachines", null); textBox1.Text += "\r\n" + mdata.ToJSON(); //Smart[] smarts = tvstools.ReadSmart(); //foreach (Smart smart in smarts) //{ // textBox1.Text += smart.ToString(); //} }
public static Boolean SendMachine(MachineData m) { JObject data = _CallAPI("updatemachine", new NameValueCollection() { {"machinedata",m.ToJSON()} }); if (data["status"].ToString().Equals("OK")) { MachineUUID = data["machineuuid"].ToString(); return true; } else { LogMan.AddLog("Error: " + data.ToString()); return false; } }
public static Boolean SendMachine(MachineData m) { JObject data = _CallAPI("updatemachine", new NameValueCollection() { { "machinedata", m.ToJSON() } }); if (data["status"].ToString().Equals("OK")) { MachineUUID = data["machineuuid"].ToString(); return(true); } else { LogMan.AddLog("Error: " + data.ToString()); return(false); } }
private void OnTimedEvent(object source, ElapsedEventArgs e) { mTimer.Stop(); MachineData mdata = new MachineData(); LogMan.AddLog("Fetching Smart"); mdata.disks = tvstools.ReadSmart(); GC.KeepAlive(mTimer); LogMan.AddLog("Fetching Network Devices"); mdata.ethernets = tvstools.GetNetworkDevices(); GC.KeepAlive(mTimer); LogMan.AddLog("Fetching Mount Points"); mdata.mounts = tvstools.GetMountPoints(); GC.KeepAlive(mTimer); mdata.UUID = MachineUUID; mdata.UpTime = tvstools.GetUpTime(); mdata.Processor = tvstools.GetProcessorName(); mdata.OS = tvstools.GetOSName(); mdata.FreeMemory = tvstools.GetFreeMemory(); mdata.FreeSwap = tvstools.GetFreeSwapMemory(); mdata.TotalMemory = tvstools.GetTotalMemory(); mdata.TotalSwap = tvstools.GetTotalSwapMemory(); mdata.Name = Name; LogMan.AddDebug(mdata.ToJSON()); GC.KeepAlive(mTimer); LogMan.AddLog("Sending data"); if (API.SendMachine(mdata)) { if (MachineUUID == null) { MachineUUID = API.MachineUUID; LogMan.AddLog("First time of this machine! Now the UUID is: " + MachineUUID); RegMan.Write("MachineUUID", MachineUUID); } LogMan.AddLog("Data sent successfully!"); } else { LogMan.AddLog("Fail sending machine data!"); } mTimer.Start(); }