Example #1
0
        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);
        }
Example #2
0
 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);
     }
 }
Example #3
0
 private void Init()
 {
     ClearFiles();
     computerUsage = new ComputerUsage();
     WatchProcesses();
     while (true)
     {
         ;
     }
 }