コード例 #1
0
        public override ResourceSet GetResourceSet(CultureInfo culture, bool createIfNotExists, bool tryParents)
        {
            DBResourceSet databaseResourceSet;

            while (true)
            {
                if (ResourceSets.Contains(culture.Name) && (DBResourceSet)ResourceSets[culture.Name] != null)
                {
                    databaseResourceSet = (DBResourceSet)ResourceSets[culture.Name];
                }
                else
                {
                    databaseResourceSet = new DBResourceSet(_fileName, culture);
                    ResourceSets.Add(culture.Name, databaseResourceSet);
                }

                if (databaseResourceSet.TableCount != 0 || culture.Equals(CultureInfo.InvariantCulture))
                {
                    break;
                }

                culture = culture.Parent;
            }

            if (DateTime.UtcNow > _updateDate.AddSeconds(2))
            {
                GetResource.UpdateDBRS(databaseResourceSet, _fileName, culture.Name, _updateDate);
                _updateDate = DateTime.UtcNow;
            }

            return(databaseResourceSet);
        }
コード例 #2
0
        public override ResourceSet GetResourceSet(CultureInfo culture, bool createIfNotExists, bool tryParents)
        {
            var baseCulture = culture;

            DBResourceSet databaseResourceSet;

            while (true)
            {
                if (!ResourceSetsTable.TryGetValue(culture.Name, out databaseResourceSet))
                {
                    databaseResourceSet = new DBResourceSet(_fileName, culture);
                    ResourceSetsTable.TryAdd(culture.Name, databaseResourceSet);
                }

                if (!databaseResourceSet.DataIsEmpty)
                {
                    break;
                }

                if (culture.Equals(CultureInfo.InvariantCulture))
                {
                    return(_resManager.GetResourceSet(baseCulture, createIfNotExists, tryParents));
                }

                culture = culture.Parent;
            }

            if (0 < updateSeconds && DateTime.UtcNow > _updateDate.AddSeconds(2))
            {
                GetResource.UpdateDBRS(databaseResourceSet, _fileName, culture.Name, _updateDate);
                _updateDate = DateTime.UtcNow;
            }

            return(databaseResourceSet);
        }
コード例 #3
0
        public override ResourceSet GetResourceSet(CultureInfo culture, bool createIfNotExists, bool tryParents)
        {
            var baseCulture = culture;

            DBResourceSet databaseResourceSet;

            while (true)
            {
                if (!ResourceSetsTable.TryGetValue(culture.Name, out databaseResourceSet))
                {
                    databaseResourceSet = new DBResourceSet(_fileName, culture);
                    ResourceSetsTable.TryAdd(culture.Name, databaseResourceSet);
                }

                if (!databaseResourceSet.DataIsEmpty)
                    break;

                if (culture.Equals(CultureInfo.InvariantCulture))
                    return _resManager.GetResourceSet(baseCulture, createIfNotExists, tryParents);

                culture = culture.Parent;
            }

            if (0 < updateSeconds && DateTime.UtcNow > _updateDate.AddSeconds(2))
            {
                GetResource.UpdateDBRS(databaseResourceSet, _fileName, culture.Name, _updateDate);
                _updateDate = DateTime.UtcNow;
            }

            return databaseResourceSet;

        }
コード例 #4
0
 protected override ResourceSet InternalGetResourceSet(CultureInfo culture, bool createIfNotExists, bool tryParents)
 {
     resourceSets.TryGetValue(culture.Name, out var set);
     if (set == null)
     {
         var invariant = culture == CultureInfo.InvariantCulture ? base.InternalGetResourceSet(CultureInfo.InvariantCulture, true, true) : null;
         set = new DBResourceSet(Configuration, Option, DbContext, invariant, culture, BaseName);
         resourceSets.AddOrUpdate(culture.Name, set, (k, v) => set);
     }
     return(set);
 }
コード例 #5
0
        public static void UpdateDBRS(DBResourceSet databaseResourceSet, string fileName, string culture, DateTime date)
        {
            using (var dbManager = new DbManager("tmresourceTrans"))
            {
                var sql = new SqlQuery("res_data")
                          .Select("title", "textValue")
                          .InnerJoin("res_files", Exp.EqColumns("res_files.id", "res_data.fileID"))
                          .Where("ResName", fileName)
                          .Where("cultureTitle", culture)
                          .Where(Exp.Ge("timechanges", date));

                var list = dbManager.ExecuteList(sql);

                foreach (var t in list)
                {
                    databaseResourceSet.SetString(t[0], t[1]);
                }
            }
        }
コード例 #6
0
        public override ResourceSet GetResourceSet(CultureInfo culture, bool createIfNotExists, bool tryParents)
        {
            var baseCulture = culture;

            DBResourceSet databaseResourceSet;

            while (true)
            {
                if (ResourceSetsTable.Contains(culture.Name) && ResourceSetsTable[culture.Name] != null)
                {
                    databaseResourceSet = (DBResourceSet)ResourceSetsTable[culture.Name];
                }
                else
                {
                    databaseResourceSet = new DBResourceSet(_fileName, culture);
                    ResourceSetsTable.Add(culture.Name, databaseResourceSet);
                }

                if (databaseResourceSet.TableCount != 0)
                    break;

                if (culture.Equals(CultureInfo.InvariantCulture))
                    return _resManager.GetResourceSet(baseCulture, createIfNotExists, tryParents);

                culture = culture.Parent;
            }

            if (0 < updateSeconds && DateTime.UtcNow > _updateDate.AddSeconds(2))
            {
                GetResource.UpdateDBRS(databaseResourceSet, _fileName, culture.Name, _updateDate);
                _updateDate = DateTime.UtcNow;
            }

            return databaseResourceSet;

        }
コード例 #7
0
        public static void UpdateDBRS(DBResourceSet databaseResourceSet, string fileName, string culture, DateTime date)
        {
            using (var dbManager = new DbManager("tmresourceTrans"))
            {
                var sql = new SqlQuery("res_data")
                    .Select("title", "textValue")
                    .InnerJoin("res_files", Exp.EqColumns("res_files.id", "res_data.fileID"))
                    .Where("ResName", fileName)
                    .Where("cultureTitle", culture)
                    .Where(Exp.Ge("timechanges", date));

                var list = dbManager.ExecuteList(sql);

                foreach (var t in list)
                {
                    databaseResourceSet.SetString(t[0], t[1]);
                }
            }
        }