Ejemplo n.º 1
0
        private List <InboundRule> GetInboundRules(Database db)
        {
            Log.Info(this, db, "Start GetInboundRules.");
            var cache        = RulesCacheManager.GetCache(db);
            var inboundRules = cache.GetInboundRules();

            Log.Info(this, db, "Stop GetInboundRules.");
            if (inboundRules != null)
            {
                Log.Info(this, db, "inboundRules!=null");
                Log.Info(this, db, "inboundRules.Any()=={0}", inboundRules.Any());
                if (inboundRules.Any())
                {
                    Log.Info(this, db, "inboundRules.Count()=={0}", inboundRules.Count);
                }
                return(inboundRules);
            }
            else
            {
                Log.Info(this, db, "inboundRules==null");
            }

            Log.Info(this, db, "Initializing Inbound Rules.");

            using (new SecurityDisabler())
            {
                var rulesEngine = new RulesEngine(db);
                inboundRules = rulesEngine.GetCachedInboundRules();
            }

            return(inboundRules);
        }
        private void RunItemDeleted(Item item)
        {
            var rulesEngine = new RulesEngine(item.Database);

            try
            {
                using (new SecurityDisabler())
                {
                    if (item.IsInboundRuleItem() || item.IsSimpleRedirectItem() || item.IsInboundRuleItemChild())
                    {
                        Log.Info(this, item.Database, "Refreshing inbound rules cache after delete event",
                                 item.Paths.FullPath);

                        rulesEngine.GetCachedInboundRules();
                    }
                    else if (item.IsOutboundRuleItem() || item.IsOutboundRuleItemChild())
                    {
                        Log.Info(this, item.Database, "Refreshing outbound rules cache after delete event",
                                 item.Parent.Paths.FullPath);

                        rulesEngine.GetCachedOutboundRules();
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(this, ex, item.Database, "Exception occured which deleting item after publish Item ID: {0} Item Path: {1}", item.ID, item.Paths.FullPath);
            }
        }
Ejemplo n.º 3
0
        public void Process(PipelineArgs args)
        {
            Log.Info(this, "Initializing URL Rewrite.");

            try
            {
                using (new SecurityDisabler())
                {

                    // cache all of the rules

                    foreach (var db in Factory.GetDatabases().Where(e => e.HasContentItem))
                    {
                        var rulesEngine = new RulesEngine(db);
                        rulesEngine.GetCachedInboundRules();
                    }

                    // make sure that the page event has been deployed
                    DeployEventIfNecessary();
                }
            }
            catch (Exception ex)
            {
                Hi.UrlRewrite.Log.Error(this, ex, "Exception during initialization.");
            }
        }
Ejemplo n.º 4
0
        public void Process(PipelineArgs args)
        {
            Log.Info(this, "Initializing URL Rewrite.");

            try
            {
                using (new SecurityDisabler())
                {
                    // cache all of the rules

                    foreach (var db in Factory.GetDatabases().Where(e => e.HasContentItem))
                    {
                        Log.Info(this, "db = {0}", db.Name);
                        var rulesEngine = new RulesEngine(db);
                        rulesEngine.GetCachedInboundRules();
                    }

                    // make sure that the page event has been deployed
                    //DeployEventIfNecessary();
                }
            }
            catch (Exception ex)
            {
                Log.Error(this, ex, "Exception during initialization.");
            }
        }
        public void Process(PipelineArgs args)
        {
            Log.Info(this, "Initializing URL Rewrite.");

            using (new SecurityDisabler())
            {
                foreach (var db in Factory.GetDatabases().Where(e => e.HasContentItem))
                {
                    var rulesEngine = new RulesEngine(db);
                    rulesEngine.GetCachedInboundRules();
                }
            }
        }
Ejemplo n.º 6
0
        private List <InboundRule> GetInboundRules(Database db)
        {
            var cache        = RulesCacheManager.GetCache(db);
            var inboundRules = cache.GetInboundRules();

            if (inboundRules != null)
            {
                return(inboundRules);
            }

            Log.Info(this, db, "Initializing Inbound Rules.");

            using (new SecurityDisabler())
            {
                var rulesEngine = new RulesEngine(db);
                inboundRules = rulesEngine.GetCachedInboundRules();
            }

            return(inboundRules);
        }
        private void RunItemSaved(Item item, ItemChanges itemChanges)
        {
            var db          = item.Database;
            var rulesEngine = new RulesEngine(db);

            try
            {
                using (new SecurityDisabler())
                {
                    var redirectFolderItem = item.Axes.GetAncestors()
                                             .FirstOrDefault(a => a.TemplateID.Equals(new ID(RedirectFolderItem.TemplateId)));

                    if (redirectFolderItem == null)
                    {
                        return;
                    }

                    if (item.IsRedirectFolderItem())
                    {
                        Log.Info(this, db, "Refreshing Redirect Folder [{0}] after save event", item.Paths.FullPath);

                        rulesEngine.GetCachedInboundRules();
                    }
                    else if (item.IsOutboundRuleItem())
                    {
                        Log.Info(this, db, "Refreshing Outbound Rule [{0}] after save event", item.Paths.FullPath);

                        rulesEngine.RefreshRule(item, redirectFolderItem);
                    }
                    else if (item.IsSimpleRedirectItem())
                    {
                        Log.Info(this, db, "Refreshing Simple Redirect [{0}] after save event", item.Paths.FullPath);

                        rulesEngine.RefreshRule(item, redirectFolderItem);
                    }
                    else if (item.IsInboundRuleItem())
                    {
                        Log.Info(this, db, "Refreshing Inbound Rule [{0}] after save event", item.Paths.FullPath);

                        rulesEngine.RefreshRule(item, redirectFolderItem);
                    }
                    else if (item.IsRedirectType() && item.IsInboundRuleItemChild() && db.Name.Equals("web", StringComparison.CurrentCultureIgnoreCase))
                    {
                        var inboundRuleItem = item.Parent;
                        var inboundRule     = new InboundRuleItem(inboundRuleItem);

                        inboundRule.BeginEdit();
                        inboundRule.Action.InnerField.SetValue(item.ID.ToString(), false);
                        inboundRule.EndEdit();
                    }
                    else if (item.IsInboundRuleItemChild())
                    {
                        Log.Info(this, db, "Refreshing Inbound Rule [{0}] after save event", item.Parent.Paths.FullPath);

                        rulesEngine.RefreshRule(item.Parent, redirectFolderItem);
                    }
                    else if (item.IsOutboundRuleItemChild())
                    {
                        Log.Info(this, db, "Refreshing Outbound Rule [{0}] after save event", item.Parent.Paths.FullPath);

                        rulesEngine.RefreshRule(item.Parent, redirectFolderItem);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(this, ex, db, "Exception occured when saving item after save - Item ID: {0} Item Path: {1}", item.ID, item.Paths.FullPath);
            }
        }
        private List<InboundRule> GetInboundRules(Database db)
        {
            var cache = RulesCacheManager.GetCache(db);
            var inboundRules = cache.GetInboundRules();

            if (inboundRules != null) return inboundRules;

            Log.Info(this, db, "Initializing Inbound Rules.");

            using (new SecurityDisabler())
            {
                var rulesEngine = new RulesEngine(db);
                var setup = new Setup();
                setup.InstallItems();
                inboundRules = rulesEngine.GetCachedInboundRules();
            }

            return inboundRules;
        }
        private void RunItemSaved(Item item, ItemChanges itemChanges)
        {
            var db = item.Database;
            var rulesEngine = new RulesEngine(db);

            try
            {
                using (new SecurityDisabler())
                {
                    var redirectFolderItem = item.Axes.GetAncestors()
                        .FirstOrDefault(a => a.TemplateID.Equals(new ID(RedirectFolderItem.TemplateId)));

                    if (redirectFolderItem == null) return;

                    if (item.IsRedirectFolderItem())
                    {
                        Log.Info(this, db, "Refreshing Redirect Folder [{0}] after save event", item.Paths.FullPath);

                        rulesEngine.GetCachedInboundRules();
                    }
                    else if (item.IsOutboundRuleItem())
                    {
                        Log.Info(this, db, "Refreshing Outbound Rule [{0}] after save event", item.Paths.FullPath);

                        rulesEngine.RefreshRule(item, redirectFolderItem);
                    }
                    else if (item.IsSimpleRedirectItem())
                    {
                        Log.Info(this, db, "Refreshing Simple Redirect [{0}] after save event", item.Paths.FullPath);

                        rulesEngine.RefreshRule(item, redirectFolderItem);
                    }
                    else if (item.IsInboundRuleItem())
                    {
                        Log.Info(this, db, "Refreshing Inbound Rule [{0}] after save event", item.Paths.FullPath);

                        rulesEngine.RefreshRule(item, redirectFolderItem);
                    }
                    else if (item.IsRedirectType() && item.IsInboundRuleItemChild() && db.Name.Equals("master", StringComparison.CurrentCultureIgnoreCase))
                    {
                        var inboundRuleItem = item.Parent;
                        var inboundRule = new InboundRuleItem(inboundRuleItem);

                        inboundRule.BeginEdit();
                        inboundRule.Action.InnerField.SetValue(item.ID.ToString(), false);
                        inboundRule.EndEdit();
                    }
                    else if (item.IsInboundRuleItemChild())
                    {
                        Log.Info(this, db, "Refreshing Inbound Rule [{0}] after save event", item.Parent.Paths.FullPath);

                        rulesEngine.RefreshRule(item.Parent, redirectFolderItem);
                    }
                    else if (item.IsOutboundRuleItemChild())
                    {
                        Log.Info(this, db, "Refreshing Outbound Rule [{0}] after save event", item.Parent.Paths.FullPath);

                        rulesEngine.RefreshRule(item.Parent, redirectFolderItem);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(this, ex, db, "Exception occured when saving item after save - Item ID: {0} Item Path: {1}", item.ID, item.Paths.FullPath);
            }

        }
        private void RunItemDeleted(Item item)
        {

            var rulesEngine = new RulesEngine(item.Database);

            try
            {

                using (new SecurityDisabler())
                {

                    if (item.IsInboundRuleItem() || item.IsSimpleRedirectItem() || item.IsInboundRuleItemChild())
                    {
                        Log.Info(this, item.Database, "Refreshing inbound rules cache after delete event",
                            item.Paths.FullPath);

                        rulesEngine.GetCachedInboundRules();
                    }
                    else if (item.IsOutboundRuleItem() || item.IsOutboundRuleItemChild())
                    {
                        Log.Info(this, item.Database, "Refreshing outbound rules cache after delete event",
                            item.Parent.Paths.FullPath);

                        rulesEngine.GetCachedOutboundRules();
                    }

                }
            }
            catch (Exception ex)
            {
                Log.Error(this, ex, item.Database, "Exception occured which deleting item after publish Item ID: {0} Item Path: {1}", item.ID, item.Paths.FullPath);
            }
        }
Ejemplo n.º 11
0
        private List<InboundRule> GetInboundRules(Database db)
        {
            Log.Info(this, db, "Start GetInboundRules.");
            var cache = RulesCacheManager.GetCache(db);
            var inboundRules = cache.GetInboundRules();
            Log.Info(this, db, "Stop GetInboundRules.");
            if (inboundRules != null)
            {
                Log.Info(this, db, "inboundRules!=null");
                Log.Info(this, db, "inboundRules.Any()=={0}", inboundRules.Any());
                if (inboundRules.Any())
                {
                    Log.Info(this, db, "inboundRules.Count()=={0}", inboundRules.Count);
                }
                return inboundRules;
            }
            else
            {
                Log.Info(this, db, "inboundRules==null");
            }

            Log.Info(this, db, "Initializing Inbound Rules.");

            using (new SecurityDisabler())
            {
                var rulesEngine = new RulesEngine(db);
                inboundRules = rulesEngine.GetCachedInboundRules();
            }

            return inboundRules;
        }