예제 #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/xml";
            using (XmlTextWriter writer = new XmlTextWriter(context.Response.OutputStream, Encoding.UTF8))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("urlset");
                writer.WriteAttributeString("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9");

                //Content Pages
                using (DataConnection dataConn = new DataConnection())
                {
                    SitemapNavigator sitemapNavigator = new SitemapNavigator(dataConn);
                    allModels = dataConn.Get <Kobelco.Models>().ToList();
                    allSizes  = dataConn.Get <Kobelco.SizeClasses>().ToList();
                    WriteContentPageSitemap(writer, sitemapNavigator.HomePageNodes.First());
                }

                if (allModels != null && allSizes != null)
                {
                    WriteKobelcoModelsToSitemap(writer, allModels, allSizes);
                }

                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();

                context.Response.End();
            }
        }
예제 #2
0
 public static string GetCurrentPageUrl()
 {
     using (var dataConnection = new DataConnection())
     {
         var sitemapNavigator = new SitemapNavigator(dataConnection);
         return(sitemapNavigator.CurrentPageNode.Url);
     }
 }
예제 #3
0
 public static string GetPageUrlById(Guid pageId)
 {
     using (var conn = new DataConnection())
     {
         var sitemapNavigator = new SitemapNavigator(conn);
         return(sitemapNavigator.GetPageNodeById(pageId).Url);
     }
 }
예제 #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     html_tag.Attributes.Add("lang", System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName);
     using (var conn = new DataConnection())
     {
         var homepageLink = new SitemapNavigator(conn).CurrentHomePageNode.Url;
         hlHomePage.NavigateUrl = homepageLink;
     }
 }
예제 #5
0
	protected void Page_Load(object sender, EventArgs e)
	{
		html_tag.Attributes.Add("lang", System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName);
		using (var conn = new DataConnection())
		{
			var homepageLink = new SitemapNavigator(conn).CurrentHomePageNode.Url;
			hlHomePage.NavigateUrl = homepageLink;
		}
	}
예제 #6
0
        public static XhtmlDocument SaveBrokenLink()
        {
            var request = HttpContext.Current.Request;

            // ignore if referer is empty
            if (request.UrlReferrer == null ||
                request.RawUrl.StartsWith("/Composite/content/flow/FlowUi.aspx", StringComparison.InvariantCultureIgnoreCase) ||
                request.UrlReferrer.ToString().IndexOf("/Composite/content/views/browser/browser.aspx", StringComparison.InvariantCultureIgnoreCase) > 0)
            {
                return(null);
            }
            var url = "http://" + request.Url.Host + request.RawUrl;

            using (var dataConnection = new DataConnection())
            {
                var sitemapNavigator = new SitemapNavigator(dataConnection);
                if (sitemapNavigator.CurrentPageNode != null && request.RawUrl.Equals(sitemapNavigator.CurrentPageNode.Url))
                {
                    return(null);
                }
            }
            var referer   = (request.UrlReferrer == null) ? "" : request.UrlReferrer.ToString();
            var userAgent = request.UserAgent ?? string.Empty;
            var ipAddress = GetIPAddress(request);

            if (!UserAgentIsTrusted(userAgent) ||
                !RefererIsTrusted(referer) ||
                IPAddressIsInBlackList(ipAddress))
            {
                return(null);
            }

            using (var conn = new DataConnection())
            {
                var item = conn.Get <BrokenLink>().FirstOrDefault(el => el.BadURL == url);
                if (item == null)
                {
                    var newItem = conn.CreateNew <BrokenLink>();
                    newItem.Id        = Guid.NewGuid();
                    newItem.BadURL    = url;
                    newItem.Referer   = referer;
                    newItem.UserAgent = userAgent;
                    newItem.IP        = ipAddress;
                    newItem.Date      = DateTime.Now;
                    conn.Add <BrokenLink>(newItem);
                }
            }
            return(null);
        }
예제 #7
0
		public static XhtmlDocument SaveBrokenLink()
		{

			var request = HttpContext.Current.Request;

			// ignore if referer is empty
			if (request.UrlReferrer == null
				|| request.RawUrl.StartsWith("/Composite/content/flow/FlowUi.aspx", StringComparison.InvariantCultureIgnoreCase)
				|| request.UrlReferrer.ToString().IndexOf("/Composite/content/views/browser/browser.aspx", StringComparison.InvariantCultureIgnoreCase) > 0)
			{
				return null;
			}
			var url = "http://" + request.Url.Host + request.RawUrl;
			using (var dataConnection = new DataConnection())
			{
				var sitemapNavigator = new SitemapNavigator(dataConnection);
				if (sitemapNavigator.CurrentPageNode != null && request.RawUrl.Equals(sitemapNavigator.CurrentPageNode.Url))
					return null;
			}
			var referer = (request.UrlReferrer == null) ? "" : request.UrlReferrer.ToString();
			var userAgent = request.UserAgent ?? string.Empty;
			var ipAddress = GetIPAddress(request);

			if (!UserAgentIsTrusted(userAgent)
				|| !RefererIsTrusted(referer)
				|| IPAddressIsInBlackList(ipAddress))
			{
				return null;
			}

			using (var conn = new DataConnection())
			{
				var item = conn.Get<BrokenLink>().FirstOrDefault(el => el.BadURL == url);
				if (item == null)
				{
					var newItem = conn.CreateNew<BrokenLink>();
					newItem.Id = Guid.NewGuid();
					newItem.BadURL = url;
					newItem.Referer = referer;
					newItem.UserAgent = userAgent;
					newItem.IP = ipAddress;
					newItem.Date = DateTime.Now;
					conn.Add<BrokenLink>(newItem);
				}
			}
			return null;
		}
예제 #8
0
        private SiteMapContainer LoadSiteMap()
        {
            var siteMapContext = SiteMapContext.Current;

            if (siteMapContext != null)
            {
                var rootPage = siteMapContext.RootPage;

                return(LoadSiteMap(rootPage.DataSourceId.LocaleScope, rootPage.Id));
            }

            var currentCulture = LocalizationScopeManager.CurrentLocalizationScope;

            if (currentCulture.Name == CultureInfo.InvariantCulture.Name)
            {
                currentCulture = CultureInfo.CurrentCulture;
            }

            Guid currentHomePage = SitemapNavigator.CurrentHomePageId;

            if (currentHomePage != Guid.Empty)
            {
                return(LoadSiteMap(currentCulture, currentHomePage));
            }

            var context = HttpContext.Current;

            using (var conn = new DataConnection(currentCulture))
            {
                PageNode pageNode = new SitemapNavigator(conn).GetPageNodeByHostname(context.Request.Url.Host);
                if (pageNode != null)
                {
                    return(LoadSiteMap(currentCulture, pageNode.Id));
                }
            }

            return(null);
        }
        private SiteMapContainer LoadSiteMap()
        {
            var siteMapContext = SiteMapContext.Current;

            if (siteMapContext != null)
            {
                var rootPage = siteMapContext.RootPage;

                return LoadSiteMap(rootPage.DataSourceId.LocaleScope, rootPage.Id);
            }

            var currentCulture = LocalizationScopeManager.CurrentLocalizationScope;
            if (currentCulture.Name == CultureInfo.InvariantCulture.Name)
            {
                currentCulture = CultureInfo.CurrentCulture;
            }

            Guid currentHomePage = SitemapNavigator.CurrentHomePageId;
            if (currentHomePage != Guid.Empty)
            {
                return LoadSiteMap(currentCulture, currentHomePage);
            }

            var context = HttpContext.Current;

            using (var conn = new DataConnection(currentCulture))
            {
                PageNode pageNode = new SitemapNavigator(conn).GetPageNodeByHostname(context.Request.Url.Host);
                if (pageNode != null)
                {
                    return LoadSiteMap(currentCulture, pageNode.Id);
                }
            }

            return null;
        }
예제 #10
0
 public static string GetPageUrlById(Guid pageId)
 {
     using (var conn = new DataConnection())
     {
         var sitemapNavigator = new SitemapNavigator(conn);
         return sitemapNavigator.GetPageNodeById(pageId).Url;
     }
 }
예제 #11
0
 public static string GetCurrentPageUrl()
 {
     using (var dataConnection = new DataConnection())
     {
         var sitemapNavigator = new SitemapNavigator(dataConnection);
         return sitemapNavigator.CurrentPageNode.Url;
     }
 }
예제 #12
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/xml";
            CultureInfo culture = DataLocalizationFacade.DefaultLocalizationCulture;

            string pathInfo = context.Request.PathInfo;

            if (pathInfo.Length > 1)
            {
                culture = new CultureInfo(pathInfo.Substring(1));
            }

            using (var con = new DataConnection(culture))
            {
                var feed = new SyndicationFeed
                {
                    Title = new TextSyndicationContent("News List")
                };
                var items = new List <SyndicationItem>();

                IQueryable <NewsItem> allNews = con.Get <NewsItem>();

                string hostname        = context.Request.Url.Host;
                var    hostnameBinding = con.Get <IHostnameBinding>().FirstOrDefault(h => h.Hostname == hostname);
                if (hostnameBinding != null)
                {
                    Guid homepageId  = hostnameBinding.HomePageId;
                    var  sm          = new SitemapNavigator(con);
                    var  pagesFilter = new HashSet <Guid>(
                        sm.GetPageNodeById(homepageId)
                        .GetPageNodes(SitemapScope.DescendantsAndCurrent)
                        .Select(p => p.Id));

                    allNews = allNews.Evaluate().Where(n => pagesFilter.Contains(n.PageId)).ToList().AsQueryable();
                }

                IEnumerable <NewsItem> latestNews = allNews.OrderByDescending(d => d.Date).Take(10);

                foreach (var news in latestNews.Evaluate())
                {
                    var page = PageManager.GetPageById(news.PageId);
                    if (page == null)
                    {
                        continue;
                    }

                    var pageUrlData = new PageUrlData(page)
                    {
                        PathInfo = NewsFacade.GetPathInfo(news.TitleUrl, news.Date)
                    };
                    string pageUrl = PageUrls.BuildUrl(pageUrlData);
                    if (pageUrl == null)
                    {
                        continue;
                    }

                    var item = new SyndicationItem(
                        news.Title,
                        news.Teaser,
                        context.GetPath(pageUrl),
                        news.Id.ToString(),
                        news.Date
                        );
                    item.Categories.Add(new SyndicationCategory(news.PageId.ToString()));
                    items.Add(item);
                }
                feed.Items = items;
                var writer = new XmlTextWriter(context.Response.Output);
                feed.SaveAsRss20(writer);
            }
        }
예제 #13
0
		public void ProcessRequest(HttpContext context)
		{
			context.Response.ContentType = "text/xml";
			CultureInfo culture = DataLocalizationFacade.DefaultLocalizationCulture;

		    string pathInfo = context.Request.PathInfo;
            if (pathInfo.Length > 1)
			{
                culture = new CultureInfo(pathInfo.Substring(1));
			}

			using (var con = new DataConnection(culture))
			{
				var feed = new SyndicationFeed
				{
				    Title = new TextSyndicationContent("News List")
				};
			    var items = new List<SyndicationItem>();

			    IQueryable<NewsItem> allNews = con.Get<NewsItem>();

				string hostname = context.Request.Url.Host;
			    var hostnameBinding = con.Get<IHostnameBinding>().FirstOrDefault(h => h.Hostname == hostname);
				if (hostnameBinding != null)
				{
					Guid homepageId = hostnameBinding.HomePageId;
					var sm = new SitemapNavigator(con);
					var pagesFilter = new HashSet<Guid>(
                        sm.GetPageNodeById(homepageId)
                          .GetPageNodes(SitemapScope.DescendantsAndCurrent)
                          .Select(p => p.Id));

                    allNews = allNews.Evaluate().Where(n => pagesFilter.Contains(n.PageId)).ToList().AsQueryable();
				}

			    IEnumerable<NewsItem> latestNews = allNews.OrderByDescending(d => d.Date).Take(10);

				foreach (var news in latestNews.Evaluate())
				{
				    var page = PageManager.GetPageById(news.PageId);
				    if (page == null)
				    {
				        continue;
				    }

				    var pageUrlData = new PageUrlData(page) {PathInfo = NewsFacade.GetPathInfo(news.TitleUrl, news.Date)};
                    string pageUrl = PageUrls.BuildUrl(pageUrlData);
				    if (pageUrl == null)
				    {
				        continue;
				    }

					var item = new SyndicationItem(
						news.Title,
						news.Teaser,
						context.GetPath(pageUrl),
						news.Id.ToString(),
						news.Date
						);
					item.Categories.Add( new SyndicationCategory(news.PageId.ToString()) );
					items.Add(item);
				}
				feed.Items = items;
				var writer = new XmlTextWriter(context.Response.Output);
				feed.SaveAsRss20(writer);
			}
		}