public void Init()
        {
            _className = this.GetType().Name;

            Runnable.EnableRunnableInEditor();

            _allTilesetNames = new string[] {
                TS_NO_OVERWRITE
                , TS_FORCE_OVERWRITE
                , TS_CONCURRENT1
                , TS_CONCURRENT2
                , TS_CONCURRENT3
                , TS_CONCURRENT4
                , TS_PRUNE
                , TS_REINIT
            };

            Vector2d       southWest = new Vector2d(48.2174, 16.3662);
            Vector2d       northEast = new Vector2d(48.2310, 16.3877);
            Vector2dBounds bounds    = new Vector2dBounds(southWest, northEast);

            _tileIds = TileCover.Get(bounds, 19);


            // delete cache from previous runs
            string dbFullPath = SQLiteCache.GetFullDbPath(_dbName);

            if (File.Exists(dbFullPath))
            {
                File.Delete(dbFullPath);
            }

            _cache = new SQLiteCache(_maxCacheTileCount, _dbName);
        }
 public void Cleanup()
 {
     if (null != _cache)
     {
         _cache.Dispose();
         _cache = null;
     }
 }
예제 #3
0
        public CustomsForgeHandler(SQLiteCache databaseCache)
        {
            DatabaseCache = databaseCache;

            Logger.Log("[CustomsForge] Checking for new songs...");

            var cookies = Program.config.customsForgeSettings.Cookie;

            if (string.IsNullOrEmpty(cookies))
            {
                Logger.LogError(
                    "[CustomsForge] You need to set the cookie. To do this, open up your browser and click 'CTRL+SHIFT+I'. " +
                    "Click on the tab at the top that says 'Network' (if you don't see it, click on the expansion arrow on the right side of the top bar) and select 'All' as the subheading. " +
                    "Load up 'http://ignition.customsforge.com' and ensure you are still in the Network tab. Look for the entry that says '200 POST' and click it. On the right you should see some headings. " +
                    "Go under 'Request headers' and copy the value after the 'Cookie:' entry. Ensure you copy it in it's entirety (click on it and click CTRL+A and CTRL+C to copy). " +
                    "Paste that after the 'cookie:' part in the config file named 'customsForge.json'.");

                return;
            }

            SetUpCookieContainer(cookies);

            Client.DefaultRequestHeaders.UserAgent.ParseAdd(USER_AGENT);
            Client.DefaultRequestHeaders.Accept.ParseAdd("application/json, text/javascript, */*; q=0.01");

            CreatorsToIgnore = Program.config.customsForgeSettings.CreatorsToIgnore.Split('|')
                               .Select(x => x.Trim().ToLower())
                               .Distinct()
                               .ToList()
                               .FindAll(x => !string.IsNullOrEmpty(x));

            FoldersToIgnore = Program.config.customsForgeSettings.FoldersToIgnore.Split('|')
                              .Select(x => x.Trim().ToLower())
                              .Distinct()
                              .ToList()
                              .FindAll(x => !string.IsNullOrEmpty(x));

            CheckForNewSongs();
        }
예제 #4
0
 public void Remove_Returns_Zero()
 {
     SQLiteCache cache = new SQLiteCache(1,1);
     int actual = cache.Remove("asdasd");
     Assert.IsTrue(actual == 0);
 }
예제 #5
0
 public void GetValue_Returns_Null()
 {
     SQLiteCache cache = new SQLiteCache(1,1);
     object actual = cache.GetValue("123123123");
     Assert.IsNull(actual);
 }
        public static async Task RunSampleAsync()
        {
            using (SqliteConnection db =
                       new SqliteConnection("Filename=sqliteSample.db"))
            {
                db.Open();



                /*
                 *
                 * USE [CacheSampleDb]
                 * GO
                 *
                 *
                 * SET ANSI_NULLS ON
                 * GO
                 *
                 * SET QUOTED_IDENTIFIER ON
                 * GO
                 *
                 * CREATE TABLE[dbo].[TestCache]
                 * (
                 *
                 * [Id] NVARCHAR (449)     COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL,
                 *
                 * [Value]                      VARBINARY(MAX)    NOT NULL,
                 *
                 * [ExpiresAtTime]              DATETIMEOFFSET(7) NOT NULL,
                 *
                 * [SlidingExpirationInSeconds] BIGINT NULL,
                 *
                 * [AbsoluteExpiration]         DATETIMEOFFSET(7) NULL
                 * );
                 *
                 *
                 * GO
                 * CREATE NONCLUSTERED INDEX[Index_ExpiresAtTime]
                 * ON[dbo].[TestCache] ([ExpiresAtTime] ASC);
                 *
                 *
                 *
                 *
                 *
                 */
                String tableCommand = "CREATE TABLE IF NOT " +
                                      "EXISTS TestCache (Id NVARCHAR(499) PRIMARY KEY, " +
                                      "Value NVARCHAR(2048) NULL)";

                SqliteCommand createTable = new SqliteCommand(tableCommand, db);

                createTable.ExecuteReader();
            }


            var configurationBuilder = new ConfigurationBuilder();
            var configuration        = configurationBuilder
                                       .AddJsonFile("config.json")
                                       .AddEnvironmentVariables()
                                       .Build();

            var key     = Guid.NewGuid().ToString();
            var message = "Hello, World!";
            var value   = Encoding.UTF8.GetBytes(message);

            Console.WriteLine("Connecting to cache");
            var cache = new SQLiteCache(new SQLiteCacheOptions()
            {
                ConnectionString = configuration["SQLiteConnectionString"],
                //  SchemaName = configuration["SchemaName"],
                TableName = configuration["TableName"]
            });

            Console.WriteLine("Connected");



            Console.WriteLine("Cache item key: {0}", key);
            Console.WriteLine($"Setting value '{message}' in cache");
            await cache.SetAsync(
                key,
                value,
                new DistributedCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromSeconds(10)));

            Console.WriteLine("Set");

            Console.WriteLine("Getting value from cache");
            value = await cache.GetAsync(key);

            if (value != null)
            {
                Console.WriteLine("Retrieved: " + Encoding.UTF8.GetString(value, 0, value.Length));
            }
            else
            {
                Console.WriteLine("Not Found");
            }

            Console.WriteLine("Refreshing value in cache");
            await cache.RefreshAsync(key);

            Console.WriteLine("Refreshed");

            Console.WriteLine("Removing value from cache");
            await cache.RemoveAsync(key);

            Console.WriteLine("Removed");

            Console.WriteLine("Getting value from cache again");
            value = await cache.GetAsync(key);

            if (value != null)
            {
                Console.WriteLine("Retrieved: " + Encoding.UTF8.GetString(value, 0, value.Length));
            }
            else
            {
                Console.WriteLine("Not Found");
            }

            Console.ReadLine();
        }