/// <summary> /// Find stats for a list of pilots /// </summary> /// <param name="pilots"></param> /// <returns></returns> public async Task <PilotStats> FindStatsFor(Affiliation affiliation) { PilotStats stats = await statController.GetPilotStats(affiliation.Character_Id); stats.Notes = GetNotesFor(stats); PilotId pilot = pilots.Find(x => x.Id == affiliation.Character_Id); cache.Add(pilot, affiliation, stats); return(stats); }
/// <summary> /// Add a row to the cache /// </summary> /// <param name="pilot">Pilot object containing Id and Name</param> /// <param name="affiliation">Affiliation object containing Corporation and Alliance</param> /// <param name="stats">PilotStats object containing DangerPercent, SoloPercent, and Notes</param> public void Add(PilotId pilot, Affiliation affiliation, PilotStats stats) { Row row = new Row { Pilot_Name = pilot.Name, Pilot_Id = pilot.Id, Corp_Name = affiliation.Corporation, Alliance_Name = affiliation.Alliance, Danger_Percent = stats.DangerPercent, Solo_Percent = stats.SoloPercent, Notes = stats.Notes }; if (!Contains(row.Pilot_Name)) { cache.Add(row); } }
/// <summary> /// Find groups for a list of pilots /// </summary> /// <param name="pilots"></param> /// <returns></returns> public async Task <List <Affiliation> > GetAffiliations(List <PilotId> pilots) { affiliations = new List <Affiliation>(); List <GroupId> groupIds = await esiController.GetGroupIds(pilots); List <Group> groups = await esiController.GetGroups(groupIds); foreach (GroupId group in groupIds) { Affiliation characterGroup = new Affiliation { Character_Id = group.Character_Id, Corporation = groups.First(x => x.Id == group.Corporation_Id).Name, Alliance = groups.FirstOrDefault(x => x.Id == group.Alliance_Id)?.Name }; affiliations.Add(characterGroup); } return(affiliations); }
/// <summary> /// Overall pilot lookup algorithm run whenever a paste is detected /// </summary> /// <param name="names">A list of names</param> private async Task StartLookup(List <string> names) { try { SetStatus(Status.PilotLookup); List <Row> cachedRows = lookup.FromCache(ref names); UpdateUI(cachedRows); if (names.Count > 0) { List <PilotId> pilots = await lookup.GetIds(names); UpdateUI(pilots); SetStatus(Status.GroupLookup); List <Affiliation> affiliations = await lookup.GetAffiliations(pilots); UpdateUI(affiliations); SetStatus(Status.StatsLookup); foreach (PilotId id in pilots) { Affiliation affiliation = affiliations.Find(x => x.Character_Id == id.Id); PilotStats stats = await lookup.FindStatsFor(affiliation); // affiliation already has pilot id UpdateUI(stats); RefreshSorting(); } } SetStatus(Status.Ready); running = false; } catch (HttpRequestException hre) { Console.WriteLine(hre.Message); statusLabel.Text = hre.Message; } }