Esempio n. 1
0
        public static List <AuthEntity> GetAllAuth()
        {
            var allAuth = MemoryCacheUtils.Get("GetAllAuth") as List <AuthEntity>;

            if (allAuth == null)
            {
                allAuth = AuthDA.GetAllAuth();
                MemoryCacheUtils.Set("GetAllAuth", allAuth);
            }
            return(allAuth);
        }
Esempio n. 2
0
        /// <summary>
        /// 保存用户信息
        /// </summary>
        public static void SaveUserInfoToCache(UserInfo user)
        {
            UserInfo accountEntities = MemoryCacheUtils.Get(user.LoginName) as UserInfo;

            if (accountEntities == null)
            {
                CacheItemPolicy policy = new CacheItemPolicy();
                policy.Priority = CacheItemPriority.NotRemovable;
                MemoryCacheUtils.Set(user.LoginName, user, policy);
            }
        }
Esempio n. 3
0
        public static List <DepartmentEntity> GetAllDepartment()
        {
            var key = "GetAllDepartmentEntity";
            var all = MemoryCacheUtils.Get(key) as List <DepartmentEntity>;

            if (all == null)
            {
                all = DepartmentDA.GetAllDepartment();
                MemoryCacheUtils.Set(key, all);
            }
            return(all);
        }
Esempio n. 4
0
        public static List <AccountAuthEntity> GetAccountAuthByAccountId(int accountId)
        {
            var key            = "GetAccountAuthByAccountId_" + accountId;
            var allAccountAuth = MemoryCacheUtils.Get(key) as List <AccountAuthEntity>;

            if (allAccountAuth == null)
            {
                allAccountAuth = AccountAuthDA.GetAccountAuthByAccountId(accountId);
                MemoryCacheUtils.Set(key, allAccountAuth);
            }
            return(allAccountAuth);
        }
Esempio n. 5
0
        /// <summary>
        /// 根据用户名称获取用户信息
        /// </summary>
        /// <param name="userName"></param>
        public static UserInfo GetUserInfoByUserName(string userName)
        {
            UserInfo accountEntities = MemoryCacheUtils.Get(userName) as UserInfo;

            if (accountEntities == null)
            {
                USER userObJ = UserDA.GetUserByLoginName(userName);
                accountEntities = new UserInfo();
                if (userObJ != null)
                {
                    accountEntities.UserId              = userObJ.ID;
                    accountEntities.UserName            = userObJ.KEYED_NAME;
                    accountEntities.LoginName           = userObJ.LOGIN_NAME;
                    accountEntities.Password            = userObJ.PASSWORD;
                    accountEntities.Email               = userObJ.EMAIL;
                    accountEntities.b_JobNumber         = userObJ.B_JOBNUMBER;
                    accountEntities.b_AffiliatedCompany = userObJ.B_AFFILIATEDCOMPANY;
                    accountEntities.language            = "Chinese";
                }
            }
            return(accountEntities);
        }
        /// <summary>
        /// 根据中文字符获取对应的英文字符
        /// </summary>
        /// <param name="chineseValue"></param>
        /// <param name="languageCategory"></param>
        /// <returns></returns>
        public string GetLanguageValueByParam(string chineseValue, string languageCategory, string fileName)
        {
            string languageType = Userinfo.language;

            //string languageType = System.Threading.Thread.CurrentThread.CurrentCulture.Name;
            if (languageType.IndexOf("zh") > 0)
            {
                return(chineseValue);
            }
            else
            {
                string value = MemoryCacheUtils.Get(chineseValue) as string;
                if (string.IsNullOrEmpty(value))
                {
                    //获取语言数据
                    string filePath = AppDomain.CurrentDomain.BaseDirectory + @"App_Data\" + fileName + ".json";
                    String jsonStr  = Common.GetFileJson(filePath);
                    value = Common.GetKeyValue(jsonStr, languageCategory, chineseValue);
                }
                return(value);
            }
        }