Example #1
0
        NestedLinkCollection IMenuProvider.GetModuleAdminMenuLinks()
        {
            var items = new NestedLinkCollection(
                RelativeToModule("users", "Пользователи", this),
                RelativeToModule("users_add", "Добавить пользователя", this),
                RelativeToModule("customer_modules", "Настройка модулей для ЛК", this),
                RelativeToModule("history", "История", this),
                RelativeToModule("historyUserLog", "История авторизации", this)
                );

            var gr = new NestedLinkGroup(new NestedLinkSimple("Заявки на регистрацию"), RelativeToModule("users/3", "Отклоненные заявки", this));

            items.Add(gr);

            using (var db = new CoreContext())
            {
                var countNewUsers = db.Users.Where(x => x.State == Core.DB.UserState.RegisterWaitForModerate).Count();
                if (countNewUsers > 0)
                {
                    gr.Links.Add(RelativeToModule("users/2", $"Заявки на регистрацию ({countNewUsers})", this));
                }
            }

            items.Add(new NestedLinkGroup("Роли и пользователи",
                                          RelativeToModule("rolesManage", "Настройка ролей", this),
                                          RelativeToModule("rolesDelegate", "Назначение ролей", this)
                                          ));

            return(items);
        }
Example #2
0
        NestedLinkCollection IMenuProvider.GetModuleAdminMenuLinks()
        {
            var moduleAdmin = AppCore.Get <Admin.ModuleAdmin>();

            var modules = AppCore.
                          GetModulesManager().
                          GetModules().
                          OfType <IModuleCore>().
                          OrderBy(x => x.Caption).
                          Select(x => new NestedLinkSimple(x.Caption, new Uri($"/{moduleAdmin.UrlName}/mnadmin/{UrlName}/FieldsList/{x.IdModule}", UriKind.Relative))).
                          ToList();

            var collection = new NestedLinkCollection(new NestedLinkGroup("В модулях", modules.ToArray()));

            return(collection);
        }
Example #3
0
        /// <summary>
        /// См. <see cref="ModuleAdmin.GetAdminMenuList(IUserContext)"/>.
        /// </summary>
        public override Dictionary <IModuleCore, NestedLinkCollection> GetAdminMenuList(IUserContext userContext)
        {
            var modulesList = AppCore.GetModulesManager().GetModules().OfType <IModuleCore>();
            var mods        = new Dictionary <IModuleCore, NestedLinkCollection>();
            var mods_errors = new Dictionary <IModuleCore, string>();

            foreach (var module in modulesList)
            {
                if (module.CheckPermission(userContext, ModulesConstants.PermissionManage) != CheckPermissionVariant.Allowed)
                {
                    mods_errors[module] = "Недостаточно прав";
                }
                else
                {
                    var links = module.GetAdminMenuItems();
                    if (links == null)
                    {
                        links = new NestedLinkCollection();
                    }

                    if (links.Count > 0)
                    {
                        if (module.CheckPermission(userContext, ModulesConstants.PermissionManage) == CheckPermissionVariant.Allowed)
                        {
                            mods[module] = links;
                        }
                        else
                        {
                            mods_errors[module] = "Недостаточно прав";
                        }
                    }
                }
            }

            var model = new Dictionary <IModuleCore, NestedLinkCollection>();

            mods.Where(x => x.Value.Count > 0).OrderBy(x => x.Key.Caption).ForEach(x => model[x.Key] = x.Value);
            mods_errors.OrderBy(x => x.Key.Caption).ForEach(x => model[x.Key].Add(new NestedLinkSimple(x.Value)));

            return(model);
        }
Example #4
0
        public static NestedLinkCollection GetAdminMenuItems(this IModuleCore module)
        {
            var list = new NestedLinkCollection();

            var itemsInternal = (module as AdminForModules.Menu.IMenuProvider)?.GetModuleAdminMenuLinks();

            if (itemsInternal != null)
            {
                list.AddRange(itemsInternal);
            }

            try
            {
                if (module.ControllerAdmin() != null)
                {
                    var moduleAdmin = module.GetAppCore().Get <Admin.ModuleAdmin>();
                    var methods     = module.ControllerAdmin().GetMethods();
                    foreach (var method in methods)
                    {
                        var attr = method.GetCustomAttributes <AdminForModules.Menu.MenuActionAttribute>(true).FirstOrDefault();
                        if (attr != null)
                        {
                            var values = new RouteValueDictionary();
                            values.Add("controller", module.UrlName);
                            values.Add("action", string.IsNullOrEmpty(attr.Alias) ? method.Name : attr.Alias);

                            var link = new NestedLinkSimple(attr.Caption, new Uri($"/{moduleAdmin.UrlName}/mnadmin/{module.UrlName}/{(string.IsNullOrEmpty(attr.Alias) ? method.Name : attr.Alias)}", UriKind.Relative));
                            list.Add(link);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                throw ex;
            }

            return(list);
        }