Esempio n. 1
0
        public bool InsertAndUpdateCache(Model.Navigation model)
        {
            model.NavType = Com.EnumHelper.NavigationEnum.System.ToString();
            var id       = Insert(model);
            var newmodel = QueryToEnetity(p => p.Id == id);

            if (newmodel.ParentId > 0)
            {
                var modelP = QueryToEnetity(p => p.Id == model.ParentId);
                newmodel.ClassList  = modelP.ClassList + newmodel.Id + ",";
                newmodel.ClassLayer = modelP.ClassLayer + 1;
            }
            else
            {
                newmodel.ClassLayer = 1;
                newmodel.ClassList  = "," + newmodel.Id + ",";
            }

            var outid   = (Update(newmodel) > 0);
            var oldData = QueryToAllList().OrderBy(p => p.SortId).ToList();
            var newData = new List <Model.Navigation>();

            GList(oldData, newData, 0);
            CacheHelper.Set(KeyWordsHelper.CacheFindNavSortList, newData, 1440);
            CacheHelper.Set(KeyWordsHelper.CacheFindNavNoSortList, oldData, 1440);
            return(outid);
        }
Esempio n. 2
0
        public bool UpdateParentAndChilds(Model.Navigation model)
        {
            var oldmodel = QueryToEnetity(p => p.Id == model.Id);

            if (oldmodel == null)
            {
                return(false);
            }
            int oldParentId = oldmodel.ParentId;

            oldmodel.ParentId   = model.ParentId;
            oldmodel.Name       = model.Name;
            oldmodel.Title      = model.Title;
            oldmodel.SubTitle   = model.SubTitle;
            oldmodel.LinkUrl    = model.LinkUrl;
            oldmodel.SortId     = model.SortId;
            oldmodel.IsLock     = model.IsLock;
            oldmodel.Remark     = model.Remark;
            oldmodel.ActionType = model.ActionType;
            oldmodel.IconUrl    = model.IconUrl;
            //var bl = Update(oldmodel);
            if (model.ParentId > 0 && oldParentId != model.ParentId)
            {
                var modelP = QueryToEnetity(p => p.Id == model.ParentId);
                oldmodel.ClassList  = modelP.ClassList + oldmodel.Id + ",";
                oldmodel.ClassLayer = modelP.ClassLayer + 1;
            }
            if (model.ParentId == 0 && oldParentId != model.ParentId)
            {
                oldmodel.ClassLayer = 1;
                oldmodel.ClassList  = "," + model.Id + ",";
            }
            var bl = (Update(oldmodel) > 0);

            if (oldParentId != model.ParentId)
            {
                UpdateChilds(oldmodel.Id);
            }
            if (bl)
            {
                var oldData = QueryToAllList().OrderBy(p => p.SortId).ToList();
                var newData = new List <Model.Navigation>();
                GList(oldData, newData, 0);
                CacheHelper.Set(KeyWordsHelper.CacheFindNavSortList, newData, 1440);
                CacheHelper.Set(KeyWordsHelper.CacheFindNavNoSortList, newData, 1440);
            }

            return(bl);
        }
Esempio n. 3
0
        public override ProvisioningTemplate ExtractObjects(Web web, ProvisioningTemplate template, ProvisioningTemplateCreationInformation creationInfo)
        {
            using (var scope = new PnPMonitoredScope(this.Name))
            {
                GlobalNavigationType  globalNavigationType;
                CurrentNavigationType currentNavigationType;

                if (!WebSupportsExtractNavigation(web))
                {
                    scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_Navigation_Context_web_is_not_publishing);
                    return(template);
                }

                // Retrieve the current web navigation settings
                var navigationSettings = new WebNavigationSettings(web.Context, web);
                navigationSettings.EnsureProperties(ns => ns.AddNewPagesToNavigation, ns => ns.CreateFriendlyUrlsForNewPages,
                                                    ns => ns.CurrentNavigation, ns => ns.GlobalNavigation);

                switch (navigationSettings.GlobalNavigation.Source)
                {
                case StandardNavigationSource.InheritFromParentWeb:
                    // Global Navigation is Inherited
                    globalNavigationType = GlobalNavigationType.Inherit;
                    break;

                case StandardNavigationSource.TaxonomyProvider:
                    // Global Navigation is Managed
                    globalNavigationType = GlobalNavigationType.Managed;
                    break;

                case StandardNavigationSource.PortalProvider:
                default:
                    // Global Navigation is Structural
                    globalNavigationType = GlobalNavigationType.Structural;
                    break;
                }

                switch (navigationSettings.CurrentNavigation.Source)
                {
                case StandardNavigationSource.InheritFromParentWeb:
                    // Current Navigation is Inherited
                    currentNavigationType = CurrentNavigationType.Inherit;
                    break;

                case StandardNavigationSource.TaxonomyProvider:
                    // Current Navigation is Managed
                    currentNavigationType = CurrentNavigationType.Managed;
                    break;

                case StandardNavigationSource.PortalProvider:
                default:
                    // Current Navigation is Structural
                    if (AreSiblingsEnabledForCurrentStructuralNavigation(web))
                    {
                        currentNavigationType = CurrentNavigationType.Structural;
                    }
                    else
                    {
                        currentNavigationType = CurrentNavigationType.StructuralLocal;
                    }
                    break;
                }

                var navigationEntity = new Model.Navigation(new GlobalNavigation(globalNavigationType,
                                                                                 globalNavigationType == GlobalNavigationType.Structural ? GetGlobalStructuralNavigation(web, navigationSettings) : null,
                                                                                 globalNavigationType == GlobalNavigationType.Managed ? GetGlobalManagedNavigation(web, navigationSettings) : null),
                                                            new CurrentNavigation(currentNavigationType,
                                                                                  currentNavigationType == CurrentNavigationType.Structural | currentNavigationType == CurrentNavigationType.StructuralLocal ? GetCurrentStructuralNavigation(web, navigationSettings) : null,
                                                                                  currentNavigationType == CurrentNavigationType.Managed ? GetCurrentManagedNavigation(web, navigationSettings) : null)
                                                            );

                navigationEntity.AddNewPagesToNavigation       = navigationSettings.AddNewPagesToNavigation;
                navigationEntity.CreateFriendlyUrlsForNewPages = navigationSettings.CreateFriendlyUrlsForNewPages;

                // If a base template is specified then use that one to "cleanup" the generated template model
                if (creationInfo.BaseTemplate != null)
                {
                    if (!navigationEntity.Equals(creationInfo.BaseTemplate.Navigation))
                    {
                        template.Navigation = navigationEntity;
                    }
                }
                else
                {
                    template.Navigation = navigationEntity;
                }
            }

            return(template);
        }