Ejemplo n.º 1
0
        /// <summary>
        /// Required to initialize the TraceMonitor. Once this is called you can call .Start()
        /// </summary>
        /// <param name="Config">Required information about how the trace monitor should operate.</param>
        public static void Init(TracingConfig Config)
        {
            if (!IsInitialized)
            {
                if (System.Windows.Deployment.Current.CheckAccess())
                {
                    IsInitialized = true;
                    config        = Config;

                    Tracing.Initialize();
                    if (Config.TracingConfigFile == null)
                    {
                        using (XmlReader reader = XmlReader.Create(DefaultTracingConfigResourceName))
                            Tracing.ReadTraceConfig(reader);
                    }
                    else
                    {
                        using (XmlReader reader = XmlReader.Create(Config.TracingConfigFile))
                            Tracing.ReadTraceConfig(reader);
                    }

                    traceClient = new TraceDataClient();
                    traceClient.EventCreated += traceClient_EventCreated;
                    timer          = new DispatcherTimer();
                    timer.Interval = Config.PollingInterval;
                    worker         = new BackgroundWorker();
                    worker.DoWork += worker_DoWork;
                }
                else
                {
                    throw new UnauthorizedAccessException("The TraceMonitor cannot be initialized on background thread. Call from the UI thread.");
                }
            }
        }
 void SetDefaultSettings()
 {
     TracingConfig = new TracingConfig();
     RecordTraceLogs = true;
     TrackQuality = true;
     TrackDownloadErrors = true;
     AggregationInterval = TimeSpan.FromSeconds(30);
     SnapshotInterval = TimeSpan.FromSeconds(1);
     LatencyAlertThreshold = 2;
     RecordTraceLogs = true;
     TrackQualitySnapshot = true;
     QualityConfig = null;
     EdgeServerRuleCollection = null;
 }
 void SetDefaultSettings()
 {
     TracingConfig            = new TracingConfig();
     RecordTraceLogs          = true;
     TrackQuality             = true;
     TrackDownloadErrors      = true;
     AggregationInterval      = TimeSpan.FromSeconds(30);
     SnapshotInterval         = TimeSpan.FromSeconds(1);
     LatencyAlertThreshold    = 2;
     RecordTraceLogs          = true;
     TrackQualitySnapshot     = true;
     QualityConfig            = null;
     EdgeServerRuleCollection = null;
 }
        /// <summary>
        /// Creates an instance of the TracingConfig from an Xml file.
        /// </summary>
        public static TracingConfig Load(XmlReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            var result = new TracingConfig();

            reader.GoToElement();
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement();
                while (reader.GoToSibling())
                {
                    switch (reader.LocalName)
                    {
                    case "TracingConfigFile":
                        result.TracingConfigFile = reader.ReadElementContentAsString();
                        break;

                    case "PollingMilliseconds":
                        result.PollingInterval = TimeSpan.FromMilliseconds(reader.ReadElementContentAsInt());
                        break;

                    case "RecordCpuLoad":
                        result.RecordCpuLoad = Convert.ToBoolean(reader.ReadElementContentAsInt());
                        break;

                    default:
                        reader.Skip();
                        break;
                    }
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Skip();
            }

            return(result);
        }
        /// <summary>
        /// Creates an instance of the TracingConfig from an Xml file.
        /// </summary>
        public static TracingConfig Load(XmlReader reader)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");

            var result = new TracingConfig();

            reader.GoToElement();
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement();
                while (reader.GoToSibling())
                {
                    switch (reader.LocalName)
                    {
                        case "TracingConfigFile":
                            result.TracingConfigFile = reader.ReadElementContentAsString();
                            break;
                        case "PollingMilliseconds":
                            result.PollingInterval = TimeSpan.FromMilliseconds(reader.ReadElementContentAsInt());
                            break;
                        case "RecordCpuLoad":
                            result.RecordCpuLoad = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;
                        default:
                            reader.Skip();
                            break;
                    }
                }
                reader.ReadEndElement();
            }
            else
                reader.Skip();

            return result;
        }
        /// <summary>
        /// Creates an instance of the main diagnostic config object from an XmlReader
        /// </summary>
        public static DiagnosticsConfig Load(XmlReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            var result = new DiagnosticsConfig();
            List <EdgeServerRules> edgeServerRuleCollection = null;

            reader.GoToElement();
            reader.ReadStartElement();
            if (!reader.IsEmptyElement)
            {
                while (reader.GoToSibling())
                {
                    switch (reader.LocalName)
                    {
                    case "TraceMonitor":
                        result.TracingConfig = TracingConfig.Load(reader);
                        break;

                    case "EdgeServerRules":
                        if (!reader.IsEmptyElement)
                        {
                            if (edgeServerRuleCollection == null)
                            {
                                edgeServerRuleCollection        = new List <EdgeServerRules>();
                                result.EdgeServerRuleCollection = edgeServerRuleCollection;
                            }
                            edgeServerRuleCollection.Add(EdgeServerRules.Load(reader));
                        }
                        else
                        {
                            reader.Skip();
                        }
                        break;

                    case "Diagnostics":
                        if (!reader.IsEmptyElement)
                        {
                            reader.ReadStartElement();
                            while (reader.GoToSibling())
                            {
                                switch (reader.LocalName)
                                {
                                case "TrackQuality":
                                    result.TrackQuality = Convert.ToBoolean(reader.ReadElementContentAsInt());
                                    break;

                                case "TrackDownloadErrors":
                                    result.TrackDownloadErrors = Convert.ToBoolean(reader.ReadElementContentAsInt());
                                    break;

                                case "AggregationIntervalMilliseconds":
                                    result.AggregationInterval = TimeSpan.FromMilliseconds(reader.ReadElementContentAsInt());
                                    break;

                                case "TrackQualitySnapshot":
                                    result.TrackQualitySnapshot = Convert.ToBoolean(reader.ReadElementContentAsInt());
                                    break;

                                case "SnapshotIntervalMilliseconds":
                                    result.SnapshotInterval = TimeSpan.FromMilliseconds(reader.ReadElementContentAsInt());
                                    break;

                                case "LatencyAlertThreshold":
                                    result.LatencyAlertThreshold = reader.ReadElementContentAsFloat();
                                    break;

                                case "RecordTraceLogs":
                                    result.RecordTraceLogs = Convert.ToBoolean(reader.ReadElementContentAsInt());
                                    break;

                                case "QualityTracking":
                                    result.QualityConfig = QualityConfig.Load(reader);
                                    break;

                                default:
                                    reader.Skip();
                                    break;
                                }
                            }
                            reader.ReadEndElement();
                        }
                        else
                        {
                            reader.Skip();
                        }
                        break;

                    default:
                        reader.Skip();
                        break;
                    }
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Skip();
            }

            return(result);
        }