示例#1
0
        private List <TreeViewObject> buildTreeApplication(List <Application> application, string userName, long?Role)
        {
            CacheUser cacheUser = LVCacheHelper.GetCacheUser(userName);

            if (cacheUser == null)
            {
                return(null);
            }
            int indexs   = 1;
            var roleList = cacheUser.roleList.Where(x => x.RoleID == Role).FirstOrDefault();;

            if (roleList != null)
            {
                foreach (var item in application)
                {
                    foreach (var app in roleList.application)
                    {
                        item.IsShow = app.AppFuncID == item.AppFuncID ? true : false;
                        if (item.IsShow == true)
                        {
                            break;
                        }
                    }
                }
            }

            var parent = application.Where(x => x.PAppFuncID == null).ToList();
            List <TreeViewObject> treeParent = new List <TreeViewObject>();

            foreach (var item in parent)
            {
                Application applications = new Application();
                applications.AppFunctions   = item.AppFunctions;
                applications.Badge          = item.Badge;
                applications.IsLongTile     = item.IsLongTile;
                applications.AppFuncID      = item.AppFuncID;
                applications.IconPath       = item.IconPath;
                applications.LandingPageURL = item.LandingPageURL;
                applications.PAppFuncID     = item.PAppFuncID;
                applications.Idx            = item.Idx;
                applications.AppTitle       = item.AppTitle.Replace("|n|", "");
                applications.AppDesc        = item.AppDesc;
                applications.ColorSchema    = item.ColorSchema;
                applications.Colors         = string.IsNullOrEmpty(item.ColorSchema) ? null : item.ColorSchema.Split(';');
                applications.NotDisplayed   = item.NotDisplayed;
                applications.FuncType       = item.FuncType;
                var trs = new TreeViewObject()
                {
                    application = applications
                };
                buildTree(trs, application);
                trs.dataindex = indexs;
                treeParent.Add(trs);
                indexs++;
            }
            return(treeParent);
        }
示例#2
0
        //Ktra co quyen tren application
        public bool IsPermision(string userName, string FunctionID, string ActionName, string Role)
        {
            try
            {
                var user = LVCacheHelper.GetCacheUser(userName);
                if (FunctionID == null)
                {
                    return(true);
                }
                var appId = long.Parse(FunctionID);
                if (user != null)
                {
                    long role = long.Parse(Role);
                    var  applicationByRole = (from h in user.roleList
                                              from i in h.application
                                              where h.RoleID == role && i.AppFuncID == appId
                                              select i).FirstOrDefault();
                    if (applicationByRole != null)
                    {
                        var permission = (from h in user.PrivilegeRole
                                          where h.AppFuncID == applicationByRole.AppFuncID
                                          select h.PersPer).FirstOrDefault();
                        if (permission != null)
                        {
                            var perByRole = permission.Where(x => x == ActionName || x == "SS" || x == "SA").FirstOrDefault();
                            if (perByRole != null)
                            {
                                return(true);
                            }
                        }
                    }
                    return(false);
                }

                return(false);
            }
            catch (Exception ex)
            {
                return(false);
            }
            //var per = (from i in LVCacheHelper.GetCacheUser(userName).UMS_tblUserPermission.Where(o => o.FunctionID == FunctionID && o.ActionName == ActionName)
            //           group i by i.ActionName into grp
            //           select new
            //           {
            //               Value = grp.Max(o => o.Value)
            //           }).FirstOrDefault();
            var model = LVCacheHelper.GetCacheUser(userName);
            var func  = long.Parse(FunctionID);
            //var per = (from h in model.PrivilegeRole
            //           join i in model.FunctionPermision on h.AppFuncID equals i.AppFuncID
            //           where i.AppFuncID == func
            //           select h.PersPer).ToList();
            bool isView = false;

            //if (per != null)
            //    isView = per.Value != 0;
            //isView = isView || LVCacheHelper.GetCacheUser(userName).UMS_tblUserAccount.FAdm || LVCacheHelper.GetCacheUser(userName).UMS_tblUserAccount.FSpv;
            //if (per.Count > 0)
            //{
            //    var action = per[0].Find(x => x == ActionName);
            //    if (action.Length > 0)
            //    {
            //        isView = true;
            //    }
            //}
            return(isView);
        }
示例#3
0
 //Ktra user co cache user. Neu xoa cache phai login lai
 public bool IsCacheUser(string username)
 {
     return(LVCacheHelper.GetCacheUser(username) != null);
 }