public void Test_Add_SubCategory() { SiteMap siteMap = new SiteMap(); siteMap.UrlCreator = new MockUrlCreator(this); // Create the base node and add it SiteMapNode baseNode = new SiteMapNode("Category", "TestUrl"); List<SiteMapNode> baseNodes = new List<SiteMapNode>(); baseNodes.Add(baseNode); siteMap.ChildNodes = baseNodes; // Create the sub category node and add it SiteMapNode subCategoryNode = new SiteMapNode("Category", "SubCategory", "TestAction", "TestType"); List<SiteMapNode> subCategoryNodes = new List<SiteMapNode>(); subCategoryNodes.Add(subCategoryNode); baseNode.ChildNodes = subCategoryNodes; // Create the sub node and add it SiteMapNode subNode = new SiteMapNode("Category/SubCategory", "SubNode", "TestAction", "TestType"); // Add the sub node - it should be placed within the sub category siteMap.Add(subNode); Assert.IsNotNull(subCategoryNode.ChildNodes, "Child nodes collection is null"); Assert.AreEqual(1, subCategoryNode.ChildNodes.Count, "Wrong number of sub nodes found."); }
public override long InsertSiteMap(SiteMap sitemap) { var obj = DbObjectModelBase<DbSiteMap, long>.New(); BizObject<SiteMap, long>.CopyToObject(sitemap, obj); obj.Save(); return obj.Id; }
public void Test_Add_SubCategory_AutoCreateParent() { SiteMap siteMap = new SiteMap(); siteMap.UrlCreator = new MockUrlCreator(this); // Create the sub node and add it SiteMapNode subNode = new SiteMapNode("Category/SubCategory", "SubNode", "TestAction", "TestType"); // Add the sub node - it should be placed within the sub category siteMap.Add(subNode); Assert.IsNotNull(siteMap.ChildNodes, "Child nodes collection is null"); Assert.AreEqual(1, siteMap.ChildNodes.Count, "Wrong number of nodes found."); Assert.AreEqual("Category", siteMap.ChildNodes[0].Title, "First level category title is incorrect."); Assert.IsNotNull(siteMap.ChildNodes[0].ChildNodes, "Second level child nodes collection is null"); Assert.AreEqual(1, siteMap.ChildNodes[0].ChildNodes.Count, "Wrong number of second level nodes found."); Assert.AreEqual("SubCategory", siteMap.ChildNodes[0].ChildNodes[0].Title, "Second level category title is incorrect."); Assert.IsNotNull(siteMap.ChildNodes[0].ChildNodes[0].ChildNodes, "Third level child nodes collection is null"); Assert.AreEqual(1, siteMap.ChildNodes[0].ChildNodes[0].ChildNodes.Count, "Wrong number of third level nodes found."); }
/// <summary> /// Creates a new MvcSiteMapProvider HtmlHelper. /// </summary> /// <param name="helper">The helper.</param> /// <param name="siteMapCacheKey">The SiteMap Cache Key.</param> /// <returns> /// A <see cref="MvcSiteMapHtmlHelper"/> instance /// </returns> public static MvcSiteMapHtmlHelper MvcSiteMap(this HtmlHelper helper, string siteMapCacheKey) { SiteMap siteMap = SiteMaps.GetSiteMap(siteMapCacheKey); if (siteMap == null) { throw new Exception("Unknown sitemap."); } return(MvcSiteMap(helper, siteMap)); }
protected virtual IEnumerable voucherEntryScreenTree( [PXGuid] Guid?NodeID) { //var primaryViews = new HashSet<string>(Tables.Select().Select(t => ((GITable)t).Name)); GLWorkBook row = this.WorkBooks.Current; if (NodeID == null) { _siteMapEnumerator = new PXSiteMapFilteredPathEnumerator(false, new PXSiteMapNodeFilter( new Func <PXSiteMapNode, bool>[] { PXSiteMapFilterRuleStorage.IsEmptyFolder, PXSiteMapFilterRuleStorage.IsWiki, PXSiteMapFilterRuleStorage.CantBeAutomated, smn => { SiteMap sm = PXSiteMapEnumeratorBase.CreateSiteMap(smn); if (PXSiteMap.IsFolder(sm.Url)) { return(true); } if (PXSiteMapFilterRuleStorage.IsGenericInquiry(smn)) { return(true); } if (String.IsNullOrEmpty(sm.Graphtype)) { return(true); } Type t = System.Web.Compilation.BuildManager.GetType(sm.Graphtype, false); if (typeof(SO.SOInvoiceEntry).IsAssignableFrom(t)) { return(true); } if (typeof(SO.SOPaymentEntry).IsAssignableFrom(t)) { return(true); } if (typeof(TX.TXInvoiceEntry).IsAssignableFrom(t)) { return(true); } Type baseEditGraph = GetGraphByDocType(row.Module, row.DocType); if (baseEditGraph != null && baseEditGraph.IsAssignableFrom(t)) { return(false); } return(true); } })); } return(_siteMapEnumerator.SiteMapNodes(NodeID)); }
public static SiteMapNode FindSiteMapNode(this SiteMap siteMap, HttpContextBase httpContext) { var node = FindSiteMapNodeFromMvc(siteMap, httpContext); // Check accessibility if (node == null || !node.IsAccessibleToUser()) { return(null); } return(node); }
protected override void SiteMap_InsertedRowPersisting(PXCache sender, SiteMap row) { if (string.IsNullOrEmpty(row.Url)) { base.SiteMap_InsertedRowPersisting(sender, row); } else { sender.SetValue <SiteMap.screenID>(row, GenerateNewScreenID(row)); } }
public override void UpdateSiteMap(SiteMap sitemap) { var obj = DbObjectModelBase<DbSiteMap, long>.FindById(sitemap.Id); if (obj == null) { return; } BizObject<SiteMap, long>.CopyToObject(sitemap, obj); obj.Save(); }
public static void Delete(SiteMap objItem) { if (objItem != null) { using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue)) { HttpResponseMessage response = client.DeleteAsync(string.Format(Resource + "?id={0}&CompanyID={1}", objItem.NodeID, objItem.CompanyID)).GetAwaiter().GetResult(); } RemoveCache(objItem); } }
public async Task <Business.Command.Contact.Message.SiteMap.Site> SiteUrlAsync(string siteId) { var site = await SiteMap.SiteUrlAsync(_routeManager, _dataFactory, siteId); var result = new Business.Command.Contact.Message.SiteMap.Site { Name = site.Name, Url = site.Url }; return(result); }
public IEnumerable <Category> GetUniqCategoriesFromSiteMap(SiteMap siteMap) { var list = new List <Category>(); siteMap.urlset.url.ForEach(category => { category.loc = ConvertLocProperty(category.loc); list.Add(category); }); return(list.GroupBy(v => v.loc).ToList().Select(v => v.First()).ToList()); }
protected virtual void GLWorkBook_SitemapParent_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e) { if (PXAccess.FeatureInstalled <CS.FeaturesSet.gLWorkBooks>()) { SiteMap node = PXSelect <SiteMap, Where <SiteMap.screenID, Equal <Required <SiteMap.screenID> > > > .Select(this, WORKBOOK_FOLDER_SCREEN_ID); if (node != null) { e.NewValue = node.NodeID; } } }
public async Task Update(string siteUrl, [FromBody] SiteMap data) { var url = new Uri(siteUrl); var doc = _sitemaps.Documents.FirstOrDefault(d => d.Data.Url.AbsoluteUri == url.AbsoluteUri); if (doc == null) { return; } await doc.SyncUpdate(data); }
private static SiteMap Convert(DbSiteMap dbSiteMap) { if (dbSiteMap == null) { return null; } var category = new SiteMap(dbSiteMap.Id, dbSiteMap.CreatedDate, dbSiteMap.CreatedBy, dbSiteMap.ModifiedDate, dbSiteMap.ModifiedBy); BizObject<SiteMap, long>.CopyFromObject(category, dbSiteMap); return category; }
public static void Populate(CommandProperties commandProperties) { _resources = (Dictionary <string, string>)Script.Literal("window.top._quickNav__resources"); _userPriviledgeNames = (Dictionary <string, string>)Script.Literal("window.top._quickNav__userPriviledgeNames"); _siteMap = (SiteMap)Script.Literal("window.top._quickNav__siteMap"); uniquePrefix = "dev1_" + DateTime.Now.GetTime().ToString() + "|"; bool isOnForm = (Page.Ui != null); LoadResources(); RibbonMenu quickNav = new RibbonMenu("dev1.QuickNav"); RibbonMenuSection topSection = new RibbonMenuSection("dev1.SiteMapMenuSection", "", 2, RibbonDisplayMode.Menu16); quickNav.AddSection(topSection); // Only show Sitemap in web client if (Page.Context.Client.GetClient() == ClientType.Web) { if (isOnForm) { RibbonFlyoutAnchor siteMapMenuFlyout = new RibbonFlyoutAnchor(uniquePrefix + "SiteMapButton", 1, ReplaceResourceToken("$Site_Map"), "Mscrm.Enabled", "/_imgs/FormEditorRibbon/Subgrid_16.png", null); topSection.AddButton((RibbonButton)(object)siteMapMenuFlyout); siteMapMenuFlyout.Menu = new RibbonMenu("dev1.SiteMapButton.Menu"); RibbonMenuSection siteMapMenuFlyoutSection = new RibbonMenuSection(uniquePrefix + "SiteMapButton.Menu.Section", "", 1, RibbonDisplayMode.Menu16); siteMapMenuFlyout.Menu.AddSection(siteMapMenuFlyoutSection); GetSiteMap(siteMapMenuFlyoutSection); } else { GetSiteMap(topSection); } } // Add Advanced Find RibbonButton advFind = new RibbonButton("dev1.OpenAdvancedFind.Button", 1, ReplaceResourceToken("$Advanced_Find"), "dev1.OpenAdvancedFind", "/_imgs/ribbon/AdvancedFind_16.png", null); topSection.AddButton(advFind); GetFormTabs(quickNav); GetFormNav(quickNav); commandProperties.PopulationXML = quickNav.SerialiseToRibbonXml(); // Store for next time Script.Literal("window.top._quickNav__resources={0}", _resources); Script.Literal("window.top._quickNav__userPriviledgeNames={0}", _userPriviledgeNames); Script.Literal("window.top._quickNav__siteMap={0}", _siteMap); }
public SiteMap Add(SiteMap SiteMap) { try { _db.SiteMap.Add(SiteMap); _db.SaveChanges(); return(_db.SiteMap.FirstOrDefault(c => c.Id == SiteMap.Id)); } catch (Exception ex) { return(null); } }
public static void Populate(CommandProperties commandProperties) { _resources = (Dictionary<string, string>)Script.Literal("window.top._quickNav__resources"); _userPriviledgeNames = (Dictionary<string, string>)Script.Literal("window.top._quickNav__userPriviledgeNames"); _siteMap = (SiteMap)Script.Literal("window.top._quickNav__siteMap"); uniquePrefix = "dev1_" + DateTime.Now.GetTime().ToString() + "|"; bool isOnForm = (Page.Ui != null); LoadResources(); RibbonMenu quickNav = new RibbonMenu("dev1.QuickNav"); RibbonMenuSection topSection = new RibbonMenuSection("dev1.SiteMapMenuSection", "", 2, RibbonDisplayMode.Menu16); quickNav.AddSection(topSection); // Only show Sitemap in web client if (Page.Context.Client.GetClient() == ClientType.Web) { if (isOnForm) { RibbonFlyoutAnchor siteMapMenuFlyout = new RibbonFlyoutAnchor(uniquePrefix + "SiteMapButton", 1, ReplaceResourceToken("$Site_Map"), "Mscrm.Enabled", "/_imgs/FormEditorRibbon/Subgrid_16.png", null); topSection.AddButton((RibbonButton)(object)siteMapMenuFlyout); siteMapMenuFlyout.Menu = new RibbonMenu("dev1.SiteMapButton.Menu"); RibbonMenuSection siteMapMenuFlyoutSection = new RibbonMenuSection(uniquePrefix + "SiteMapButton.Menu.Section", "", 1, RibbonDisplayMode.Menu16); siteMapMenuFlyout.Menu.AddSection(siteMapMenuFlyoutSection); GetSiteMap(siteMapMenuFlyoutSection); } else GetSiteMap(topSection); } // Add Advanced Find RibbonButton advFind = new RibbonButton("dev1.OpenAdvancedFind.Button", 1, ReplaceResourceToken("$Advanced_Find"), "dev1.OpenAdvancedFind", "/_imgs/ribbon/AdvancedFind_16.png", null); topSection.AddButton(advFind); GetFormTabs(quickNav); GetFormNav(quickNav); commandProperties.PopulationXML = quickNav.SerialiseToRibbonXml(); // Store for next time Script.Literal("window.top._quickNav__resources={0}",_resources); Script.Literal("window.top._quickNav__userPriviledgeNames={0}",_userPriviledgeNames); Script.Literal("window.top._quickNav__siteMap={0}",_siteMap); }
public ActionResult Register(RegisterViewModel model) { Require.NotNull(model, "model"); if (User.Identity.IsAuthenticated) { return(RedirectToHome()); } // Ontologie. Ontology.Title = Strings.Account_Register_Title; Ontology.Description = Strings.Account_Register_Description; Ontology.Relationships.CanonicalUrl = SiteMap.Register(); // LayoutViewModel. LayoutViewModel.AddAlternateUrls(Environment.Language, _ => _.Register()); LayoutViewModel.MainMenuCssClass = "register"; LayoutViewModel.MainHeading = Strings.Account_Register_MainHeading; if (!ModelState.IsValid) { return(View(Constants.ViewName.Account.Register, model)); } _memberService.MemberCreated += (sender, e) => { new AuthenticationService(HttpContext).SignIn(e.Member); }; var result = _memberService.RegisterMember(new RegisterMemberRequest { CompanyName = model.CompanyName, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, NewsletterChecked = IsCheckBoxOn_(model.Newsletter), }); if (result.IsBreak) { return(View( Constants.ViewName.Account.RegisterFailure, new RegisterFailureViewModel { Message = result.Reason })); } string returnUrl = (from _ in ParseTo.Uri(model.ReturnUrl, UriKind.Relative) select _.ToString()) .ValueOrElse(String.Empty); return(RedirectToRoute(Constants.RouteName.Account.RegisterSuccess, new { returnUrl = returnUrl })); }
public SiteMapTests() { IUrlHelper url = Substitute.For <IUrlHelper>(); authorization = Substitute.For <IAuthorization>(); siteMap = new SiteMap(CreateSiteMap(), authorization); context = HtmlHelperFactory.CreateHtmlHelper().ViewContext; IUrlHelperFactory factory = Substitute.For <IUrlHelperFactory>(); context.HttpContext.RequestServices.GetService(typeof(IUrlHelperFactory)).Returns(factory); url.Action(Arg.Any <UrlActionContext>()).Returns("/test"); factory.GetUrlHelper(context).Returns(url); route = context.RouteData.Values; }
private static async Task SendEmailAsync(IRouteManager routeManager, IDataFactory _dataFactory, IEmailService _emailService, SendMailAdmin sendMailAdmin) { var siteInfo = await SiteMap.SiteUrlAsync(routeManager, _dataFactory, sendMailAdmin.SiteId); if (sendMailAdmin.UserCreated == null) { await SendMailNoUserAsync(siteInfo, _emailService, sendMailAdmin.UserCreator, sendMailAdmin.Mail); } else { await SendEmailAdminAsync(siteInfo, _emailService, sendMailAdmin.UserCreated, sendMailAdmin.SiteId, sendMailAdmin.UserCreator, sendMailAdmin.Mail); } }
public void Update(SiteMap siteMap) { using (var context = new PunchClockDbContext()) { var entity = context.SiteMaps.FirstOrDefault(x => x.Id == siteMap.Id); if (entity == null) { return; } entity.Name = siteMap.Name; entity.ModifiedDateUtc = DateTime.UtcNow; context.SaveChanges(); } }
private async Task SaveMapAsync(SiteMap newMap) { //update the cache var siteMapDoc = _map.Mapper.Map <SiteMapDocument>(newMap); try { await _docDbClient.UpsertDocumentAsync(_config.SiteContentCollectionUrl, siteMapDoc).ConfigureAwait(false); } catch (Exception ex) { throw new ApplicationException("Unable to save site map ", ex); } }
public void AssignSiteMap(Guid SesId, string _ImportWebResourcesSolutionUniqueName) { SiteMap sMap = new SiteMap(); sMap.Id = SesId; UpdateRequest updateSiteMapResourceItem = new UpdateRequest() { Target = sMap, }; updateSiteMapResourceItem.Parameters.Add("SolutionUniqueName", _ImportWebResourcesSolutionUniqueName); _serviceProxy.Execute(updateSiteMapResourceItem); }
public SiteMap Update(SiteMap SiteMap) { try { _db.SiteMap.Attach(SiteMap); _db.Entry(SiteMap).State = EntityState.Modified; _db.SaveChanges(); return(_db.SiteMap.FirstOrDefault(c => c.Id == SiteMap.Id)); } catch (Exception ex) { return(null); } }
public static SiteMapNode FindSiteMapNodeFromMvcRoute(SiteMap siteMap, IDictionary <string, object> values, RouteBase route) { var routes = RouteTable.Routes; // keyTable contains every node in the SiteMap foreach (var node in siteMap.GetKeyToNodeDictionary()) { if (node.MatchesRoute(values)) { return(node); } } return(null); }
public void Index() { // Arrange HomeController controller = new HomeController(_repo, _contentRepo); // Act ViewResult result = controller.Index().GetAwaiter().GetResult() as ViewResult; // Assert Assert.IsNotNull(result); SiteMap map = result.ViewBag.SiteMap; //test that map is null, but we should not have any exceptions Assert.IsNull(map, "Site map is NOT null on home page."); }
public static SiteMap Update(SiteMap objItem) { SiteMap item = new SiteMap(); using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue)) { HttpResponseMessage response = client.PutAsJsonAsync(string.Format(Resource + "?id={0}", objItem.NodeID), objItem).GetAwaiter().GetResult(); if (response.IsSuccessStatusCode) { item = response.Content.ReadAsAsync <SiteMap>().GetAwaiter().GetResult(); RemoveCache(item); } } return(item); }
public ActionResult Category(DesignerKey designerKey, string categoryKey, int p = 1) { // Modèle. var pagedList = _patternService.ListPreviews(designerKey, categoryKey, p, PreviewsPageSize_); if (pagedList == null) { return(new HttpNotFoundResult()); } var designer = GetDesigner_(designerKey, categoryKey); var category = (from _ in designer.Categories where _.Key == categoryKey select _).Single(); var model = new CategoryViewModel { Category = category, Designer = designer, IsFirstPage = pagedList.IsFirstPage, IsLastPage = pagedList.IsLastPage, PageCount = pagedList.PageCount, PageIndex = pagedList.PageIndex, Previews = from _ in pagedList.Previews select PatternViewItem.Of(_, designer.DisplayName) }; // Ontologie. Ontology.Title = String.Format( CultureInfo.CurrentUICulture, Strings.Designer_Category_TitleFormat, model.Category.DisplayName, model.Designer.DisplayName); Ontology.Description = String.Format( CultureInfo.CurrentUICulture, Strings.Designer_Category_DescriptionFormat, model.Designer.DisplayName, model.Category.DisplayName); //Ontology.SchemaOrg.ItemType = SchemaOrgType.CollectionPage; Ontology.Relationships.CanonicalUrl = SiteMap.DesignerCategory(designerKey, categoryKey, p); var image = model.Previews.First(); SetOpenGraphImage_(designerKey, image.Reference, image.Variant); // LayoutViewModel. LayoutViewModel.AddAlternateUrls(Environment.Language, _ => _.DesignerCategory(designerKey, categoryKey, p)); LayoutViewModel.DesignerMenuCssClass = ViewUtility.DesignerClass(designerKey); LayoutViewModel.MainHeading = category.DisplayName; return(View(Constants.ViewName.Designer.Category, model)); }
private async Task SendMail(IRouteManager routeManager, string siteId, CommentsDbModel commentsDbModel) { /* (new BusinessModuleFactory()).GetModule("NewsItem").GetInfoAsync(new GetModuleInput() * { * * });*/ var site = await SiteMap.SiteUrlAsync(routeManager, _dataFactory, siteId); var userIds = commentsDbModel.Comments .GroupBy(p => p.UserId) .Select(g => g.First().UserId) .ToList(); var administrators = await _userService.UserByRoleAsync(siteId); foreach (var administrator in administrators) { if (!userIds.Contains(administrator.Id)) { userIds.Add(administrator.Id); } } foreach (var userId in userIds) { var user = await _userService.FindApplicationUserByIdAsync(userId); if (user.IsUserNotifyComment && user.Id != Input.UserId) { var model = new CommentAddedMailModel { SiteName = site.Name, SiteUrl = site.Url, UserName = user.FullName, ArticleTitle = Input.Data.ArticleTitle, ArticleUrl = UrlHelper.Concat(site.Url, Input.Data.UrlPath) }; var identityMessage = new MailMessage(); identityMessage.Subject = string.Format("[{0}] Commentaire envoyé sur le site", model.SiteName); //TODO identityMessage.Body = new StringTemplateRenderer().Render( //Encoding.UTF8.GetString(TemplateResource.CommentAdded), model); identityMessage.Destination = user.Email; await _emailService.SendAsync(identityMessage); } } }
/// <summary> /// 生成网站地图 及时更新当前更新的2000条数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void createSitemap_Click(object sender, RoutedEventArgs e) { createSitemap.IsEnabled = false; System.Threading.Tasks.Task.Factory.StartNew(() => { SiteMap map = new SiteMap(); using (TygModel.Entities entity = new TygModel.Entities()) { var query = entity.文章表.OrderByDescending(p => p.ID).Take(2000).Where(p => p.创建时间.Day == DateTime.Now.Day); //更新数据 map.ForUpdateDocs(query); } Dispatcher.BeginInvoke(new Action(delegate { createSitemap.IsEnabled = true; })); }); }
public static SiteMap Add(SiteMap objItem) { SiteMap b = new SiteMap(); using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue)) { HttpResponseMessage response = client.PostAsJsonAsync(Resource, objItem).GetAwaiter().GetResult(); if (response.IsSuccessStatusCode) { b = response.Content.ReadAsAsync <SiteMap>().GetAwaiter().GetResult(); } } RemoveCache(b); return(b); }
public SiteMap NavSummary(List <MenuItem> navItems, int itemId) { var siteMapItem = new SiteMap(); foreach (var navItem in navItems) { if (navItem.Id == itemId) { siteMapItem.Id = navItem.Id; siteMapItem.Title = navItem.Title; siteMapItem.Link = navItem.Link; siteMapItem.Children = MapChildren(navItems, itemId); } } return(siteMapItem); }
//public static SiteMapNode FindSiteMapNodeFromPublicFacingUrl(this SiteMap siteMap, HttpContextBase httpContext) //{ // var publicFacingUrl = UrlPath.GetPublicFacingUrl(httpContext); // return FindSiteMapNodeFromUrl(siteMap, publicFacingUrl.PathAndQuery, publicFacingUrl.AbsolutePath, publicFacingUrl.Host, httpContext.CurrentHandler); //} //public static SiteMapNode FindSiteMapNodeFromUrl(this SiteMap siteMap, string relativeUrl, string relativePath, string hostName, IHttpHandler handler) //{ // SiteMapNode node = null; // // Try absolute match with querystring // var absoluteMatch = siteMapChildStateFactory.CreateUrlKey(relativeUrl, hostName); // node = FindSiteMapNodeFromUrlMatch(absoluteMatch); // // Try absolute match without querystring // if (node == null && !string.IsNullOrEmpty(relativePath)) // { // var absoluteMatchWithoutQueryString = siteMapChildStateFactory.CreateUrlKey(relativePath, hostName); // node = FindSiteMapNodeFromUrlMatch(absoluteMatchWithoutQueryString); // } // // Try relative match // if (node == null) // { // var relativeMatch = siteMapChildStateFactory.CreateUrlKey(relativeUrl, string.Empty); // node = FindSiteMapNodeFromUrlMatch(relativeMatch); // } // // Try relative match with ASP.NET handler querystring // if (node == null) // { // Page currentHandler = handler as Page; // if (currentHandler != null) // { // string clientQueryString = currentHandler.ClientQueryString; // if (clientQueryString.Length > 0) // { // var aspNetRelativeMatch = siteMapChildStateFactory.CreateUrlKey(relativePath + "?" + clientQueryString, string.Empty); // node = FindSiteMapNodeFromUrlMatch(aspNetRelativeMatch); // } // } // } // // Try relative match without querystring // if (node == null && !string.IsNullOrEmpty(relativePath)) // { // var relativeMatchWithoutQueryString = siteMapChildStateFactory.CreateUrlKey(relativePath, string.Empty); // node = FindSiteMapNodeFromUrlMatch(relativeMatchWithoutQueryString); // } // return node; //} public static SiteMapNode FindSiteMapNode(this SiteMap siteMap, string rawUrl) { if (rawUrl == null) { throw new ArgumentNullException(nameof(rawUrl)); } rawUrl = rawUrl.Trim(); if (rawUrl.Length == 0) { return(null); } // NOTE: If the URL passed is absolute, the public facing URL will be ignored // and the current URL will be the absolute URL that is passed. var publicFacingUrl = UrlPath.GetPublicFacingUrl(UrlPath.HttpContext); var currentUrl = new Uri(publicFacingUrl, rawUrl); //// Search the internal dictionary for the URL that is registered manually. //var node = FindSiteMapNodeFromUrl(currentUrl.PathAndQuery, currentUrl.AbsolutePath, currentUrl.Host, System.Web.HttpContext.Current); SiteMapNode node = null; // Search for the URL by creating a context based on the new URL and matching route values. if (node == null) { // Create a TextWriter with null stream as a backing stream // which doesn't consume resources using (var nullWriter = new StreamWriter(Stream.Null)) { // create a new http context using the node's URL instead of the current one. var currentUrlRequest = new HttpRequest(string.Empty, currentUrl.ToString(), currentUrl.Query); var currentUrlResponse = new HttpResponse(nullWriter); var currentUrlContext = new HttpContext(currentUrlRequest, currentUrlResponse); var currentUrlHttpContext = new HttpContextWrapper(currentUrlContext); // Find node for the passed-in URL using the new HTTP context. This will do a // match based on route values and/or query string values. node = FindSiteMapNodeFromMvc(siteMap, currentUrlHttpContext); } } // Check accessibility if (node == null || !node.IsAccessibleToUser()) { return(null); } return(node); }
public void For_NoAuthorization_ReturnsAllNodes() { siteMap = new SiteMap(CreateSiteMap(), null); SiteMapNode[] actual = siteMap.For(context).ToArray(); Assert.Single(actual); Assert.Null(actual[0].Action); Assert.Equal("#", actual[0].Url); Assert.Null(actual[0].Controller); Assert.Equal("Administration", actual[0].Area); Assert.Equal("fa fa-cogs", actual[0].IconClass); Assert.Equal(Resource.ForSiteMap("Administration", null, null), actual[0].Title); actual = actual[0].Children.ToArray(); Assert.Equal(2, actual.Length); Assert.Empty(actual[0].Children); Assert.Equal("/test", actual[0].Url); Assert.Equal("Index", actual[0].Action); Assert.Equal("Accounts", actual[0].Controller); Assert.Equal("Administration", actual[0].Area); Assert.Equal("fa fa-user", actual[0].IconClass); Assert.Equal(Resource.ForSiteMap("Administration", "Accounts", "Index"), actual[0].Title); Assert.Null(actual[1].Action); Assert.Equal("#", actual[1].Url); Assert.Equal("Roles", actual[1].Controller); Assert.Equal("Administration", actual[1].Area); Assert.Equal("fa fa-users", actual[1].IconClass); Assert.Equal(Resource.ForSiteMap("Administration", "Roles", null), actual[1].Title); actual = actual[1].Children.ToArray(); Assert.Single(actual); Assert.Empty(actual[0].Children); Assert.Equal("/test", actual[0].Url); Assert.Equal("Create", actual[0].Action); Assert.Equal("Roles", actual[0].Controller); Assert.Equal("Administration", actual[0].Area); Assert.Equal("far fa-file", actual[0].IconClass); Assert.Equal(Resource.ForSiteMap("Administration", "Roles", "Create"), actual[0].Title); }
public ActionResult About() { // Modèle. var model = _queries.ListDesigners(CultureInfo.CurrentUICulture).OrderBy(_ => _.Nickname.ValueOrElse(_.LastName)); // Ontologie. Ontology.Title = Strings.Home_About_Title; Ontology.Description = Strings.Home_About_Description; Ontology.Relationships.CanonicalUrl = SiteMap.About(); Ontology.SchemaOrg.ItemType = SchemaOrgType.AboutPage; // LayoutViewModel. LayoutViewModel.AddAlternateUrls(Environment.Language, _ => _.About()); LayoutViewModel.MainHeading = Strings.Home_About_MainHeading; LayoutViewModel.MainMenuCssClass = "about"; return(View(Constants.ViewName.Home.About, model)); }
public void IndexWithSiteMap() { // Arrange HomeControllerWrapper controller = new HomeControllerWrapper(_repo, _contentRepo); //call wrapper method to invoke protected load from base controller.LoadSiteMap(); // Act ViewResult result = controller.Index().GetAwaiter().GetResult() as ViewResult; // Assert Assert.IsNotNull(result); SiteMap map = result.ViewBag.SiteMap; //test that map is not null, and has the default entries Assert.IsNotNull(map, "Site map is null on home page."); Assert.AreEqual <int>(2, map.Entries.Count); }
public void Test_Add() { SiteMapNode homeNode = new SiteMapNode(); homeNode.Action = "Home"; homeNode.TypeName = "Home"; homeNode.Title = "Home"; SiteMapNode item = new SiteMapNode(); item.Action = "TestAction"; item.TypeName = "TestType"; item.Title = "Test Title"; SiteMap map = new SiteMap(); map.UrlCreator = new MockUrlCreator(this); map.Add(new SiteMapNode("Home", "Default.aspx")); map.Add(item); Assert.AreEqual(2, map.ChildNodes.Count, "Invalid number of child nodes."); }
/// <summary> /// Loads the site map from the specified path. /// </summary> /// <param name="path">The path of the site map to load.</param> /// <returns>The site map loaded from the specified path.</returns> public static SiteMap Load(string path) { SiteMap map = new SiteMap(); using (LogGroup logGroup = LogGroup.StartDebug("Loading site map: " + path)) { map.FilePath = path; // load site map file XmlDocument nodeData = new XmlDocument(); nodeData.Load(path); // skip the <xml> document element XmlNode first = nodeData.FirstChild; if (first.NodeType == XmlNodeType.XmlDeclaration) first = nodeData.FirstChild.NextSibling;//.FirstChild; else first = first.FirstChild; if (first == null) { throw new Exception("The site map contains no elements."); } else { // NodeAddRoot.Enabled = false; XmlToObjects(first.ChildNodes, map.ChildNodes); } LogWriter.Debug("Root nodes: " + map.ChildNodes.Count.ToString()); } return map; }
public void Test_GetNodeByTitle_TwoLevelTitle() { SiteMap siteMap = new SiteMap(); // Create the base node and add it SiteMapNode baseNode = new SiteMapNode("Category", "TestUrl"); List<SiteMapNode> baseNodes = new List<SiteMapNode>(); baseNodes.Add(baseNode); siteMap.ChildNodes = baseNodes; // Create the sub node and add it SiteMapNode subNode = new SiteMapNode("Category", "SubNode", "TestAction", "TestType"); List<SiteMapNode> subNodes = new List<SiteMapNode>(); subNodes.Add(subNode); baseNode.ChildNodes = subNodes; // Try to get the node by providing the 2 level title SiteMapNode node = siteMap.GetNodeByTitle(baseNodes, "Category/SubNode"); Assert.IsNotNull(node, "No node found."); }
public abstract long InsertSiteMap(SiteMap sitemap);
private static void LoadResources() { jQueryAjaxOptions options = new jQueryAjaxOptions(); options.Async = false; int lcid = Page.Context.GetUserLcid(); if (_siteMap == null) { options.Url = Page.Context.GetClientUrl() + "/" + PageEx.GetCacheKey() + "/WebResources/dev1_/js/SiteMap" + lcid.ToString() + ".js"; _siteMap = jQuery.ParseJsonData<SiteMap>(jQuery.Ajax(options).ResponseText); } if (_resources == null) { Dictionary<string, string> loadedResources = null; options.Url = GetResourceStringWebResourceUrl(lcid); try { loadedResources = jQuery.ParseJsonData<Dictionary<string, string>>(jQuery.Ajax(options).ResponseText); } catch { } if (loadedResources == null) { // We fall back to the 1033 because this is included in the solution options.Url = GetResourceStringWebResourceUrl(1033); loadedResources = jQuery.ParseJsonData<Dictionary<string, string>>(jQuery.Ajax(options).ResponseText); } _resources = loadedResources; } }
/// <summary> /// Creates a new MvcSiteMapProvider HtmlHelper. /// </summary> /// <param name="helper">The helper.</param> /// <param name="siteMap">The SiteMap.</param> /// <returns> /// A <see cref="MvcSiteMapHtmlHelper"/> instance /// </returns> public static MvcSiteMapHtmlHelper MvcSiteMap(this HtmlHelper helper, SiteMap siteMap) { return new MvcSiteMapHtmlHelper(helper, siteMap); }
public abstract void UpdateSiteMap(SiteMap sitemap);
public void Test_Remove() { SiteMapNode homeNode = new SiteMapNode(); homeNode.Action = "Home"; homeNode.TypeName = "Home"; homeNode.Title = "Home"; SiteMapNode item = new SiteMapNode(); item.Action = "TestAction"; item.TypeName = "TestType"; item.Title = "Test Title"; SiteMap map = new SiteMap(); map.UrlCreator = new MockUrlCreator(this); map.Add(homeNode); map.Add(item); Assert.AreEqual(2, map.ChildNodes.Count, "Invalid number of nodes before removal."); map.Remove(item); Assert.AreEqual(1, map.ChildNodes.Count, "Invalid number of nodes after removal."); Assert.AreEqual(0, map.ChildNodes[0].ChildNodes.Count, "Invalid number of child nodes after removal."); }
protected virtual SiteMap VisitSiteMap(SiteMap siteMap) { var siteMapNodes = new List<SiteMapNode>(); if (siteMap.Nodes != null) { // copy all root nodes and children, this makes all subsequent siteMap modifications only for this cloned instance // this solves an issue of an inmemory cacheable object foreach (var node in siteMap.Nodes.Select(n => n.Copy())) { if (IsNodeAccessible(node)) siteMapNodes.Add(node); } } return new SiteMap { CacheKey = siteMap.CacheKey, Nodes = siteMapNodes }; }