private string GetGoogleSitemapAsString() { SiteMapGenerator generator = new SiteMapGenerator(CrawlerService.Collected); generator.SiteChangeFreq = ChangeFreqCB.SelectedItem.ToString(); generator.SiteLastMod = LastModDP.Date; return(generator.GetGoogleSitemapAsString());; }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); DependencyInjectionConfig.Register(); CacheFiller.FillCache(); SiteMapGenerator.Generate(); }
public async Task <ActionResult> IndexAsync() { string domain = TenantConvention.GetBaseDomain(this.HttpContext, true); if (string.IsNullOrWhiteSpace(domain)) { return(this.Failed(Resources.CouldNotGenerateSiteMap, HttpStatusCode.InternalServerError)); } string siteMap = await SiteMapGenerator.GetAsync(this.Tenant, domain).ConfigureAwait(false); return(this.Content(siteMap, "text/xml", Encoding.UTF8)); }
public ActionResult Index() { string domain = DbConvention.GetBaseDomain(this.HttpContext, true); if (string.IsNullOrWhiteSpace(domain)) { return(this.Failed("Could not generate sitemap.", HttpStatusCode.InternalServerError)); } string siteMap = SiteMapGenerator.Get(domain); return(this.Content(siteMap, "text/xml", Encoding.UTF8)); }
public FileResult xmlMap() { SiteMapGenerator generator = new SiteMapGenerator("http://pyramidastroy.com", AppDomain.CurrentDomain.BaseDirectory); var _routeItemRepository = new RouteItemRepository(); var items = _routeItemRepository.GetAll().Select(s => new SiteMapGenerator.SiteMapNode(s.FriendlyUrl, DateTime.Now, SiteMapGenerator.ChangeFrequency.Monthly)); try { generator.SaveMap(items); } catch (Exception ex) { throw; } return(File(generator.SiteMapPath, "text/xml")); }
// GET: Admin/Generate public ActionResult Zip() { var model = new GenerateZipViewModel(); model.Articles = this.articleService.GetQuery().ToList().Select(q => new ArticleViewModel(q)).ToList(); model.Archives = this.articleService.GetArchiveList(); model.Categories = this.categoryService.GetAllCategoryView(); int limit = Config.ArticleCountPerPage; int totalPage = (int)Math.Ceiling((double)this.articleService.GetQuery().Count() / limit); model.PageUrl = new List <string>() { "/", "/All/" }; for (int i = 1; i <= totalPage; i++) { model.PageUrl.Add("/Page/" + i.ToString() + "/"); } string publishFolder = this.SitePath + "_Publish"; if (Directory.Exists(publishFolder)) { Directory.Delete(publishFolder, true); } Directory.CreateDirectory(publishFolder); #region Copy publish folder var CopyDirs = new List <string>() { "public", "files" }; CopyDirs.ForEach(dir => { try { string sourcePublicFolderPath = this.SitePath + dir; string destinationPublishFolderPath = publishFolder + "/" + dir; var sourceDirectory = Directory.GetDirectories(sourcePublicFolderPath, "*", SearchOption.AllDirectories); foreach (string dirPath in Directory.GetDirectories(sourcePublicFolderPath, "*", SearchOption.AllDirectories)) { Directory.CreateDirectory(dirPath.Replace(sourcePublicFolderPath, destinationPublishFolderPath)); } foreach (var filePath in Directory.GetFiles(sourcePublicFolderPath, "*", SearchOption.AllDirectories)) { System.IO.File.Copy(filePath, filePath.Replace(sourcePublicFolderPath, destinationPublishFolderPath)); } } catch (Exception) { // TODO: 之後再來看看要怎麼做例外處理吧 } }); #endregion #region Generate Archive, Article, Category, Page Path, SiteMap var siteMapGenerator = new SiteMapGenerator(publishFolder + "/sitemap.xml"); model.Articles.ForEach(article => { Directory.CreateDirectory(publishFolder + article.Url); using (WebClient client = new WebClient()) { client.Encoding = Encoding.UTF8; string content = client.DownloadString(this.SiteUrl + article.Url); System.IO.File.WriteAllText(publishFolder + article.Url + "index.html", content, Encoding.UTF8); siteMapGenerator.PutUrl(this.PublishSiteUrl + article.Url, "monthly", 1.0); } }); model.Categories.ForEach(category => { Directory.CreateDirectory(publishFolder + category.Url); using (WebClient client = new WebClient()) { client.Encoding = Encoding.UTF8; string content = client.DownloadString(this.SiteUrl + category.Url); System.IO.File.WriteAllText(publishFolder + category.Url + "index.html", content, Encoding.UTF8); siteMapGenerator.PutUrl(this.PublishSiteUrl + category.Url, "monthly", 0.8); } }); model.Archives.ForEach(archive => { Directory.CreateDirectory(publishFolder + archive.Url); using (WebClient client = new WebClient()) { client.Encoding = Encoding.UTF8; string content = client.DownloadString(this.SiteUrl + archive.Url); System.IO.File.WriteAllText(publishFolder + archive.Url + "index.html", content, Encoding.UTF8); siteMapGenerator.PutUrl(this.PublishSiteUrl + archive.Url, "monthly", 0.5); } }); model.PageUrl.ForEach(url => { Directory.CreateDirectory(publishFolder + url); using (WebClient client = new WebClient()) { client.Encoding = Encoding.UTF8; string content = client.DownloadString(this.SiteUrl + url); System.IO.File.WriteAllText(publishFolder + url + "index.html", content, Encoding.UTF8); siteMapGenerator.PutUrl(this.PublishSiteUrl + url, "monthly", 0.3); } }); siteMapGenerator.Save(); #endregion #region robots.txt string robots = "User-agent: *\r\nDisallow:\r\nSitemap: " + this.PublishSiteUrl + "/sitemap.xml"; System.IO.File.WriteAllText(publishFolder + "/robots.txt", robots); //System.IO.File.WriteAllText(publishFolder + "/.htaccess", "Options -Indexes", Encoding.UTF8); #endregion return(this.ReturnJson(model)); }
private static void SaveSitemap() { try { string sitemapPath = string.Format("{0}/{1}sitemap.xml", _options.FolderPath, DateTime.Now.ToString("MM-dd-yyyy")); using (var fileStream = new FileStream(sitemapPath, FileMode.Create)) { var siteMapGenerator = new SiteMapGenerator(fileStream, Encoding.UTF8); siteMapGenerator.Generate(pageVisitedURLMapping.Keys.ToList()); siteMapGenerator.Close(); } logger.Info("SiteMap save to {0}", sitemapPath); } catch (Exception ex) { logger.Error(ex); } }
public ActionResult Xml() { string sitemap = SiteMapGenerator.BuildForStore(HccApp); return(Content(sitemap, "text/xml")); }
public SiteMappingViewModel(string path, string colorText, string colorLines, string colorRectWithText, string colorRectWithoutText, string linesConnection) { SiteMapGenerator smg = new SiteMapGenerator(); List <SiteMapObject> allObj = smg.GetAllObjects(path); int sizeAndLevel = 1; if (path != null) { sizeAndLevel = path.Split('/').Count(); } if (linesConnection == null) { LinesConnection = "1"; } else { LinesConnection = linesConnection; } PositionBuilder cm = new PositionBuilder(allObj, sizeAndLevel, LinesConnection); AllObjects = cm.Build(); HeightSize = cm.HeightSize; WidthSize = cm.WidthSize; RectWidth = cm.recWidht; RectHight = cm.recHight; RectWidthText = cm.recWidhtText; RectHightText = cm.recHightText; ColumnsDiff = cm.columnsDiff; RowDiff = cm.rowDiff; if (colorText == null) { ColorText = "#1a1aff"; } else { ColorText = colorText; } if (colorLines == null) { ColorLines = "#ffff00"; } else { ColorLines = colorLines; } if (colorRectWithText == null) { ColorRectWithText = "#ff0000"; } else { ColorRectWithText = colorRectWithText; } if (colorRectWithoutText == null) { ColorRectWithoutText = "#ff00ff"; } else { ColorRectWithoutText = colorRectWithoutText; } AllLineObjects = cm.SiteMapLineObjects(); }