Ejemplo n.º 1
0
        public Task TraceAsync(string data, DataOperation operation)
        {
            return(App.Current.Dispatcher.InvokeAsync(() =>
            {
                if (!string.IsNullOrWhiteSpace(data))
                {
                    DataLenght += data.Length;

                    var json = JObject.Parse(data);
                    json.ToString(Formatting.Indented);
                    var traceData = new TraceDataViewModel()
                    {
                        Operation = operation,
                        Data = json.ToString()
                    };

                    TraceLogs.Add(traceData);

                    while (TraceLogs.Count > TraceLimit)
                    {
                        TraceLogs.RemoveAt(0);
                    }
                }
            }).Task);
        }
        void ProcessEvent(Log log)
        {
            if (log.Type != VideoLogTypes.Trace && log.Type != VideoLogTypes.VideoQualitySnapshot)
            {
                // weed these out, there are way too many of them. This is consistent with what a logagent that sends to the server would do too.
                Logs.Add(log);
            }

            IEnumerable <ChartViewModel> charts = ChartViewModel.Charts;

            switch (log.Type)
            {
            case VideoLogTypes.VideoQuality:
                QualityData = new QualityDataViewModel(log.CastLog <VideoQualityLog>());
                break;

            case VideoLogTypes.VideoQualitySnapshot:
                VideoQualitySnapshotLog qualityLog = log.CastLog <VideoQualitySnapshotLog>();

                foreach (ChartViewModel chartVM in charts)
                {
                    if (log.Data.ContainsKey(chartVM.QualityAttribute))
                    {
                        if (chartVM.QualityAttribute == VideoLogAttributes.PerceivedBandwidth)
                        {
                            chartVM.AddDataPoint(qualityLog.PerceivedBandwidth.GetValueOrDefault(0) / 1024);
                        }
                        else
                        {
                            chartVM.AddDataPoint(Convert.ToDouble(log.Data[chartVM.QualityAttribute]));
                        }
                    }
                }

                ClientIP           = qualityLog.ClientIP.ToString();
                EdgeServerIP       = qualityLog.EdgeIP;
                SmoothStreamingUrl = qualityLog.VideoUrl;
                ProcessCPU         = qualityLog.ProcessCPULoad.GetValueOrDefault(0);
                SystemCPU          = qualityLog.SystemCPULoad.GetValueOrDefault(0);

                break;

            case VideoLogTypes.VideoStarted:
            case VideoLogTypes.VideoLoaded:
                VideoLoadLog loadLog = log.CastLog <VideoLoadLog>();

                var bitrateChartData = charts.First(vm => vm.QualityAttribute == VideoLogAttributes.BitRate);
                if (loadLog.MaxBitRate.HasValue)
                {
                    bitrateChartData.MaxValue = loadLog.MaxBitRate.Value;
                }
                ClientIP           = loadLog.ClientIP.ToString();
                EdgeServerIP       = loadLog.EdgeIP;
                SmoothStreamingUrl = loadLog.VideoUrl;
                break;

            case VideoLogTypes.Trace:
                TraceLogs.Add(log.CastLog <TraceLog>());
                break;
            }
        }