/// <summary> /// Creates a new language given the culture code - ie. da-dk (denmark) /// </summary> /// <param name="cultureCode">Culturecode of the language</param> public static void MakeNew(string cultureCode) { lock (Locker) { var culture = GetCulture(cultureCode); if (culture != null) { //insert it SqlHelper.ExecuteNonQuery( "insert into umbracoLanguage (languageISOCode) values (@CultureCode)", SqlHelper.CreateParameter("@CultureCode", cultureCode)); InvalidateCache(); //get it's id var newId = SqlHelper.ExecuteScalar <int>("SELECT MAX(id) FROM umbracoLanguage WHERE languageISOCode=@cultureCode", SqlHelper.CreateParameter("@cultureCode", cultureCode)); //load it and raise events using (var dr = SqlHelper.ExecuteReader(string.Format("{0} where id = {1}", m_SQLOptimizedGetAll, newId))) { while (dr.Read()) { var ct = new Language(); ct.PopulateFromReader(dr); ct.OnNew(new NewEventArgs()); } } } } }
/// <summary> /// Returns all installed languages /// </summary> /// <returns></returns> /// <remarks> /// This will return a cached set of all languages. if the cache is not found it will create it. /// </remarks> public static IEnumerable <Language> GetAllAsList() { return(ApplicationContext.Current.ApplicationCache.GetCacheItem <IEnumerable <Language> >( UmbracoLanguageCacheKey, TimeSpan.FromMinutes(60), () => { var languages = new List <Language>(); using (var dr = SqlHelper.ExecuteReader(m_SQLOptimizedGetAll)) { while (dr.Read()) { //create the ContentType object without setting up var ct = new Language(); ct.PopulateFromReader(dr); languages.Add(ct); } } return languages; })); }
/// <summary> /// Returns all installed languages /// </summary> /// <returns></returns> /// <remarks> /// This will return a cached set of all languages. if the cache is not found it will create it. /// </remarks> public static IEnumerable <Language> GetAllAsList() { return(Cache.GetCacheItem <IEnumerable <Language> >(UmbracoLanguageCacheKey, getLanguageSyncLock, TimeSpan.FromMinutes(60), delegate { var languages = new List <Language>(); using (IRecordsReader dr = SqlHelper.ExecuteReader(m_SQLOptimizedGetAll)) { while (dr.Read()) { //create the ContentType object without setting up Language ct = new Language(); ct.PopulateFromReader(dr); languages.Add(ct); } } return languages; })); }
/// <summary> /// Returns all installed languages /// </summary> /// <returns></returns> /// <remarks> /// This will return a cached set of all languages. if the cache is not found it will create it. /// </remarks> public static IEnumerable<Language> GetAllAsList() { return Cache.GetCacheItem<IEnumerable<Language>>(UmbracoLanguageCacheKey, getLanguageSyncLock, TimeSpan.FromMinutes(60), delegate { var languages = new List<Language>(); using (IRecordsReader dr = SqlHelper.ExecuteReader(m_SQLOptimizedGetAll)) { while (dr.Read()) { //create the ContentType object without setting up Language ct = new Language(); ct.PopulateFromReader(dr); languages.Add(ct); } } return languages; }); }
/// <summary> /// Creates a new language given the culture code - ie. da-dk (denmark) /// </summary> /// <param name="cultureCode">Culturecode of the language</param> public static void MakeNew(string cultureCode) { lock (Locker) { var culture = GetCulture(cultureCode); if (culture != null) { //insert it SqlHelper.ExecuteNonQuery( "insert into umbracoLanguage (languageISOCode) values (@CultureCode)", SqlHelper.CreateParameter("@CultureCode", cultureCode)); //get it's id var newId = SqlHelper.ExecuteScalar<int>("SELECT MAX(id) FROM umbracoLanguage WHERE languageISOCode=@cultureCode", SqlHelper.CreateParameter("@cultureCode", cultureCode)); //load it and raise events using (var dr = SqlHelper.ExecuteReader(string.Format("{0} where id = {1}", m_SQLOptimizedGetAll, newId))) { while (dr.Read()) { var ct = new Language(); ct.PopulateFromReader(dr); ct.OnNew(new NewEventArgs()); } } } } }
/// <summary> /// Returns all installed languages /// </summary> /// <returns></returns> /// <remarks> /// This will return a cached set of all languages. if the cache is not found it will create it. /// </remarks> public static IEnumerable<Language> GetAllAsList() { return ApplicationContext.Current.ApplicationCache.GetCacheItem<IEnumerable<Language>>( CacheKeys.LanguageCacheKey, TimeSpan.FromMinutes(60), () => { var languages = new List<Language>(); using (var dr = SqlHelper.ExecuteReader(m_SQLOptimizedGetAll)) { while (dr.Read()) { //create the ContentType object without setting up var ct = new Language(); ct.PopulateFromReader(dr); languages.Add(ct); } } return languages; }); }