public void WriteHardDiskState(HardDiskState hardDiskState)
 {
     lock (context)
     {
         context.HardDiskStatistics.Add(hardDiskState);
         context.SaveChanges();
     }
 }
Ejemplo n.º 2
0
 protected override void WriteMonitoringResource()
 {
     foreach (var driveInfo in DriveInfo.GetDrives())
     {
         if (driveInfo.IsReady && (driveInfo.DriveType == DriveType.Fixed || driveInfo.DriveType == DriveType.Removable))
         {
             var drive = diskDriveStateLoader.GetDrive(driveInfo.Name) ?? new Drive { Name = driveInfo.Name };
             var state = new HardDiskState
             {
                 Drive = drive,
                 Date = DateTime.Now,
                 AvailableFreeSpace = driveInfo.AvailableFreeSpace
             };
             diskDriveStateWriter.WriteHardDiskState(state);
         }
     }
 }