public IActionResult Index() { var allPages = this.sitePageRepository.GetLivePage(1, MaxPageSizeForSiteMap, out int total); var siteMapHelper = new SiteMapHelper(); foreach (var page in allPages) { if (!page.IsLive || page.ExcludePageFromSiteMapXml) { continue; } string url; if (page.IsSectionHomePage) { url = new Uri(UrlBuilder.GetCurrentDomain(this.HttpContext)).ToString(); } else { url = new Uri(UrlBuilder.GetCurrentDomain(this.HttpContext) + UrlBuilder.BlogUrlPath(page.SitePageSection.Key, page.Key)).ToString().TrimEnd('/'); } var lastUpdated = page.UpdateDate == null ? page.CreateDate : (DateTime)page.UpdateDate; siteMapHelper.AddUrl(url, lastUpdated, ChangeFrequency.Weekly, .5); } var xml = siteMapHelper.GenerateXml(); return(this.Content(xml, "text/xml")); }
// // GET: /SiteMap/ public ActionResult Index() { Response.ContentType = "text/xml"; var urlSet = SiteMapHelper.GetSiteMapUrls(this.ControllerContext); return(View(urlSet)); }
public IActionResult Index() { int total; var allBlogs = _blogEntryRepository.GetLivePage(1, int.MaxValue, out total); var siteMapHelper = new SiteMapHelper(); foreach (var blog in allBlogs) { if (!blog.IsLive) { continue; } var url = new Uri(HttpContext.Request.Scheme + "://" + HttpContext.Request.Host.ToUriComponent() + UrlBuilder.BlogUrlPath(blog.Key, blog.BlogPublishDateTimeUtc)); var lastUpdated = blog.UpdateDate == null ? blog.CreateDate : (DateTime)blog.UpdateDate; siteMapHelper.AddUrl(url.ToString(), lastUpdated, ChangeFrequency.weekly, .5); } var xml = siteMapHelper.GenerateXml(); return(Content(xml, "text/xml")); }
public void BuildModel_Case1_StartingNodeNotInChildLevel_ShouldReturnHierarchicalNodes() { // @Html.MvcSiteMap().SiteMap(false) // Arrange var siteMap = HtmlHelperTestCases.CreateFakeSiteMapCase1(); var startingNode = siteMap.RootNode; HtmlHelper helper = new HtmlHelper(this.viewContext.Object, this.iView.Object); MvcSiteMapHtmlHelper helperExtension = new MvcSiteMapHtmlHelper(helper, siteMap, false); // Act var result = SiteMapHelper.BuildModel( helper: helperExtension, sourceMetadata: new SourceMetadataDictionary(), startingNode: startingNode, startingNodeInChildLevel: false, visibilityAffectsDescendants: true); // Assert // Tree structure - 3 nodes Assert.AreEqual("Home", result.Nodes[0].Title); Assert.AreEqual("About", result.Nodes[0].Children[0].Title); Assert.AreEqual("Contact", result.Nodes[0].Children[1].Title); // Check Counts Assert.AreEqual(1, result.Nodes.Count); Assert.AreEqual(2, result.Nodes[0].Children.Count); Assert.AreEqual(0, result.Nodes[0].Children[0].Children.Count); Assert.AreEqual(0, result.Nodes[0].Children[1].Children.Count); }
public void BuildModel_Case2_StartingNodeNotInChildLevel_ShouldReturnHierarchicalNodes() { // @Html.MvcSiteMap().Menu(false) // Arrange var siteMap = HtmlHelperTestCases.CreateFakeSiteMapCase2(); var startingNode = siteMap.RootNode; HtmlHelper helper = new HtmlHelper(this.viewContext.Object, this.iView.Object); MvcSiteMapHtmlHelper helperExtension = new MvcSiteMapHtmlHelper(helper, siteMap, false); // Act var result = SiteMapHelper.BuildModel( helper: helperExtension, sourceMetadata: new SourceMetadataDictionary(), startingNode: startingNode, startingNodeInChildLevel: false, visibilityAffectsDescendants: true); // Assert Assert.AreEqual("Home", result.Nodes[0].Title); Assert.AreEqual("About", result.Nodes[0].Children[0].Title); Assert.AreEqual("About Me", result.Nodes[0].Children[0].Children[0].Title); Assert.AreEqual("About You", result.Nodes[0].Children[0].Children[1].Title); // "Contact" is inaccessible - should be skipped. So should its child node "ContactSomebody". Assert.AreEqual("Categories", result.Nodes[0].Children[1].Title); Assert.AreEqual("Cameras", result.Nodes[0].Children[1].Children[0].Title); Assert.AreEqual("Nikon Coolpix 200", result.Nodes[0].Children[1].Children[0].Children[0].Title); Assert.AreEqual("Canon Ixus 300", result.Nodes[0].Children[1].Children[0].Children[1].Title); // "Memory Cards" is not visible. None of its children should be visible. Assert.AreEqual(1, result.Nodes[0].Children[1].Children.Count); }
public virtual string GenerateXmlString(IEnumerable <SiteMapItem> items) { var sitemapCount = (int)Math.Ceiling(items.Count() / (double)SiteMapHelper.MaximumSitemapIndexCount); SiteMapHelper.CheckSitemapCount(sitemapCount); if (items == null || !items.Any()) { throw new ArgumentNullException($"{nameof(items)} is null"); } var sitemap = new XDocument( new XDeclaration("1.0", "utf-8", "yes"), new XElement(Xmlns + "urlset", new XAttribute("xmlns", Xmlns), new XAttribute(XNamespace.Xmlns + "xsi", Xsi), new XAttribute(Xsi + "schemaLocation", @"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"), from item in items select CreateItemElement(item) ) ); var xml = sitemap.ToString(Encoding.UTF8); SiteMapHelper.CheckDocumentSize(xml); return(xml); }
private ActionResult RedirectToLocal(string returnUrl, System.Security.Principal.GenericPrincipal tempPrincipal = null) { if (Url.IsLocalUrl(returnUrl)) { if (tempPrincipal != null && tempPrincipal.HasAccessToNode(returnUrl)) { return(Redirect(returnUrl)); } } if (tempPrincipal != null) { if (tempPrincipal.HasAccessToNode(Url.Action("Index", "Home"))) { RedirectToAction("Index", "Home"); } List <string> allowdNodesKeys = tempPrincipal.GetAuthorizedNodesList(MvcSiteMapProvider.SiteMaps.Current.RootNode, false); if (allowdNodesKeys.Count() > 0) { return(Redirect(SiteMapHelper.GetUrlByKey(allowdNodesKeys.First()))); } } return(RedirectToAction("Index", "Home")); }
public ActionResult SitemapXml() { var sitemap = new SiteMapHelper(); var sitemapNodes = GetSitemapNodes(); string xml = sitemap.GetSitemapDocument(sitemapNodes); return(this.Content(xml, "text/xml", Encoding.UTF8)); }
public ActionResult SiteMap() { return(new ContentResult { ContentType = "text/xml", Content = SiteMapHelper.GetSiteMap().ToHtmlString(), ContentEncoding = Encoding.UTF8 }); }
public Page GetPage(string pageKey) { if (!Pages.ContainsKey(pageKey)) { Pages.Add(pageKey, SiteMapHelper.LoadPageFromJson($"{pageKey}.json")); } return(Pages[pageKey]); }
protected void Page_Load(object sender, EventArgs e) { var allCountries = (new LocaleCountryLoader()).Load().ToList(); _CountryLanguage.Text = allCountries.Where(c => c.Key == CultureInfo.CurrentUICulture.Name).Select(k => k.Value).FirstOrDefault(); SiteMapHelper.SetFooterSitemap(_FooterNavDataSource); }
public void BuildModel_Case2_StartingNodeNotInChildLevel_VisibilyDoesntAffectDescendants_ShouldReturnHierarchialNodes() { // @Html.MvcSiteMap().SiteMap(null, MvcSiteMapProvider.SiteMaps.Current.RootNode, false, false) // Arrange var siteMap = HtmlHelperTestCases.CreateFakeSiteMapCase2(); var startingNode = siteMap.RootNode; HtmlHelper helper = new HtmlHelper(this.viewContext.Object, this.iView.Object); MvcSiteMapHtmlHelper helperExtension = new MvcSiteMapHtmlHelper(helper, siteMap, false); // Act var result = SiteMapHelper.BuildModel( helper: helperExtension, sourceMetadata: new SourceMetadataDictionary(), startingNode: startingNode, startingNodeInChildLevel: false, visibilityAffectsDescendants: false); // Assert Assert.AreEqual("Home", result.Nodes[0].Title); Assert.AreEqual("About", result.Nodes[0].Children[0].Title); Assert.AreEqual("About Me", result.Nodes[0].Children[0].Children[0].Title); Assert.AreEqual("About You", result.Nodes[0].Children[0].Children[1].Title); // "Contact" is inaccessible - should be skipped. So should its child node "ContactSomebody". Assert.AreEqual("Categories", result.Nodes[0].Children[1].Title); Assert.AreEqual("Cameras", result.Nodes[0].Children[1].Children[0].Title); Assert.AreEqual("Nikon Coolpix 200", result.Nodes[0].Children[1].Children[0].Children[0].Title); Assert.AreEqual("Canon Ixus 300", result.Nodes[0].Children[1].Children[0].Children[1].Title); // "Memory Cards" is not visible. However its children should be in its place. Assert.AreEqual("Kingston 256 GB SD", result.Nodes[0].Children[1].Children[1].Title); Assert.AreEqual("Sony 256 GB SD", result.Nodes[0].Children[1].Children[2].Title); Assert.AreEqual("Sony SD Card Reader", result.Nodes[0].Children[1].Children[2].Children[0].Title); // Check counts Assert.AreEqual(1, result.Nodes.Count); Assert.AreEqual(2, result.Nodes[0].Children.Count); // Home Assert.AreEqual(2, result.Nodes[0].Children[0].Children.Count); // About Assert.AreEqual(0, result.Nodes[0].Children[0].Children[0].Children.Count); // About Me Assert.AreEqual(0, result.Nodes[0].Children[0].Children[1].Children.Count); // About You Assert.AreEqual(3, result.Nodes[0].Children[1].Children.Count); // Categories Assert.AreEqual(2, result.Nodes[0].Children[1].Children[0].Children.Count); // Cameras Assert.AreEqual(0, result.Nodes[0].Children[1].Children[0].Children[0].Children.Count); // Nikon Coolpix 200 Assert.AreEqual(0, result.Nodes[0].Children[1].Children[0].Children[1].Children.Count); // Canon Ixus 300 Assert.AreEqual(0, result.Nodes[0].Children[1].Children[1].Children.Count); // Kingston 256 GB SD Assert.AreEqual(1, result.Nodes[0].Children[1].Children[2].Children.Count); // Sony 256 GB SD Assert.AreEqual(0, result.Nodes[0].Children[1].Children[2].Children[0].Children.Count); // Sony SD Card Reader }
public ActionResult Delete(string id) { RoleModel roleModel = new RoleModel(); roleModel.Id = id; using (RoleBAL roleBAL = new RoleBAL(ContextInfo)) { roleBAL.GetRoleModel(roleModel); } SiteMapHelper.PrepareSiteMapModel(roleModel.SiteMapModel, roleModel.Id); return(View(roleModel)); }
public Page GetPage(string pageKey, ExecutionEnvironment execEnv) { lock (syncDic) { if (!Pages.ContainsKey(pageKey)) { Pages.Add(pageKey, SiteMapHelper.LoadPageFromJson(execEnv.SiteMapDirectoryLocation, $"{pageKey}.json")); } } lock (syncDic) { return(Pages[pageKey]); } }
public ActionResult Create(BaseModel baseModel) { RoleModel roleModel = new RoleModel(); roleModel.CopyBaseModel(baseModel); using (RoleBAL roleBAL = new RoleBAL(ContextInfo)) { roleBAL.PrepareRoleModel(roleModel); } SiteMapHelper.PrepareSiteMapModel(roleModel.SiteMapModel); return(View("Create", roleModel)); }
private List <string> GetSitemapUrls(string url) { List <string> result; try { result = SiteMapHelper.GetPageUrls(url + "sitemap.xml"); } catch (WebException) { result = SiteMapHelper.GetPageUrls(SiteMapHelper.GetUrlFromRobots(url)); } return(result); }
public void addStateElements(XmlWriter writer) { DataSet reg_list = SiteMapHelper.getStateList(); int count = reg_list.Tables[0].Rows.Count; for (int i = 0; i < count; i++) { writer.WriteStartElement("url"); writer.WriteElementString("loc", String.Format("{0}/{1}/{2}/default.aspx", site_addr, reg_list.Tables[0].Rows[i][0], reg_list.Tables[0].Rows[i][1]).ToLower().Replace(" ", "_")); writer.WriteElementString("changefreq", "daily"); writer.WriteElementString("priority", "0.9"); writer.WriteEndElement(); } }
protected void Page_Load(object sender, EventArgs e) { if (Page.User.Identity.IsAuthenticated) { SiteMapHelper.SetMainMenuSitemap(_SiteMapDS); if (GlobalContext.CultureConfiguration.DefaultExperienceType == ExperienceType.Green) { SetMainNavigation(); } else { SetMainNavigationFromLegacy(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { lblUserName.Text = "<b>User Name:</b> " + Request.QueryString["UserName"]; List <string> formUrls = new List <string>(); foreach (var node in SiteMapHelper.GetUrls()) { lstMenu.Items.Add(new ListItem(node.Value, node.Key)); formUrls.Add(node.Key); } lstMenu.Rows = formUrls.Count + 1; } }
private List <PageResponse> MeasureResponseTime(Site site, string pageUrl) { var pageResponses = new List <PageResponse>(); for (int i = 0; i < NumOfRequests; i++) { var resTime = SiteMapHelper.SendReqAndMeasureResTime(pageUrl); var pRes = new PageResponse() { ResponseTime = resTime, Url = pageUrl, SiteId = site.Id }; pageResponses.Add(pRes); } return(pageResponses); }
public ActionResult Delete(RoleModel roleModel) { using (RoleBAL roleBAL = new RoleBAL(ContextInfo)) { roleBAL.Delete(roleModel); if (roleModel.HasErrorByType()) { roleBAL.GetRoleModel(roleModel); } } if (roleModel.HasErrorByType()) { SiteMapHelper.PrepareSiteMapModel(roleModel.SiteMapModel, roleModel.Id); } return(View(roleModel)); }
public virtual string GenerateXmlString(IEnumerable <SiteMapImageItem> items) { if (items == null || !items.Any()) { throw new ArgumentNullException($"{nameof(items)} is null"); } var sitemap = new XDocument( new XDeclaration("1.0", "utf-8", "yes"), new XElement(Xmlns + "urlset", new XAttribute("xmlns", Xmlns), new XAttribute(XNamespace.Xmlns + "image", Image), from item in items select CreateItemElement(item) ) ); var xml = sitemap.ToString(Encoding.UTF8); SiteMapHelper.CheckDocumentSize(xml); return(xml); }
static void Main(string[] args) { var xmlPath = $@"{AppDomain.CurrentDomain.BaseDirectory}Config\AppConfig.xml"; var newsSiteMapName = XmlHelper.GetNodeInnerText(xmlPath, "root/NewsSiteMapName"); var newsSiteMapPath = XmlHelper.GetNodeInnerText(xmlPath, "root/NewsSiteMapPath"); //定义 siteMap生成顺序 var siteMapSort = new List <ISiteMap>() { new NewsSiteMap() }; var siteMapHelper = new SiteMapHelper(newsSiteMapName); foreach (var instance in siteMapSort) { var siteMapData = instance.GetSiteMapList(); siteMapHelper.WriteData(siteMapData, newsSiteMapPath); } Logger.Info($"【{DateTime.Now.ToString("yyyy-MM-dd HH:mm")}】资讯站siteMap生成成功!"); }
public static void AppendCommonItems(string pageTitle, string omnitureEventName, HttpRequest request, IIdentity identity, DistributorProfileModel distributorProfileModel, string browseScheme) { var isAuthenticated = identity.IsAuthenticated; var distributorId = isAuthenticated ? identity.Name : null; AnalyticsProvider.Set(AnalyticsFact.Id, distributorId); AnalyticsProvider.Set(AnalyticsFact.EncId, Encryption.Encrypt(distributorId, EncriptionKey)); if (!string.IsNullOrEmpty(omnitureEventName)) { AnalyticsProvider.Set(AnalyticsFact.OmnitureEventName, omnitureEventName); } AnalyticsProvider.Set(AnalyticsFact.IsLoggedIn, isAuthenticated); if (isAuthenticated) { var roles = Roles.GetRolesForUser(); AnalyticsProvider.Set(AnalyticsFact.Roles, roles); var profile = distributorProfileModel; if (profile != null) { AnalyticsProvider.Set(AnalyticsFact.IsPresidentsTeam, profile.IsPresidentTeam); AnalyticsProvider.Set(AnalyticsFact.IsChairmanClub, profile.IsChairmanClubMember); AnalyticsProvider.Set(AnalyticsFact.IsTabTeam, !string.IsNullOrWhiteSpace(profile.TabTeamType)); AnalyticsProvider.Set(AnalyticsFact.SubtypeCode, profile.SubTypeCode); AnalyticsProvider.Set(AnalyticsFact.EncSubtypeCode, Encryption.Encrypt(profile.SubTypeCode, EncriptionKey)); AnalyticsProvider.Set(AnalyticsFact.ProcessingCountryCode, profile.ProcessingCountryCode); AnalyticsProvider.Set(AnalyticsFact.Scheme, profile.Scheme); } } AnalyticsProvider.Set(AnalyticsFact.BrowseScheme, browseScheme); var dsSiteMap = new SiteMapDataSource(); SiteMapHelper.SetCombinedSitemap(dsSiteMap); var currentNode = dsSiteMap.Provider.CurrentNode; AnalyticsProvider.Set(AnalyticsFact.Title, currentNode == null ? pageTitle : currentNode.Title); string searchKeyword = request.QueryString[RequestExtension.SEARCH_TERMS_KEY] ?? ""; AnalyticsProvider.Set(AnalyticsFact.SearchTerms, searchKeyword.ToLower()); }
public virtual string GenerateXmlString(IEnumerable <SiteMapIndexItem> items) { if (items?.Any() != true) { throw new ArgumentNullException($"{nameof(items)} is null"); } var sitemap = new XDocument( new XDeclaration("1.0", "utf-8", "yes"), new XElement(Xmlns + "sitemapindex", new XAttribute("xmlns", Xmlns), new XAttribute(XNamespace.Xmlns + "xsi", Xsi), new XAttribute(Xsi + "schemaLocation", @"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd"), from item in items select CreateItemElement(item) ) ); var xml = sitemap.ToString(Encoding.UTF8); SiteMapHelper.CheckDocumentSize(xml); return(xml); }
public static void WriteSiteMapForListing15Am() { //Create the XmlDocument. var doc = new XmlDocument(); var xmltype = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; var sitemapHelper = new SiteMapHelper(); var getDate = DateTime.Now; var listSiteMapEntry = new List<SiteMapEntry>(); var siteMap = new XDocument(); #region listing follow sub-category // Get list sub category listing var listCategory = new SitemapData().GetCategoryListingList(); // Get 2000 newest by subcategory foreach (var category in listCategory) { var listingModel = new SitemapData().GetListingByCategory(category.CategoryId); listSiteMapEntry = new List<SiteMapEntry>(); listSiteMapEntry.AddRange(listingModel.Select(item => new SiteMapEntry { Loc = "http://www.muabannhadat.vn/" + item.Level2Category.UrlFriendly() + "-" + item.Category.UrlFriendly() + "-" + item.CategoryId + "/" + item.Title.UrlFriendly() + "-" + item.Id, Lastmod = getDate, Changefreq = "daily", Priority = 0.9m })); siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry); doc.LoadXml((xmltype + siteMap)); //Save the document to a file. doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + category.Level2Category.UrlFriendly() + "-" + category.Category.UrlFriendly() + "-" + category.CategoryId + ConfigurationManager.AppSettings["extSitemap"]); } #endregion }
private void PopulateModel() { model = new Models.AdminMenuPage { PageTitle = Resource.AdminMenuHeading, PageHeading = Resource.AdminMenuHeading }; //Site Settings if (IsAdminOrContentAdmin || isSiteEditor) { model.Links.Add(new ContentAdminLink { ResourceFile = "Resource", ResourceKey = "AdminMenuSiteSettingsLink", Url = SiteRoot + "/Admin/SiteSettings.aspx", CssClass = "adminlink-sitesettings", IconCssClass = "fa fa-cog", SortOrder = -1 }); } //Site List if (WebConfigSettings.AllowMultipleSites && siteSettings.IsServerAdminSite && IsAdmin) { model.Links.Add(new ContentAdminLink { ResourceFile = "Resource", ResourceKey = "SiteList", Url = SiteRoot + "/Admin/SiteList.aspx", CssClass = "adminlink-sitelist", IconCssClass = "fa fa-list", SortOrder = 10 }); } //Security Advisor if (IsAdmin && siteSettings.IsServerAdminSite) { var needsAttention = !securityAdvisor.UsingCustomMachineKey() || securityAdvisor.DefaultAdmin().userExists; model.Links.Add(new ContentAdminLink { ResourceFile = "Resource", ResourceKey = needsAttention ? "SecurityAdvisorNeedsAttention" : "SecurityAdvisor", Url = SiteRoot + "/Admin/SecurityAdvisor.aspx", CssClass = needsAttention ? "adminlink-securityadvisor text-danger" : "adminlink-securityadvisor", IconCssClass = needsAttention ? "fa fa-shield text-danger" : "fa fa-shield", SortOrder = 15 }); } //Role Admin if (WebUser.IsRoleAdmin || IsAdmin) { var addLink = true; if (WebConfigSettings.UseRelatedSiteMode && WebConfigSettings.RelatedSiteModeHideRoleManagerInChildSites && siteSettings.SiteId != WebConfigSettings.RelatedSiteID) { addLink = false; } if (addLink) { model.Links.Add(new ContentAdminLink { ResourceFile = "Resource", ResourceKey = "AdminMenuRoleAdminLink", Url = SiteRoot + "/Admin/RoleManager.aspx", CssClass = "adminlink-rolemanager", IconCssClass = "fa fa-users", SortOrder = 20 }); } } //Site Permissions if (IsAdmin) { model.Links.Add(new ContentAdminLink { ResourceFile = "Resource", ResourceKey = "SiteSettingsPermissionsTab", Url = SiteRoot + "/Admin/PermissionsMenu.aspx", CssClass = "adminlink-sitepermissions", IconCssClass = "fa fa-key", SortOrder = 25 }); } //Member List if (WebUser.IsInRoles(siteSettings.RolesThatCanViewMemberList) || WebUser.IsInRoles(siteSettings.RolesThatCanLookupUsers)) { model.Links.Add(new ContentAdminLink { ResourceFile = "Resource", ResourceKey = "MemberListLink", Url = SiteRoot + WebConfigSettings.MemberListUrl, CssClass = "adminlink-memberlist", IconCssClass = "fa fa-address-book-o", SortOrder = 30 }); } //Add User if (WebUser.IsInRoles(siteSettings.RolesThatCanCreateUsers + siteSettings.RolesThatCanManageUsers + siteSettings.RolesThatCanLookupUsers)) { model.Links.Add(new ContentAdminLink { ResourceFile = "Resource", ResourceKey = "MemberListAddUserLabel", Url = SiteRoot + "/Admin/ManageUsers.aspx?userId=-1", CssClass = "adminlink-adduser", IconCssClass = "fa fa-user-plus", SortOrder = 35 }); } //Page Manager if (IsAdminOrContentAdmin || isSiteEditor || SiteMapHelper.UserHasAnyCreatePagePermissions(siteSettings)) { model.Links.Add(new ContentAdminLink { ResourceFile = "Resource", ResourceKey = "AdminMenuPageTreeLink", Url = SiteRoot + WebConfigSettings.PageTreeRelativeUrl, CssClass = "adminlink-pagemanager", IconCssClass = "fa fa-sitemap", SortOrder = 40 }); } //Content Manager if (IsAdminOrContentAdmin || isSiteEditor) { model.Links.Add(new ContentAdminLink { ResourceFile = "Resource", ResourceKey = "AdminMenuContentManagerLink", Url = SiteRoot + "/Admin/ContentCatalog.aspx", CssClass = "adminlink-contentmanager", IconCssClass = "fa fa-hand-pointer-o", SortOrder = 45 }); } //Content Workflow if (WebConfigSettings.EnableContentWorkflow && siteSettings.EnableContentWorkflow) { model.Links.Add(new ContentAdminLink { ResourceFile = "Resource", ResourceKey = "AdminMenuContentWorkflowLabel", Url = SiteRoot + "/Admin/ContentWorkflow.aspx", CssClass = "adminlink-contentworkflow", IconCssClass = "fa fa-code-fork", SortOrder = 50 }); } //Content Templates/Styles if (IsAdminOrContentAdmin || isSiteEditor || WebUser.IsInRoles(siteSettings.RolesThatCanEditContentTemplates)) { model.Links.AddRange(new List <ContentAdminLink> { new ContentAdminLink { ResourceFile = "Resource", ResourceKey = "ContentTemplates", Url = SiteRoot + "/Admin/ContentTemplates.aspx", CssClass = "adminlink-contenttemplates", IconCssClass = "fa fa-object-group", SortOrder = 55 }, new ContentAdminLink { ResourceFile = "Resource", ResourceKey = "ContentStyleTemplates", Url = SiteRoot + "/Admin/ContentStyles.aspx", CssClass = "adminlink-contentstyles", IconCssClass = "fa fa-code", SortOrder = 60 } }); } //Design Tools if (IsAdmin || WebUser.IsContentAdmin || WebUser.IsInRoles(siteSettings.RolesThatCanManageSkins)) { model.Links.Add(new ContentAdminLink { ResourceFile = "DevTools", ResourceKey = "DesignTools", Url = SiteRoot + "/DesignTools/Default.aspx", CssClass = "adminlink-designtools", IconCssClass = "fa fa-paint-brush", SortOrder = 65 }); } //File Manager //using the FileManagerLink to check if the link should render because it has a lot of criteria, best not to duplicate it var fileManagerLinkTest = new FileManagerLink(); if (fileManagerLinkTest.ShouldRender()) { model.Links.Add(new ContentAdminLink { ResourceFile = "Resource", ResourceKey = "AdminMenuFileManagerLink", Url = SiteRoot + "/FileManager?view=fullpage", CssClass = "adminlink-filemanager", IconCssClass = "fa fa-folder-open", SortOrder = 70 }); } //Newsletter if (WebConfigSettings.EnableNewsletter && (IsAdmin || isSiteEditor || WebUser.IsNewsletterAdmin)) { model.Links.Add(new ContentAdminLink { ResourceFile = "Resource", ResourceKey = "AdminMenuNewsletterAdminLabel", Url = SiteRoot + "/eletter/Admin.aspx", CssClass = "adminlink-newsletter", IconCssClass = "fa fa-newspaper-o", SortOrder = 75 }); } //Commerce if (isCommerceReportViewer && commerceConfig != null && commerceConfig.IsConfigured) { model.Links.Add(new ContentAdminLink { ResourceFile = "Resource", ResourceKey = "CommerceReportsLink", Url = SiteRoot + "/Admin/SalesSummary.aspx", CssClass = "adminlink-commercereports", IconCssClass = "fa fa-shopping-basket", SortOrder = 80 }); } //Registration Agreement if (IsAdminOrContentAdmin) { model.Links.Add(new ContentAdminLink { ResourceFile = "Resource", ResourceKey = "RegistrationAgreementLink", Url = SiteRoot + "/Admin/EditRegistrationAgreement.aspx", CssClass = "adminlink-registrationagreement", IconCssClass = "fa fa-handshake-o", SortOrder = 85 }); //Login Page Text if (!WebConfigSettings.DisableLoginInfo) { model.Links.Add(new ContentAdminLink { ResourceFile = "Resource", ResourceKey = "LoginPageContent", Url = SiteRoot + "/Admin/EditLoginInfo.aspx", CssClass = "adminlink-logininfo", IconCssClass = "fa fa-file-o", SortOrder = 90 }); } //Core Data if (siteSettings.IsServerAdminSite) { model.Links.Add(new ContentAdminLink { ResourceFile = "Resource", ResourceKey = "CoreDataAdministrationLink", Url = SiteRoot + "/Admin/CoreData.aspx", CssClass = "adminlink-coredata", IconCssClass = "fa fa-database", SortOrder = 95 }); } } //Adv. Tools if (IsAdminOrContentAdmin || isSiteEditor) { model.Links.Add(new ContentAdminLink { ResourceFile = "Resource", ResourceKey = "AdvancedToolsLink", Url = SiteRoot + "/Admin/AdvancedTools.aspx", CssClass = "adminlink-advancedtools", IconCssClass = "fa fa-wrench", SortOrder = 100 }); //System Info if (siteSettings.IsServerAdminSite || WebConfigSettings.ShowSystemInformationInChildSiteAdminMenu) { model.Links.Add(new ContentAdminLink { ResourceFile = "Resource", ResourceKey = "AdminMenuServerInfoLabel", Url = SiteRoot + "/Admin/ServerInformation.aspx", CssClass = "adminlink-serverinfo", IconCssClass = "fa fa-info-circle", SortOrder = 105 }); } } //Log Viewer if (IsAdmin && siteSettings.IsServerAdminSite && WebConfigSettings.EnableLogViewer) { model.Links.Add(new ContentAdminLink { ResourceFile = "Resource", ResourceKey = "AdminMenuServerLogLabel", Url = SiteRoot + "/Admin/ServerLog.aspx", CssClass = "adminlink-log", IconCssClass = "fa fa-clipboard", SortOrder = 110 }); } //Supplemental Links model.Links.AddRange(supplementalLinks.AdminLinks.Where(l => l.Parent.ToLower() == "root").ToList()); //Sort the whole thing (allows mixing Supplemental Links with system links instead of them always being at the bottom) model.Links.Sort((a, b) => a.SortOrder.CompareTo(b.SortOrder)); }
public ContentResult Main() { return(SiteMapHelper.GetSiteMapContentResult(Url)); }
public async Task <ActionResult> Index() { #region Generate SiteMap string mainUrl = "http://moemisto.com.ua/"; var siteMapPath = Server.MapPath("/"); var sitemapGenerator = new SitemapGenerator(); var years = await _context.GetYearsForSiteMap(); foreach (var year in years) { var fileName = string.Format("{0}/sitemap{1}.xml.gz", siteMapPath, year); if (year != DateTime.Now.Year && System.IO.File.Exists(fileName)) { continue; } var siteMapsInfo = await _context.GetSiteMapInfoByYear(year); SiteMapHelper.SaveSiteMap(siteMapsInfo, fileName); } // Places var fileNamePlaces = string.Format("{0}/sitemap-places.xml.gz", siteMapPath); var siteMapsPlaces = await _context.GetSiteMapInfoPlaces(); SiteMapHelper.SaveSiteMap(siteMapsPlaces, fileNamePlaces); // Site Sections var fileNameSections = string.Format("{0}/sitemap-sections.xml.gz", siteMapPath); var siteMapsSections = new List <SiteMapItemDb> { new SiteMapItemDb { Url = mainUrl, ChangeFrequency = SitemapChangeFrequency.Hourly }, new SiteMapItemDb { Url = string.Format("{0}news", mainUrl), ChangeFrequency = SitemapChangeFrequency.Hourly }, new SiteMapItemDb { Url = string.Format("{0}afisha", mainUrl), ChangeFrequency = SitemapChangeFrequency.Hourly }, new SiteMapItemDb { Url = string.Format("{0}travel", mainUrl), ChangeFrequency = SitemapChangeFrequency.Hourly }, new SiteMapItemDb { Url = string.Format("{0}places", mainUrl), ChangeFrequency = SitemapChangeFrequency.Hourly }, new SiteMapItemDb { Url = string.Format("{0}about", mainUrl), ChangeFrequency = SitemapChangeFrequency.Monthly } }; SiteMapHelper.SaveSiteMap(siteMapsSections, fileNameSections); //var listSiteMapFiles = // years.Select(s => new SitemapItem(string.Format("{0}sitemap{1}.xml.gz", mainUrl, s))) // .ToList(); // //listSiteMapFiles.Add(new SitemapItem(string.Format("{0}sitemap-places.xml.gz", mainUrl))); //listSiteMapFiles.Add(new SitemapItem(string.Format("{0}sitemap-sections.xml.gz", mainUrl))); //var mainXmlDoc = sitemapGenerator.GenerateSiteMap(listSiteMapFiles); //mainXmlDoc.Save(string.Format("{0}/sitemap.xml", siteMapPath)); #endregion return(View()); }
public static void WriteSiteMapDaily() { //Create the XmlDocument. var doc = new XmlDocument(); var xmltype = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; var sitemapHelper = new SiteMapHelper(); var getDate = DateTime.Now; var listSiteMap = new List<SiteMapEntry>(); var listSiteMapEntry = new List<SiteMapEntry>(); var siteMap = new XDocument(); #region LISTING var listingModel = new SitemapData().GetListings(); if (listingModel.Count > 0) { #region category-listing listSiteMapEntry = new List<SiteMapEntry>(); listSiteMapEntry.Add(new SiteMapEntry { Loc = "http://www.muabannhadat.vn/nha-dat-3490", Lastmod = getDate, Changefreq = "daily", Priority = 0.8m }); foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry { Loc = "http://www.muabannhadat.vn/" + item.Level2Category.UrlFriendly() + "-" + item.Level2CategoryId, Lastmod = getDate, Changefreq = "daily", Priority = 0.8m }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc))) { listSiteMapEntry.Add(siteMapEntry); } siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry); doc.LoadXml((xmltype + siteMap)); // Save the document to a file. doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["category-listing"] + ConfigurationManager.AppSettings["extSitemap"]); // Save to sitemap listSiteMap.Add(new SiteMapEntry { Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["category-listing"] + ConfigurationManager.AppSettings["extSitemap"], Lastmod = getDate }); #endregion #region category-sub-category-listing listSiteMapEntry = new List<SiteMapEntry>(); foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry { Loc = "http://www.muabannhadat.vn/" + item.Level2Category.UrlFriendly() + "-" + item.Category.UrlFriendly() + "-" + item.CategoryId, Lastmod = getDate, Changefreq = "daily", Priority = 0.8m }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc))) { listSiteMapEntry.Add(siteMapEntry); } siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry); doc.LoadXml((xmltype + siteMap)); //Save the document to a file. doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["category-sub-category-listing"] + ConfigurationManager.AppSettings["extSitemap"]); // Save to sitemap listSiteMap.Add(new SiteMapEntry { Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["category-sub-category-listing"] + ConfigurationManager.AppSettings["extSitemap"], Lastmod = getDate }); #endregion #region category-city-listing listSiteMapEntry = new List<SiteMapEntry>(); foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry { Loc = "http://www.muabannhadat.vn/nha-dat-3490/" + item.State.UrlFriendly() + "-s" + item.StateId, Lastmod = getDate, Changefreq = "daily", Priority = 0.8m }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc))) { listSiteMapEntry.Add(siteMapEntry); } foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry { Loc = "http://www.muabannhadat.vn/" + item.Level2Category.UrlFriendly() + "-" + item.Level2CategoryId + "/" + item.State.UrlFriendly() + "-s" + item.StateId, Lastmod = getDate, Changefreq = "daily", Priority = 0.8m }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc))) { listSiteMapEntry.Add(siteMapEntry); } siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry); doc.LoadXml((xmltype + siteMap)); //Save the document to a file. doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["category-city-listing"] + ConfigurationManager.AppSettings["extSitemap"]); // Save to sitemap listSiteMap.Add(new SiteMapEntry { Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["category-city-listing"] + ConfigurationManager.AppSettings["extSitemap"], Lastmod = getDate }); #endregion #region subcategory-category-city-listing listSiteMapEntry = new List<SiteMapEntry>(); foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry { Loc = "http://www.muabannhadat.vn/" + item.Level2Category.UrlFriendly() + "-" + item.Category.UrlFriendly() + "-" + item.CategoryId + "/" + item.State.UrlFriendly() + "-s" + item.StateId, Lastmod = getDate, Changefreq = "daily", Priority = 0.8m }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc))) { listSiteMapEntry.Add(siteMapEntry); } siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry); doc.LoadXml((xmltype + siteMap)); //Save the document to a file. doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["subcategory-category-city-listing"] + ConfigurationManager.AppSettings["extSitemap"]); // Save to sitemap listSiteMap.Add(new SiteMapEntry { Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["subcategory-category-city-listing"] + ConfigurationManager.AppSettings["extSitemap"], Lastmod = getDate }); #endregion #region category-city-district-listing listSiteMapEntry = new List<SiteMapEntry>(); foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry { Loc = "http://www.muabannhadat.vn/nha-dat-3490/" + item.State.UrlFriendly() + "-" + item.District.UrlFriendly() + "-d" + item.DistrictId, Lastmod = getDate, Changefreq = "daily", Priority = 0.8m }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc))) { listSiteMapEntry.Add(siteMapEntry); } foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry { Loc = "http://www.muabannhadat.vn/" + item.Level2Category.UrlFriendly() + "-" + item.Level2CategoryId + "/" + item.State.UrlFriendly() + "-" + item.District.UrlFriendly() + "-d" + item.DistrictId, Lastmod = getDate, Changefreq = "daily", Priority = 0.8m }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc))) { listSiteMapEntry.Add(siteMapEntry); } siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry); doc.LoadXml((xmltype + siteMap)); //Save the document to a file. doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["category-city-district-listing"] + ConfigurationManager.AppSettings["extSitemap"]); // Save to sitemap listSiteMap.Add(new SiteMapEntry { Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["category-city-district-listing"] + ConfigurationManager.AppSettings["extSitemap"], Lastmod = getDate }); #endregion #region subcategory-category-city-district-listing listSiteMapEntry = new List<SiteMapEntry>(); foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry { Loc = "http://www.muabannhadat.vn/" + item.Level2Category.UrlFriendly() + "-" + item.Category.UrlFriendly() + "-" + item.CategoryId + "/" + item.State.UrlFriendly() + "-" + item.District.UrlFriendly() + "-d" + item.DistrictId, Lastmod = getDate, Changefreq = "daily", Priority = 0.8m }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc))) { listSiteMapEntry.Add(siteMapEntry); } siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry); doc.LoadXml((xmltype + siteMap)); //Save the document to a file. doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["subcategory-category-city-district-listing"] + ConfigurationManager.AppSettings["extSitemap"]); // Save to sitemap listSiteMap.Add(new SiteMapEntry { Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["subcategory-category-city-district-listing"] + ConfigurationManager.AppSettings["extSitemap"], Lastmod = getDate }); #endregion #region listing //var size = Convert.ToInt32(ConfigurationManager.AppSettings["sizeSitemap"]); //var countListingModel = listingModel.Count; //var totalPage = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(countListingModel) / size)); //for (var i = 1; i <= totalPage; i++) //{ // // Save to sitemap // listSiteMap.Add(new SiteMapEntry // { // Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["listing"] + i + ConfigurationManager.AppSettings["extSitemap"], // Lastmod = getDate // }); //} #endregion #region listing follow sub-category listSiteMapEntry = new List<SiteMapEntry>(); foreach (var siteMapEntry in listingModel.Select(item => new SiteMapEntry { Loc = "http://www.muabannhadat.vn/sitemap/" + item.Level2Category.UrlFriendly() + "-" + item.Category.UrlFriendly() + "-" + item.CategoryId }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc))) { listSiteMapEntry.Add(siteMapEntry); } listSiteMap.AddRange(listSiteMapEntry.Select(siteMapEntry => new SiteMapEntry { Loc = siteMapEntry.Loc + ConfigurationManager.AppSettings["extSitemap"], Lastmod = getDate })); #endregion #region subcategory-category-city-project-listing // Save to sitemap listSiteMap.Add(new SiteMapEntry { Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["subcategory-category-city-project-listing"] + ConfigurationManager.AppSettings["extSitemap"], Lastmod = getDate }); #endregion #region subcategory-category-city-district-project-listing // Save to sitemap listSiteMap.Add(new SiteMapEntry { Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["subcategory-category-city-district-project-listing"] + ConfigurationManager.AppSettings["extSitemap"], Lastmod = getDate }); #endregion } #endregion #region PROJECT var projectModel = new SitemapData().GetProjects(); if (projectModel.Count > 0) { #region category-project listSiteMapEntry = new List<SiteMapEntry>(); foreach (var siteMapEntry in projectModel.Select(item => new SiteMapEntry { Loc = "http://www.muabannhadat.vn/" + item.Category.UrlFriendly() + "-" + item.CategoryId, Lastmod = getDate, Changefreq = "daily", Priority = 0.8m }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc))) { listSiteMapEntry.Add(siteMapEntry); } siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry); doc.LoadXml((xmltype + siteMap)); // Save the document to a file. doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["category-project"] + ConfigurationManager.AppSettings["extSitemap"]); // Save to sitemap listSiteMap.Add(new SiteMapEntry { Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["category-project"] + ConfigurationManager.AppSettings["extSitemap"], Lastmod = getDate }); #endregion #region category-city-project listSiteMapEntry = new List<SiteMapEntry>(); foreach (var siteMapEntry in projectModel.Select(item => new SiteMapEntry { Loc = "http://www.muabannhadat.vn/" + item.Category.UrlFriendly() + "-" + item.CategoryId + "/" + item.State.UrlFriendly() + "-s" + item.StateId, Lastmod = getDate, Changefreq = "daily", Priority = 0.8m }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc))) { listSiteMapEntry.Add(siteMapEntry); } siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry); doc.LoadXml((xmltype + siteMap)); // Save the document to a file. doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["category-city-project"] + ConfigurationManager.AppSettings["extSitemap"]); // Save to sitemap listSiteMap.Add(new SiteMapEntry { Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["category-city-project"] + ConfigurationManager.AppSettings["extSitemap"], Lastmod = getDate }); #endregion #region category-city-district-project listSiteMapEntry = new List<SiteMapEntry>(); foreach (var siteMapEntry in projectModel.Select(item => new SiteMapEntry { Loc = "http://www.muabannhadat.vn/" + item.Category.UrlFriendly() + "-" + item.CategoryId + "/" + item.State.UrlFriendly() + "-" + item.District.UrlFriendly() + "-d" + item.DistrictId, Lastmod = getDate, Changefreq = "daily", Priority = 0.8m }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc))) { listSiteMapEntry.Add(siteMapEntry); } siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry); doc.LoadXml((xmltype + siteMap)); // Save the document to a file. doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["category-city-district-project"] + ConfigurationManager.AppSettings["extSitemap"]); // Save to sitemap listSiteMap.Add(new SiteMapEntry { Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["category-city-district-project"] + ConfigurationManager.AppSettings["extSitemap"], Lastmod = getDate }); #endregion #region project listSiteMapEntry = new List<SiteMapEntry>(); listSiteMapEntry.AddRange(projectModel.Select(item => new SiteMapEntry { Loc = "http://www.muabannhadat.vn/" + item.Category.UrlFriendly() + "-" + item.CategoryId + "/" + item.Title.UrlFriendly() + "-" + item.Id, Lastmod = getDate, Changefreq = "daily", Priority = 0.8m })); siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry); doc.LoadXml((xmltype + siteMap)); // Save the document to a file. doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["project"] + ConfigurationManager.AppSettings["extSitemap"]); // Save to sitemap listSiteMap.Add(new SiteMapEntry { Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["project"] + ConfigurationManager.AppSettings["extSitemap"], Lastmod = getDate }); #endregion } var projectListingModel = new SitemapData().GetProjectListings(); #region subcategory-category-city-project-listing listSiteMapEntry = new List<SiteMapEntry>(); foreach (var siteMapEntry in projectListingModel.Select(item => new SiteMapEntry { Loc = "http://www.muabannhadat.vn/" + item.Level2Category.UrlFriendly() + "-" + item.Category.UrlFriendly() + "-" + item.CategoryId + "/" + item.State.UrlFriendly() + "-s" + item.StateId + "/" + item.ProjectName.UrlFriendly() + "-p" + item.ProjectId, Lastmod = getDate, Changefreq = "daily", Priority = 0.9m }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc))) { listSiteMapEntry.Add(siteMapEntry); } siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry); doc.LoadXml((siteMap.ToString())); //Save the document to a file. doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["subcategory-category-city-project-listing"] + ConfigurationManager.AppSettings["extSitemap"]); #endregion #region subcategory-category-city-district-project-listing listSiteMapEntry = new List<SiteMapEntry>(); foreach (var siteMapEntry in projectListingModel.Select(item => new SiteMapEntry { Loc = "http://www.muabannhadat.vn/" + item.Level2Category.UrlFriendly() + "-" + item.Category.UrlFriendly() + "-" + item.CategoryId + "/" + item.State.UrlFriendly() + "-" + item.District.UrlFriendly() + "-d" + item.DistrictId + "/" + item.ProjectName.UrlFriendly() + "-p" + item.ProjectId, Lastmod = getDate, Changefreq = "daily", Priority = 0.9m }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc))) { listSiteMapEntry.Add(siteMapEntry); } siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry); doc.LoadXml((siteMap.ToString())); //Save the document to a file. doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["subcategory-category-city-district-project-listing"] + ConfigurationManager.AppSettings["extSitemap"]); #endregion #endregion #region BUSINESS var businessModel = new SitemapData().GetCompanies(); if (businessModel.Count > 0) { #region category-business listSiteMapEntry = new List<SiteMapEntry>(); foreach (var siteMapEntry in businessModel.Select(item => new SiteMapEntry { Loc = "http://www.muabannhadat.vn/doanh-nghiep/" + item.Category.UrlFriendly() + "-" + item.CategoryId, Lastmod = getDate, Changefreq = "weekly", Priority = 0.5m }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc))) { listSiteMapEntry.Add(siteMapEntry); } siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry); doc.LoadXml((xmltype + siteMap)); // Save the document to a file. doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["category-business"] + ConfigurationManager.AppSettings["extSitemap"]); // Save to sitemap listSiteMap.Add(new SiteMapEntry { Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["category-business"] + ConfigurationManager.AppSettings["extSitemap"], Lastmod = getDate }); #endregion #region category-city-business listSiteMapEntry = new List<SiteMapEntry>(); foreach (var siteMapEntry in businessModel.Select(item => new SiteMapEntry { //Loc = "http://www.muabannhadat.vn/doanh-nghiep/" + item.Category.UrlFriendly() + "-" + item.CategoryId + "?cmpsct=" + item.StateId, Loc = "http://www.muabannhadat.vn/doanh-nghiep/" + item.Category.UrlFriendly() + "-" + item.CategoryId, Lastmod = getDate, Changefreq = "weekly", Priority = 0.5m }).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc))) { listSiteMapEntry.Add(siteMapEntry); } siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry); doc.LoadXml((xmltype + siteMap)); // Save the document to a file. doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["category-city-business"] + ConfigurationManager.AppSettings["extSitemap"]); // Save to sitemap listSiteMap.Add(new SiteMapEntry { Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["category-city-business"] + ConfigurationManager.AppSettings["extSitemap"], Lastmod = getDate }); #endregion #region business listSiteMapEntry = new List<SiteMapEntry>(); //listSiteMapEntry.AddRange(businessModel.Select(item => new SiteMapEntry //{ // Loc = "http://www.muabannhadat.vn/doanh-nghiep/" + item.Category.UrlFriendly() + "-" + item.CategoryId + "/detail/" + item.Name.UrlFriendly() + "-" + item.Id, // Lastmod = getDate, // Changefreq = "weekly", // Priority = 0.5m //})); listSiteMapEntry.AddRange(businessModel.Select(item => new SiteMapEntry { Loc = "http://www.muabannhadat.vn/doanh-nghiep/detail/" + item.Name.UrlFriendly() + "-" + item.Id, Lastmod = getDate, Changefreq = "weekly", Priority = 0.5m })); siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry); doc.LoadXml((xmltype + siteMap)); // Save the document to a file. doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["business"] + ConfigurationManager.AppSettings["extSitemap"]); // Save to sitemap listSiteMap.Add(new SiteMapEntry { Loc = ConfigurationManager.AppSettings["linkCategorySitemap"] + ConfigurationManager.AppSettings["business"] + ConfigurationManager.AppSettings["extSitemap"], Lastmod = getDate }); #endregion } #endregion // SITEMAP listSiteMap.Add(new SiteMapEntry { Loc = "http://www.muabannhadat.vn/tin-tuc/sitemap-3.xml", Lastmod = getDate }); siteMap = sitemapHelper.GenerateSiteMapMain(listSiteMap); doc.LoadXml((xmltype + siteMap)); //Save the document to a file. doc.Save(ConfigurationManager.AppSettings["pathSitemap"] + "sitemap.xml"); }
private void BuildViewBagMetadata() { SiteMapNode node = SiteMapHelper.GetCurrentSiteMapNode(); if (node != null) { if (node.Title != null) { ViewBag.Title = node.Title; } ViewBag.Schema = node.Url; ViewBag.MetaTags = new Dictionary <string, string>(); if (!String.IsNullOrEmpty(node.Description)) { ViewBag.MetaTags["description"] = node.Description; } if (!String.IsNullOrEmpty(node["OGTitle"])) { ViewBag.MetaTags["og:title"] = node["OGTitle"]; } if (!String.IsNullOrEmpty(node["OGDescription"])) { ViewBag.MetaTags["og:description"] = node["OGDescription"]; } if (!String.IsNullOrEmpty(node["OGImage"])) { ViewBag.MetaTags["og:image"] = node["OGImage"]; } if (!String.IsNullOrEmpty(node["OGUrl"])) { ViewBag.MetaTags["og:url"] = node["OGUrl"]; } if (!String.IsNullOrEmpty(node["OGName"])) { ViewBag.MetaTags["og:site_name"] = node["OGName"]; } if (!String.IsNullOrEmpty(node["OGType"])) { ViewBag.MetaTags["og:type"] = node["OGType"]; } if (!String.IsNullOrEmpty(node["FBAppID"])) { ViewBag.MetaTags["fb:app_id"] = node["FBAppID"]; } if (!String.IsNullOrEmpty(node["robots"])) { ViewBag.MetaTags["robots"] = node["robots"]; } if (!String.IsNullOrEmpty(node["canonical"])) { ViewBag.Canonical = node["canonical"]; } //Prev, Next if (!String.IsNullOrEmpty(node["prev"])) { ViewBag.Prev = node["prev"]; } if (!String.IsNullOrEmpty(node["next"])) { ViewBag.Next = node["next"]; } } }
public static void WriteSiteMapHourly() { //Create the XmlDocument. var doc = new XmlDocument(); var xmltype = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; var sitemapHelper = new SiteMapHelper(); var getDate = DateTime.Now; var listSiteMapEntry = new List<SiteMapEntry>(); var siteMap = new XDocument(); #region LISTING //var listingModel = new SitemapData().GetListings(); //if (listingModel.Count > 0) //{ // var size = Convert.ToInt32(ConfigurationManager.AppSettings["sizeSitemap"]); // var countListingModel = listingModel.Count; // var totalPage = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(countListingModel) / size)); // for (var i = 1; i <= totalPage; i++) // { // listSiteMapEntry = new List<SiteMapEntry>(); // var listingModelPaging = listingModel.Skip((i - 1) * size).Take(size).ToList(); // listSiteMapEntry.AddRange(listingModelPaging.Select(item => new SiteMapEntry // { // Loc = // "http://www.muabannhadat.vn/" + item.Level2Category.UrlFriendly() + "-" + // item.Category.UrlFriendly() + "-" + item.CategoryId + "/" + item.Title.UrlFriendly() + "-" + // item.Id, // Lastmod = getDate, // Changefreq = "hourly", // Priority = 0.9m // })); // siteMap = sitemapHelper.GenerateHourlySiteMap(listSiteMapEntry); // doc.LoadXml((xmltype + siteMap)); // //Save the document to a file. // doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["listing"] + i + ConfigurationManager.AppSettings["extSitemap"]); // } //} #endregion #region PROJECT //var projectListingModel = new SitemapData().GetProjectListings(); //#region subcategory-category-city-project-listing //listSiteMapEntry = new List<SiteMapEntry>(); //foreach (var siteMapEntry in projectListingModel.Select(item => new SiteMapEntry //{ // Loc = // "http://www.muabannhadat.vn/" + item.Level2Category.UrlFriendly() + "-" + item.Category.UrlFriendly() // + "-" + item.CategoryId + "/" + item.State.UrlFriendly() + "-s" + item.StateId + "/" + item.ProjectName.UrlFriendly() + "-p" + item.ProjectId, // Lastmod = getDate, // Changefreq = "hourly", // Priority = 0.9m //}).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc))) //{ // listSiteMapEntry.Add(siteMapEntry); //} //siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry); //doc.LoadXml((siteMap.ToString())); ////Save the document to a file. //doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["subcategory-category-city-project-listing"] + ConfigurationManager.AppSettings["extSitemap"]); //#endregion //#region subcategory-category-city-district-project-listing //listSiteMapEntry = new List<SiteMapEntry>(); //foreach (var siteMapEntry in projectListingModel.Select(item => new SiteMapEntry //{ // Loc = // "http://www.muabannhadat.vn/" + item.Level2Category.UrlFriendly() + "-" + item.Category.UrlFriendly() + "-" + item.CategoryId + "/" + item.State.UrlFriendly() + "-" + item.District.UrlFriendly() + "-d" + item.DistrictId + "/" + item.ProjectName.UrlFriendly() + "-p" + item.ProjectId, // Lastmod = getDate, // Changefreq = "hourly", // Priority = 0.9m //}).Where(siteMapEntry => listSiteMapEntry.All(s => s.Loc != siteMapEntry.Loc))) //{ // listSiteMapEntry.Add(siteMapEntry); //} //siteMap = sitemapHelper.GenerateSiteMap(listSiteMapEntry); //doc.LoadXml((siteMap.ToString())); ////Save the document to a file. //doc.Save(ConfigurationManager.AppSettings["pathSitemapCategory"] + ConfigurationManager.AppSettings["subcategory-category-city-district-project-listing"] + ConfigurationManager.AppSettings["extSitemap"]); //#endregion #endregion }
private void PopulateLabels() { Title = SiteUtils.FormatPageTitle(siteSettings, Resource.AdminMenuHeading); heading.Text = Resource.AdminMenuHeading; liSiteSettings.Visible = IsAdminOrContentAdmin || isSiteEditor; lnkSiteSettings.Text = Resource.AdminMenuSiteSettingsLink; lnkSiteSettings.NavigateUrl = SiteRoot + "/Admin/SiteSettings.aspx"; liSiteList.Visible = ((WebConfigSettings.AllowMultipleSites) && (siteSettings.IsServerAdminSite) && IsAdmin); lnkSiteList.Text = Resource.SiteList; lnkSiteList.NavigateUrl = SiteRoot + "/Admin/SiteList.aspx"; lnkSecurityAdvisor.Text = Resource.SecurityAdvisor; lnkSecurityAdvisor.NavigateUrl = SiteRoot + "/Admin/SecurityAdvisor.aspx"; if (IsAdmin && siteSettings.IsServerAdminSite) { liSecurityAdvisor.Visible = true; if (!securityAdvisor.UsingCustomMachineKey()) { imgMachineKeyDanger.Visible = true; lblNeedsAttantion.Visible = true; lnkSecurityAdvisor.CssClass = "lnkSecurityAdvisorWarning"; } } imgMachineKeyDanger.ImageUrl = "~/Data/SiteImages/warning.png"; imgMachineKeyDanger.AlternateText = Resource.SecurityDangerLabel; liCommerceReports.Visible = (isCommerceReportViewer && (commerceConfig != null) && (commerceConfig.IsConfigured)); lnkCommerceReports.Text = Resource.CommerceReportsLink; lnkCommerceReports.NavigateUrl = SiteRoot + "/Admin/SalesSummary.aspx"; liContentManager.Visible = (IsAdminOrContentAdmin || isSiteEditor); lnkContentManager.Text = Resource.AdminMenuContentManagerLink; lnkContentManager.NavigateUrl = SiteRoot + "/Admin/ContentCatalog.aspx"; liContentWorkFlow.Visible = (WebConfigSettings.EnableContentWorkflow && siteSettings.EnableContentWorkflow); lnkContentWorkFlow.Visible = siteSettings.EnableContentWorkflow && WebUser.IsAdminOrContentAdminOrContentPublisher; lnkContentWorkFlow.Text = Resource.AdminMenuContentWorkflowLabel; lnkContentWorkFlow.NavigateUrl = SiteRoot + "/Admin/ContentWorkflow.aspx"; liContentTemplates.Visible = (IsAdminOrContentAdmin || isSiteEditor || (WebUser.IsInRoles(siteSettings.RolesThatCanEditContentTemplates))); lnkContentTemplates.Text = Resource.ContentTemplates; lnkContentTemplates.NavigateUrl = SiteRoot + "/Admin/ContentTemplates.aspx"; liStyleTemplates.Visible = (IsAdminOrContentAdmin || isSiteEditor || (WebUser.IsInRoles(siteSettings.RolesThatCanEditContentTemplates))); lnkStyleTemplates.Text = Resource.ContentStyleTemplates; lnkStyleTemplates.NavigateUrl = SiteRoot + "/Admin/ContentStyles.aspx"; liPageTree.Visible = (IsAdminOrContentAdmin || isSiteEditor || (SiteMapHelper.UserHasAnyCreatePagePermissions(siteSettings))); lnkPageTree.Text = Resource.AdminMenuPageTreeLink; lnkPageTree.NavigateUrl = SiteRoot + WebConfigSettings.PageTreeRelativeUrl; liRoleAdmin.Visible = (WebUser.IsRoleAdmin || IsAdmin); lnkRoleAdmin.Text = Resource.AdminMenuRoleAdminLink; lnkRoleAdmin.NavigateUrl = SiteRoot + "/Admin/RoleManager.aspx"; liPermissions.Visible = IsAdmin; lnkPermissionAdmin.Text = Resource.SiteSettingsPermissionsTab; lnkPermissionAdmin.NavigateUrl = SiteRoot + "/Admin/PermissionsMenu.aspx"; if ((WebConfigSettings.UseRelatedSiteMode) && (WebConfigSettings.RelatedSiteModeHideRoleManagerInChildSites)) { if (siteSettings.SiteId != WebConfigSettings.RelatedSiteID) { liRoleAdmin.Visible = false; } } // // File Manager Link // //liFileManager.Visible = IsAdminOrContentAdmin; //if ((!siteSettings.IsServerAdminSite) && (!WebConfigSettings.AllowFileManagerInChildSites)) //{ // liFileManager.Visible = false; //} //if (WebConfigSettings.DisableFileManager) //{ // liFileManager.Visible = false; //} //lnkFileManager.Text = Resource.AdminMenuFileManagerLink; //lnkFileManager.NavigateUrl = SiteRoot + "/FileManager"; // // Member List // lnkMemberList.Text = Resource.MemberListLink; lnkMemberList.NavigateUrl = SiteRoot + WebConfigSettings.MemberListUrl; lnkMemberList.Visible = ((WebUser.IsInRoles(siteSettings.RolesThatCanViewMemberList)) || (WebUser.IsInRoles(siteSettings.RolesThatCanLookupUsers))); liAddUser.Visible = ((WebUser.IsInRoles(siteSettings.RolesThatCanCreateUsers)) || (WebUser.IsInRoles(siteSettings.RolesThatCanManageUsers)) || (WebUser.IsInRoles(siteSettings.RolesThatCanLookupUsers))); lnkAddUser.Text = Resource.MemberListAddUserLabel; lnkAddUser.NavigateUrl = SiteRoot + "/Admin/ManageUsers.aspx?userId=-1"; if (WebConfigSettings.EnableNewsletter) { liNewsletter.Visible = (IsAdmin || isSiteEditor || WebUser.IsNewsletterAdmin); lnkNewsletter.Text = Resource.AdminMenuNewsletterAdminLabel; lnkNewsletter.NavigateUrl = SiteRoot + "/eletter/Admin.aspx"; //liTaskQueue.Visible = IsAdmin || WebUser.IsNewsletterAdmin; //lnkTaskQueue.Text = Resource.TaskQueueMonitorHeading; //lnkTaskQueue.NavigateUrl = SiteRoot + "/Admin/TaskQueueMonitor.aspx"; } else { liNewsletter.Visible = false; //liTaskQueue.Visible = false; } liRegistrationAgreement.Visible = (IsAdminOrContentAdmin); lnkRegistrationAgreement.Text = Resource.RegistrationAgreementLink; lnkRegistrationAgreement.NavigateUrl = SiteRoot + "/Admin/EditRegistrationAgreement.aspx"; liLoginInfo.Visible = (IsAdminOrContentAdmin) && !WebConfigSettings.DisableLoginInfo; lnkLoginInfo.Text = Resource.LoginPageContent; lnkLoginInfo.NavigateUrl = SiteRoot + "/Admin/EditLoginInfo.aspx"; liCoreData.Visible = (IsAdminOrContentAdmin && siteSettings.IsServerAdminSite); lnkCoreData.Text = Resource.CoreDataAdministrationLink; lnkCoreData.NavigateUrl = SiteRoot + "/Admin/CoreData.aspx"; liAdvancedTools.Visible = (IsAdminOrContentAdmin || isSiteEditor); lnkAdvancedTools.Text = Resource.AdvancedToolsLink; lnkAdvancedTools.NavigateUrl = SiteRoot + "/Admin/AdvancedTools.aspx"; liServerInfo.Visible = (IsAdminOrContentAdmin || isSiteEditor) && (siteSettings.IsServerAdminSite || WebConfigSettings.ShowSystemInformationInChildSiteAdminMenu); lnkServerInfo.Text = Resource.AdminMenuServerInfoLabel; lnkServerInfo.NavigateUrl = SiteRoot + "/Admin/ServerInformation.aspx"; liLogViewer.Visible = IsAdmin && siteSettings.IsServerAdminSite && WebConfigSettings.EnableLogViewer; lnkLogViewer.Text = Resource.AdminMenuServerLogLabel; lnkLogViewer.NavigateUrl = SiteRoot + "/Admin/ServerLog.aspx"; }