Ejemplo n.º 1
0
        private void UpdateStats()
        {
            try
            {
                var totalQueueSizeInBytes  = Queue.ToList().Sum((q) => q.File == null ? 0d : q.File.SizeInBytes);
                var totalToTransferInBytes = Workers.ToList().Sum((w) => w.SizeInBytes);

                var speedSample = new List <Worker>(Workers.Where((w) => w.SpeedInBytes > 0));
                speedSample.AddRange(WorkersHistory.Skip(WorkersHistory.Count - 10).Where((w) => w.SpeedInBytes > 0));
                var currentSpeed = speedSample.Count == 0 ? 0d : speedSample.Average((w) => w.SpeedInBytes);

                _SpeedHistory.Add(currentSpeed);
                while (_SpeedHistory.Count > 120)
                {
                    _SpeedHistory.RemoveAt(0);
                }

                var averageSpeed = _SpeedHistory.Average((s) => s);
                if (Workers.Count == 0)
                {
                    averageSpeed = 0;
                }

                AverageSpeed       = SizeUtil.Format(averageSpeed, "/s");
                TotalQueueSize     = SizeUtil.Format(totalQueueSizeInBytes);
                TotalToTransfer    = SizeUtil.Format(totalToTransferInBytes);
                TotalTransfered    = SizeUtil.Format(Workers.ToList().Sum((w) => w.TransferedInBytes));
                RemainingTime      = Workers.Count == 0 ? TimeSpan.FromSeconds(0) : Workers.ToList().Max((w) => w.TimeRemaining);
                QueueCount         = Queue.Count;
                WorkersCount       = Workers.Count;
                QueueRemainingTime = TimeSpan.FromSeconds(averageSpeed == 0 ? 0 : Convert.ToInt32((totalQueueSizeInBytes + totalToTransferInBytes) / averageSpeed));
            }
            catch { }
        }
Ejemplo n.º 2
0
 private void ArchiveWorker(Worker worker)
 {
     worker.Thread = null;
     worker.BlobJob.StorageAccountKey = null;
     ExecuteOnUI(() =>
     {
         Workers.Remove(worker);
         WorkersHistory.Add(worker);
     });
 }