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

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

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

                _lastTokenUpdate = DateTime.Now;

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

            if (_isBusy)
            {
                return;
            }

            _isBusy = true;

            LoadLocationInfo();

            _isBusy = false;
        }
예제 #2
0
        private void LoadLocationInfo()
        {
            Log.DebugFormat("[Pilot.LoadLocationInfo] starting for Id = {0}", Id);

            try
            {
                //if (Global.Pilots.Selected == null) return;

                if (Location == null)
                {
                    Location = new StarSystemEntity();
                }

                dynamic locationInfo = CrestData.GetLocation(Id);

                if (Location.System == locationInfo.SelectToken("solarSystem.name").Value)
                {
                    return;
                }

                if (Global.Space.SolarSystems.ContainsKey(locationInfo.SelectToken("solarSystem.name").Value.ToString()))
                {
                    var location = (StarSystemEntity)Global.Space.SolarSystems[locationInfo.SelectToken("solarSystem.name").Value.ToString()];

                    Location = location.Clone() as StarSystemEntity;

                    if (Location != null)
                    {
                        Location.Id = locationInfo.SelectToken("solarSystem.id").Value.ToString();
                    }
                }
                else
                {
                    Location.Region       = "";
                    Location.Constelation = "";
                    Location.Effect       = "";
                    Location.Class        = "";
                    Location.Static2      = "";
                    Location.Static       = "";

                    Location.Id = locationInfo.SelectToken("solarSystem.id").Value.ToString();

                    Location.System = locationInfo.SelectToken("solarSystem.name").Value;
                }
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("[Pilot.LoadLocationInfo] pilot Id = {0} not login in game. Exception {1}", Id, ex);

                if (Location != null)
                {
                    Location.System = "unknown";
                }
            }
        }
예제 #3
0
        private void LoadCharacterInfo()
        {
            Log.DebugFormat("[Pilot.LoadCharacterInfo] starting for Id = {0}", Id);



            dynamic characterInfo = CrestData.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);
                }
        }