internal static SignboardDiagnosticModel From(SignboardDiagnostics diagnostics)
 {
     return new SignboardDiagnosticModel()
     {
         DiagnosticDate = diagnostics.Date,
         SoftwareVersion = diagnostics.SoftwareVersion.VersionNumber,
         Metrics = diagnostics.Metrics.Select(x => SignboardDiagnosticMetricModel.From(x.Metric.ToString(), x.Value)).ToList()
     };
 }
        private static DiagnosticsTableEntity Map(SignboardDiagnostics entity)
        {
            if (entity == null)
            {
                return null;
            }

            var tableEntity = new DiagnosticsTableEntity(entity.SignboardId, entity.Date, entity.SoftwareVersion);

            tableEntity.CpuPercentageMetric = entity.GetMetricValue(DiagnosticMetricType.CpuUsagePercentage);
            tableEntity.RamPercentageMetric = entity.GetMetricValue(DiagnosticMetricType.RamUsagePercentage);
            tableEntity.DiskPercentageMetric = entity.GetMetricValue(DiagnosticMetricType.DiskUsagePercentage);
            tableEntity.SignboardStateMetric = entity.GetMetricValue(DiagnosticMetricType.SignboardState);
            tableEntity.IsShowingScreensaverMetric = entity.GetMetricValue(DiagnosticMetricType.IsShowingScreensaver);
            tableEntity.SlideshowObject = entity.GetMetricValue(DiagnosticMetricType.SlideshowHealthMetric);
            tableEntity.NetworkTrafficBytesRecieved = entity.GetMetricValue(DiagnosticMetricType.NetworkTrafficBytesRecieved);
            tableEntity.NetworkTrafficBytesSent = entity.GetMetricValue(DiagnosticMetricType.NetworkTrafficBytesSent);

            return tableEntity;
        }
        private static SignboardDiagnostics Map(DiagnosticsTableEntity tableEntity)
        {
            if (tableEntity == null)
            {
                return null;
            }

            var diagnostics = new SignboardDiagnostics(tableEntity.SignboardId, tableEntity.Date, SoftwareVersion.From(tableEntity.Version));

            diagnostics.AddMetricValue(DiagnosticMetricType.CpuUsagePercentage, tableEntity.CpuPercentageMetric);
            diagnostics.AddMetricValue(DiagnosticMetricType.RamUsagePercentage, tableEntity.RamPercentageMetric);
            diagnostics.AddMetricValue(DiagnosticMetricType.DiskUsagePercentage, tableEntity.DiskPercentageMetric);
            diagnostics.AddMetricValue(DiagnosticMetricType.SignboardState, tableEntity.SignboardStateMetric);
            diagnostics.AddMetricValue(DiagnosticMetricType.IsShowingScreensaver, tableEntity.IsShowingScreensaverMetric);
            diagnostics.AddMetricValue(DiagnosticMetricType.SlideshowHealthMetric, tableEntity.SlideshowObject);
            diagnostics.AddMetricValue(DiagnosticMetricType.NetworkTrafficBytesRecieved, tableEntity.NetworkTrafficBytesRecieved);
            diagnostics.AddMetricValue(DiagnosticMetricType.NetworkTrafficBytesSent, tableEntity.NetworkTrafficBytesSent);

            return diagnostics;
        }
 public void Write(SignboardDiagnostics diagnostics)
 {
     DiagnosticsTableStorage.Write(DiagnosticsComponent.Map(diagnostics));
 }
        private SignboardDiagnostics GetSignboardDiagnostics(Guid signboardId, DiagnosticInputModel diagnosticsModel)
        {
            var diagnostics = new SignboardDiagnostics(signboardId, diagnosticsModel.DiagnosticDate, SoftwareVersion.From(diagnosticsModel.SoftwareVersion));
            foreach (DiagnosticMetricInputModel metric in diagnosticsModel.Metrics)
            {
                diagnostics.AddMetricValue((DiagnosticMetricType)Enum.Parse(typeof(DiagnosticMetricType), metric.Name), metric.Value.ToString());
            }

            if (diagnosticsModel.SignboardHealth == null)
            {
                return diagnostics;
            }
            else
            {
                diagnostics.AddMetricValue(DiagnosticMetricType.SignboardState, diagnosticsModel.SignboardHealth.ScreenState);
                diagnostics.AddMetricValue(DiagnosticMetricType.IsShowingScreensaver, diagnosticsModel.SignboardHealth.IsShowingScreensaver.ToString());

                if (diagnosticsModel.SignboardHealth.SlideHealth == null || diagnosticsModel.SignboardHealth.SlideHealth.Count == 0)
                {
                    return diagnostics;
                }

                diagnostics.AddMetricValue(DiagnosticMetricType.SlideshowHealthMetric, diagnosticsModel.SignboardHealth.ToString());
            }

            return diagnostics;
        }