Пример #1
0
 public ISettings GetDefault()
 {
     var settings = new WebItemSettings();
     WebItemManager.Instance.GetItemsAll().ForEach(w =>
     {
         var opt = new WebItemOption()
         {
             ItemID = w.ID,
             SortOrder = WebItemManager.GetSortOrder(w),
             Disabled = false,
         };
         settings.SettingsCollection.Add(opt);
     });
     return settings;
 }
Пример #2
0
        public ISettings GetDefault()
        {
            var settings = new WebItemSettings();

            WebItemManager.Instance.GetItemsAll().ForEach(w =>
            {
                var opt = new WebItemOption()
                {
                    ItemID    = w.ID,
                    SortOrder = WebItemManager.GetSortOrder(w),
                    Disabled  = false,
                };
                settings.SettingsCollection.Add(opt);
            });
            return(settings);
        }
Пример #3
0
        public ISettings GetDefault(IServiceProvider serviceProvider)
        {
            var settings       = new WebItemSettings();
            var webItemManager = serviceProvider.GetService <WebItemManager>();

            webItemManager.GetItemsAll().ForEach(w =>
            {
                var opt = new WebItemOption
                {
                    ItemID    = w.ID,
                    SortOrder = webItemManager.GetSortOrder(w),
                    Disabled  = false,
                };
                settings.SettingsCollection.Add(opt);
            });
            return(settings);
        }
Пример #4
0
        public object SaveModules(List<ASC.Web.Core.Utility.Settings.WebItemSettings.WebItemOption> options)
        {
            try
            {
                SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

                var itemSettings = SettingsManager.Instance.LoadSettings<WebItemSettings>(TenantProvider.CurrentTenantID);

                foreach (var itemOption in options)
                {
                    foreach (var webItemOption in itemSettings.SettingsCollection)
                    {
                        if (webItemOption.ItemID == itemOption.ItemID)
                        {
                            webItemOption.Disabled = itemOption.Disabled;
                            continue;
                        }
                    }
                }

                //foreach (var webItemOption in itemSettings.SettingsCollection)
                //{
                //    foreach (var itemOption in options)
                //    {
                //        if (webItemOption.ItemID == itemOption.ItemID)
                //        {
                //            webItemOption.Disabled = itemOption.Disabled;
                //            continue;
                //        }
                //    }
                //}

                var settings = new WebItemSettings();
                foreach (var opt in itemSettings.SettingsCollection.Select((o, i) => { o.SortOrder = i; return o; }))
                    settings.SettingsCollection.Add(opt);
                SettingsManager.Instance.SaveSettings(settings, TenantProvider.CurrentTenantID);

                return new { Status = 1, Message = Resources.Resource.WizardModulesSaved };
            }
            catch (Exception ex)
            {

                return new { Status = 0, Message = ex.Message };
            }
        }
Пример #5
0
 public static List<IWebItem> SortItems(this IEnumerable<IWebItem> items, WebItemSettings settings)
 {
     return items.OrderBy(i => WebItemManager.GetSortOrder(i, settings)).ToList();
 }
Пример #6
0
        public static int GetSortOrder(IWebItem item, WebItemSettings settings)
        {
            if (item == null) return 0;

            if (settings != null && item.IsSubItem())
            {
                var s = settings.SettingsCollection.Find(o => o.ItemID == item.ID);
                if (s != null && s.SortOrder != int.MinValue) return s.SortOrder;
            }

            var index = allowedItems.IndexOf(GetSystemName(item));
            if (index != -1) return index;

            return item.Context != null ? item.Context.DefaultSortOrder : 0;
        }