Example #1
0
 private static IEnumerable <UrlRule> getRules(int PortalId)
 {
     /*
      * if (PortalId < 0) // host menu
      *  return new List<UrlRule>();
      * else
      */
     return(UrlRuleConfiguration.GetConfig(PortalId).Rules.Where(r => r.Action == UrlRuleAction.Rewrite));
 }
Example #2
0
        protected void gvPortals_RowDataBound(Object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                PortalInfo portal     = (PortalInfo)e.Row.DataItem;
                int        RulesCount = UrlRuleConfiguration.GetConfig(portal.PortalID).Rules.Count();
                e.Row.Cells[1].Text = RulesCount.ToString();

                /*
                 * int Memsize = 0;
                 * foreach (var rule in UrlRuleConfiguration.GetConfig(portal.PortalID).Rules) {
                 *  Memsize += sizeof(UrlRuleType);
                 *  if (rule.CultureCode != null)
                 *  Memsize += sizeof(char) * rule.CultureCode.Length;
                 *  Memsize += sizeof(int); // tabid
                 *  if (rule.Parameters != null)
                 *  Memsize += sizeof(char) * rule.Parameters.Length; // Parameters
                 *  Memsize += sizeof(Boolean); //RemoveTab
                 *  Memsize += sizeof(UrlRuleAction);
                 *  if (rule.Url != null)
                 *  Memsize += sizeof(char) * rule.Url.Length; // Url
                 *  if (rule.RedirectDestination != null)
                 *  Memsize += sizeof(char) * rule.RedirectDestination.Length; //
                 *  Memsize += sizeof(int); // RedirectionStatus
                 *
                 * }
                 */

#if DEBUG
                System.IO.MemoryStream stream       = new System.IO.MemoryStream();
                BinaryFormatter        objFormatter = new BinaryFormatter();
                objFormatter.Serialize(stream, UrlRuleConfiguration.GetConfig(portal.PortalID));
                long Memsize = stream.Length;



                e.Row.Cells[2].Text = Memsize / 1000 + " kb"; //(RulesCount * sizeof(UrlRule) / 1000) + "";
#endif
            }
        }
Example #3
0
        private void ShowCache()
        {
            var Rules = UrlRuleConfiguration.GetConfig(PortalId).Rules;

            var stats = from r in Rules

                        group r by new { r.RuleTypeString, r.ActionString } into g
            orderby g.Key.RuleTypeString, g.Key.ActionString
                select new { Type = g.Key.RuleTypeString, Action = g.Key.ActionString, Count = g.Count() };

            gvCache.DataSource = stats;
            gvCache.DataBind();

            var clashes = from r in Rules /* .Where(r=> r.RuleType != UrlRuleType.Custom)*/

                          group r by new { r.RuleTypeString, r.CultureCode, r.TabId, r.Url } into g
            where g.Count() > 1
            select new { Type = g.Key.RuleTypeString, Culture = g.Key.CultureCode, g.Key.TabId, g.Key.Url, Count = g.Count() };

            //clashes = clashes.Where(c => c.Count > 1);

            gvClashes.DataSource = clashes;
            gvClashes.DataBind();
        }
Example #4
0
        /// <summary>
        ///   Includes page urls on the sitemap
        /// </summary>
        /// <remarks>
        ///   Pages that are included:
        ///   - are not deleted
        ///   - are not disabled
        ///   - are normal pages (not links,...)
        ///   - are visible (based on date and permissions)
        /// </remarks>
        public override List <SitemapUrl> GetUrls(int portalId, PortalSettings ps, string version)
        {
            var            objTabs = new TabController();
            OpenSitemapUrl pageUrl = null;
            var            urls    = new List <SitemapUrl>();

            useLevelBasedPagePriority = bool.Parse(PortalController.GetPortalSetting("SitemapLevelMode", portalId, "False"));
            minPagePriority           = float.Parse(PortalController.GetPortalSetting("SitemapMinPriority", portalId, "0.1"), CultureInfo.InvariantCulture);
            includeHiddenPages        = bool.Parse(PortalController.GetPortalSetting("SitemapIncludeHidden", portalId, "False"));

            PortalController portalController = new PortalController();
            PortalInfo       objPortal        = new PortalController().GetPortal(portalId);

            this.ps = ps;

            var Locales = ps.ContentLocalizationEnabled ?
                          LocaleController.Instance.GetPublishedLocales(ps.PortalId).Values :
                          LocaleController.Instance.GetLocales(ps.PortalId).Values;

            bool MultiLanguage = Locales.Count > 1;

            foreach (Locale loc in Locales)
            {
                foreach (TabInfo objTab in objTabs.GetTabsByPortal(portalId).Values)
                {
                    if (objTab.CultureCode == loc.Code || objTab.IsNeutralCulture)
                    {
                        if (MultiLanguage)
                        {
                            objPortal = new PortalController().GetPortal(portalId, loc.Code);
                        }
                        if (!objTab.IsDeleted && !objTab.DisableLink && objTab.TabType == TabType.Normal && (Null.IsNull(objTab.StartDate) || objTab.StartDate < DateTime.Now) &&
                            (Null.IsNull(objTab.EndDate) || objTab.EndDate > DateTime.Now) && IsTabPublic(objTab.TabPermissions) &&
                            objTab.TabID != objPortal.SearchTabId && objTab.TabID != objPortal.UserTabId && (objPortal.UserTabId == Null.NullInteger || objTab.ParentId != objPortal.UserTabId) && objTab.TabID != objPortal.LoginTabId && objTab.TabID != objPortal.RegisterTabId)
                        {
                            var allowIndex = true;
                            if ((!objTab.TabSettings.ContainsKey("AllowIndex") || !bool.TryParse(objTab.TabSettings["AllowIndex"].ToString(), out allowIndex) || allowIndex) &&
                                (includeHiddenPages || objTab.IsVisible))
                            {
                                // page url
                                pageUrl = GetPageUrl(objTab, MultiLanguage ? loc.Code : null);
                                pageUrl.Alternates.AddRange(GetAlternates(objTab.TabID));
                                urls.Add(pageUrl);

                                // modules urls
                                var rules = UrlRuleConfiguration.GetConfig(portalId).Rules;
                                foreach (var rule in rules.Where(r => r.RuleType == UrlRuleType.Module && r.Action == UrlRuleAction.Rewrite && r.TabId == objTab.TabID && r.InSitemap == true))
                                {
                                    if (rule.CultureCode == null || rule.CultureCode == loc.Code)
                                    {
                                        string[] pars = rule.Parameters.Split('&');
                                        pageUrl = GetPageUrl(objTab, MultiLanguage ? loc.Code : null, pars);
                                        // if module support ML
                                        //pageUrl.Alternates.AddRange(GetAlternates(objTab.TabID, pars));
                                        urls.Add(pageUrl);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(urls);
        }
 private void ShowCache()
 {
     GridView1.DataSource = UrlRuleConfiguration.GetConfig(PortalId).Rules;
     GridView1.DataBind();
 }