public void DeserializeFiddlerTrace()

in Source/RulesEngine/ServiceCallData.cs [126:205]


        public void DeserializeFiddlerTrace(String filePath, String customAgent)
        {
            // Open the SAZ
            var archive = System.IO.Compression.ZipFile.Open(filePath, ZipArchiveMode.Read);

            // Group the archive entries by frame number
            var result = from e in archive.Entries
                         where e.Name.Contains("_c.txt") || e.Name.Contains("_s.txt") || e.Name.Contains("_m.xml")
                         group e by Utils.GetFrameNumber(e.Name) into g
                         select new { Frame = g.Key, Data = g };
            m_dataTelemetry.m_totalCalls = result.Count();

            List<ServiceCallItem> frameData = new List<ServiceCallItem>();

            int frameNumber = 1;
            // Process data per frame
            foreach (var group in result)
            {
                // Grab the individual files
                ZipArchiveEntry cFileArchive = group.Data.ElementAt(0);
                ZipArchiveEntry mFileArchive = group.Data.ElementAt(1);
                ZipArchiveEntry sFileArchive = group.Data.ElementAt(2);

                ServiceCallItem frame = null;

                System.Diagnostics.Debug.WriteLine("Analyzing Frame# " + frameNumber);
                frameNumber++;

                frame = ServiceCallItem.FromFiddlerFrame((UInt32)group.Frame, cFileArchive, mFileArchive, sFileArchive, o => m_allEndpoints || Utils.IsAnalyzedService(o, customAgent));

                // If this is not an Xbox Service Endpoint that we are checking, then move along.
                if (frame == null)
                {
                    System.Diagnostics.Debug.WriteLine("Skipping\r\n");
                    continue;
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("Processing Call\r\n");
                }

                frameData.Add(frame);
                m_dataTelemetry.m_callsProcessed++;
            }

            var consoleGroups = from f in frameData
                                group f by f.m_consoleIP;

            foreach (var consoleFrames in consoleGroups.Where(g => g.Key != String.Empty))
            {
                var consoleData = new PerConsoleData();

                var xboxServiceFrames = consoleFrames.GroupBy(f => f.m_host)
                                                     .Select(group => new { Host = group.Key, History = group.AsEnumerable() });

                consoleData.m_servicesHistory = xboxServiceFrames.ToDictionary(g => g.Host, g => new LinkedList<ServiceCallItem>(g.History.OrderBy(call => call.m_reqTimeUTC)));

                // Xbox telemetry endpoint
                if(consoleData.m_servicesHistory.ContainsKey("data-vef.xboxlive.com"))
                {
                    ConvertCS1ToEvent(consoleData.m_servicesHistory);
                }

                // Windows Telemetry endpoint
                if(consoleData.m_servicesHistory.Any(k => k.Key.Contains(".data.microsoft.com")))
                {
                    ConvertCS2ToEvent(consoleData.m_servicesHistory);
                }

                // clear empty items
                consoleData.m_servicesHistory = consoleData.m_servicesHistory.Where( o => o.Value.Count > 0).ToDictionary(x => x.Key, x => x.Value);

                foreach (var endpoint in consoleData.m_servicesHistory)
                {
                    consoleData.m_servicesStats.Add(endpoint.Key, new ServiceCallStats(endpoint.Value));
                }

                m_perConsoleData.Add(consoleFrames.Key, consoleData);
            }
        }