Example #1
0
        public void ReadFlatCatalog()
        {
            string[] pngFiles = Directory.GetFiles(RenderedRoot, "*.png", SearchOption.AllDirectories);
            Dictionary <Guid, string> guidsWithPngs = new Dictionary <Guid, string>();

            AllGuidsWithPngs(pngFiles, guidsWithPngs);
            StreamReader catalogReader = File.OpenText(SourceRoot + "Catalog.txt");
            Dictionary <Guid, TempSeenKeptRecord> performanceValues = new Dictionary <Guid, TempSeenKeptRecord>();

            ReadPerformanceSummary(performanceValues);
            int guidStringLength = Guid.Empty.ToString().Length;

            while (!catalogReader.EndOfStream)
            {
                string bpLine = catalogReader.ReadLine();
                if (bpLine == string.Empty)
                {
                    continue;
                }
                int firstSpaceIndex = bpLine.IndexOf(' ');
                if (firstSpaceIndex != guidStringLength)
                {
                    Console.WriteLine(bpLine);
                    continue;
                }

                if (!Guid.TryParse(bpLine.Substring(0, firstSpaceIndex), out Guid bluePrintGuid))
                {
                    continue;
                }
                string   original = bpLine.Substring(firstSpaceIndex + 1);
                string[] segments = original.Split('\\');
                string   layout   = segments[0];
                string   type     = segments[1];
                string   crop     = segments[2];
                string   aspect   = segments[3];
                string   path     = segments[4];
                if (guidsWithPngs.ContainsKey(bluePrintGuid))
                {
                    BluePrint bp = new BluePrint
                    {
                        Source           = path,
                        FlattendPptxPath = SourceRoot + bluePrintGuid + ".pptx",
                        OriginalPath     = original,
                        Layout           = layout,
                        Type             = type,
                        AspectRaio       = aspect,
                        CropNonCrop      = crop,
                        Guid             = bluePrintGuid,
                        PngPath          = guidsWithPngs[bluePrintGuid],
                    };
                    if (performanceValues.ContainsKey(bluePrintGuid))
                    {
                        bp.Kept = performanceValues[bluePrintGuid].kept;
                        bp.Seen = performanceValues[bluePrintGuid].seen;
                        if (bp.Seen > 0)
                        {
                            bp.KeptRate = (double)bp.Kept * 800 / bp.Seen;
                        }
                    }
                    this.BluePrints.Add(bp);
                }
                else
                {
                    Console.WriteLine("No png found for " + bluePrintGuid);
                }
            }
            catalogReader.Close();
        }