예제 #1
0
        private void LoadCharacterInfo()
        {
            Log.DebugFormat("[Pilot.LoadCharacterInfo] starting for Id = {0}", Id);

            dynamic characterInfo = EsiData.GetCharacterInfo(Id);

            var portraitAddress = characterInfo.SelectToken("portrait.64x64.href").Value;

            var request = WebRequest.Create(portraitAddress);

            using (var response = request.GetResponse())
                using (var stream = response.GetResponseStream())
                {
                    Portrait = Image.FromStream(stream);
                }
        }
예제 #2
0
        private void RefreshInfo()
        {
            Log.DebugFormat("[Pilot.RefreshInfo] starting for Id = {0}", Id);

            var span = DateTime.Now - _lastTokenUpdate;
            var ms   = (int)span.TotalMilliseconds;

            if (ms > EsiData.ExpiresIn * 1000 - 20000)
            {
                EsiData.Refresh();

                _lastTokenUpdate = DateTime.Now;

                Log.DebugFormat("[Pilot.RefreshInfo] set LastTokenUpdate for Id = {0}", Id);
            }

            if (_isBusy == false)
            {
                Log.DebugFormat("[Pilot '{0}'] Load location info.", Name);
                LoadLocationInfo();
            }
        }
예제 #3
0
        private void LoadLocationInfo()
        {
            Log.DebugFormat("[Pilot.LoadLocationInfo] starting for Id = {0}", Id);

            _isBusy = true;

            var isNeedChangeLocation = false;

            try
            {
                if (Location == null)
                {
                    Location = new EveJimaUniverse.System();
                }

                Log.DebugFormat("[Pilot {0}] Call CrestData.GetLocation with ID={1}", Name, Id);

                dynamic locationInfo = EsiData.GetLocation(Id);

                var systemId = locationInfo.solar_system_id.ToString();

                dynamic solarSystemInfo = EsiData.GetSolarSystemInfo(systemId);

                var systemName = solarSystemInfo.name.ToString();

                if (Location.Name == systemName)
                {
                    Log.DebugFormat("[Pilot {0}] No need change location {1}", Name, Location.Name);
                    return;
                }

                if (!string.IsNullOrEmpty(systemId))
                {
                    if (LocationCurrentSystemName != systemName)
                    {
                        LocationPreviousSystemName = LocationCurrentSystemName;
                        LocationCurrentSystemName  = systemName;

                        isNeedChangeLocation = true;
                    }
                }

                if (Global.Space.GetSystemByName(systemName) != null)
                {
                    var location = Global.Space.GetSystemByName(systemName);

                    Location = location.Clone() as EveJimaUniverse.System;

                    if (Location != null)
                    {
                        Location.Id = systemId;
                    }
                }
                else
                {
                    Location.Region       = "";
                    Location.Constelation = "";
                    Location.Effect       = "";
                    Location.Class        = "";
                    Location.Static2      = "";
                    Location.Static       = "";

                    Location.Id = systemId;

                    Location.Name = systemName;
                }

                if (isNeedChangeLocation)
                {
                    ChangeLocation();
                }
            }
            catch (Exception ex)
            {
                Log.DebugFormat("[Pilot.LoadLocationInfo] pilot Id = {0} not login in game. Exception {1}", Id, ex);

                if (Location != null)
                {
                    Location.Name = "unknown";
                }
            }
            finally
            {
                _isBusy = false;
            }
        }