Esempio n. 1
0
        public static void Generate(IServiceScopeFactory serviceScopeFactory, GeneratorConfig config, string basePath, bool generateSearchDocuments, string searchIndex, List <SitemapEntry> sitemapEntries)
        {
            using (StreamReader fileReader = new StreamReader(FileHelper.GetActualFilePath(basePath, "output/json/habitats.json")))
            {
                List <InterestFeature> habitats = JsonConvert.DeserializeObject <List <InterestFeature> >(fileReader.ReadToEnd());

                foreach (var habitat in habitats)
                {
                    var habitatPageContent = HabitatPageBuilder.RenderPage(serviceScopeFactory, config, habitat).Result;
                    FileHelper.WriteToFile(FileHelper.GetActualFilePath(basePath, String.Format("output/html/habitat/{0}/index.html", habitat.Code)), habitatPageContent);
                    sitemapEntries.Add(new SitemapEntry
                    {
                        URL = String.Format("/habitat/{0}/", habitat.Code)
                    });

                    if (generateSearchDocuments)
                    {
                        FileHelper.WriteJSONToFile(
                            String.Format("output/search/habitat/{0}.json", habitat.Code),
                            SearchHelpers.GetHabitatPageSearchDocument(searchIndex, habitat.Code, habitat.Name, habitatPageContent)
                            );
                    }

                    var habitatMapCompareContent = InterestFeatureComparisonPageBuilder.RenderPage(serviceScopeFactory, config, habitat).Result;
                    FileHelper.WriteToFile(FileHelper.GetActualFilePath(basePath, String.Format("output/html/habitat/{0}/comparison.html", habitat.Code)), habitatMapCompareContent);
                    sitemapEntries.Add(new SitemapEntry
                    {
                        URL = String.Format("/habitat/{0}/comparison", habitat.Code)
                    });

                    var habitatMapContent = InterestFeatureMapPageBuilder.RenderPage(serviceScopeFactory, config, habitat).Result;
                    FileHelper.WriteToFile(FileHelper.GetActualFilePath(basePath, String.Format("output/html/habitat/{0}/map.html", habitat.Code)), habitatMapContent);
                    sitemapEntries.Add(new SitemapEntry
                    {
                        URL = String.Format("/habitat/{0}/map", habitat.Code)
                    });

                    var habitatDistributionContent = InterestFeatureDistributionPageBuilder.RenderPage(serviceScopeFactory, config, habitat).Result;
                    FileHelper.WriteToFile(FileHelper.GetActualFilePath(basePath, String.Format("output/html/habitat/{0}/distribution.html", habitat.Code)), habitatDistributionContent);
                    sitemapEntries.Add(new SitemapEntry
                    {
                        URL = String.Format("/habitat/{0}/distribution", habitat.Code)
                    });
                }

                var habitatListContent = InterestFeatureListPageBuilder.RenderPage(serviceScopeFactory, config, true, habitats).Result;
                FileHelper.WriteToFile(FileHelper.GetActualFilePath(basePath, "output/html/habitat/index.html"), habitatListContent);
                sitemapEntries.Add(new SitemapEntry
                {
                    URL = "/habitat/"
                });

                Console.WriteLine("Generated pages for {0} habitats", habitats.Count);

                if (generateSearchDocuments)
                {
                    Console.WriteLine("Generated search elements for {0} habitats", habitats.Count);
                }
            }
        }
Esempio n. 2
0
        public static void Generate(IServiceScopeFactory serviceScopeFactory, GeneratorConfig config, string basePath, bool generateSearchDocuments, string searchIndex, List <SitemapEntry> sitemapEntries)
        {
            using (StreamReader fileReader = new StreamReader(FileHelper.GetActualFilePath(basePath, "output/json/species.json")))
            {
                List <InterestFeature> speciesList = JsonConvert.DeserializeObject <List <InterestFeature> >(fileReader.ReadToEnd());

                foreach (var species in speciesList)
                {
                    var speciesPageContent = SpeciesPageBuilder.RenderPage(serviceScopeFactory, config, species).Result;
                    FileHelper.WriteToFile(FileHelper.GetActualFilePath(basePath, String.Format("output/html/species/{0}/index.html", species.Code)), speciesPageContent);

                    sitemapEntries.Add(new SitemapEntry
                    {
                        URL = String.Format("/species/{0}/", species.Code)
                    });

                    if (generateSearchDocuments)
                    {
                        FileHelper.WriteJSONToFile(
                            String.Format("output/search/species/{0}.json", species.Code),
                            SearchHelpers.GetSpeciesPageSearchDocument(searchIndex, species.Code, String.Format("{0} [{1}]", species.LayTitle, species.Name), speciesPageContent)
                            );
                    }

                    // don't generate comparrison pages

                    // var speciesMapCompareContent = InterestFeatureComparisonPageBuilder.RenderPage(serviceScopeFactory, config, species).Result;
                    // FileHelper.WriteToFile(FileHelper.GetActualFilePath(basePath, String.Format("output/html/species/{0}/comparison.html", species.Code)), speciesMapCompareContent);
                    // sitemapEntries.Add(new SitemapEntry
                    // {
                    //     URL = String.Format("/species/{0}/comparison", species.Code)
                    // });

                    var speciesMapContent = InterestFeatureMapPageBuilder.RenderPage(serviceScopeFactory, config, species).Result;
                    FileHelper.WriteToFile(FileHelper.GetActualFilePath(basePath, String.Format("output/html/species/{0}/map.html", species.Code)), speciesMapContent);
                    sitemapEntries.Add(new SitemapEntry
                    {
                        URL = String.Format("/species/{0}/map", species.Code)
                    });

                    // don't generate distribution pages

                    // var speciesDistributionContent = InterestFeatureDistributionPageBuilder.RenderPage(serviceScopeFactory, config, species).Result;
                    // FileHelper.WriteToFile(FileHelper.GetActualFilePath(basePath, String.Format("output/html/species/{0}/distribution.html", species.Code)), speciesDistributionContent);
                    // sitemapEntries.Add(new SitemapEntry
                    // {
                    //     URL = String.Format("/species/{0}/distribution", species.Code)
                    // });
                }

                var speciesListContent = InterestFeatureListPageBuilder.RenderPage(serviceScopeFactory, config, false, speciesList).Result;
                FileHelper.WriteToFile(FileHelper.GetActualFilePath(basePath, "output/html/species/index.html"), speciesListContent);
                sitemapEntries.Add(new SitemapEntry
                {
                    URL = "/species/"
                });

                Console.WriteLine("Generated pages for {0} species", speciesList.Count);

                if (generateSearchDocuments)
                {
                    Console.WriteLine("Generated search elements for {0} species", speciesList.Count);
                }
            }
        }