Esempio n. 1
0
        //public void SetConnectionOracleDB()
        //{
        //    oracleConnection = new Services.ConnectOracleDB(CONNECT_STRING_STAGING);
        //}
        /// <summary>
        /// GET THE DATA USE FOR COMMON TARGET AS MENUS,....
        /// </summary>
        public void SetCommonData()
        {
            //this.SetConnectionDB();
            //BI_Project.Services.User.UserServices userServices = new UserServices(this.DBConnection);
            //ViewData["block_menu_left_data"] = userServices.GetListMenus((int)Session[this.SESSION_NAME_USERID],    (bool) Session["IsAdmin"]);

            this.SetConnectionDB();
            UserServices userServices = new UserServices(DBConnection);

            EntityUserModel currentUser = userServices.GetEntityById((int)Session[SESSION_NAME_USERID]);

            ViewData["block_menu_left_data"] = userServices.GetListMenus(currentUser);
            var          it           = ViewData["block_menu_left_data"];
            MenuServices menuServices = new MenuServices(DBConnection);

            var menuData = menuServices.GetMenusByDepId(currentUser.UserId, currentUser.DeptId);

            ViewData["MenuHeaderData"] = menuData;
        }
Esempio n. 2
0
        //public ActionResult List()
        //{
        //    if (null == Session[this.SESSION_NAME_USERID])
        //    {
        //        return RedirectToAction("Login", "Home");
        //    }
        //    if (Session["IsAdmin"] is false)
        //    {
        //        return RedirectToAction("Logout", "Home");
        //    }
        //    this.SetCommonData();
        //    ViewData["pagename"] = "menu_list";
        //    ViewData["action_block"] = "Menus/block_menu_list";


        //    this.GetLanguage();
        //    ViewData["VIEWDATA_LANGUAGE"] = this.LANGUAGE_OBJECT;


        //    BlockMenuListLangModel blockLang = new BlockMenuListLangModel();
        //    BI_Project.Models.UI.BlockModel blockModel = new Models.UI.BlockModel("block_menu_list", this.LANGUAGE_OBJECT, blockLang);
        //    //blockModel.DataModel = ViewData["block_menu_left_data"];
        //    blockModel.Hidden = 0;
        //    ViewData["BlockData"] = blockModel;
        //    return View("~/" + this.THEME_FOLDER + "/" + this.THEME_ACTIVE + "/index.cshtml");
        //}

        //lIST


        public ActionResult List(int?DeptID = null, int?userId = null, int?roleId = null)
        {
            if (Session["IsAdmin"] is false)
            {
                return(RedirectToAction("Logout", "Home"));
            }
            var _deptID = (int)Session["DepartIdUserLogin"];

            //DeptID = (int)Session["DepartIdUserLogin"];
            if (DeptID == null)
            {
                DeptID = _deptID;
            }

            //CheckAdminPermission();
            SetCommonData();
            MenuServices menuServices = new MenuServices(DBConnection);

            if (!Request.IsAjaxRequest())
            {
                if (null == Session[SESSION_NAME_USERID])
                {
                    return(RedirectToAction("Login", "Home"));
                }
                if (Session["IsAdmin"] is false)
                {
                    return(RedirectToAction("Logout", "Home"));
                }

                ViewData["pagename"]     = "menu_list";
                ViewData["action_block"] = "Menus/block_menu_list";

                GetLanguage();
                ViewData["VIEWDATA_LANGUAGE"] = LANGUAGE_OBJECT;

                BlockMenuListLangModel blockLang  = new BlockMenuListLangModel();
                BlockModel             blockModel = new BlockModel("block_menu_list", LANGUAGE_OBJECT, blockLang);
                Services.Departments.DepartmentServices departmentServices = new Services.Departments.DepartmentServices(this.DBConnection);

                ViewData["departments"]          = departmentServices.GetList();
                ViewData["listdepartmentsadmin"] = departmentServices.GetListAdminLogin((string)Session["CodeIsAdmin"]);



                ViewData["BlockData"] = blockModel;

                SetConnectionDB();

                var menuData = menuServices.GetMenusByDepId((int)Session[SESSION_NAME_USERID], DeptID);
                ViewData["CurrentOrgId"] = DeptID;
                ViewData["MenuData"]     = menuData;

                return(View("~/" + THEME_FOLDER + "/" + THEME_ACTIVE + "/index.cshtml"));
            }
            else
            {
                var menuData = menuServices.GetMenusByDepId((int)Session[SESSION_NAME_USERID], DeptID);
                // lấy danh sách quyền
                if (userId != null)
                {
                    var menuUserData = menuServices.GetUserMenusByUserId(userId.Value);
                    foreach (var item in menuData)
                    {
                        var inttt = menuUserData.IndexOf(item.MenuId);
                        if (menuUserData.IndexOf(item.MenuId) != -1)
                        {
                            item.Selected = true;
                        }
                        else
                        {
                            item.Selected = false;
                        }
                    }
                }
                else if (roleId != null)
                {
                    var menuUserData = menuServices.GetRoleMenusByRoleId(roleId.Value);
                    foreach (var item in menuData)
                    {
                        if (menuUserData.IndexOf(item.MenuId) != -1)
                        {
                            item.Selected = true;
                        }
                        else
                        {
                            item.Selected = false;
                        }
                    }
                }

                var uiMenuTreeHelper = new UIMenuTreeHelper(menuData);
                var uiMenuDataJson   = uiMenuTreeHelper.BuildMenuToJsonStr(uiMenuTreeHelper.RootId);
                return(Json((new JavaScriptSerializer()).Deserialize(uiMenuDataJson, typeof(object)), JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 3
0
        public ActionResult Create()
        {
            if (Session["IsAdmin"] == null || (bool)Session["IsAdmin"] == false)
            {
                return(RedirectToAction("Logout", "Home"));
            }
            this.SetCommonData();


            ViewData["pagename"]     = "user_create";
            ViewData["action_block"] = "Users/block_user_create";
            ViewData["data_form"]    = TempData["data"];

            string id = (Request.QueryString["id"] == null ? "0" : Request.QueryString["id"].ToString());

            this.SetConnectionDB();
            UserServices             services = new UserServices(this.DBConnection);
            BlockDataUserCreateModel model    = new BlockDataUserCreateModel();

            if (TempData["data"] != null)
            {
                model = (BlockDataUserCreateModel)ViewData["data_form"];
            }
            else
            {
                model = services.GetEntityById(Int32.Parse(id));
            }
            ViewData["data_form"] = model;
            Services.Departments.DepartmentServices departmentServices = new Services.Departments.DepartmentServices(this.DBConnection);

            ViewData["departments"]          = departmentServices.GetList();
            ViewData["listdepartmentsadmin"] = departmentServices.GetListAdminLogin((string)Session["CodeIsAdmin"]);
            ViewData["CurrentUser"]          = id;
            ViewData["currentOrgId"]         = model.DeptId;
            this.GetLanguage();
            if (model.UserId > 0)
            {
                ViewData["pagename"] = "user_edit";
            }

            BI_Project.Services.Roles.RoleServices roleServices = new Services.Roles.RoleServices(this.DBConnection);

            model.ListAllRoles = roleServices.GetList();

            MenuServices menuServices = new MenuServices(DBConnection);
            var          menuData     = menuServices.GetMenusByDepId((int)Session[SESSION_NAME_USERID]);

            //ViewData["CurrentDeptId"] = deptId;
            ViewData["MenuData"] = menuData;

            BlockLangUserCreateModel blockLang = new BlockLangUserCreateModel();

            BI_Project.Models.UI.BlockModel blockModel = new Models.UI.BlockModel("block_user_create", this.LANGUAGE_OBJECT, blockLang);
            blockModel.DataModel  = model;
            ViewData["BlockData"] = blockModel;

            if (roleServices.ERROR != null)
            {
                FileHelper.SaveFile(roleServices.ERROR, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + BI_Project.Helpers.Utility.APIStringHelper.GenerateFileId() + ".txt");
            }
            if (services.ERROR != null)
            {
                FileHelper.SaveFile(services.ERROR, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + BI_Project.Helpers.Utility.APIStringHelper.GenerateFileId() + ".txt");
            }

            return(View("~/" + this.THEME_FOLDER + "/" + this.THEME_ACTIVE + "/index.cshtml"));
        }