Ejemplo n.º 1
0
        public Form1()
        {
            ExitMenu exitMenu = new ExitMenu();

            exitMenu.ExitMenuClick += new EventHandler(exitMenu_ExitMenuClick);

            InitializeComponent();

            InitDefaultHost();
            HostSelected hostSelected = CreateHostSelected();
            EditMenu     editMenu     = CreateEditMenu();

            this.contextMenuStrip1.Items.AddRange(
                AppMenu.CreateAppMenu().
                Builder(HostManagerFactory.GetInstance().GetHostList(),
                        hostSelected,
                        Server.GetInstance().ReadCurrentHostKey()).
                Builder("-").
                Builder("编辑", editMenu).
                Builder("退出", exitMenu).ToMenuList().ToArray()
                );

            this.Hide();
            this.WindowState   = FormWindowState.Minimized;
            this.ShowInTaskbar = false;
        }
Ejemplo n.º 2
0
        public virtual JsonResult GetApplicationMenu()
        {
            var appMenu  = new List <dynamic>();
            var cacheKey = string.Empty;

            try
            {
                if (UserClaims != null)
                {
                    //Creates a cacheKey using user login
                    cacheKey = "appMenu" + UserClaims.FirstOrDefault(uc => uc.ClaimType == ClaimTypes.WindowsAccountName).Value;
                    appMenu  = (List <dynamic>)HttpContext.Cache.Get(cacheKey);
                }

                if (appMenu == null || appMenu.Count <= 0)
                {
                    var menu = AppMenu.GetApplicationMenu();
                    appMenu = AppMenu.CastToDynamicMenuList(menu);

                    if (!string.IsNullOrEmpty(cacheKey))
                    {
                        HttpContext.Cache.Add(cacheKey, appMenu, null, DateTime.Now.AddHours(1), Cache.NoSlidingExpiration, CacheItemPriority.Default, null);
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(Json(appMenu, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        public void CreateMap()
        {
            if (string.IsNullOrEmpty(Name.text))
            {
                GenericPopup.ShowPopup(GenericPopup.PopupTypes.OneButton, "Warning", "Name must not be empty!", "OK", null);
                return;
            }

            MapPath = EnvPaths.GetMapsPath();
            string Error = "";

            if (!Directory.Exists(MapPath))
            {
                Error = "Maps folder not exist: " + MapPath;
                Debug.LogError(Error);
                GenericPopup.ShowPopup(GenericPopup.PopupTypes.OneButton, "Warning", "The map folder does not exist:\n" + MapPath, "OK", null);

                return;
            }

            FolderName = AppMenu.ForceVersionControllValue(Name.text, 1);            // Name.text.Replace(" ", "_") + ".v0001";

            string path = MapPath + FolderName;

            Debug.Log(path);
            if (Directory.Exists(path))
            {
                Error = "Map folder already exist: " + path;
                Debug.LogError(Error);
                GenericPopup.ShowPopup(GenericPopup.PopupTypes.OneButton, "Warning", "Map already exist: \n" + path, "OK", null);
                return;
            }

            StartCoroutine(CreateFiles());
        }
        public async Task <IActionResult> Insert(string menu_name, string menu_icon, string menu_url, string menu_type, double menu_sort, int parent_menu_id)
        {
            try
            {
                AppMenu appMenu = new AppMenu()
                {
                    MenuIcon     = menu_icon,
                    MenuName     = menu_name,
                    MenuSort     = menu_sort,
                    MenuType     = menu_type,
                    MenuUrl      = menu_url,
                    ParentMenuId = parent_menu_id
                };
                await context.AppMenus.AddAsync(appMenu);

                await context.SaveChangesAsync();

                logger.LogError(HttpContext.Session.GetString("who") + "新增成功");
                return(Json(new { code = 200, msg = "新增成功" }));
            }
            catch (Exception ex)
            {
                logger.LogError(HttpContext.Session.GetString("who") + "新增菜单出错:" + ex.Message);
                return(Json(new { code = 300, msg = "新增失败,请联系管理员" }));
            }
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            AppMenu menu = new AppMenu();

            while (true)
            {
                menu.writeMenu();
                var userInput = Console.ReadLine();

                switch (userInput.ToLower())
                {
                case "0":
                    return;

                case "1":
                    SetCors();
                    break;

                case "2":
                    MoveAssets();
                    break;

                case "3":
                    DeleteAssets();
                    break;

                case "4":
                    CopyProductTemplateFromProduction();
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 6
0
    private void SetHeader()
    {
        time.Attributes.Add("title", DateTime.Now.ToString(@"HH:mm:ss, G\MT zzz"));
        time.InnerText = DateTime.Now.ToString("HH:mm") + " | ";
        if (AunthUI.Handheld)
        {
            date.InnerText = DateTime.Now.ToShortDateString() + " | ";
        }
        else
        {
            date.InnerText = DateTime.Now.ToLongDateString() + " | ";
        }
        string Name = AunthUI.CurrentUser.AdminUser.Name;

        useredit.HRef      = "/logix/user-edit.aspx?UserID=" + AunthUI.CurrentUser.AdminUser.ID;
        useredit.InnerText = (Name.Length > 20 ? Name.Substring(0, 19) + "..." : Name);
        if (!string.IsNullOrEmpty(Tab_Name))
        {
            IAppMenuService     AppMenuSvc = CurrentRequest.Resolver.Resolve <IAppMenuService>();
            AMSResult <AppMenu> result     = AppMenuSvc.GetApplicationMenus(AunthUI.CurrentUser, Tab_Name, Request.QueryString);
            if (result.ResultType != AMSResultType.Success)
            {
                lblErrorMsg.Text = result.GetLocalizedMessage(AunthUI.LanguageID);
                return;
            }
            AppMenu         appMenu = result.Result;
            AppMenuEventArg e       = new AppMenuEventArg();
            e.AppMenu = appMenu;
            if (OnOverridePageMenu != null)
            {
                OnOverridePageMenu(this, e);
            }
            SetUpMenu(e.AppMenu);
        }
    }
Ejemplo n.º 7
0
    private void SetUpMenu(AppMenu appMenu)
    {
        int counter = 1;

        foreach (CMS.AMS.Models.Menu menu in appMenu.Menus)
        {
            if (menu != null)
            {
                HyperLink hyp = new HyperLink();
                hyp.NavigateUrl = menu.NavigateURL;
                hyp.CssClass    = menu.Highlighet? "on": "";
                if (counter < 10)
                {
                    hyp.Attributes["accesskey"] = counter.ToString();
                    counter++;
                }
                hyp.ID                  = "tab" + (menu.AppMenuID).ToString();
                hyp.ClientIDMode        = ClientIDMode.Static;
                hyp.Attributes["title"] = menu.TitlePhraseID == 0?menu.Caption:AunthUI.PhraseLib.Lookup(menu.TitlePhraseID, AunthUI.LanguageID);
                hyp.Text                = menu.PhraseID == 0?menu.Caption:AunthUI.PhraseLib.Lookup(menu.PhraseID, AunthUI.LanguageID);
                phMenu.Controls.Add(hyp);
                phMenu.Controls.Add(new LiteralControl("\n"));
                if (menu.Highlighet)
                {
                    SetUpSubMenu(menu);
                }
            }
        }
    }
Ejemplo n.º 8
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Grade,Sequence,Follow,Ico,Url,Area,Controller,Action,Valid,Description,State")] AppMenu appMenu)
        {
            if (id != appMenu.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(appMenu);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AppMenuExists(appMenu.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(PartialView("~/Areas/AppIdentity/Views/AppMenu/CreateEdit.cshtml", appMenu));
        }
Ejemplo n.º 9
0
    void logix_tcp_edit_OnOverridePageMenu(object myObject, AppMenuEventArg args)
    {
        AppMenu appmenu = args.AppMenu;
        //Top Level TAB
        var menu = (from m in appmenu.Menus
                    where m.Highlighet == true
                    select m).SingleOrDefault();

        if (menu == null)
        {
            return;
        }
        var submenu = (from m in menu.Menus
                       where m.Highlighet == true
                       select m

                       ).SingleOrDefault();

        if (submenu == null)
        {
            return;
        }

        if (Request.QueryString["tcprogramid"].ConvertToInt32() == 0)
        {
            var pagemenus = from m in submenu.Menus
                            where m.Highlighet == true && m.PageSpecific == true
                            select m;
            submenu.Menus = pagemenus.ToList();
        }
    }
Ejemplo n.º 10
0
        // Custom-defined Menu

        // https://api.weixin.qq.com/cgi-bin/menu/create?access_token=ACCESS_TOKEN
        public string CreateMenu(string menu)
        {
            string accessToken = GetAccessToken();

            string      relativeUri = string.Format("/cgi-bin/menu/create?access_token={0}", accessToken);
            HttpContent content     = new StringContent(menu, Encoding.UTF8, "application/json");

            // {"errcode":0,"errmsg":"ok"}
            // {"errcode":40018,"errmsg":"invalid button name size"}
            string json = ApiPost(relativeUri, content);
            Dictionary <string, object> result = JsonConvert.DeserializeObject <Dictionary <string, object> >(json);

            if (result.ContainsKey("errcode"))
            {
                if (result["errcode"].ToString() == "0")
                {
                    Log4.Logger.Debug(json);

                    AppMenu.Save(menu);
                }
                else
                {
                    Log4.Logger.Error(json);
                }
            }
            else
            {
                Log4.Logger.Error(json);
            }
            return(json);
        }
Ejemplo n.º 11
0
        public List <AppMenu> getAllbyRol(int rolid, ref string mensaje)
        {
            List <AppMenu> menus = new List <AppMenu>();

            sql = new ConsultasSQL();
            sql.Comando.CommandType = CommandType.StoredProcedure;
            sql.Comando.CommandText = "pa_getMenu";
            sql.Comando.Parameters.AddWithValue("@RolID", rolid);

            try
            {
                sql.AbrirConexion();
                IDataReader reader = sql.EjecutaReader(ref mensaje);
                while (reader.Read())
                {
                    menus.Add(AppMenu.CreateAppMenuFromDataRecord(reader));
                }
            }
            catch (Exception ex)
            {
                mensaje = ex.Message;
            }
            finally
            {
                sql.CerrarConexion();
            }

            return(menus);
        }
Ejemplo n.º 12
0
 public void Update(AppMenu menu)
 {
     if (!_context.Exists(menu))
     {
         _context.Menus.Attach(menu);
     }
     _context.Entry(menu).State = System.Data.Entity.EntityState.Modified;
 }
Ejemplo n.º 13
0
        /// <summary>
        /// 调用 <see cref="CQ_Menu"/> 方法
        /// </summary>
        /// <param name="appMenu">目标菜单信息</param>
        /// <exception cref="ObjectDisposedException">当前对象已经被释放</exception>
        /// <exception cref="MissingMethodException">尝试访问未公开的函数</exception>
        /// <returns>返回函数处理结果</returns>
        public int InvokeCQMenu(AppMenu appMenu)
        {
            if (appMenu is null)
            {
                throw new ArgumentNullException(nameof(appMenu));
            }

            return(this.GetFunction <CQ_Menu> (appMenu.Function) ());
        }
Ejemplo n.º 14
0
    // Use this for initialization
    void Start()
    {
        AppSoftware     = GameObject.Find("Applications");
        HackingSoftware = GameObject.Find("Hacking");
        SysSoftware     = GameObject.Find("System");
        //Computer = GameObject.Find("Computer");

        //System
        clk    = SysSoftware.GetComponent <Clock>();
        defalt = SysSoftware.GetComponent <Defalt>();
        am     = SysSoftware.GetComponent <AppMenu>();
        cmd    = SysSoftware.GetComponent <CLI>();
        com    = SysSoftware.GetComponent <Computer>();
        sc     = SysSoftware.GetComponent <SoundControl>();
        appman = SysSoftware.GetComponent <AppMan>();
        boot   = SysSoftware.GetComponent <Boot>();
        post   = SysSoftware.GetComponent <POST>();
        os     = SysSoftware.GetComponent <OS>();
        mouse  = SysSoftware.GetComponent <Mouse>();
        desk   = SysSoftware.GetComponent <Desktop>();

        //Applications
        al = AppSoftware.GetComponent <AccLog>();
        sm = AppSoftware.GetComponent <SystemMap>();
        ib = AppSoftware.GetComponent <InternetBrowser>();

        //Hacking
        prog  = HackingSoftware.GetComponent <Progtive>();
        trace = HackingSoftware.GetComponent <Tracer>();
        cy    = HackingSoftware.GetComponent <Descy>();
        ds    = HackingSoftware.GetComponent <DirSearch>();

        mb    = GetComponent <MissionBrow>();
        cc    = GetComponent <CurContracts>();
        sl    = GetComponent <SiteList>();
        note  = GetComponent <Notepad>();
        fav   = GetComponent <Favs>();
        tv    = GetComponent <TreeView>();
        mPass = GetComponent <MonitorBypass>();
        wsv   = GetComponent <WebSecViewer>();
        sdp   = GetComponent <ShutdownProm>();
        Audio = GetComponent <AudioSource>();

        windowRect.x = Customize.cust.windowx[windowID];
        windowRect.y = Customize.cust.windowy[windowID];

        Audio.volume = Customize.cust.Volume;
        DesktopY     = -50;
        StartTime    = 0.030f;
        Snap         = false;

        if (Size == 0)
        {
            Size = 21;
        }
    }
Ejemplo n.º 15
0
        public static List <AppMenu> GetSideMenu(User user)
        {
            List <AppMenu> userMenuList = new List <AppMenu>();

            try
            {
                using (var context = new PYMFEEEntities())
                {
                    var appMenus = (from m in context.AppMenus select m).ToList();

                    //Check menu which user have role to display
                    var roleMenuList = appMenus.Where(b => user.RoleList.Any(a => a.RoleID.Equals(b.RoleForDisplay, StringComparison.OrdinalIgnoreCase)) ||
                                                      user.RoleList.Any(a => a.RoleID.Equals(b.RoleForManage, StringComparison.OrdinalIgnoreCase))).ToList();

                    //var groupMenuList = appMenus.Where(b => b.MenuType.Equals("GROUP", StringComparison.OrdinalIgnoreCase)).ToList();
                    var groupMenuList = appMenus.Where(b => b.MenuType == "GROUP").ToList();

                    //Find parent menu
                    int maxParent = 10; //Prevent infinity loop
                    foreach (var item in roleMenuList)
                    {
                        bool findParent     = true;
                        int  countParent    = 0;
                        var  parentMenuCode = item.ParentMenuCode;

                        userMenuList.Add(item);

                        while (findParent && !string.IsNullOrEmpty(parentMenuCode) && countParent < maxParent)
                        {
                            AppMenu parentMenu = appMenus.FirstOrDefault(b => b.MenuCode.Equals(parentMenuCode, StringComparison.OrdinalIgnoreCase));

                            if (!parentMenu.MenuCode.Equals(ConstantVariableService.RootMenuCode, StringComparison.OrdinalIgnoreCase))
                            {
                                findParent     = true;
                                parentMenuCode = parentMenu.ParentMenuCode;
                                userMenuList.Add(parentMenu);
                            }
                            else
                            {
                                findParent = false;
                            }

                            countParent++;
                        }
                    }

                    //Remove duplicate menu
                    userMenuList = userMenuList.Distinct().ToList();
                }
            }
            catch (Exception ex)
            {
            }

            return(userMenuList);
        }
Ejemplo n.º 16
0
        public MainForm()
        {
            //Application.Run(new Splash());
            //Application.Run(new Login());

            InitializeComponent();

            AppMenu.ConstructMenu(this);
            ConstructLogo();
        }
Ejemplo n.º 17
0
    void Start()
    {
        SysSoftware     = GameObject.Find("System");
        AppSoftware     = GameObject.Find("Applications");
        HackingSoftware = GameObject.Find("Hacking");

        com  = SysSoftware.GetComponent <Computer>();
        ib   = AppSoftware.GetComponent <InternetBrowser>();
        note = AppSoftware.GetComponent <Notepad>();
        prog = HackingSoftware.GetComponent <Progtive>();
        al   = SysSoftware.GetComponent <AccLog>();

        trace = HackingSoftware.GetComponent <Tracer>();

        cy      = SysSoftware.GetComponent <Descy>();
        ds      = SysSoftware.GetComponent <DirSearch>();
        tv      = SysSoftware.GetComponent <TreeView>();
        al      = AppSoftware.GetComponent <AccLog>();
        cmd     = SysSoftware.GetComponent <CLI>();
        sm      = AppSoftware.GetComponent <SystemMap>();
        clk     = SysSoftware.GetComponent <Clock>();
        defalt  = SysSoftware.GetComponent <Defalt>();
        sc      = SysSoftware.GetComponent <SoundControl>();
        appmenu = SysSoftware.GetComponent <AppMenu>();
        appman  = SysSoftware.GetComponent <AppMan>();

        windowRect.x = Customize.cust.windowx[windowID];
        windowRect.y = Customize.cust.windowy[windowID];

        native_height = Customize.cust.native_height;
        native_width  = Customize.cust.native_width;

        UpdateUI();
        for (Index = 0; Index < GameControl.control.ProgramFiles.Count; Index++)
        {
            if (GameControl.control.ProgramFiles[Index].Name == "Gateway")
            {
                TestCheck = true;
            }
        }

        if (Index >= GameControl.control.ProgramFiles.Count)
        {
            if (TestCheck == false)
            {
                Test();
            }
        }

        X     = -350;
        Speed = 600;

        windowID = appmenu.windowID;
    }
Ejemplo n.º 18
0
        public async Task <IActionResult> Create([Bind("Id,Name,Grade,Sequence,Follow,Ico,Url,Area,Controller,Action,Valid,Description,State")] AppMenu appMenu)
        {
            if (ModelState.IsValid)
            {
                _context.Add(appMenu);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(PartialView("~/Areas/AppIdentity/Views/AppMenu/CreateEdit.cshtml", appMenu));
        }
Ejemplo n.º 19
0
        public void DownloadMenus(int appId)
        {
            var apps = _CommonService.GetApps();
            var app  = apps.FirstOrDefault(x => x.Value == appId.ToString());

            if (app == null)
            {
                throw new Exception("app not found. appId:" + appId);
            }

            var accessToken = _CommonService.GetAccessToken(app.Key);
            var menus       = _MenuService.GetMenus(accessToken, appId.ToString());

            // 删除旧的菜单
            var list = _Repository.FindBy(appId, null, 1, int.MaxValue);

            foreach (var m in list)
            {
                _Repository.Remove(m);
            }

            // 添加新的菜单
            var parentSortOrder = 1;

            foreach (var m in menus)
            {
                var parent = new AppMenu();
                parent.Id        = IdentityGenerator.NewSequentialGuid();
                parent.Created   = DateTime.UtcNow;
                parent.Name      = m.Menu.Name;
                parent.SortOrder = parentSortOrder++;
                parent.AppId     = appId;
                _Repository.Add(parent);

                var childSortOrder = 10;
                foreach (var c in m.Childs)
                {
                    var child = new AppMenu();
                    child.Id        = IdentityGenerator.NewSequentialGuid();
                    child.Created   = DateTime.UtcNow;
                    child.Name      = c.Name;
                    child.Key       = c.Key;
                    child.Url       = c.Url;
                    child.SortOrder = childSortOrder++;
                    child.AppId     = appId;
                    child.Parent    = parent;
                    _Repository.Add(child);
                }
            }

            //commit unit of work
            _Repository.UnitOfWork.Commit();
        }
Ejemplo n.º 20
0
        private void ValidateModel(AppMenu model)
        {
            if (model.Name.IsNullOrBlank())
            {
                throw new DefinedException(CommonMessageResources.Name_Empty);
            }

            if (_Repository.Exists(model))
            {
                throw new DataExistsException(string.Format(WeixinMessagesResources.AppMenu_Exists_WithValue, model.Name));
            }
        }
Ejemplo n.º 21
0
        static void Main()
        {
            _connString = "mongodb://localhost:27017/";
            _DbName     = "SocialNetwork";
            _connNeo4j  = "http://localhost:7474/db/data/";
            _login      = "******";
            _pass       = "******";
            ConfigureContainer();


            AppMenu.ShowEntry();
        }
Ejemplo n.º 22
0
        public virtual List <MenuModel> GetAboutMenu()
        {
            var aboutMenu = new List <MenuModel>();

            try
            {
                aboutMenu = AppMenu.GetAboutMenu(HeaderModel.LabelMenuHelp, HeaderModel.LabelMenuOpenTicket, HeaderModel.LabelMenuAbout);
            }
            catch (Exception ex)
            {
            }

            return(aboutMenu);
        }
Ejemplo n.º 23
0
        public virtual List <MenuModel> GetMyAppsMenu()
        {
            var myAppsMenu = new List <MenuModel>();

            try
            {
                myAppsMenu = AppMenu.GetMyAppsMenu(AppCode, HeaderModel.LabelMenuMyApps);
            }
            catch (Exception ex)
            {
            }

            return(myAppsMenu);
        }
Ejemplo n.º 24
0
        public virtual List <MenuModel> GetApplicationMenu()
        {
            var appMenu = new List <MenuModel>();

            try
            {
                appMenu = AppMenu.GetApplicationMenu();
            }
            catch (Exception ex)
            {
            }

            return(appMenu);
        }
Ejemplo n.º 25
0
        public virtual JsonResult GetAboutMenu()
        {
            var aboutMenu = new List <dynamic>();

            try
            {
                var menuList = AppMenu.GetAboutMenu(Header.LabelMenuHelp, Header.LabelMenuOpenTicket, Header.LabelMenuAbout);
                aboutMenu = AppMenu.CastToDynamicMenuList(menuList);
            }
            catch (Exception ex)
            {
            }

            return(Json(aboutMenu, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 26
0
        public AppShell()
        {
            if (_shell != null)
            {
                throw new Exception("Application shell has already been initialized");
            }

            InitializeComponent();
            _shell = this;

            Menu = new AppMenu(InnerFrame);

            PopupContent.PopupOpening += OnPopupOpening;
            PopupContent.PopupClosed  += OnPopupClosed;
        }
Ejemplo n.º 27
0
        private List <AppMenu> GetSideMenu(List <AppSingleRole> rolelist)
        {
            List <AppMenu> userMenuList = new List <AppMenu>();

            var appMenus = _unitOfWork.GetRepository <AppMenu>().GetCache();

            //Check menu which user have role to display
            var roleMenuList = appMenus.Where(b => rolelist.Any(a => a.RoleId.Equals(b.RoleForDisplay, StringComparison.OrdinalIgnoreCase)) ||
                                              rolelist.Any(a => a.RoleId.Equals(b.RoleForManage, StringComparison.OrdinalIgnoreCase))).ToList();

            var groupMenuList = appMenus.Where(b => b.MenuType.Equals("GROUP", StringComparison.OrdinalIgnoreCase)).ToList();

            //Find parent menu
            int maxParent = 10; //Prevent infinity loop

            foreach (var item in roleMenuList)
            {
                bool findParent     = true;
                int  countParent    = 0;
                var  parentMenuCode = item.ParentMenuCode;

                userMenuList.Add(item);

                while (findParent && !string.IsNullOrEmpty(parentMenuCode) && countParent < maxParent)
                {
                    AppMenu parentMenu = appMenus.FirstOrDefault(b => b.MenuCode.Equals(parentMenuCode, StringComparison.OrdinalIgnoreCase));

                    if (!parentMenu.MenuCode.Equals(ConstantValue.RootMenuCode, StringComparison.OrdinalIgnoreCase))
                    {
                        findParent     = true;
                        parentMenuCode = parentMenu.ParentMenuCode;
                        userMenuList.Add(parentMenu);
                    }
                    else
                    {
                        findParent = false;
                    }

                    countParent++;
                }
            }

            //Remove duplicate menu
            userMenuList = userMenuList.Distinct().ToList();

            return(userMenuList);
        }
Ejemplo n.º 28
0
        private void ShowSubMenuLinks()
        {
            //Get current user roles
            string[] userRoles;
            userRoles = Roles.GetRolesForUser();

            // Get submenus and submenu links per column
            string[] subMenuLinks;
            AppMenu  appMenu = new AppMenu();

            subMenuLinks = appMenu.GetSubMenuLinks((int)TopMenuID.Personnel, userRoles, 3);

            //Assign submenu and submenu links to their column in the page
            Column1.InnerHtml = subMenuLinks[0];
            Column2.InnerHtml = subMenuLinks[1];
            Column3.InnerHtml = subMenuLinks[2];
        }
Ejemplo n.º 29
0
        private async void MenuItems_OnItemTapped(object sender, ItemTappedEventArgs e)
        {
            var item    = (MenuPageItem)e.ItemData;
            var page    = item.TargetType;
            var appMenu = new AppMenu();

            if (page != typeof(LogoutPage))
            {
                await Navigation.PushAsync(appMenu);

                appMenu.Detail      = new NavigationPage((Page)Activator.CreateInstance(page));
                appMenu.IsPresented = false;
            }
            else
            {
                await Navigation.PushAsync(new Login());
            }
        }
        /// <summary>
        /// Binding Menu to ViewModel.
        /// </summary>
        /// <param name="userMenuList">The Menu current user can be visible.</param>
        /// <param name="menu">The current menu.</param>
        /// <param name="userRoleList">The user role list.</param>
        /// <returns></returns>
        private List <MenuViewModel> GetMenuItem(IEnumerable <AppMenu> userMenuList, AppMenu menu, IEnumerable <AppCompositeRoleItem> userRoleList, string url = null)
        {
            List <MenuViewModel> result = new List <MenuViewModel>();

            url = string.Format("{0}/{1}", url, menu.MenuCode);
            if (menu.MenuType.Equals("GROUP", StringComparison.OrdinalIgnoreCase))
            {
                List <AppMenu> childMenuList = userMenuList.Where(a => a.ParentMenuCode.Equals(menu.MenuCode, StringComparison.OrdinalIgnoreCase)).OrderBy(a => a.Sequence).ToList();

                MenuViewModel mItem = new MenuViewModel
                {
                    Name        = menu.MenuName,
                    DisplayOnly = false,
                    Icon        = menu.Icon,
                    Url         = url,
                    Parent      = new List <MenuViewModel>()
                };

                foreach (var item in childMenuList)
                {
                    mItem.Parent.AddRange(this.GetMenuItem(userMenuList, item, userRoleList, url));
                }

                if (mItem.Parent.Count <= 0)
                {
                    mItem.Parent = null;
                }

                result.Add(mItem);
            }
            else if (menu.MenuType.Equals("ITEM", StringComparison.OrdinalIgnoreCase))
            {
                MenuViewModel sItem = new MenuViewModel
                {
                    Name        = menu.MenuName,
                    DisplayOnly = !userRoleList.Any(x => x.RoleMenu == menu.RoleForManage),
                    Icon        = menu.Icon,
                    Url         = url,
                    Parent      = null,
                };
                result.Add(sItem);
            }
            return(result);
        }