Exemplo n.º 1
0
        private void CalculateStatistics(int queueCount, DateTime start, DateTime end, TimeSpan totalTime)
        {
            if (queueCount > 0)
            {
                UpdateStatus(end.ToString(Resource.DateTimeFormat, CultureInfo.CurrentCulture), StatusEventType.UpgradeEndTime);
                UpdateStatus(start.ToString(Resource.DateTimeFormat, CultureInfo.CurrentCulture), StatusEventType.UpgradeStartTime);

                long     avgQueueCreationTime      = totalTime.Ticks / (long)queueCount;
                TimeSpan avgQueueUpgradeTimeSpan   = new TimeSpan(avgQueueCreationTime);
                string   queueUpgradeDurationValue = Resource.DurationFormat.FormatWith
                                                     (
                    avgQueueUpgradeTimeSpan.Hours,
                    avgQueueUpgradeTimeSpan.Minutes,
                    avgQueueUpgradeTimeSpan.Seconds,
                    avgQueueUpgradeTimeSpan.Milliseconds
                                                     );
                UpdateStatus(queueUpgradeDurationValue, StatusEventType.AverageQueueUpgradeDuration);

                string durationValue = Resource.LongDurationFormat.FormatWith
                                       (
                    totalTime.Days,
                    totalTime.Hours,
                    totalTime.Minutes,
                    totalTime.Seconds,
                    totalTime.Milliseconds
                                       );
                UpdateStatus(durationValue, StatusEventType.TotalUpgradeTime);

                PrinterInstallStatus status = _queueManager.Installer.InstallStatus;
                string key = "Overall Driver Upgrade Process";
                status.Create(key);
                status[key].Record("OVERALL UPGRADE START", start);
                status[key].Record("OVERALL UPGRADE END", end);
                status[key].Record("AVERAGE QUEUE UPGRADE TIME", avgQueueUpgradeTimeSpan);
                status[key].Record("TOTAL QUEUE UPGRADE TIME", totalTime);
            }

            FireUpgradeCompleted();
        }