Example #1
0
        public static ExistsTableCache FromFile()
        {
            var file   = CoreHelper.RequestHelper.GetFilePath(confgiFile);
            var folder = CoreHelper.RequestHelper.GetFilePath(@"\config");

            if (!System.IO.Directory.Exists(folder))
            {
                System.IO.Directory.CreateDirectory(folder);
            }
            ExistsTableCache cache = null;
            var server             = CoreHelper.RequestHelper.GetServerIp();

            if (System.IO.File.Exists(file))
            {
                try
                {
                    //cache = CoreHelper.SerializeHelper.BinaryDeserialize<ExistsTableCache>(file);
                    //cache = CoreHelper.SerializeHelper.XmlDeserialize<ExistsTableCache>(file);
                    var json = System.IO.File.ReadAllText(file);
                    cache = (ExistsTableCache)CoreHelper.SerializeHelper.SerializerFromJSON(json, typeof(ExistsTableCache), Encoding.UTF8);
                    //不是同一服务器创建的缓存则重建
                    if (cache.Server != server)
                    {
                        cache = new ExistsTableCache()
                        {
                            Server = server
                        };
                    }
                }
                catch { }
            }
            if (cache == null)
            {
                cache = new ExistsTableCache()
                {
                    Server = server
                }
            }
            ;
            return(cache);
        }
Example #2
0
 public static ExistsTableCache FromFile()
 {
     var file = CoreHelper.RequestHelper.GetFilePath(confgiFile);
     var folder = CoreHelper.RequestHelper.GetFilePath(@"\config");
     if (!System.IO.Directory.Exists(folder))
     {
         System.IO.Directory.CreateDirectory(folder);
     }
     ExistsTableCache cache = null;
     var server = CoreHelper.RequestHelper.GetServerIp();
     if (System.IO.File.Exists(file))
     {
         try
         {
             //cache = CoreHelper.SerializeHelper.BinaryDeserialize<ExistsTableCache>(file);
             //cache = CoreHelper.SerializeHelper.XmlDeserialize<ExistsTableCache>(file);
             var json = System.IO.File.ReadAllText(file);
             cache = (ExistsTableCache)CoreHelper.SerializeHelper.SerializerFromJSON(json, typeof(ExistsTableCache), Encoding.UTF8);
             //不是同一服务器创建的缓存则重建
             if (cache.Server != server)
             {
                 cache = new ExistsTableCache() { Server = server };
             }
         }
         catch { }
     }
     if (cache == null)
         cache = new ExistsTableCache() { Server = server };
     return cache;
 }