Exemple #1
0
 public List <MemoryViewModel> GetMemoryInfos()
 {
     try
     {
         using (var scope = new SQLServerDBContextScope(this.mDBConnect))
         {
             SQLServerDBRepertory   db          = new SQLServerDBRepertory();
             List <RingBuffer>      buffers     = db.Filter <RingBuffer, DateTime>(d => d.Type == "RING_BUFFER_SCHEDULER_MONITOR" && d.Record.Contains("<SystemHealth>"), d => d.EventTime);
             SystemInfo             system      = db.Find <SystemInfo>(d => d.PhysicalMemory > 0);
             List <MemoryViewModel> memoryInfos = new List <MemoryViewModel>();
             foreach (RingBuffer buffer in buffers)
             {
                 MemoryViewModel info = RingBufferHelper.ParseXMLToMemoryInfo(buffer.Record);
                 info.TotalMemory = system.PhysicalMemory;
                 info.UseMemory   = Convert.ToInt32(system.PhysicalMemory * ((double)info.MemoryUtilization / 100));
                 info.EventTime   = buffer.EventTime.ToLocalTime().ToString();
                 memoryInfos.Add(info);
             }
             return(memoryInfos);
         }
     }
     catch (Exception e)
     {
         throw;
     }
 }
Exemple #2
0
 public List <CPUViewModel> GetCPUInfos()
 {
     try
     {
         using (var scope = new SQLServerDBContextScope(this.mDBConnect))
         {
             SQLServerDBRepertory db       = new SQLServerDBRepertory();
             List <RingBuffer>    buffers  = db.Filter <RingBuffer, DateTime>(d => d.Type == "RING_BUFFER_SCHEDULER_MONITOR" && d.Record.Contains("<SystemHealth>"), d => d.EventTime);
             List <CPUViewModel>  cpuInfos = new List <CPUViewModel>();
             foreach (RingBuffer buffer in buffers)
             {
                 CPUViewModel info = RingBufferHelper.ParseXMLToCPUnfo(buffer.Record);
                 info.EventTime = buffer.EventTime.ToLocalTime().ToString();
                 cpuInfos.Add(info);
             }
             return(cpuInfos);
         }
     }
     catch (Exception e)
     {
         throw;
     }
 }