Ejemplo n.º 1
0
 public TempPermissionModel Get(Guid id)
 {
     var service = new SecurityService();
     TempPermissionModel result = new TempPermissionModel();
     result.Data = service.GetAllPermission(id);
     return result;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// [Hien.Nguyen]
 /// </summary>
 /// <param name="userID"></param>
 /// <returns></returns>
 public TempPermissionModel Put(PermissionModel userID)
 {
     var service = new SecurityService();
     TempPermissionModel result = new TempPermissionModel();
     result.Data = service.GetAllPermission(userID.UserID);
     return result;
 }
Ejemplo n.º 3
0
 public ActionResult GetPermissionForGeneralProfile()
 {
     Guid userId = Guid.Empty;
     if (Session[SessionObjects.UserId] != null)
     {
         if (Session[SessionObjects.UserId].ToString() != Common.UserNameSystem)
         {
             userId = (Guid)Session[SessionObjects.UserId];
         }
         else
         {
             return Json(new List<string>());
         }
     }
     PermissionModel permission = new PermissionModel();   //do không truyền kiểu string lên được nên mượn model có guid để truyền lên api
     permission.UserID = userId;
     TempPermissionModel result = new TempPermissionModel();
     var service = new RestServiceClient<TempPermissionModel>(UserLogin);
     if (HttpContext.Cache[SessionObjects.Permission + userId] == null)
     {
         service.SetCookies(this.Request.Cookies, _hrm_Sys_Service);
         result = service.Put(_hrm_Sys_Service, "api/SysPermission/", permission);
         //lưu cache quyền của user
         HttpContext.Cache[SessionObjects.Permission + userId] = result;
     }
     else
     {
         result = (TempPermissionModel)HttpContext.Cache[SessionObjects.Permission + userId];
     }
     return Json(result.Data);
 }
Ejemplo n.º 4
0
        public ActionResult LoadMenu()
        {
            //try
            //{
            #region Load Menu
            var siteMap = new HRM.Presentation.UI.Controls.Menu.XmlSiteMap();
            if (HttpContext.Cache["SiteMap"] == null)
            {
                var serviceMaster = new RestServiceClient<List<Rep_MasterModel>>(UserLogin);
                serviceMaster.SetCookies(this.Request.Cookies, _hrm_Sys_Service);
                siteMap.LoadFrom("~/Mvc.sitemap");

                var listMaster = serviceMaster.Get(_hrm_Sys_Service, "api/Rep_Control/", Guid.NewGuid());
                UI.Controls.Menu.SiteMapNode _tmp;
                if (listMaster != null && listMaster.Count > 0)
                {
                    foreach (var i in siteMap.RootNode.ChildNodes)
                    {
                        if (i.ChildNodes.Count > 0)
                        {
                            switch (i.HrmWebSite)
                            {
                                case "Hrm_Rec_Web":
                                    _tmp = CreateMenuForCustomReport(siteMap, listMaster, ModuleName.Recruitment, i.ChildNodes.FirstOrDefault().Alias);
                                    if (_tmp != null)
                                    {
                                        i.ChildNodes.Add(_tmp);
                                    }
                                    break;
                                case "Hrm_Eva_Web":
                                    _tmp = CreateMenuForCustomReport(siteMap, listMaster, ModuleName.Evaluation, i.ChildNodes.FirstOrDefault().Alias);
                                    if (_tmp != null)
                                    {
                                        i.ChildNodes.Add(_tmp);
                                    }
                                    break;
                                case "Hrm_Main_Web":
                                    _tmp = CreateMenuForCustomReport(siteMap, listMaster, ModuleName.HR, i.ChildNodes.FirstOrDefault().Alias);
                                    if (_tmp != null)
                                    {
                                        i.ChildNodes.Add(_tmp);
                                    }
                                    break;
                                case "Hrm_Att_Web":
                                    _tmp = CreateMenuForCustomReport(siteMap, listMaster, ModuleName.Attendance, i.ChildNodes.FirstOrDefault().Alias);
                                    if (_tmp != null)
                                    {
                                        i.ChildNodes.Add(_tmp);
                                    }
                                    break;
                                case "Hrm_Sal_Web":
                                    _tmp = CreateMenuForCustomReport(siteMap, listMaster, ModuleName.Salary, i.ChildNodes.FirstOrDefault().Alias);
                                    if (_tmp != null)
                                    {
                                        i.ChildNodes.Add(_tmp);
                                    }
                                    break;
                                case "Hrm_Can_Web":
                                    _tmp = CreateMenuForCustomReport(siteMap, listMaster, ModuleName.Canteen, i.ChildNodes.FirstOrDefault().Alias);
                                    if (_tmp != null)
                                    {
                                        i.ChildNodes.Add(_tmp);
                                    }
                                    break;
                                case "Hrm_Lau_Web":
                                    _tmp = CreateMenuForCustomReport(siteMap, listMaster, ModuleName.Laundry, i.ChildNodes.FirstOrDefault().Alias);
                                    if (_tmp != null)
                                    {
                                        i.ChildNodes.Add(_tmp);
                                    }
                                    break;
                                case "Hrm_Cat_Web":
                                    _tmp = CreateMenuForCustomReport(siteMap, listMaster, ModuleName.Category, i.ChildNodes.FirstOrDefault().Alias);
                                    if (_tmp != null)
                                    {
                                        i.ChildNodes.Add(_tmp);
                                    }
                                    break;
                                case "Hrm_Ins_Web":
                                    _tmp = CreateMenuForCustomReport(siteMap, listMaster, ModuleName.Insurance, i.ChildNodes.FirstOrDefault().Alias);
                                    if (_tmp != null)
                                    {
                                        i.ChildNodes.Add(_tmp);
                                    }
                                    break;
                                case "Hrm_Sys_Web":
                                    _tmp = CreateMenuForCustomReport(siteMap, listMaster, ModuleName.System, i.ChildNodes.FirstOrDefault().Alias);
                                    if (_tmp != null)
                                    {
                                        i.ChildNodes.Add(_tmp);
                                    }
                                    break;

                                default:
                                    break;
                            }
                        }
                    }
                }

                HttpContext.Cache["SiteMap"] = siteMap;
            }
            else
            {
                siteMap = (HRM.Presentation.UI.Controls.Menu.XmlSiteMap)HttpContext.Cache["SiteMap"];
            }
            #endregion

            #region Load Permission
            TempPermissionModel result = new TempPermissionModel();
            Guid userId = Guid.Empty;
            if (Session[SessionObjects.UserId] != null)
            {
                if (Session[SessionObjects.UserId].ToString() != Common.UserNameSystem)
                {
                    userId = (Guid)Session[SessionObjects.UserId];
                }
                else
                {
                    return View(new List<string>());
                }
            }
            PermissionModel permission = new PermissionModel();   //do không truyền kiểu string lên được nên mượn model có guid để truyền lên api
            permission.UserID = userId;

            var service = new RestServiceClient<TempPermissionModel>(UserLogin);
            if (HttpContext.Cache[SessionObjects.Permission + userId] == null)
            {
                service.SetCookies(this.Request.Cookies, _hrm_Sys_Service);
                result = service.Put(_hrm_Sys_Service, "api/SysPermission/", permission);
                //lưu cache quyền của user
                if (result != null)
                {
                    HttpContext.Cache[SessionObjects.Permission + userId] = result;
                }
            }
            else
            {
                result = (TempPermissionModel)HttpContext.Cache[SessionObjects.Permission + userId];
            }
            #endregion

            if (result != null)
            {
                List<string> modelResult = GetPermissionCurrentUser(result.Data, siteMap.RootNode.ChildNodes.ToList()).Distinct().ToList();
                modelResult.Add(siteMap.RootNode.ControllerName);//Add Quyền View Của Trang Home
                modelResult.Add("Sys_CustomReport");
                return View(modelResult);
            }
            return View();
            //}
            //catch
            //{
            //    return View();
            //}
        }