예제 #1
0
        public static HHConfiguration GetConfig()
        {
            HHConfiguration config = HHCache.Instance.Get(CacheKeyManager.HHConfigurationKey) as HHConfiguration;

            if (config == null)
            {
                lock (configLocker)
                {
                    config = HHCache.Instance.Get(CacheKeyManager.HHConfigurationKey) as HHConfiguration;
                    if (config == null)
                    {
                        string      path = HHConfiguration.ConfigFilePath;//GlobalSettings.MapPath("~/HHOnline.config");
                        XmlDocument doc  = new XmlDocument();
                        doc.Load(path);
                        config = new HHConfiguration(doc);
                        //更新缓存因子
                        HHCache.Instance.ResetFactor(config.CacheFactor);
                        //添加到缓存
                        FileDependency dp = new FileDependency(path);
                        HHCache.Instance.Max(CacheKeyManager.HHConfigurationKey, config, dp);
                    }
                }
            }
            return(config);
        }
        public static string EncodePassword(string pass)
        {
            string hashAlgorithmType = HHConfiguration.GetConfig()["encryptType"] != null?
                                       HHConfiguration.GetConfig()["encryptType"].ToString() : "SHA1";

            return(EncodePassword(pass, PasswordFormat.Hashed, hashAlgorithmType));
        }
        static StrategyFactory()
        {
            gradeStrategies = new Dictionary <string, Type>();
            strategies      = new List <KeyValue>();
            XmlNode node = HHConfiguration.GetConfig().GetConfigSection("HHOnline/GradeStrategy");

            if (node != null)
            {
                string itemName = string.Empty;
                string itemText = string.Empty;
                string itemType = string.Empty;
                Type   t        = null;
                foreach (XmlNode n in node.ChildNodes)
                {
                    if (n.NodeType != XmlNodeType.Comment)
                    {
                        if (n.Name == "add")
                        {
                            itemName = n.Attributes["name"].Value;
                            itemText = n.Attributes["text"].Value;
                            itemType = n.Attributes["type"].Value;
                            t        = Type.GetType(itemType);
                            if (t == null)
                            {
                                throw new Exception(itemType);
                            }
                            gradeStrategies.Add(itemName, t);
                            strategies.Add(new KeyValue(itemName, itemText));
                        }
                    }
                }
            }
        }
        /// <summary>
        /// 获取文件存储位置
        /// </summary>
        /// <param name="fileStoreKey">文件Key</param>
        /// <returns></returns>
        public static string GetFileStorageFolder(string fileStoreKey)
        {
            string baseFolder = HHConfiguration.GetConfig()["fileStorePath"].ToString();

            baseFolder = MapPath(baseFolder);
            baseFolder = Path.Combine(baseFolder, fileStoreKey);
            EnsureDirectoryExists(baseFolder);
            return(baseFolder);
        }
        /// <summary>
        /// 获取缓存配置实例
        /// </summary>
        /// <returns></returns>
        public static SearchConfiguration GetConfig()
        {
            SearchConfiguration config = HHCache.Instance.Get(CacheKeyManager.SearchConfigurationKey) as SearchConfiguration;

            if (config == null)
            {
                lock (configLocker)
                {
                    config = HHCache.Instance.Get(CacheKeyManager.SearchConfigurationKey) as SearchConfiguration;
                    if (config == null)
                    {
                        XmlNode node = HHConfiguration.GetConfig().GetConfigSection("HHOnline/LuceneSearch");
                        config = new SearchConfiguration(node);
                        //添加到缓存
                        FileDependency dp = new FileDependency(HHConfiguration.ConfigFilePath);
                        HHCache.Instance.Max(CacheKeyManager.SearchConfigurationKey, config, dp);
                    }
                }
            }
            return(config);
        }
예제 #6
0
        private static Hashtable GetResource(ResourceManagerType resourceType, string userLanguage, string fileName, bool defaultOnly)
        {
            string defaultLanguage = HHConfiguration.GetConfig().DefaultLanguage;
            string cacheKey        = "HHOnline/Framework/" + resourceType.ToString() + defaultLanguage + userLanguage + fileName;

            if (GlobalSettings.IsNullOrEmpty(userLanguage) || defaultOnly)
            {
                userLanguage = defaultLanguage;
            }

            Hashtable resources = HHCache.Instance.Get(cacheKey) as Hashtable;

            if (resources == null)
            {
                resources = new Hashtable();
                resources = LoadResource(resourceType, resources, defaultLanguage, cacheKey, fileName);
                if (defaultLanguage != userLanguage)
                {
                    resources = LoadResource(resourceType, resources, userLanguage, cacheKey, fileName);
                }
            }
            return(resources);
        }
 /// <summary>
 /// 生成盐值
 /// </summary>
 /// <returns></returns>
 private static string GenerateSalt()
 {
     byte[] buffer = Encoding.Unicode.GetBytes(HHConfiguration.GetConfig()["encryptSalt"].ToString());
     return(Convert.ToBase64String(buffer));
 }
예제 #8
0
 /// <summary>
 /// 判断是否支持<paramref name="language"/>语言
 /// </summary>
 /// <param name="language"></param>
 /// <returns>支持:language 反之默认语言</returns>
 public static string GetSupportedLanguage(string language)
 {
     return(GetSupportedLanguage(language, HHConfiguration.GetConfig().DefaultLanguage));
 }
        private GlobalApplication()
        {
            XmlNode sectionNode = HHConfiguration.GetConfig().GetConfigSection("HHOnline/GlobalApplication");

            LoadModules(sectionNode);
        }