Example #1
0
 public static void Load(LightDBMapper mapper, bool failException)
 {
     try
     {
         if (ContentMgr.EnableCaching && mapper.SupportsCaching && mapper.LoadCache())
         {
             return;
         }
         mapper.Fetch();
         if (!ContentMgr.EnableCaching || !mapper.SupportsCaching)
         {
             return;
         }
         ContentMgr.log.Info("Saving cache for: " +
                             ((IEnumerable <DataHolderDefinition>)mapper.Mapping.DataHolderDefinitions)
                             .ToString <DataHolderDefinition>(", "));
         mapper.SaveCache();
     }
     catch (Exception ex)
     {
         if (failException)
         {
             throw new ContentException(ex, "Unable to load entries using \"{0}\"", new object[1]
             {
                 (object)mapper
             });
         }
     }
 }
Example #2
0
 public static void Load(LightDBMapper mapper, bool failException)
 {
     try
     {
         if (EnableCaching && mapper.SupportsCaching && mapper.LoadCache())
         {
             return;
         }
         mapper.Fetch();
         if (!EnableCaching || !mapper.SupportsCaching)
         {
             return;
         }
         log.Info("Saving cache for: " +
                  mapper.Mapping.DataHolderDefinitions
                  .ToString(", "));
         mapper.SaveCache();
     }
     catch (Exception ex)
     {
         if (failException)
         {
             throw new ContentException(ex, "Unable to load entries using \"{0}\"", (object)mapper);
         }
     }
 }
Example #3
0
        public static void Load(LightDBMapper mapper, bool failException)
        {
            try
            {
                if (EnableCaching && mapper.SupportsCaching)
                {
                    if (mapper.LoadCache())
                    {
                        // loaded cache successfully
                        return;
                    }
                }

                //Utility.Measure("Loading content from DB - " + mapper + "", 1, () => {
                mapper.Fetch();
                //});

                if (EnableCaching && mapper.SupportsCaching)
                {
                    log.Info("Saving cache for: " + mapper.Mapping.DataHolderDefinitions.ToString(", "));
                    mapper.SaveCache();
                }
            }
            catch (Exception e)
            {
                if (failException)
                {
                    throw new ContentException(e, "Unable to load entries using \"{0}\"", mapper);
                }
                // LogUtil.ErrorException(e, "Unable to load entries using \"{0}\"", mapper);
            }
        }
Example #4
0
        public static void SaveCache(this LightDBMapper mapper)
        {
            string cacheFilename = mapper.GetCacheFilename();

            try
            {
                mapper.SaveCache(cacheFilename);
            }
            catch (Exception ex)
            {
                File.Delete(cacheFilename);
                LogUtil.ErrorException(ex, "Failed to save cache to file: " + cacheFilename, new object[0]);
            }
        }
Example #5
0
        public static void SaveCache(this LightDBMapper mapper)
        {
            // save cache after loading
            var file = GetCacheFilename(mapper);

            try
            {
                mapper.SaveCache(file);
            }
            catch (Exception e)
            {
                File.Delete(file);
                LogUtil.ErrorException(e, "Failed to save cache to file: " + file);
            }
        }