Exemplo n.º 1
0
        public QueryCacheItem GetQueryCacheItem(string collectionName, string query, string lastRequest)
        {
            lock (DBConnectionSync)
            {
                QueryCacheItem result = null;

                if (!TableExists <QueryCacheItem>(DBConnectionSync))
                {
                    DBConnectionSync.CreateTable <QueryCacheItem>();
                }
                else
                {
                    var items = DBConnectionSync.Table <QueryCacheItem>().Where(item => item.collectionName == collectionName && item.query == query);
                    if (items.Count() == 1)
                    {
                        foreach (QueryCacheItem item in items)
                        {
                            result = item;
                        }
                    }
                }

                return(result);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Clears the storage.
        /// </summary>
        public void clearStorage()
        {
            lock (DBConnectionSync)
            {
                if (TableExists <CollectionTableMap>(DBConnectionSync))
                {
                    List <CollectionTableMap> collections = DBConnectionSync.Table <CollectionTableMap>().ToList();
                    if (collections != null)
                    {
                        foreach (var collection in collections)
                        {
                            string dropQuery = $"DROP TABLE IF EXISTS {collection.TableName}";
                            DBConnectionSync.Execute(dropQuery);
                            GetSyncQueue(collection.CollectionName).RemoveAll();
                            mapCollectionToCache.Remove(collection.CollectionName);
                        }

                        DBConnectionSync.DeleteAll <CollectionTableMap>();

                        // Remove _QueryCache table
                        if (TableExists <QueryCacheItem>(DBConnectionSync))
                        {
                            DBConnectionSync.DeleteAll <QueryCacheItem>();
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the collection tables.
        /// </summary>
        /// <returns>The collection tables.</returns>
        public List <string> getCollectionTables()
        {
            lock (DBConnectionSync)
            {
                List <SQLTemplates.TableItem> result = DBConnectionSync.Table <SQLTemplates.TableItem>().OrderByDescending(t => t.name).ToList();
                List <string> collections            = new List <string>();

                foreach (SQLTemplates.TableItem item in result)
                {
                    collections.Add(item.name);
                }

                return(collections);
            }
        }