Exemple #1
0
        private IQueryable <MenuDAO> OrFilter(IQueryable <MenuDAO> query, MenuFilter filter)
        {
            if (filter.OrFilter == null || filter.OrFilter.Count == 0)
            {
                return(query);
            }
            IQueryable <MenuDAO> initQuery = query.Where(q => false);

            foreach (MenuFilter MenuFilter in filter.OrFilter)
            {
                IQueryable <MenuDAO> queryable = query;
                if (MenuFilter.Id != null)
                {
                    queryable = queryable.Where(q => q.Id, MenuFilter.Id);
                }
                if (MenuFilter.Code != null)
                {
                    queryable = queryable.Where(q => q.Code, MenuFilter.Code);
                }
                if (MenuFilter.Name != null)
                {
                    queryable = queryable.Where(q => q.Name, MenuFilter.Name);
                }
                if (MenuFilter.Path != null)
                {
                    queryable = queryable.Where(q => q.Path, MenuFilter.Path);
                }
                initQuery = initQuery.Union(queryable);
            }
            return(initQuery);
        }
Exemple #2
0
        public async Task <int> Count(MenuFilter filter)
        {
            IQueryable <MenuDAO> Menus = DataContext.Menu;

            Menus = DynamicFilter(Menus, filter);
            return(await Menus.CountAsync());
        }
Exemple #3
0
 private IQueryable <MenuDAO> DynamicFilter(IQueryable <MenuDAO> query, MenuFilter filter)
 {
     if (filter == null)
     {
         return(query.Where(q => false));
     }
     if (filter.Id != null)
     {
         query = query.Where(q => q.Id, filter.Id);
     }
     if (filter.Code != null)
     {
         query = query.Where(q => q.Code, filter.Code);
     }
     if (filter.Name != null)
     {
         query = query.Where(q => q.Name, filter.Name);
     }
     if (filter.Path != null)
     {
         query = query.Where(q => q.Path, filter.Path);
     }
     query = OrFilter(query, filter);
     return(query);
 }
Exemple #4
0
        public async Task <List <MenuDto> > GetMenusByUserRoles(MenuFilter menuFilter)
        {
            var menuOrigins = await _unitOfWork.MenuRepository.FindAll().AsNoTracking().ToListAsync();

            var menuFilters = menuOrigins.Where(r => !r.Parent.HasValue).OrderBy(r => r.OrderNumber).ToList();

            return(GetMenuByParent(menuOrigins, menuFilters));
        }
Exemple #5
0
        public async Task <IActionResult> GetMenus()
        {
            var result      = new ApiJsonResult();
            var menuFileter = new MenuFilter();

            result.Data = await _menuService.GetMenusByUserRoles(menuFileter);

            return(Ok(result));
        }
Exemple #6
0
        private IQueryable <MenuDAO> DynamicOrder(IQueryable <MenuDAO> query, MenuFilter filter)
        {
            switch (filter.OrderType)
            {
            case OrderType.ASC:
                switch (filter.OrderBy)
                {
                case MenuOrder.Id:
                    query = query.OrderBy(q => q.Id);
                    break;

                case MenuOrder.Code:
                    query = query.OrderBy(q => q.Code);
                    break;

                case MenuOrder.Name:
                    query = query.OrderBy(q => q.Name);
                    break;

                case MenuOrder.Path:
                    query = query.OrderBy(q => q.Path);
                    break;

                case MenuOrder.IsDeleted:
                    query = query.OrderBy(q => q.IsDeleted);
                    break;
                }
                break;

            case OrderType.DESC:
                switch (filter.OrderBy)
                {
                case MenuOrder.Id:
                    query = query.OrderByDescending(q => q.Id);
                    break;

                case MenuOrder.Code:
                    query = query.OrderByDescending(q => q.Code);
                    break;

                case MenuOrder.Name:
                    query = query.OrderByDescending(q => q.Name);
                    break;

                case MenuOrder.Path:
                    query = query.OrderByDescending(q => q.Path);
                    break;

                case MenuOrder.IsDeleted:
                    query = query.OrderByDescending(q => q.IsDeleted);
                    break;
                }
                break;
            }
            query = query.Skip(filter.Skip).Take(filter.Take);
            return(query);
        }
Exemple #7
0
        public MenuFilterSuppression(INavigationManager navigationManager,
                                     IWorkContextAccessor workContextAccessor,
                                     IShapeFactory shapeFactory)
        {
            _navigationManager   = navigationManager;
            _workContextAccessor = workContextAccessor;
            _shapeFactory        = shapeFactory;

            _menuFilter = new MenuFilter(_navigationManager, _workContextAccessor, _shapeFactory);
        }
Exemple #8
0
 public int Count(MenuFilter filter)
 {
     return(AmigooDbContext
            .Menus
            .Count(m =>
                   m.Name.Contains(filter.MenuName) &&
                   m.CategoryId == filter.CategoryId &&
                   m.Availability == filter.Availability &&
                   m.Flag == filter.Flag));
 }
Exemple #9
0
        /// <summary>
        /// Utilizado para buscar os menus, tanto no Bootstra-Table quando para o Select2.
        /// </summary>
        /// <param name="filter">Filtro de parâmetros</param>
        /// <returns>Json com a lista dos objetos encontrados</returns>
        public async Task <ActionResult> Search(MenuFilter filter)
        {
            var query = new StringBuilder();

            query.Append($@"
                    WITH menus (MenuId, MenuRootId, [Name], [Level], [Order], Controller, [Action], Icon, Css) AS 
                        (
                            SELECT m.MenuId, m.MenuRootId, cast(m.[Name] as varchar(max)), 1, cast(m.[Order] as varchar(50)) as OrderS, m.Controller, m.Action, m.Icon, m.Css
	                        FROM Menu m
                            WHERE m.MenuRootId IS NULL
                            UNION ALL 
                            SELECT m.MenuId, m.MenuRootId, m2.[Name] +'/'+ m.[Name] as [Name], m2.[Level]+1, cast(cast(m2.[Order] AS varchar(10)) + '.' + cast(m.[Order] AS varchar(10)) as varchar(50)) as OrdemS, m.Controller, m.Action, m.Icon, m.Css
                            FROM Menu m 
                            INNER JOIN menus m2 ON m.MenuRootId = m2.MenuId
                        )");
            query.AppendLine(
                $@"SELECT MenuId as Id, MenuRootId as RootId, [Name], [Level], [Order] AS OrdemS, m.Controller, [Action], m.Icon, m.Css, COUNT(*) OVER() as Total FROM menus m WHERE 1 = 1 ");

            if (!string.IsNullOrEmpty(filter.Name))
            {
                query.AppendLine($@"AND m.Name LIKE '%{string.Join("%", filter.Name.Split())}%' ");
            }

            if (filter.Id != null && filter.Id != 0)
            {
                query.AppendLine($@"AND m.MenuId = {filter.Id.Value} ");
            }

            if (filter.PageSize <= 0)
            {
                filter.PageSize = 15;
            }

            if (filter.Page <= 1)
            {
                filter.Page = 0;
            }
            else
            {
                filter.Page = (filter.Page - 1) * filter.PageSize;
            }

            query.AppendLine($"ORDER BY {filter.OrderBy ?? "Name"} {filter.Sort ?? "ASC"} ");
            query.AppendLine($"OFFSET {filter.Page} ROWS FETCH NEXT {filter.PageSize} ROWS ONLY");

            using (var cn = new SqlConnection(ConnectionStrings))
            {
                var list = await cn.QueryAsync <MenuViewModel>(query.ToString());

                var menuViewModels = list as MenuViewModel[] ?? list.ToArray();
                return(Json(new { Result = menuViewModels, Total = menuViewModels.FirstOrDefault()?.Total ?? 0 },
                            JsonRequestBehavior.AllowGet));
            }
        }
Exemple #10
0
        public FileResult Export(MenuFilter filter)
        {
            var response = _menuService.Filter(filter);

            var csv = new CsvExport();

            csv.ConcatRow(0, "TIPO,DÍA,FECHA INICIO,FECHA FIN,PLATILLO,CONCESIONARIO,COMENTARIO,ESTADO");
            csv.ConcatRows(0, "MealTypeLabel,DayWeekLabel,StartDate,EndDate,Saucer,Dealer,Comment,Status", response.Menus);

            var stream = csv.RetrieveFile();

            return(new StreamFactory().Csv(stream, "Menús"));
        }
Exemple #11
0
        private async Task <List <Menu> > DynamicSelect(IQueryable <MenuDAO> query, MenuFilter filter)
        {
            List <Menu> Menus = await query.Select(q => new Menu()
            {
                Id        = filter.Selects.Contains(MenuSelect.Id) ? q.Id : default(long),
                Code      = filter.Selects.Contains(MenuSelect.Code) ? q.Code : default(string),
                Name      = filter.Selects.Contains(MenuSelect.Name) ? q.Name : default(string),
                Path      = filter.Selects.Contains(MenuSelect.Path) ? q.Path : default(string),
                IsDeleted = filter.Selects.Contains(MenuSelect.IsDeleted) ? q.IsDeleted : default(bool),
            }).ToListAsync();

            return(Menus);
        }
Exemple #12
0
        public async Task <List <Menu> > List(MenuFilter filter)
        {
            if (filter == null)
            {
                return(new List <Menu>());
            }
            IQueryable <MenuDAO> MenuDAOs = DataContext.Menu.AsNoTracking();

            MenuDAOs = DynamicFilter(MenuDAOs, filter);
            MenuDAOs = DynamicOrder(MenuDAOs, filter);
            List <Menu> Menus = await DynamicSelect(MenuDAOs, filter);

            return(Menus);
        }
Exemple #13
0
        private void InitializeProperties()
        {
            _filter = new MenuFilter()
            {
                MenuName     = string.Empty,
                CategoryId   = 10,
                MenuOrder    = new MenuOrderByAscending(),
                Availability = true,
                Flag         = true
            };

            FillMenuFilters();
            FillMenus(true);
        }
Exemple #14
0
        public IEnumerable <Menu> GetMenusByFilter(MenuFilter filter)
        {
            var menus = AmigooDbContext
                        .Menus
                        .Include(m => m.MenuCategory)
                        .Where(m =>
                               m.Name.Contains(filter.MenuName) &&
                               m.CategoryId == filter.CategoryId &&
                               m.Availability == filter.Availability &&
                               m.Flag == filter.Flag)
                        .OrderBy(m => m.Id)
                        .Skip(filter.Skip)
                        .Take(filter.Take)
                        .ToList();

            return(filter.MenuOrder.SetMenuOrder(menus));
        }
Exemple #15
0
        public List <Menu> Get(MenuFilter objFilter)
        {
            MenuDAL objDAL = null;

            try
            {
                objDAL = new MenuDAL();
                //SetAttendenceFilter(objFilter);
                return(objDAL.Get(objFilter));
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                objDAL = null;
            }
        }
        internal MenuEntryAttribute(string path, int priority, MenuFilter filter)
        {
            this.filter   = filter;
            path          = path ?? string.Empty;
            path          = L10n.Tr(path);
            this.priority = priority;

            var index = path.LastIndexOf('/');

            if (index >= 0)
            {
                name        = (index == path.Length - 1) ? string.Empty : path.Substring(index + 1);
                subMenuPath = path.Substring(0, index + 1);
            }
            else
            {
                name        = path;
                subMenuPath = string.Empty;
            }
        }
        private void btnAddWeapon_Click(object sender, EventArgs e)
        {
            ItemSelectionChoice = ItemSelectionChoices.AddWeapon;
            IEnumerable <ItemContainer> Items = GetItemsByRoot(GUIRootPathTripleThunderWeapons);
            MenuFilter OutMenu = new MenuFilter();

            OutMenu.ListItem = new Dictionary <string, string>();

            foreach (ItemContainer ActiveItemContainer in Items)
            {
                foreach (KeyValuePair <string, string> ActiveItem in ActiveItemContainer.ListItem)
                {
                    string Name = FilePath.Substring(29);
                    Name = Name.Substring(0, Name.Length - 4);

                    if (ActiveItem.Key.StartsWith(Name))
                    {
                        if (ActiveItem.Key.StartsWith(Name + "/Weapons"))
                        {
                            string WeaponName = ActiveItem.Key.Substring(24);
                            OutMenu.ListItem.Add(WeaponName, WeaponName);
                        }
                        else if (ActiveItem.Key.StartsWith(Name + "/Grenades"))
                        {
                            string WeaponName = ActiveItem.Key.Substring(25);
                            OutMenu.ListItem.Add(WeaponName, WeaponName);
                        }
                    }
                }
            }

            ItemSelector ItemSelectorMenu = new ItemSelector(OutMenu, true);

            ItemSelectorMenu.TopMost = true;
            ItemSelectorMenu.ShowDialog();
            //Item selected, call the ItemsSelected method.
            if (ItemSelectorMenu.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                ListMenuItemsSelected(ItemSelectorMenu.GetResult());
            }
        }
        public async Task <List <Role_MenuDTO> > SingleListMenu([FromBody] Role_MenuFilterDTO Role_MenuFilterDTO)
        {
            MenuFilter MenuFilter = new MenuFilter();

            MenuFilter.Skip      = 0;
            MenuFilter.Take      = 20;
            MenuFilter.OrderBy   = MenuOrder.Id;
            MenuFilter.OrderType = OrderType.ASC;
            MenuFilter.Selects   = MenuSelect.ALL;
            MenuFilter.Id        = Role_MenuFilterDTO.Id;
            MenuFilter.Code      = Role_MenuFilterDTO.Code;
            MenuFilter.Name      = Role_MenuFilterDTO.Name;
            MenuFilter.Path      = Role_MenuFilterDTO.Path;

            List <Menu> Menus = await MenuService.List(MenuFilter);

            List <Role_MenuDTO> Role_MenuDTOs = Menus
                                                .Select(x => new Role_MenuDTO(x)).ToList();

            return(Role_MenuDTOs);
        }
Exemple #19
0
 public MenuFilter ToFilter(MenuFilter filter)
 {
     if (filter.OrFilter == null)
     {
         filter.OrFilter = new List <MenuFilter>();
     }
     if (CurrentContext.Filters == null || CurrentContext.Filters.Count == 0)
     {
         return(filter);
     }
     foreach (var currentFilter in CurrentContext.Filters)
     {
         MenuFilter subFilter = new MenuFilter();
         filter.OrFilter.Add(subFilter);
         List <FilterPermissionDefinition> FilterPermissionDefinitions = currentFilter.Value;
         foreach (FilterPermissionDefinition FilterPermissionDefinition in FilterPermissionDefinitions)
         {
         }
     }
     return(filter);
 }
Exemple #20
0
        public async Task <bool> ValidateMenu(Menu Menu)
        {
            MenuFilter MenuFilter = new MenuFilter
            {
                Skip = 0,
                Take = 10,
                Code = new StringFilter {
                    Equal = Menu.Code
                },
                Selects = MenuSelect.Code
            };

            var MenuInDB = (await UOW.MenuRepository.List(MenuFilter)).FirstOrDefault();

            if (MenuInDB == null)
            {
                Menu.AddError(nameof(RoleValidator), nameof(Menu.Code), ErrorCode.CodeNotExisted);
            }
            else
            {
                foreach (var Field in Menu.Fields)
                {
                    if (!MenuInDB.Fields.Select(f => f.Name).Contains(Field.Name))
                    {
                        Field.AddError(nameof(RoleValidator), nameof(Field.Name), ErrorCode.FieldNotExisted);
                        return(false);
                    }
                }

                //foreach (var Page in Menu.Actions)
                //{
                //    if (!MenuInDB.Actions.Select(p => p.Path).Contains(Page.Path))
                //    {
                //        Page.AddError(nameof(RoleValidator), nameof(Page.Path), ErrorCode.PageNotExisted);
                //        return false;
                //    }
                //}
            }
            return(Menu.IsValidated);
        }
Exemple #21
0
        public IActionResult Index(MenuFilter filter = null)
        {
            try
            {
                var menu_type = _menuRepo.getQueryable();
                if (!string.IsNullOrWhiteSpace(filter.title))
                {
                    menu_type = menu_type.Where(a => a.name.Contains(filter.title));
                }
                ViewBag.pagerInfo = _paginatedMetaService.GetMetaData(menu_type.Count(), filter.page, filter.number_of_rows);
                menu_type         = menu_type.Skip(filter.number_of_rows * (filter.page - 1)).Take(filter.number_of_rows);
                var menuDetails = menu_type.ToList();

                var menuIndexVM = getViewModelFrom(menuDetails);
                return(View(menuIndexVM));
            }
            catch (Exception ex)
            {
                AlertHelper.setMessage(this, ex.Message, messageType.error);
                return(Redirect("/admin"));
            }
        }
Exemple #22
0
        public async Task <List <Menu> > List(MenuFilter MenuFilter)
        {
            try
            {
                List <Menu> Menus = await UOW.MenuRepository.List(MenuFilter);

                return(Menus);
            }
            catch (Exception ex)
            {
                if (ex.InnerException == null)
                {
                    await Logging.CreateSystemLog(ex, nameof(MenuService));

                    throw new MessageException(ex);
                }
                else
                {
                    await Logging.CreateSystemLog(ex.InnerException, nameof(MenuService));

                    throw new MessageException(ex.InnerException);
                };
            }
        }
Exemple #23
0
        public async Task <int> Count(MenuFilter MenuFilter)
        {
            try
            {
                int result = await UOW.MenuRepository.Count(MenuFilter);

                return(result);
            }
            catch (Exception ex)
            {
                if (ex.InnerException == null)
                {
                    await Logging.CreateSystemLog(ex, nameof(MenuService));

                    throw new MessageException(ex);
                }
                else
                {
                    await Logging.CreateSystemLog(ex.InnerException, nameof(MenuService));

                    throw new MessageException(ex.InnerException);
                };
            }
        }
 static void BuildMenu(MarkerAction action, IEnumerable <IMarker> markers, List <MenuActionItem> menuItems, MenuFilter filter)
 {
     BuildMenu(action, action.Validate(markers), () => ExecuteMarkerAction(action, markers), menuItems, filter);
 }
        static void BuildMenu(IAction action, ActionValidity validity, GenericMenu.MenuFunction executeFunction, List <MenuActionItem> menuItems, MenuFilter filter, bool isChecked = false)
        {
            var menuAttribute = action.GetType().GetCustomAttribute <MenuEntryAttribute>(false);

            if (menuAttribute == null || filter.ShouldFilterOut(menuAttribute))
            {
                return;
            }

            if (validity == ActionValidity.NotApplicable)
            {
                return;
            }

            var menuActionItem = new MenuActionItem
            {
                state          = validity,
                entryName      = action.GetMenuEntryName(),
                priority       = menuAttribute.priority,
                category       = menuAttribute.subMenuPath,
                isActiveInMode = action.IsActionActiveInMode(TimelineWindow.instance.currentMode.mode),
                shortCut       = action.GetShortcut(),
                callback       = executeFunction,
                isChecked      = action.IsChecked()
            };

            menuItems.Add(menuActionItem);
        }
 public static bool ShouldFilterOut(this MenuFilter filter, MenuEntryAttribute attr)
 {
     return((filter & attr.filter) != filter);
 }
        public static void GetMenuEntries(IReadOnlyList <TimelineAction> actions, Vector2?mousePos, List <MenuActionItem> menuItems, MenuFilter filter = MenuFilter.Default)
        {
            var globalContext = TimelineEditor.CurrentContext(mousePos);

            foreach (var action in actions)
            {
                try
                {
                    BuildMenu(action, globalContext, menuItems, filter);
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
            }
        }
        public static void GetMenuEntries(IReadOnlyList <ClipAction> actions, List <MenuActionItem> menuItems, MenuFilter filter = MenuFilter.Item)
        {
            var  clips = SelectionManager.SelectedClips();
            bool any   = clips.Any();

            if (!clips.Any())
            {
                return;
            }

            foreach (var action in actions)
            {
                try
                {
                    if (action is EditSubTimeline editSubTimelineAction)
                    {
                        editSubTimelineAction.AddMenuItem(menuItems);
                    }
                    else if (any)
                    {
                        BuildMenu(action, clips, menuItems, filter);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
            }
        }
        public static void GetMenuEntries(IReadOnlyList <MarkerAction> actions, List <MenuActionItem> menuItems, MenuFilter filter = MenuFilter.Item)
        {
            var markers = SelectionManager.SelectedMarkers();

            if (!markers.Any())
            {
                return;
            }

            foreach (var action in actions)
            {
                try
                {
                    BuildMenu(action, markers, menuItems, filter);
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
            }
        }
Exemple #30
0
        public JsonResult Filter(MenuFilter filter)
        {
            var response = _menuService.Filter(filter);

            return(new JsonFactory().Success(response.Menus, response.TotalRecords));
        }