Beispiel #1
0
        public void Load(string service, string method, string query, CacheObjectType type)
        {
            Log.Debug($"Loading cache data for {service}::{method} of type {type}");

            // if the cache already exists do not generate it again!
            if (this.Exists(service, method) == true)
            {
                return;
            }

            try
            {
                MySqlConnection connection  = null;
                MySqlDataReader reader      = Database.Query(ref connection, query);
                PyDataType      cacheObject = null;

                using (connection)
                    using (reader)
                    {
                        switch (type)
                        {
                        case CacheObjectType.Rowset:
                            cacheObject = Rowset.FromMySqlDataReader(reader);
                            break;

                        case CacheObjectType.CRowset:
                            cacheObject = CRowset.FromMySqlDataReader(reader);
                            break;

                        case CacheObjectType.TupleSet:
                            cacheObject = TupleSet.FromMySqlDataReader(reader);
                            break;

                        case CacheObjectType.PackedRowList:
                            cacheObject = PyPackedRowList.FromMySqlDataReader(reader);
                            break;

                        case CacheObjectType.IntIntDict:
                            cacheObject = IntIntDictionary.FromMySqlDataReader(reader);
                            break;

                        case CacheObjectType.IndexRowset:
                            cacheObject = IndexRowset.FromMySqlDataReader(reader, 0);
                            break;
                        }

                        StoreCall(service, method, cacheObject, DateTime.UtcNow.ToFileTimeUtc());
                    }
            }
            catch (Exception)
            {
                Log.Error($"Cannot generate cache data for {service}::{method}");
                throw;
            }
        }
Beispiel #2
0
        public PyDataType GetMultiAllianceShortNamesEx(PyList <PyInteger> ids)
        {
            MySqlConnection connection = null;
            MySqlDataReader reader     = Database.PrepareQuery(ref connection,
                                                               $"SELECT allianceID, shortName FROM alliance_shortnames WHERE allianceID IN ({PyString.Join(',', ids)}"
                                                               ).ExecuteReader();

            using (connection)
                using (reader)
                {
                    return(TupleSet.FromMySqlDataReader(Database, reader));
                }
        }
Beispiel #3
0
        public PyDataType GetMultiLocationsEx(PyList <PyInteger> ids)
        {
            MySqlConnection connection = null;
            MySqlDataReader reader     = Database.PrepareQuery(ref connection,
                                                               $"SELECT itemID as locationID, itemName as locationName, x, y, z FROM invItems LEFT JOIN eveNames USING(itemID) LEFT JOIN invPositions USING (itemID) WHERE itemID IN ({PyString.Join(',', ids)})"
                                                               ).ExecuteReader();

            using (connection)
                using (reader)
                {
                    return(TupleSet.FromMySqlDataReader(Database, reader));
                }
        }
Beispiel #4
0
        public PyDataType GetMultiGraphicsEx(PyList <PyInteger> ids)
        {
            MySqlConnection connection = null;
            MySqlDataReader reader     = Database.PrepareQuery(ref connection,
                                                               $"SELECT graphicID, url3D, urlWeb, icon, urlSound, explosionID FROM eveGraphics WHERE graphicID IN ({PyString.Join(',', ids)})"
                                                               ).ExecuteReader();

            using (connection)
                using (reader)
                {
                    return(TupleSet.FromMySqlDataReader(Database, reader));
                }
        }
Beispiel #5
0
        public PyDataType GetMultiOwnersEx(PyList <PyInteger> ids)
        {
            MySqlConnection connection = null;
            MySqlDataReader reader     = Database.PrepareQuery(ref connection,
                                                               $"SELECT itemID as ownerID, itemName as ownerName, typeID FROM eveNames WHERE itemID IN ({PyString.Join(',', ids)})"
                                                               ).ExecuteReader();

            using (connection)
                using (reader)
                {
                    return(TupleSet.FromMySqlDataReader(Database, reader));
                }
        }
Beispiel #6
0
        /// <summary>
        /// Helper method that queries the cached object and converts it to the proper type to be stored
        /// </summary>
        /// <param name="query">The query to run</param>
        /// <param name="type">The type of object to store</param>
        /// <returns>The final object to be used by the cache</returns>
        private PyDataType QueryCacheObject(string query, CacheObjectType type)
        {
            MySqlConnection connection = null;
            MySqlDataReader reader     = Database.Query(ref connection, query);

            using (connection)
                using (reader)
                {
                    return(type switch
                    {
                        CacheObjectType.Rowset => Rowset.FromMySqlDataReader(Database, reader),
                        CacheObjectType.CRowset => CRowset.FromMySqlDataReader(Database, reader),
                        CacheObjectType.TupleSet => TupleSet.FromMySqlDataReader(Database, reader),
                        CacheObjectType.PackedRowList => PyPackedRowList.FromMySqlDataReader(Database, reader),
                        CacheObjectType.IntIntDict => IntIntDictionary.FromMySqlDataReader(reader),
                        CacheObjectType.IndexRowset => IndexRowset.FromMySqlDataReader(Database, reader, 0),
                        _ => null
                    });
Beispiel #7
0
        private void Load(string name, string query, CacheObjectType type)
        {
            Log.Debug($"Loading cache data for {name} of type {type}");

            try
            {
                MySqlConnection connection  = null;
                MySqlDataReader reader      = Database.Query(ref connection, query);
                PyDataType      cacheObject = null;

                using (connection)
                    using (reader)
                    {
                        switch (type)
                        {
                        case CacheObjectType.Rowset:
                            cacheObject = Rowset.FromMySqlDataReader(reader);
                            break;

                        case CacheObjectType.CRowset:
                            cacheObject = CRowset.FromMySqlDataReader(reader);
                            break;

                        case CacheObjectType.TupleSet:
                            cacheObject = TupleSet.FromMySqlDataReader(reader);
                            break;

                        case CacheObjectType.PackedRowList:
                            cacheObject = PyPackedRowList.FromMySqlDataReader(reader);
                            break;
                        }

                        Store(name, cacheObject, DateTime.Now.ToFileTimeUtc());
                    }
            }
            catch (Exception e)
            {
                Log.Error($"Cannot generate cache data for {name}");
                throw;
            }
        }
Beispiel #8
0
        public PyDataType GetMultiAllianceShortNamesEx(PyList ids)
        {
            string query = "SELECT allianceID, shortName FROM alliance_shortnames WHERE allianceID IN (";
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            foreach (PyDataType id in ids)
            {
                parameters["@itemID" + parameters.Count.ToString("X")] = (int)(id as PyInteger);
            }

            // prepare the correct list of arguments
            query += String.Join(',', parameters.Keys) + ")";

            MySqlConnection connection = null;
            MySqlDataReader reader     = Database.PrepareQuery(ref connection, query, parameters);

            using (connection)
                using (reader)
                {
                    return(TupleSet.FromMySqlDataReader(reader));
                }
        }
Beispiel #9
0
        public PyDataType GetMultiLocationsEx(PyList ids)
        {
            string query = "SELECT itemID as locationID, itemName as locationName, x, y, z FROM invItems LEFT JOIN eveNames USING(itemID) LEFT JOIN invPositions USING (itemID) WHERE itemID IN (";
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            foreach (PyDataType id in ids)
            {
                parameters["@itemID" + parameters.Count.ToString("X")] = (int)(id as PyInteger);
            }

            // prepare the correct list of arguments
            query += String.Join(',', parameters.Keys) + ")";

            MySqlConnection connection = null;
            MySqlDataReader reader     = Database.PrepareQuery(ref connection, query, parameters);

            using (connection)
                using (reader)
                {
                    return(TupleSet.FromMySqlDataReader(reader));
                }
        }
Beispiel #10
0
        public PyDataType GetMultiGraphicsEx(PyList ids)
        {
            string query = "SELECT graphicID, url3D, urlWeb, icon, urlSound, explosionID FROM eveGraphics WHERE graphicID IN (";
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            foreach (PyDataType id in ids)
            {
                parameters["@graphicID" + parameters.Count.ToString("X")] = (int)(id as PyInteger);
            }

            // prepare the correct list of arguments
            query += String.Join(',', parameters.Keys) + ")";

            MySqlConnection connection = null;
            MySqlDataReader reader     = Database.PrepareQuery(ref connection, query, parameters);

            using (connection)
                using (reader)
                {
                    return(TupleSet.FromMySqlDataReader(reader));
                }
        }