public void AddHistoryItem(FixedSizeQueue <DiskStatQueue> from, int count, FixedSizeQueue <DiskStatQueue> to, long index)
        {
            if (from.Count() < count)
            {
                return;
            }
            double used = 0;
            double free = 0;
            double size = 0;

            for (int i = 1; i <= count; i++)
            {
                DiskStatQueue sample = from.ElementAt(history.Count() - i);
                used += sample.used;
                free += sample.free;
                size += sample.size;
            }
            used /= count;
            free /= count;
            size /= count;

            var hourSample = new DiskStatQueue
            {
                SampleID = index,
                used     = used,
                free     = free,
                size     = size
            };

            to.Enqueue(hourSample);
        }
        public void AddDisk(DriveInfo d)
        {
            bool found = false;

            foreach (var s in _disks)
            {
                if (s.name == d.Name)
                {
                    found = true;
                }
            }
            if (found == false)
            {
                var disk = new StatDiskItem(d.Name);
                _disks.Add(disk);
                sessionID = DateTime.Now.Ticks;
            }
            foreach (var s in _disks)
            {
                if (s.name == d.Name)
                {
                    var ns = new DiskStatQueue
                    {
                        size       = d.TotalSize / 1048576,
                        used       = (d.TotalSize - d.AvailableFreeSpace) / 1048576,
                        free       = d.AvailableFreeSpace / 1048576,
                        percentage = 100 - ((d.TotalFreeSpace * 100 / d.TotalSize)),
                        SampleID   = historyIndex
                    };
                    s.history.Enqueue(ns);
                }
            }
        }
Ejemplo n.º 3
0
        public void AddHistoryItem(FixedSizeQueue<DiskStatQueue> from, int count, FixedSizeQueue<DiskStatQueue> to, long index)
        {
            if (from.Count() < count)
                return;
            double used = 0;
            double free = 0;
            double size = 0;
            for (int i = 1; i <= count; i++)
              		{
              			DiskStatQueue sample = from.ElementAt(history.Count() - i);
                used += sample.used;
                free += sample.free;
                size += sample.size;
              		}
            used /= count;
            free /= count;
            size /= count;

            var hourSample = new DiskStatQueue
            {
                SampleID = index,
                used = used,
                free = free,
                size = size
            };
            to.Enqueue(hourSample);
        }
Ejemplo n.º 4
0
 public void AddDisk(DriveInfo d)
 {
     bool found = false;
         foreach (var s in _disks){
             if (s.name == d.Name)
             {
                 found = true;
             }
         }
         if(found == false){
             var disk = new StatDiskItem(d.Name);
             _disks.Add(disk);
             sessionID = DateTime.Now.Ticks;
         }
         foreach (var s in _disks){
             if(s.name == d.Name){
                  var ns = new DiskStatQueue
                  {
                      size = d.TotalSize / 1048576,
                      used = (d.TotalSize - d.AvailableFreeSpace) / 1048576,
                      free = d.AvailableFreeSpace / 1048576,
                      percentage = 100 - ((d.TotalFreeSpace * 100 / d.TotalSize)),
                      SampleID = historyIndex
                  };
                  s.history.Enqueue(ns);
             }
         }
 }