Example #1
0
        public ActionResult Index(AdminMenu selectedMenu = AdminMenu.Screens)
        {
            TempData["menuId"] = selectedMenu;

            switch (selectedMenu)
            {
                case AdminMenu.Screens:
                    TempData["menuColor"] = "blue";

                    var screensVm = new ViewModels.Screens.Screens
                    {
                        Categories = GetBoards(),
                        ScreenList = _screensDomain.GetScreens(Server.MapPath(@"~/App_Data/Screens.json")).ToList()
                    };

                    return View("Screens", screensVm);
                case AdminMenu.Environments:
                    TempData["menuColor"] = "red";
                    return View("Environments");
                case AdminMenu.Builds:
                    TempData["menuColor"] = "blue";
                    return View();
                case AdminMenu.Deployments:
                    TempData["menuColor"] = "apricot";
                    return View();
                case AdminMenu.Issues:
                    TempData["menuColor"] = "red";

                    var issuesVm = _issuesDomain.GetQueries(Server.MapPath(@"~/App_Data/Issues.json"));

                    return View("Issues", issuesVm);
                case AdminMenu.RedAlert:
                    TempData["menuColor"] = "blue";

                    var redAlertDetails = _redAlertDomain.GetRedAlert(Server.MapPath(@"~/App_Data/RedAlert.json"));

                    var redAlertVm = new ViewModels.Admin.RedAlert
                    {
                        IsEnabled = redAlertDetails.IsEnabled,
                        AlertType = redAlertDetails.AlertType,
                        TargetYear = Convert.ToDateTime(redAlertDetails.TargetDate).Year,
                        TargetMonth = Convert.ToDateTime(redAlertDetails.TargetDate).Month,
                        TargetDay = Convert.ToDateTime(redAlertDetails.TargetDate).Day,
                        TargetHour = Convert.ToDateTime(redAlertDetails.TargetDate).Hour,
                        TargetMinute = Convert.ToDateTime(redAlertDetails.TargetDate).Minute
                    };

                    return View("RedAlert", redAlertVm);
                case AdminMenu.Settings:
                    TempData["menuColor"] = "apricot";

                    var settingsVm = _settingsDomain.GetSettings(Server.MapPath(@"~/App_Data/Settings.json"));

                    return View("Settings", settingsVm);
                default:
                    throw new ArgumentOutOfRangeException(nameof(selectedMenu), selectedMenu, null);
            }
        }
Example #2
0
        public IActionResult Install()
        {
            string lockPath = $"{_env.WebRootPath}{Path.DirectorySeparatorChar}install.lock";

            if (System.IO.File.Exists(lockPath))
            {
                return(EchoTip("COMCMS系统已经安装过,如果需要重新安装,请删除程序wwwroot目录下的install.lock文件!", false, "/"));
            }
            //判断数据库类型 mysql mssql 暂时只支持这两种
            string sqltype         = "mysql";
            string sqlProviderName = Utils.GetSetting("connectionStrings:dbconn:providerName");

            if (sqlProviderName == "System.Data.SqlClient")
            {
                sqltype = "mssql";
            }
            bool hasData = AdminMenu.FindCount(null, null, null, 0, 0) > 0;

            ViewBag.hasData = hasData;
            ViewBag.sqltype = sqltype;
            return(View());
        }
Example #3
0
        /// <summary>
        /// 获取管理员列表(分页)
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public JsonRsp <MenuViewModel> GetPageList(int pageIndex, int pageSize)
        {
            JsonRsp <MenuViewModel> rsp = new JsonRsp <MenuViewModel>();

            AdminMenu m = new AdminMenu();
            OQL       q = OQL.From(m)
                          .Select()
                          .OrderBy(m.ID, "asc")
                          .END;

            //分页
            q.Limit(pageSize, pageIndex, true);
            //q.PageWithAllRecordCount = allCount;
            //List<Employee> list= EntityQuery<Employee>.QueryList(q);
            List <AdminMenu> list = q.ToList <AdminMenu>();//使用OQL扩展

            rsp.data = list.ConvertAll <MenuViewModel>(o =>
            {
                return(new MenuViewModel()
                {
                    ID = o.ID,
                    MenuKey = o.MenuKey,
                    MenuName = o.MenuName,
                    MenuUrl = o.MenuUrl,
                    MenuType = o.MenuType,
                    IDPath = o.IDPath,
                    Remark = o.Remark,
                    Sort = o.Sort,
                    Status = o.Status,
                    CreateTIme = o.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
                });
            }
                                                       );
            rsp.success = true;
            rsp.code    = 0;
            rsp.count   = q.PageWithAllRecordCount;
            return(rsp);
        }
Example #4
0
        void LoadAdminMenuItems()
        {
            MenuItems.Clear();

            MenuItems.Add(new AdminMenuItem {
                Id = 0, Text = GetLocalResourceObject("UserDetails").ToString(), Argument = "UserDetails", ImageUrl = "vcard.gif"
            });
            MenuItems.Add(new AdminMenuItem {
                Id = 1, Text = GetLocalResourceObject("UserRoles").ToString(), Argument = "UserRoles", ImageUrl = "shield.gif"
            });
            MenuItems.Add(new AdminMenuItem {
                Id = 2, Text = GetLocalResourceObject("UserPassword").ToString(), Argument = "UserPassword", ImageUrl = "key.gif"
            });
            MenuItems.Add(new AdminMenuItem {
                Id = 3, Text = GetLocalResourceObject("UserProfile").ToString(), Argument = "UserProfile", ImageUrl = "user.gif"
            });
            MenuItems.Add(new AdminMenuItem {
                Id = 4, Text = GetLocalResourceObject("UserDelete").ToString(), Argument = "UserDelete", ImageUrl = "user_delete.gif"
            });

            AdminMenu.DataSource = MenuItems;
            AdminMenu.DataBind();
        }
Example #5
0
        /// <summary>
        /// 更新后台菜单数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ActionResult EditAdminMenu(AdminMenu model)
        {
            try
            {
                Dictionary <string, object> param = new Dictionary <string, object>();
                param.Add("ObjectId", model.ObjectId);
                int i = _adminMenuService.UpdateTable <AdminMenu>(model, param);
                if (i > 0)
                {
                    return(AjaxJson(true, i, "编辑数据成功.", ""));
                }
                else
                {
                    return(AjaxJson(false, 0, "", "编辑数据失败."));
                }
            }
            catch (Exception)
            {
                return(AjaxJson(false, 0, "", "查询出错."));

                throw;
            }
        }
Example #6
0
        public IActionResult EditAdminRole(int id)
        {
            AdminRoles entity = AdminRoles.Find(AdminRoles._.Id == id);

            if (entity == null)
            {
                return(EchoTipPage("系统找不到本记录!", 0, true, ""));
            }
            if (string.IsNullOrEmpty(entity.Powers))
            {
                entity.Powers = "[]";
            }
            if (string.IsNullOrEmpty(entity.Menus))
            {
                entity.Menus = "[]";
            }
            //获取所有的菜单列表
            IList <AdminMenu> list = AdminMenu.GetListTree(0, -1, false, false);

            ViewBag.MenuList = list;
            Core.Admin.WriteLogActions($"查看管理组({id})详情;");
            return(View(entity));
        }
Example #7
0
        public void Login()
        {
            Console.Write("Enter your username: "******"Enter your password: ");
            var password = Console.ReadLine();

            _user = _login.SignIn(username, password);

            if (_user.Role == 0)
            {
                _regularUser = Authentication <RegularUser>(_user);
                var menu = new RegularMenu(_regularFunction, _regularUser);
                menu.Menu();
            }
            else
            {
                _adminUser = Authentication <AdminUser>(_user);
                var menu = new AdminMenu(_adminFunction, _adminUser);
                menu.Menu();
            }
        }
Example #8
0
        protected AdminMenu GetAdminMenu()
        {
            var menu = new AdminMenu
            {
                Links = new List <AdminNavLink>
                {
                    new AdminNavLink {
                        Url = Url.Action("Index", "Dashboard"), Text = "Dashboard", IconClass = "icon-home"
                    },
                    new AdminNavLink {
                        Url = Url.Action("Index", "Sections"), Text = "Site Sections", IconClass = "icon-book"
                    },
                    new AdminNavLink {
                        Url = Url.Action("Index", "Media"), Text = "Media", IconClass = "icon-hdd"
                    },
                    new AdminNavLink {
                        Url = Url.Action("Index", "Trash"), Text = "Trash", IconClass = "icon-trash"
                    }
                }
            };

            return(menu);
        }
Example #9
0
        /// <summary>
        /// 迭代获得子菜单
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public List <object> ReturnChildMenu(AdminMenu model)
        {
            List <object>    result = new List <object>();
            List <AdminMenu> list   = _adminMenuService.GetMenuListByParentId(model.ObjectId);

            if (list.Count > 0)
            {
                foreach (var item in list)
                {
                    var obj = new object();
                    if (item.IsLeaf)
                    {
                        obj = new { id = item.ObjectId, text = item.DisplayName };
                    }
                    else
                    {
                        obj = new { id = item.ObjectId, text = item.DisplayName, children = ReturnChildMenu(item) };
                    }

                    result.Add(obj);
                }
            }
            return(result);
        }
Example #10
0
        public override string RenderToString(CmsControlDefinition controlDefnToRender, CmsLanguage langToRenderFor)
        {
            if (!CmsContext.currentPage.currentUserCanRead)
            {
                return("Access Denied");
            }


            StringBuilder html = new StringBuilder();
            // -- always render the admin menu
            AdminMenu adminMenu = new AdminMenu();

            html.Append(adminMenu.Render());

            BaseCmsAdminTool toolToRun = AdminMenu.getToolToRun();

            if (toolToRun.getToolInfo().Category != BaseCmsAdminTool.CmsAdminToolCategory._AdminMenu)
            {
                string toolHtml = toolToRun.Render();
                html.Append(toolHtml);
            }

            return(html.ToString());
        }
Example #11
0
        private void LoginExecute()
        {
            try
            {
                switch (currentEmployee.role)
                {
                case "admin":
                    AdminMenu adminMenu = new AdminMenu();
                    adminMenu.ShowDialog();
                    break;

                case "employee":
                    DAN_XLIII.View.Employee e = new DAN_XLIII.View.Employee(currentEmployee.id);
                    e.ShowDialog();
                    break;

                case "manager":
                    tblManager m = Service.Service.GetManagerById(currentEmployee.id);
                    if (m.access == "modify")
                    {
                        ManagerModify managerModify = new ManagerModify();
                        managerModify.ShowDialog();
                    }
                    else
                    {
                        ManagerReadonly managerReadonly = new ManagerReadonly();
                        managerReadonly.ShowDialog();
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #12
0
        public JsonRsp <TreeSelect> GetMenuTreeSelect(int roleId)
        {
            AdminRole role    = new AdminRoleBLL().GetModelById(roleId);
            string    menuIds = "0";

            if (roleId > 0)
            {
                menuIds = "," + role.MenuIds + ",";
            }
            //int[] checkedArray = Array.ConvertAll(role.MenuIds.Split(','), int.Parse);

            JsonRsp <TreeSelect> rsp   = new JsonRsp <TreeSelect>();
            AdminMenu            model = new AdminMenu();
            OQL q = OQL.From(model)
                    .Select()
                    .OrderBy(model.ID, "asc")
                    .END;
            List <AdminMenu>  list    = q.ToList <AdminMenu>();//使用OQL扩展
            List <TreeSelect> allList = list.ConvertAll <TreeSelect>(o =>
            {
                return(new TreeSelect()
                {
                    id = o.ID,
                    value = o.ID,
                    ParentID = o.ParentID,
                    name = o.MenuName,
                    isChecked = menuIds.IndexOf("," + o.ID + ",") > -1,
                });
            }
                                                                     );

            rsp.data    = getMenuNodes(0, 0, allList);
            rsp.success = true;
            rsp.code    = 0;
            return(rsp);
        }
Example #13
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                IList <string> segments = Request.GetFriendlyUrlSegments();
                ProjectId = Int32.Parse(segments[0]);
            }
            catch
            {
                ProjectId = Request.QueryString.Get("pid", 0);
            }

            if (!UserManager.IsSuperUser())
            {
                if (!UserManager.HasPermission(ProjectId, Permission.AdminEditProject.ToString()))
                {
                    Response.Redirect("~/Errors/AccessDenied");
                }
            }

            if (!Page.IsPostBack)
            {
                litProjectName.Text         = ProjectManager.GetById(ProjectId).Name;
                lblExistingProjectName.Text = litProjectName.Text;

                var message = string.Format(GetLocalResourceObject("ConfirmDelete").ToString(), litProjectName.Text);
                DeleteButton.OnClientClick = String.Format("return confirm('{0}');", message);

                if (!UserManager.HasPermission(ProjectId, Permission.AdminDeleteProject.ToString()))
                {
                    DeleteButton.Visible = false;
                }

                if (!UserManager.HasPermission(ProjectId, Permission.AdminCloneProject.ToString()))
                {
                    linkCloneProject.Visible = false;
                }
            }

            _menuItems.Add(GetLocalResourceObject("Details").ToString(), "application_home.png");
            _menuItems.Add(GetLocalResourceObject("Categories").ToString(), "plugin.gif");
            _menuItems.Add(GetLocalResourceObject("Status").ToString(), "greencircle.png");
            _menuItems.Add(GetLocalResourceObject("Priorities").ToString(), "Critical.gif");
            _menuItems.Add(GetLocalResourceObject("Milestones").ToString(), "package.gif");
            _menuItems.Add(GetLocalResourceObject("IssueTypes").ToString(), "bug.gif");
            _menuItems.Add(GetLocalResourceObject("Resolutions").ToString(), "accept.gif");
            _menuItems.Add(GetLocalResourceObject("Members").ToString(), "users_group.png");
            _menuItems.Add(GetLocalResourceObject("SecurityRoles").ToString(), "shield.gif");
            _menuItems.Add(GetLocalResourceObject("Notifications").ToString(), "email_go.gif");
            _menuItems.Add(GetLocalResourceObject("CustomFields").ToString(), "textfield.gif");
            _menuItems.Add(GetLocalResourceObject("Mailboxes").ToString(), "email.gif");
            _menuItems.Add(GetLocalResourceObject("Subversion").ToString(), "svnLogo_sm.jpg");
            _menuItems.Add(GetLocalResourceObject("Defaults").ToString(), "Default.png");

            AdminMenu.DataSource = _menuItems;
            AdminMenu.DataBind();

            if (TabId != -1)
            {
                LoadTab(TabId);
            }
        }
Example #14
0
        private void Login_btn_Click(object sender, EventArgs e)
        {
            if (LoginUser_txt.Text == "" || LoginPw_txt.Text == "")
            {
                username_wrn.Text = "*Tài khoản không được để trống";
                pass_wrn.Text     = "*Mật khẩu không được để trống";
                username_wrn.Show();
                pass_wrn.Show();
                Cafe.Close();
            }
            else
            {
                username_wrn.Visible = false;
                pass_wrn.Visible     = false;
                Cafe.Open();
                SqlDataAdapter loginAdapter = new SqlDataAdapter
                                                  ("select * from [dbo].[TAI_KHOAN_HE_THONG] where TAI_KHOAN='" + LoginUser_txt.Text + "' and MAT_KHAU='" + LoginPw_txt.Text + "' ", Cafe);
                DataTable result = new DataTable();
                loginAdapter.Fill(result);
                try
                {
                    if (result.Rows.Count == 1)
                    {
                        if (LoginUser_txt.Text == result.Rows[0]["TAI_KHOAN"].ToString() && LoginPw_txt.Text == result.Rows[0]["MAT_KHAU"].ToString())
                        {
                            login_role = result.Rows[0]["LOAI_TK"].ToString();
                            switch (login_role)
                            {
                            case "Admin":
                            {
                                AdminMenu AdminMenu = new AdminMenu();
                                MessageBox.Show("Đăng nhập thành công\n Xin chào Admin");
                                AdminMenu.Login_Main_Data(login_role);
                                this.Hide();
                                AdminMenu.Show();
                                break;
                            }

                            case "Thu ngân":
                            {
                                CashierMenu CashierMenu = new CashierMenu();
                                MessageBox.Show("Đăng nhập thành công\n Xin chào Thu ngân");
                                CashierMenu.Login_Main_Data(login_role);
                                this.Hide();
                                CashierMenu.Show();
                                break;
                            }

                            case "Khách hàng":
                            {
                                MessageBox.Show("Tính năng đang trong quá trình phát triển");
                                break;
                            }
                            }
                        }
                        else
                        {
                            MessageBox.Show("Đăng nhập thất bại\n Vui lòng kiểm tra tài khoản và mật khẩu");
                            Cafe.Close();
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "ERROR", MessageBoxButtons.OK);
                    Cafe.Close();
                }
            }
        }
        public IActionResult EditAdminMenu(AdminMenu model)
        {
            if (!ModelState.IsValid)
            {
                string messages = string.Join("; ", ModelState.Values
                                              .SelectMany(x => x.Errors)
                                              .Select(x => x.ErrorMessage));
                tip.Message = messages;
                return(Json(tip));
            }
            if (model.Id <= 0)
            {
                tip.Message = "错误参数传递!";
                return(Json(tip));
            }
            AdminMenu entity = AdminMenu.Find(AdminMenu._.Id == model.Id);

            if (entity == null)
            {
                tip.Message = "系统找不到本记录!";
                return(Json(tip));
            }
            //赋值
            entity.MenuName = model.MenuName;
            //如果key修改了。判断是否有存在
            if (entity.MenuKey != model.MenuKey)
            {
                if (AdminMenu.FindCount(AdminMenu._.MenuKey == model.MenuKey & AdminMenu._.Id != entity.Id, null, null, 0, 0) > 0)
                {
                    tip.Message = "您修改的菜单KEY已经存在,请填写其他的!";
                    return(Json(tip));
                }
                entity.MenuKey = model.MenuKey;
            }
            entity.Link      = model.Link;
            entity.IsHide    = model.IsHide;
            entity.ClassName = model.ClassName;
            entity.Rank      = model.Rank;
            if (entity.PId != model.PId)
            {
                //重新获取level和location
                entity.Level    = AdminMenu.GetNewLevel(model.PId);
                entity.Location = AdminMenu.GetNewLocation(model.PId);
            }
            entity.PId = model.PId;
            entity.Update();

            //处理权限
            IList <AdminMenuEvent> oldevent = AdminMenuEvent.FindAll(AdminMenuEvent._.MenuId == entity.Id, null, null, 0, 0);

            //所有的权限
            IList <TargetEvent> listevent = TargetEvent.FindAll(TargetEvent._.Id > 0, TargetEvent._.Rank.Asc(), null, 0, 0);

            //新的权限
            string[] eventkeys           = Request.Form["eventkey"];
            List <AdminMenuEvent> listme = new List <AdminMenuEvent>();

            if (eventkeys != null && eventkeys.Length > 0)
            {
                foreach (string s in eventkeys)
                {
                    if (Utils.IsInt(s))
                    {
                        TargetEvent te = listevent.FirstOrDefault(t => t.Id == int.Parse(s));
                        if (te != null)
                        {
                            AdminMenuEvent tmp = new AdminMenuEvent();
                            tmp.EventId   = te.Id;
                            tmp.EventKey  = te.EventKey;
                            tmp.EventName = te.EventName;
                            tmp.MenuKey   = model.MenuKey;
                            tmp.MenuId    = entity.Id;
                            listme.Add(tmp);
                        }
                    }
                }
            }

            //判断是否在旧的里面
            listme.ForEach(s =>
            {
                var oe = oldevent.FirstOrDefault(o => o.EventId == s.EventId);
                //如果是旧列表存在,则删掉旧列表里面的,然后更新自己
                if (oe != null)
                {
                    s.Id = oe.Id;
                    s.Update();
                    oldevent.Remove(oe);
                }
                else
                {
                    //如果不存在,则是新增的。直接新增处理
                    s.Insert();
                }
            });
            //如果还有,则删除旧列表里面的
            if (oldevent != null && oldevent.Count > 0)
            {
                oldevent.Delete();
            }

            tip.Status    = JsonTip.SUCCESS;
            tip.Message   = "编辑后台菜单成功";
            tip.ReturnUrl = "close";
            return(Json(tip));
        }
 public void SetMenu(AdminMenu someMenu) => menu = someMenu;
Example #17
0
        private static void StartRegister()
        {
            if (AdminMenu.Meta.Count > 0)
            {
                return;
            }
            // 操作项定义
            var menuEventDic = new Dictionary <string, KeyValuePair <int, string> >
            {
                { "add", new KeyValuePair <int, string>(1, "添加") },
                { "edit", new KeyValuePair <int, string>(2, "修改") },
                { "del", new KeyValuePair <int, string>(3, "删除") },
                { "view", new KeyValuePair <int, string>(4, "查看") },
                { "viewlist", new KeyValuePair <int, string>(5, "查看列表") },
                { "import", new KeyValuePair <int, string>(6, "导入") },
                { "export", new KeyValuePair <int, string>(7, "导出") },
                { "filter", new KeyValuePair <int, string>(8, "搜索") },
                { "batch", new KeyValuePair <int, string>(9, "批量操作") },
                { "recycle", new KeyValuePair <int, string>(10, "回收站") },
                { "confirm", new KeyValuePair <int, string>(11, "确认") },
            };

            var asms = AppDomain.CurrentDomain.GetAssemblies();

            foreach (var asmItem in asms)
            {
                var types = asmItem.GetTypes().Where(e => e.Name.EndsWith("Controller")).ToList();
                if (types.Count == 0)
                {
                    continue;
                }

                foreach (var type in types)
                {
                    if (!type.Namespace.Contains(".AdminCP.Controller"))
                    {
                        continue;
                    }

                    // 控制器名称
                    var ctrName = type.Name.TrimEnd("Controller");

                    // 控制器展示名
                    var ctrDpName = type.GetDisplayName();

                    var ctrDes = type.GetDescription();

                    var url = ctrName;

                    var fAdminMenu = AdminMenu.Find(AdminMenu._.MenuKey == ctrName + "Sys" & AdminMenu._.Link == "#");
                    var nAdminMenu = new AdminMenu
                    {
                        Description = ctrDes,
                        IsHide      = 0,
                        Level       = 0,
                        Link        = "#",
                        Location    = "0,",
                        MenuKey     = ctrName + "Sys",
                        MenuName    = ctrDpName,
                        PId         = 0
                    };
                    var pAdminMenu = fAdminMenu ?? nAdminMenu;
                    if (pAdminMenu.Id > 0)
                    {
                        pAdminMenu.Description = nAdminMenu.Description;
                        pAdminMenu.MenuName    = nAdminMenu.MenuName;
                    }

                    // 控制器所有包含MyAuthorizeAttribute的方法
                    var acts = type.GetMethods()
                               .Where(w => w.IsDefined(typeof(MyAuthorizeAttribute)))
                               .ToList();

                    if (!acts.Any())
                    {
                        continue;
                    }

                    pAdminMenu.Save();

                    var eventKeyDic        = new Dictionary <string, int>();
                    var adminMenuEventList = new List <AdminMenuEvent>();

                    foreach (var method in acts)
                    {
                        var dn          = method.GetDisplayName();
                        var methodDes   = method.GetDescription();
                        var actName     = method.Name;
                        var myAuthorize = method.GetCustomAttribute <MyAuthorizeAttribute>();

                        var menuKey    = myAuthorize.GetValue("_menuKey").ToString();
                        var eventKey   = myAuthorize.GetValue("_eventKey").ToString();
                        var returnType = myAuthorize.GetValue("_returnType").ToString();

                        //保存菜单
                        if (eventKey == "viewlist" && returnType == "HTML")
                        {
                            var adminMenu = AdminMenu.Find(AdminMenu._.MenuKey == menuKey & AdminMenu._.Link == url + "/" + actName) ?? new AdminMenu
                            {
                                Description = methodDes,
                                IsHide      = 0,
                                Level       = pAdminMenu.Level + 1,
                                Link        = url + "/" + actName,
                                Location    = pAdminMenu.Location + ",",
                                MenuKey     = menuKey,
                                MenuName    = dn,
                                PId         = pAdminMenu.Id
                            };
                            adminMenu.Save();

                            eventKeyDic[menuKey] = adminMenu.Id;
                        }

                        // 保存操作
                        var adminmenuevent = AdminMenuEvent.Find(AdminMenuEvent._.MenuId == menuEventDic[eventKey].Key
                                                                 & AdminMenuEvent._.MenuKey == menuKey & AdminMenuEvent._.EventKey == eventKey)
                                             ?? new AdminMenuEvent
                        {
                            MenuKey   = menuKey,
                            MenuId    = menuEventDic[eventKey].Key,
                            EventKey  = eventKey,
                            EventName = menuEventDic[eventKey].Value
                        };
                        adminMenuEventList.Add(adminmenuevent);
                    }

                    adminMenuEventList.ForEach(f => f.MenuId = eventKeyDic.ContainsKey(f.MenuKey) ? eventKeyDic[f.MenuKey] : 0);
                    adminMenuEventList.Save();
                }
            }
        }
 public ActionResult Edit(AdminMenu model)
 {
     return(Json(bll.Save(model), JsonRequestBehavior.AllowGet));
 }
Example #19
0
 public void LaunchAdminMenuView(string loginusername)
 {
     adminmenu = new AdminMenu();
     adminmenu.Show();
 }
        public IActionResult AdminMenuList()
        {
            IList <AdminMenu> list = AdminMenu.GetListTree(0, -1, false, true);

            return(View(list));
        }
Example #21
0
        public void ListAllUser(List <Account> listAccount)
        {
            int pageSize   = 10;
            var pageNumber = listAccount.Count < pageSize ? 0 : listAccount.Count / pageSize + 1;

            if (firtPage == 1)
            {
                Console.WriteLine("--- Danh sách tài khoản ---");
                Console.WriteLine("-----------------------------");
                // toString()
                Console.WriteLine("#   " + "AccountNumber   " + "Username   " + "Email   " + "Số điện thoại   " + "Tên đầy đủ   " + "Quyền sử dụng   " + "Trạng thái   ");
                var lengthPage = pageNumber > 0 ? currentPageIndex * 10 : listAccount.Count;
                if (pageNumber > 0)
                {
                    for (int i = 0; i < 10; i++)
                    {
                        Console.WriteLine((i + 1) + "   " + listAccount[i].AccountNumber + "   " + listAccount[i].Username + "   " +
                                          listAccount[i].Email + "   " + listAccount[i].PhoneNumber + "   " +
                                          listAccount[i].FullName + "   " + listAccount[i].Role + "   " +
                                          listAccount[i].Status);
                    }
                    Console.WriteLine("Số hàng trên trang: " + lengthPage + ", Số trang: 1/" + pageNumber);
                    Console.WriteLine("Vui lòng nhấp phím '>' để sang trang tiếp");
                    Console.WriteLine("Vui lòng nhấp phím '<' để quay lại trang trước");
                }
                else
                {
                    for (int i = 0; i < listAccount.Count; i++)
                    {
                        Console.WriteLine((i + 1) + "   " + listAccount[i].AccountNumber + "   " + listAccount[i].Username + "   " +
                                          listAccount[i].Email + "   " + listAccount[i].PhoneNumber + "   " +
                                          listAccount[i].FullName + "   " + listAccount[i].Role + "   " +
                                          listAccount[i].Status);
                    }
                    Console.WriteLine("Số hàng trên trang: " + lengthPage + ", Số trang: 1/" + (pageNumber + 1));
                }
            }
            else
            {
                Console.WriteLine("#   " + "AccountNumber   " + "Username   " + "Email   " + "Số điện thoại   " + "Tên đầy đủ   " + "Quyền sử dụng   " + "Trạng thái   ");
                if (currentPageIndex != pageNumber)
                {
                    for (int j = (currentPageIndex - 1) * 10; j < currentPageIndex * 10; j++)
                    {
                        Console.WriteLine((j + 1) + "   " + listAccount[j].AccountNumber + "   " + listAccount[j].Username + "   " + listAccount[j].Email + "   " + listAccount[j].PhoneNumber + "   " + listAccount[j].FullName + "   " + listAccount[j].Role + "   " + listAccount[j].Status);
                    }
                    Console.WriteLine("Số hàng trên trang: " + 10 + ", Số trang: " + currentPageIndex + "/" + pageNumber);
                    Console.WriteLine("Vui lòng nhấp phím '>' để sang trang tiếp");
                    Console.WriteLine("Vui lòng nhấp phím '<' để quay lại trang trước");
                }
                else
                {
                    for (int j = (currentPageIndex - 1) * 10; j < listAccount.Count; j++)
                    {
                        Console.WriteLine((j + 1) + "   " + listAccount[j].AccountNumber + "   " + listAccount[j].Username + "   " + listAccount[j].Email + "   " + listAccount[j].PhoneNumber + "   " + listAccount[j].FullName + "   " + listAccount[j].Role + "   " + listAccount[j].Status);
                    }
                    Console.WriteLine("Số hàng trên trang: " + (listAccount.Count - (currentPageIndex - 1) * 10) + ", Số trang: " + pageNumber + "/" + pageNumber);
                    Console.WriteLine("Vui lòng nhấp phím '>' để sang trang tiếp");
                    Console.WriteLine("Vui lòng nhấp phím '<' để quay lại trang trước");
                }
            }

            while (true)
            {
                var keyB = Console.ReadKey(true).Key;
                if (listAccount.Count > 10)
                {
                    if (keyB == ConsoleKey.RightArrow)
                    {
                        firtPage = 2;
                        currentPageIndex++;
                        if (currentPageIndex > pageNumber)
                        {
                            currentPageIndex = 1;
                        }
                        ListAllUser(listAccount);
                        break;
                    }
                    if (keyB == ConsoleKey.LeftArrow)
                    {
                        firtPage = 2;
                        currentPageIndex--;
                        if (currentPageIndex < 1)
                        {
                            currentPageIndex = pageNumber;
                        }
                        ListAllUser(listAccount);
                        break;
                    }
                }
                if (keyB == ConsoleKey.Escape)
                {
                    AdminMenu.GenerateAdminMenu();
                    break;
                }
            }
        }
Example #22
0
        public IActionResult EditAdminRole(IFormCollection fc)
        {
            string Id                    = fc["Id"];
            string RoleName              = fc["RoleName"];
            string RoleDescription       = fc["RoleDescription"];
            string IsSuperAdmin          = fc["IsSuperAdmin"];
            string NotAllowDel           = fc["NotAllowDel"];
            string OnlyEditMyselfArticle = fc["OnlyEditMyselfArticle"];
            string OnlyEditMyselfProduct = fc["OnlyEditMyselfProduct"];

            if (string.IsNullOrEmpty(OnlyEditMyselfArticle) || !Utils.IsInt(OnlyEditMyselfProduct))
            {
                OnlyEditMyselfProduct = "0";
            }
            if (string.IsNullOrEmpty(OnlyEditMyselfProduct) || !Utils.IsInt(OnlyEditMyselfProduct))
            {
                OnlyEditMyselfProduct = "0";
            }

            if (string.IsNullOrEmpty(Id))
            {
                tip.Message = "错误参数传递!";
                return(Json(tip));
            }

            if (string.IsNullOrEmpty(RoleName))
            {
                tip.Message = "管理组名称不能为空!";
                return(Json(tip));
            }

            AdminRoles entity = AdminRoles.Find(AdminRoles._.Id == int.Parse(Id));

            if (entity == null)
            {
                tip.Message = "系统找不到本记录!";
                return(Json(tip));
            }
            entity.RoleName              = RoleName;
            entity.RoleDescription       = RoleDescription;
            entity.IsSuperAdmin          = int.Parse(IsSuperAdmin);
            entity.NotAllowDel           = !string.IsNullOrEmpty(NotAllowDel) && NotAllowDel == "1" ? 1 : 0;
            entity.OnlyEditMyselfArticle = int.Parse(OnlyEditMyselfArticle);
            entity.OnlyEditMyselfProduct = int.Parse(OnlyEditMyselfProduct);

            //处理权限
            if (entity.IsSuperAdmin == 1)
            {
                entity.Powers = "";
                entity.Menus  = "";
            }
            else
            {
                //第一步,获取菜单
                string[] menuids = Request.Form["menuid"];
                //获取所有的菜单列表
                IList <AdminMenu>      alllist    = AdminMenu.GetListTree(0, -1, false, false);
                IList <AdminMenu>      list       = new List <AdminMenu>();
                IList <AdminMenuEvent> listevents = new List <AdminMenuEvent>();
                if (menuids != null && menuids.Length > 0)
                {
                    foreach (string s in menuids)
                    {
                        if (Utils.IsInt(s) && alllist.FirstOrDefault(v => v.Id == int.Parse(s)) != null)
                        {
                            AdminMenu tmp = alllist.FirstOrDefault(a => a.Id == int.Parse(s)).CloneEntity();
                            list.Add(tmp);
                            //处理详细权限  详细权限,每一行,则每一个菜单的详细权限,则同一个name
                            string[] eventids = Request.Form["EventKey_" + s];
                            if (eventids != null && eventids.Length > 0)
                            {
                                foreach (var item in eventids)
                                {
                                    if (Utils.IsInt(item))
                                    {
                                        AdminMenuEvent model = AdminMenuEvent.Find(AdminMenuEvent._.Id == int.Parse(item));
                                        if (model != null)
                                        {
                                            listevents.Add(model);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    //序列化成json
                    if (list != null && list.Count > 0)
                    {
                        entity.Menus = JsonConvert.SerializeObject(list);
                    }
                    if (listevents != null && listevents.Count > 0)
                    {
                        entity.Powers = JsonConvert.SerializeObject(listevents);
                    }
                }
            }

            //处理文章和商品栏目权限
            string[] acpower = Request.Form["acpower"];
            string[] pcpower = Request.Form["pcpower"];

            List <int> acids = new List <int>();
            List <int> pcids = new List <int>();

            foreach (var item in acpower)
            {
                if (!string.IsNullOrEmpty(item) && Utils.IsInt(item))
                {
                    acids.Add(int.Parse(item));
                }
            }
            foreach (var item in pcpower)
            {
                if (!string.IsNullOrEmpty(item) && Utils.IsInt(item))
                {
                    pcids.Add(int.Parse(item));
                }
            }

            entity.AuthorizedArticleCagegory = JsonConvert.SerializeObject(acids);
            entity.AuthorizedCagegory        = JsonConvert.SerializeObject(pcids);

            entity.Update();
            tip.Status    = JsonTip.SUCCESS;
            tip.Message   = "编辑管理组详情成功";
            tip.ReturnUrl = "close";
            Core.Admin.WriteLogActions($"执行编辑管理组({entity.Id})详情;");
            return(Json(tip));
        }
Example #23
0
 public Task <bool> AdminMenuExist(AdminMenu adminMenu)
 {
     throw new System.NotImplementedException();
 }
Example #24
0
        public void ListAllTransactionHistory(List <SHBTransaction> listHistory)
        {
            int pageSize   = 10;
            var pageNumber = listHistory.Count < pageSize ? 0 : listHistory.Count / pageSize + 1;

            if (firtPage == 1)
            {
                Console.WriteLine("--- Lịch sử giao dịch ---");
                Console.WriteLine("-----------------------------");
                Console.WriteLine("#   " + "TransactionCode   " + "SenderAccountNumber   " + "ReceiverAccountNumber   " +
                                  "Type   " + "Amount   " + "Fee   " + "Message   " + "CreateAt   " + "UpdatedAt   " + "Status   ");
                var lengthPage = pageNumber > 0 ? currentPageIndex * 10 : listHistory.Count;
                if (pageNumber > 0)
                {
                    for (int i = 0; i < 10; i++)
                    {
                        Console.WriteLine((i + 1) + "   " + listHistory[i].TransactionCode + "   " + listHistory[i].SenderAccountNumber + "   " +
                                          listHistory[i].ReceiverAccountNumber + "   " + listHistory[i].Type + "   " +
                                          listHistory[i].Amount + "   " + listHistory[i].Fee + "   " + listHistory[i].Message + "   " +
                                          listHistory[i].CreateAt + "   " + listHistory[i].UpdatedAt + "   " + listHistory[i].Status);
                    }
                    Console.WriteLine("Số hàng trên trang: " + lengthPage + ", Số trang: 1/" + pageNumber);
                    Console.WriteLine("Vui lòng nhấp phím '>' để sang trang tiếp");
                    Console.WriteLine("Vui lòng nhấp phím '<' để quay lại trang trước");
                }
                else
                {
                    for (int i = 0; i < listHistory.Count; i++)
                    {
                        Console.WriteLine((i + 1) + "   " + listHistory[i].TransactionCode + "   " + listHistory[i].SenderAccountNumber + "   " +
                                          listHistory[i].ReceiverAccountNumber + "   " + listHistory[i].Type + "   " +
                                          listHistory[i].Amount + "   " + listHistory[i].Fee + "   " + listHistory[i].Message + "   " +
                                          listHistory[i].CreateAt + "   " + listHistory[i].UpdatedAt + "   " + listHistory[i].Status);
                    }
                    Console.WriteLine("Số hàng trên trang: " + lengthPage + ", Số trang: 1/" + (pageNumber + 1));
                }
            }
            else
            {
                Console.WriteLine("#   " + "TransactionCode   " + "SenderAccountNumber   " + "ReceiverAccountNumber   " +
                                  "Type   " + "Amount   " + "Fee   " + "Message   " + "CreateAt   " + "UpdatedAt   " + "Status   ");
                if (currentPageIndex != pageNumber)
                {
                    for (int j = (currentPageIndex - 1) * 10; j < currentPageIndex * 10; j++)
                    {
                        Console.WriteLine(j + "   " + listHistory[j].TransactionCode + "   " + listHistory[j].SenderAccountNumber + "   " +
                                          listHistory[j].ReceiverAccountNumber + "   " + listHistory[j].Type + "   " +
                                          listHistory[j].Amount + "   " + listHistory[j].Fee + "   " + listHistory[j].Message + "   " +
                                          listHistory[j].CreateAt + "   " + listHistory[j].UpdatedAt + "   " + listHistory[j].Status);
                    }
                    Console.WriteLine("Số hàng trên trang: " + 10 + ", Số trang: " + currentPageIndex + "/" + pageNumber);
                    Console.WriteLine("Vui lòng nhấp phím '>' để sang trang tiếp");
                    Console.WriteLine("Vui lòng nhấp phím '<' để quay lại trang trước");
                }
                else
                {
                    for (int j = (currentPageIndex - 1) * 10; j < listHistory.Count; j++)
                    {
                        Console.WriteLine(j + "   " + listHistory[j].TransactionCode + "   " + listHistory[j].SenderAccountNumber + "   " +
                                          listHistory[j].ReceiverAccountNumber + "   " + listHistory[j].Type + "   " +
                                          listHistory[j].Amount + "   " + listHistory[j].Fee + "   " + listHistory[j].Message + "   " +
                                          listHistory[j].CreateAt + "   " + listHistory[j].UpdatedAt + "   " + listHistory[j].Status);
                    }
                    Console.WriteLine("Số hàng trên trang: " + (listHistory.Count - (currentPageIndex - 1) * 10) + ", Số trang: " + pageNumber + "/" + pageNumber);
                    Console.WriteLine("Vui lòng nhấp phím '>' để sang trang tiếp");
                    Console.WriteLine("Vui lòng nhấp phím '<' để quay lại trang trước");
                }
            }

            while (true)
            {
                var keyB = Console.ReadKey(true).Key;
                if (listHistory.Count > 10)
                {
                    if (keyB == ConsoleKey.RightArrow)
                    {
                        firtPage = 2;
                        currentPageIndex++;
                        if (currentPageIndex > pageNumber)
                        {
                            currentPageIndex = 1;
                        }
                        ListAllTransactionHistory(listHistory);
                        break;
                    }
                    if (keyB == ConsoleKey.LeftArrow)
                    {
                        firtPage = 2;
                        currentPageIndex--;
                        if (currentPageIndex < 1)
                        {
                            currentPageIndex = pageNumber;
                        }
                        ListAllTransactionHistory(listHistory);
                        break;
                    }
                }
                if (keyB == ConsoleKey.Escape)
                {
                    if ((int)Program.currentLogin.Role == 1)
                    {
                        UserMenu.GenerateGuestMenu();
                    }
                    else
                    {
                        AdminMenu.GenerateAdminMenu();
                    }
                    break;
                }
            }
        }
        private void LoginBtn_Click(object sender, RoutedEventArgs e)
        {
            using (LibraryDBEntities db = new LibraryDBEntities())
            {
                var login = Login.Text;

                var password = Password.Password;

                var loginSearch = from user in db.Users
                                  where user.Login == login
                                  select user;

                var userResult = loginSearch.FirstOrDefault();



                try
                {
                    if (Login.Text != "" && Password.Password != "")
                    {
                        if (userResult != null)
                        {
                            if (password == userResult.Password)
                            {
                                if (userResult.RoleID == 1)
                                {
                                    AdminMenu menu = new AdminMenu(userResult.Id);
                                    menu.Show();

                                    StartingUC startUC = new StartingUC(st);
                                    st.startGrid.Children.Clear();
                                    st.startGrid.Children.Add(startUC);
                                }
                                if (userResult.RoleID == 2)
                                {
                                    UserMenu menu = new UserMenu(userResult.Id);
                                    menu.Show();
                                    StartingUC startUC = new StartingUC(st);
                                    st.startGrid.Children.Clear();
                                    st.startGrid.Children.Add(startUC);
                                }
                            }
                            else
                            {
                                MessageBox.Show("Wrong password!");
                            }
                        }

                        else
                        {
                            MessageBox.Show("Login not found!");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Fill in all fields!");
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message);
                }
            }
        }
Example #26
0
        private void BtnEntrar_Click(object sender, RoutedEventArgs e)
        {
            if (!txtUser.Text.Equals("") && !txtSenha.Password.Equals(""))
            {
                Dashboard   dashboard = new Dashboard();
                ProjetoMenu pm        = new ProjetoMenu();
                TarefaMenu  tm        = new TarefaMenu();
                AdminMenu   am        = new AdminMenu();
                CriarTarefa ct        = new CriarTarefa();


                u = LoginDAO.AutenticarUsuario(txtUser.Text, txtSenha.Password);
                //u.Nickname = txtUser.Text;

                if (u != null)
                {
                    //u = UsuarioDAO.BuscarUsuarioPorNome(u.Nickname);
                    if (u.Cargo.Equals("Gerente de projetos") || u.Cargo.Equals("Administrador"))
                    {
                        ValidaLogin.GerenteLogado = true;
                    }
                }

                #region Validações de acesso
                //Valida se admin logado, se sim, habilita botão de configuração do sistema
                if (!txtUser.Text.Equals("admin"))
                {
                    //Desabilita botão de config quando não é adm
                    dashboard.btnConfigurações.IsEnabled = false;
                    pm.btnConfigurações.IsEnabled        = false;
                    tm.btnConfigurações.IsEnabled        = false;
                    am.btnConfigurações.IsEnabled        = false;

                    //Atribui o valor do txtUser em uma variavel estatica
                    ValidaLogin.user        = txtUser.Text;
                    ValidaLogin.adminLogado = false;

                    //Insere nome do user logado na label branca do menu superior
                    dashboard.lbUserLogado.Foreground = new SolidColorBrush(Colors.White);
                    dashboard.lbUserLogado.Content    = ValidaLogin.user;

                    pm.lbUserLogado.Foreground = new SolidColorBrush(Colors.White);
                    pm.lbUserLogado.Content    = ValidaLogin.user;

                    tm.lbUserLogado.Foreground = new SolidColorBrush(Colors.White);
                    tm.lbUserLogado.Content    = ValidaLogin.user;


                    am.lbUserLogado.Foreground = new SolidColorBrush(Colors.White);
                    am.lbUserLogado.Content    = ValidaLogin.user;
                }
                else
                {
                    if (txtUser.Text.Equals("admin"))
                    {
                        //Habilita botão de config quando é adm
                        dashboard.btnConfigurações.IsEnabled = true;
                        pm.btnConfigurações.IsEnabled        = true;
                        tm.btnConfigurações.IsEnabled        = true;
                        am.btnConfigurações.IsEnabled        = true;

                        ValidaLogin.user        = txtUser.Text;
                        ValidaLogin.adminLogado = true;

                        dashboard.btnConfigurações.IsEnabled = true;

                        dashboard.lbUserLogado.Foreground = new SolidColorBrush(Colors.White);
                        dashboard.lbUserLogado.Content    = ValidaLogin.user;

                        pm.lbUserLogado.Foreground = new SolidColorBrush(Colors.White);
                        pm.lbUserLogado.Content    = ValidaLogin.user;

                        tm.lbUserLogado.Foreground = new SolidColorBrush(Colors.White);
                        tm.lbUserLogado.Content    = ValidaLogin.user;


                        am.lbUserLogado.Foreground = new SolidColorBrush(Colors.White);
                        am.lbUserLogado.Content    = ValidaLogin.user;
                    }
                    else
                    {
                        ValidaLogin.user = txtUser.Text;
                        dashboard.btnConfigurações.IsEnabled = false;

                        dashboard.lbUserLogado.Foreground = new SolidColorBrush(Colors.White);
                        dashboard.lbUserLogado.Content    = ValidaLogin.user;

                        pm.lbUserLogado.Foreground = new SolidColorBrush(Colors.White);
                        pm.lbUserLogado.Content    = ValidaLogin.user;

                        tm.lbUserLogado.Foreground = new SolidColorBrush(Colors.White);
                        tm.lbUserLogado.Content    = ValidaLogin.user;


                        am.lbUserLogado.Foreground = new SolidColorBrush(Colors.White);
                        am.lbUserLogado.Content    = ValidaLogin.user;
                    }
                }

                #endregion

                if (u != null)
                {
                    dashboard.Show();
                    this.Close();
                }
                else
                {
                    LimparCampos();
                    lbMensagem.Foreground = new SolidColorBrush(Colors.DarkRed);
                    MensagemDeConfirmacaoOuErro("Credenciais incorretas !");
                }
            }
            else
            {
                lbMensagem.Foreground = new SolidColorBrush(Colors.DarkRed);
                MensagemDeConfirmacaoOuErro("Preencha o LOGIN e SENHA para entrar !");
            }
        }
Example #27
0
 public AdminViewModel(AdminMenu openAdminMenu)
 {
     adminMenu   = openAdminMenu;
     newEmployee = new tblEmployee();
 }
Example #28
0
 public Task <bool> DeleteAdminMenu(AdminMenu adminMenu)
 {
     throw new System.NotImplementedException();
 }
        public async Task <ResponseResult <int> > Delete(AdminMenu model)
        {
            var serviceResult = await _adminMenuService.DeleteMenuAsync(model.Id);

            return(new ResponseResult <int>(true, serviceResult));
        }
 private void LoadMenu()
 {
     AdminMenu.SetMenu(this, this.HeaderBox, this.SubmenuBox, this.CopyrightBox);
 }
        public async Task <ResponseResult <int> > Add_Save(AdminMenu model)
        {
            var serviceResult = await _adminMenuService.AddModelAsync(model);

            return(new ResponseResult <int>(true, serviceResult));
        }