示例#1
0
        private static void SyncRules(int functionTypeID, List <TypeIdContentAreaId> rules)
        {
            if (CurrentRules == null)
            {
                CurrentRules = RuleContentAreaManager.XMLRuleContentAreaList();
            }

            var add    = rules.Where(r => !CurrentRules.ContainsRule(r.TypeId, r.ContentAreaId, functionTypeID));
            var remove = CurrentRules
                         .SelectMany(r => r.RuleContentAreas, (r, c) => new { typeId = r.ID, contentAreaId = c.ID, functions = c.ListContentFunctionID })
                         .Where(r => r.functions.Any(f => f.ID == functionTypeID))
                         .Where(r => !rules.Any(rr => rr.TypeId == r.typeId && rr.ContentAreaId == r.contentAreaId));

            if (add.Any() || remove.Any())
            {
                CurrentRules.RemoveRuleContentFunction(functionTypeID);

                foreach (var r in rules)
                {
                    CurrentRules.AddRule(r.TypeId, r.ContentAreaId, functionTypeID);
                }

                RuleContentAreaManager.SaveRuleContentAreaCollection(CurrentRules);
                Logger.DebugFormat("UpdateRules for {0}", functionTypeID);
            }
        }
示例#2
0
        private void UpdateRules(FunctionTypeAttribute functionTypeAttribute, PageType functionType)
        {
            int functionTypeID = functionType.ID;

            RuleContentAreaCollection ruleCaCollection = RuleContentAreaManager.XMLRuleContentAreaList();

            ruleCaCollection.RemoveRuleContentFunction(functionTypeID);

            var filteredPageTypes   = _pageTypes;
            var filteredContetTypes = _contentTypes;

            if (functionTypeAttribute.AvailableOnPages == AvailableOn.Specific)
            {
                filteredPageTypes = PageTypeHelper.GetPageTypes(functionTypeAttribute.AvailableOnPageTypes);
            }

            if (functionTypeAttribute.AvailableOnContent == AvailableOn.Specific)
            {
                filteredContetTypes = PageTypeHelper.GetFunctionPageTypes(functionTypeAttribute.AvailableOnContentTypes);
            }

            foreach (var pageType in filteredPageTypes)
            {
                List <ContentAreaData> pageAreas = ContentAreaManager.GetAvailableContentAreasViaProperty(pageType);

                foreach (var pageArea in pageAreas)
                {
                    ruleCaCollection.AddRule(pageType.ID, pageArea.ID, functionTypeID);
                }
            }

            foreach (var contentType in filteredContetTypes)
            {
                if (contentType.ID == functionTypeID)
                {
                    continue;
                }

                List <ContentAreaData> contentAreas = ContentAreaManager.GetAvailableContentAreasViaProperty(contentType.ID);

                foreach (var contentArea in contentAreas)
                {
                    ruleCaCollection.AddRule(contentType.ID, contentArea.ID, functionTypeID);
                }
            }

            RuleContentAreaManager.SaveRuleContentAreaCollection(ruleCaCollection);
        }
示例#3
0
        public static void SetDefaultRulePageType(int pageTypeID)
        {
            RuleContentAreaCollection ruleCaCollection = RuleContentAreaManager.XMLRuleContentAreaList();
            PageType pageType = PageType.Load(pageTypeID);

            if (pageType != null)
            {
                List <ContentAreaData>      availableContentAreasViaProperty = ContentAreaManager.GetAvailableContentAreasViaProperty(pageType);
                IList <ContentFunctionType> list2 = ContentFunctionTypeManager.List();
                foreach (ContentAreaData data in availableContentAreasViaProperty)
                {
                    ruleCaCollection.RemoveRuleContentArea(pageType.ID, data.ID);
                    foreach (ContentFunctionType type2 in list2)
                    {
                        ruleCaCollection.AddRule(pageTypeID, data.ID, type2.FunctionTypeID);
                    }
                }
                RuleContentAreaManager.SaveRuleContentAreaCollection(ruleCaCollection);
            }
        }