public static Data Collect(PerformanceCounter ramCounter, PerformanceCounter totalCpu) { User user = new User { PcName = Environment.MachineName, UserName = Environment.UserName, MAC = GetMACAddress(), Ip = GetIP() }; ComputerUsage cu = new ComputerUsage { CPU = totalCpu.NextValue(), RAM = ramCounter.NextValue() }; Data data = new Data { ComputerUsage = cu, User = user, Date = DateTime.Now }; return(data); }
private void WriteToJson(ComputerUsage computerUsage, string fileName = "") { //todo handle being used by another process exception try { FileHandler.WriteJsonInFile(computerUsage, fileName); } catch (Exception exception) { Console.WriteLine("Error " + exception); } }
private void Init() { ClearFiles(); computerUsage = new ComputerUsage(); WatchProcesses(); while (true) { ; } }