Ejemplo n.º 1
0
        public static async Task <SolarSystem> GetSystem(int id)
        {
            EnsureInit();

            // TODO: I believe this can probably be simplified through some template magic
            SolarSystem system;

            if (s_cachedSystems.TryGetValue(id, out system))
            {
                return(system);
            }

            system = RedisHelper.Get <SolarSystem>(string.Format("esi:systems:{0}", id));

            if (system != null)
            {
                return(system);
            }

            EsiResponse <SolarSystem> response = await s_client.Universe.System(id);

            if (response.StatusCode != HttpStatusCode.OK)
            {
                Console.WriteLine("[Error] Unable to query ESI for systems. Status: {0} Error {1}", response.StatusCode, response.Message);
                return(null);
            }

            s_cachedSystems[id] = response.Data;
            RedisHelper.Set <SolarSystem>(string.Format("esi:systems:{0}", id), response.Data);

            return(response.Data);
        }
Ejemplo n.º 2
0
        public static async Task <Constellation> GetConstellation(int id)
        {
            EnsureInit();

            Constellation constellation;

            if (s_cachedConstellations.TryGetValue(id, out constellation))
            {
                return(constellation);
            }

            constellation = RedisHelper.Get <Constellation>(string.Format("esi:constellations:{0}", id));

            if (constellation != null)
            {
                return(constellation);
            }

            // Call ESI
            EsiResponse <Constellation> response = await s_client.Universe.Constellation(id);

            if (response.StatusCode != HttpStatusCode.OK)
            {
                Console.WriteLine("[Error] Unable to query ESI for constellation. Status: {0} Error {1}", response.StatusCode, response.Message);
                return(null);
            }

            s_cachedConstellations[id] = response.Data;
            RedisHelper.Set <Constellation>(string.Format("esi:constellation:{0}", id), response.Data);

            return(response.Data);
        }
Ejemplo n.º 3
0
        public static async Task <Region> GetRegion(int id)
        {
            Region region = RedisHelper.Get <Region>(string.Format("esi:regions:{0}", id));

            if (region != null)
            {
                return(region);
            }

            EsiResponse <Region> response = await s_client.Universe.Region(id);

            if (response.StatusCode != HttpStatusCode.OK)
            {
                Console.WriteLine("[Error] Unable to query ESI for a region. Status: {0} Error {1}", response.StatusCode, response.Message);
                return(null);
            }

            RedisHelper.Set <Region>(string.Format("esi:regions:{0}", id), response.Data);

            return(response.Data);
        }
Ejemplo n.º 4
0
        public static ResolvedInfo GetNameFromId(int id)
        {
            EnsureInit();

            ResolvedInfo info;

            // Check in memory cache
            if (s_cachedNames.TryGetValue(id, out info))
            {
                return(info);
            }

            // Check persistent redis
            info = RedisHelper.Get <ResolvedInfo>(string.Format("esi:names:{0}", id));

            if (info != null)
            {
                s_cachedNames[id] = info;
            }

            return(info);
        }
Ejemplo n.º 5
0
        public static async Task <int[]> GetJumps(int src, int dst)
        {
            EnsureInit();


            int[] route = RedisHelper.Get <int[]>(string.Format("esi:jumps:{0}:{1}", src, dst));

            if (route != null)
            {
                return(route);
            }

            EsiResponse <int[]> response = await s_client.Routes.Map(src, dst);

            if (response.StatusCode != HttpStatusCode.OK)
            {
                Console.WriteLine("[Error] Unable to query ESI for a route. Status: {0} Error {1}", response.StatusCode, response.Message);
                return(null);
            }

            RedisHelper.Set <int[]>(string.Format("esi:jumps:{0}:{1}", src, dst), response.Data);

            return(response.Data);
        }
Ejemplo n.º 6
0
 public static Instructions Get()
 {
     return(RedisHelper.Get <Instructions>(WaitlistRedisKey));
 }