Exemple #1
0
        public static RoleRightDAL getInstance(string json = null)
        {
            if (null == _DataDal)
            {
                lock (_loker)
                {
                    if (null == _DataDal)
                    {
                        _DataDal = new RoleRightDAL();
                    }
                }
            }

            return(_DataDal);
        }
Exemple #2
0
        private string queryMenuInf(int userID, DateTime?lastTime)
        {
            string   retValue = "unknown process.";
            IDBCache dbCache  = (null == _dbCacheFactory)?null:_dbCacheFactory.DefautCache;

            if (null != dbCache && null != lastTime && DateTime.Now.Subtract((DateTime)lastTime).TotalSeconds < 3)
            {
                return(string.Empty);
            }
            MenuInfAdapter menuAdp = new MenuInfAdapter();

            List <MenuInf>         listMenu  = new List <MenuInf>();
            IList <t_CM_RoleRight> roleRight = RoleRightDAL.getInstance().GetRoles(userID);

            if (null == roleRight || roleRight.Count() < 1)
            {
                return(JsonConvert.SerializeObject(listMenu));
            }
            string moduleIDS         = string.Join(",", roleRight.Select(c => c.ModuleID));
            IList <t_CM_Module> data = new List <t_CM_Module>();//

            try
            {
                //string query = "select * from  t_CM_Module  where ModuleID in(" + moduleIDS + ");";
                //using (IModule _hisDataDao = new ModuleDBContext())
                //{
                //    data = (_hisDataDao as IDAOBase).SQLQuery<t_CM_Module>(query);
                //}
                data = _dbFactory.module.GetModules(moduleIDS);
                var menu1 = from s in data where s.ParentID == 0 orderby s.SN select s;
                foreach (t_CM_Module model in menu1)
                {
                    MenuInf menu = new MenuInf();
                    listMenu.Add(menu);
                    menu.moduleParent = model;
                    int mid = (int)model.ModuleID;

                    List <t_CM_Module> list2 = (from s in data where s.ParentID == model.ModuleID orderby s.SN select s).ToList <t_CM_Module>();
                    //ViewData["list" + mid] = list2;
                    menu.childern        = list2;
                    menu.disenableModule = (from s in roleRight where s.Disenable select s).ToList <t_CM_RoleRight>();
                    //隐藏链接
                    var right = from c in menu.disenableModule where c.ModuleID == model.ModuleID && c.Disenable select c;
                    if (right.Count() > 0)
                    {
                        model.Location = "#";
                    }
                    foreach (var m in menu.childern)
                    {
                        right = from c in menu.disenableModule where c.ModuleID == m.ModuleID && c.Disenable select c;
                        if (right.Count() > 0)
                        {
                            m.Location = "#";
                        }
                    }
                }
                retValue = JsonConvert.SerializeObject(listMenu);
                //redis.StringSet(key + "_" + DateTime.Now.ToString(), retValue);
                menuAdp.dateTime    = DateTime.Now;
                menuAdp.menuInfJson = retValue;
                if (null != dbCache)
                {
                    string key = "user_" + userID;
                    dbCache.HashSet(MenuKey, key, menuAdp);
                }
                data.Clear();
                data = null;
                roleRight.Clear();
                roleRight = null;
                menuAdp   = null;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(retValue);
        }