コード例 #1
0
ファイル: LocalCharacter.cs プロジェクト: MatiasGil/SMT
        /// <summary>
        /// Update the characters position from ESI (will override the position read from any log files
        /// </summary>
        private async Task UpdatePositionFromESI()
        {
            if (ID == 0 || !ESILinked || ESIAuthData == null)
            {
                return;
            }

            try
            {
                ESI.NET.EsiClient esiClient = EveManager.Instance.ESIClient;
                esiClient.SetCharacterData(ESIAuthData);
                ESI.NET.EsiResponse <ESI.NET.Models.Location.Location> esr = await esiClient.Location.Location();

                if (ESIHelpers.ValidateESICall <ESI.NET.Models.Location.Location>(esr))
                {
                    if (!EveManager.Instance.SystemIDToName.Keys.Contains(esr.Data.SolarSystemId))
                    {
                        Location = "";
                        Region   = "";
                        return;
                    }
                    Location = EveManager.Instance.SystemIDToName[esr.Data.SolarSystemId];
                    System s = EVEData.EveManager.Instance.GetEveSystem(Location);
                    if (s != null)
                    {
                        Region = s.Region;
                    }
                    else
                    {
                        Region = "";
                    }
                }
            }
            catch { }
        }
コード例 #2
0
ファイル: LocalCharacter.cs プロジェクト: afarazit/SMT
        /// <summary>
        /// Update the characters position from ESI (will override the position read from any log files
        /// </summary>
        private async void UpdatePositionFromESI()
        {
            if (string.IsNullOrEmpty(ESIAccessToken))
            {
                return;
            }

            ESI.NET.EsiClient esiClient = EveManager.Instance.ESIClient;
            esiClient.SetCharacterData(ESIAuthData);
            ESI.NET.EsiResponse <ESI.NET.Models.Location.Location> esr = await esiClient.Location.Location();

            if (ESIHelpers.ValidateESICall <ESI.NET.Models.Location.Location>(esr))
            {
                Location = EveManager.Instance.SystemIDToName[esr.Data.SolarSystemId];
                System s = EVEData.EveManager.Instance.GetEveSystem(Location);
                if (s != null)
                {
                    Region = s.Region;
                }
                else
                {
                    Region = "";
                }
            }
        }
コード例 #3
0
ファイル: LocalCharacter.cs プロジェクト: MatiasGil/SMT
        /// <summary>
        /// Update the characters logged on status from ESI
        /// </summary>
        private async Task UpdateOnlineStatus()
        {
            if (ID == 0 || !ESILinked || ESIAuthData == null)
            {
                return;
            }

            try
            {
                ESI.NET.EsiClient esiClient = EveManager.Instance.ESIClient;
                esiClient.SetCharacterData(ESIAuthData);
                ESI.NET.EsiResponse <ESI.NET.Models.Location.Activity> esr = await esiClient.Location.Online();

                if (ESIHelpers.ValidateESICall <ESI.NET.Models.Location.Activity>(esr))
                {
                    IsOnline = esr.Data.Online;
                }
            }
            catch { }
        }
コード例 #4
0
ファイル: LocalCharacter.cs プロジェクト: luccion/SMT
        /// <summary>
        /// Update the characters FleetInfo
        /// </summary>
        private async void UpdateFleetInfo()
        {
            if (ID == 0 || !ESILinked || ESIAuthData == null)
            {
                return;
            }

            try
            {
                ESI.NET.EsiClient esiClient = EveManager.Instance.ESIClient;
                esiClient.SetCharacterData(ESIAuthData);

                ESI.NET.EsiResponse <ESI.NET.Models.Fleets.FleetInfo> esr = await esiClient.Fleets.FleetInfo();

                if (ESIHelpers.ValidateESICall <ESI.NET.Models.Fleets.FleetInfo>(esr))
                {
                    FleetInfo.FleetID = esr.Data.FleetId;

                    // in fleet, extract info
                    ESI.NET.EsiResponse <List <ESI.NET.Models.Fleets.Member> > esrf = await esiClient.Fleets.Members(esr.Data.FleetId);

                    if (ESIHelpers.ValidateESICall <List <ESI.NET.Models.Fleets.Member> >(esrf))
                    {
                        foreach (ESI.NET.Models.Fleets.Member fm in esrf.Data)
                        {
                            //fm.CharacterId
                        }
                    }
                }
                else
                {
                    FleetInfo.FleetID = 0;
                    FleetInfo.Members.Clear();
                }
            }
            catch { }
        }
コード例 #5
0
ファイル: LocalCharacter.cs プロジェクト: MatiasGil/SMT
        /// <summary>
        /// Update the characters FleetInfo
        /// </summary>
        private async Task UpdateFleetInfo()
        {
            if (ID == 0 || !ESILinked || ESIAuthData == null)
            {
                return;
            }

            try
            {
                ESI.NET.EsiClient esiClient = EveManager.Instance.ESIClient;
                esiClient.SetCharacterData(ESIAuthData);

                if (FleetInfo.NextFleetMembershipCheck < DateTime.Now)
                {
                    // route is cached for 60s, however checking this can hit the rate limit
                    FleetInfo.NextFleetMembershipCheck = DateTime.Now + TimeSpan.FromSeconds(240);

                    ESI.NET.EsiResponse <ESI.NET.Models.Fleets.FleetInfo> esr = await esiClient.Fleets.FleetInfo();

                    if (ESIHelpers.ValidateESICall <ESI.NET.Models.Fleets.FleetInfo>(esr))
                    {
                        FleetInfo.FleetID     = esr.Data.FleetId;
                        FleetInfo.IsFleetBoss = esr.Data.Role == "fleet_commander" ? true : false;
                    }
                    else
                    {
                        FleetInfo.FleetID = 0;

                        Application.Current.Dispatcher.Invoke((Action)(() =>
                        {
                            FleetInfo.Members.Clear();
                        }), DispatcherPriority.Normal);
                    }
                }

                if (FleetInfo.FleetID != 0 && FleetInfo.IsFleetBoss)
                {
                    List <long> characterIDsToResolve = new List <long>();

                    ESI.NET.EsiResponse <List <ESI.NET.Models.Fleets.Member> > esrf = await esiClient.Fleets.Members(FleetInfo.FleetID);

                    if (ESIHelpers.ValidateESICall <List <ESI.NET.Models.Fleets.Member> >(esrf))
                    {
                        foreach (Fleet.FleetMember ff in FleetInfo.Members)
                        {
                            ff.IsValid = false;
                        }

                        foreach (ESI.NET.Models.Fleets.Member esifm in esrf.Data)
                        {
                            Fleet.FleetMember fm = null;

                            foreach (Fleet.FleetMember ff in FleetInfo.Members)
                            {
                                if (ff.CharacterID == esifm.CharacterId)
                                {
                                    fm         = ff;
                                    fm.IsValid = true;
                                }
                            }

                            if (fm == null)
                            {
                                fm         = new Fleet.FleetMember();
                                fm.IsValid = true;

                                Application.Current.Dispatcher.Invoke((Action)(() =>
                                {
                                    FleetInfo.Members.Add(fm);
                                }), DispatcherPriority.Normal);
                            }

                            fm.Name        = EveManager.Instance.GetCharacterName(esifm.CharacterId);
                            fm.Location    = EveManager.Instance.GetEveSystemNameFromID(esifm.SolarSystemId);
                            fm.CharacterID = esifm.CharacterId;
                            if (EveManager.Instance.ShipTypes.ContainsKey(esifm.ShipTypeId.ToString()))
                            {
                                fm.ShipType = EveManager.Instance.ShipTypes[esifm.ShipTypeId.ToString()];
                            }
                            else
                            {
                                fm.ShipType = "Unknown : " + esifm.ShipTypeId.ToString();
                            }

                            if (String.IsNullOrEmpty(fm.Name))
                            {
                                characterIDsToResolve.Add(esifm.CharacterId);
                            }
                        }

                        if (characterIDsToResolve.Count > 0)
                        {
                            EveManager.Instance.ResolveCharacterIDs(characterIDsToResolve).Wait();
                        }

                        foreach (Fleet.FleetMember ff in FleetInfo.Members.ToList())
                        {
                            if (!ff.IsValid)
                            {
                                Application.Current.Dispatcher.Invoke((Action)(() =>
                                {
                                    FleetInfo.Members.Remove(ff);
                                }), DispatcherPriority.Normal);
                            }
                        }
                    }
                    else
                    {
                        // something went wrong (probably lost fleet_commander), reset this check
                        FleetInfo.NextFleetMembershipCheck = DateTime.Now + TimeSpan.FromSeconds(60);
                        FleetInfo.FleetID = 0;

                        Application.Current.Dispatcher.Invoke((Action)(() =>
                        {
                            FleetInfo.Members.Clear();
                        }), DispatcherPriority.Normal);
                    }
                }
            }
            catch { }
        }