/// <summary> /// Processes the queried character's corporation medals. /// </summary> /// <param name="result"></param> private void OnMedalsUpdated(EsiResult <EsiAPIMedals> result) { // Character may have been deleted or set to not be monitored since we queried if (m_ccpCharacter == null || !m_ccpCharacter.Monitored) { return; } // Notify an error occurred if (m_ccpCharacter.ShouldNotifyError(result, CCPAPICorporationMethods.CorporationMedals)) { EveMonClient.Notifications.NotifyCorporationMedalsError(m_ccpCharacter, result); } // Quits if there is an error if (result.HasError) { return; } // Import the data m_ccpCharacter.CorporationMedals.Import(result.Result.ToXMLItem().CorporationMedals); // Fires the event regarding corporation medals update EveMonClient.OnCorporationMedalsUpdated(m_ccpCharacter); }
/// <summary> /// Constructor. /// </summary> /// <param name="character">The character to monitor.</param> /// <param name="method">The method to use.</param> /// <param name="onSuccess">An action to call on success.</param> /// <param name="onFailure">The callback to use upon failure.</param> internal CharacterQueryMonitor(CCPCharacter character, Enum method, Action <T> onSuccess, NotifyErrorCallback onFailure) : base(method, (result) => { // Character may have been set to not be monitored if (character.Monitored) { if (character.ShouldNotifyError(result, method)) { onFailure.Invoke(character, result); } if (!result.HasError) { onSuccess.Invoke(result.Result); } } foreach (var monitor in character.QueryMonitors.Where(monitor => monitor.Method. HasParent(method))) { character.QueryMonitors.Query(monitor.Method); } }) { m_character = character; }
/// <summary> /// Constructor. /// </summary> /// <param name="character"></param> /// <param name="method"></param> /// <param name="onUpdated"></param> internal CorporationQueryMonitor(CCPCharacter character, Enum method, Action <T> onSuccess, NotifyErrorCallback onFailure) : base(method, (result) => { if (character.Monitored) { // "No corp role(s)" = 403 if (result.HasError) { int rolesError = result.ErrorMessage?.IndexOf("role", StringComparison.InvariantCultureIgnoreCase) ?? -1; // Do not invoke onFailure on corp roles error since we cannot actually // determine whether the key had the roles until we try if ((result.ErrorCode != 403 || rolesError <= 0) && character. ShouldNotifyError(result, method)) { onFailure.Invoke(character, result); } } else { onSuccess.Invoke(result.Result); } } }) { m_character = character; }
/// <summary> /// Constructor. /// </summary> /// <param name="character"></param> /// <param name="method"></param> /// <param name="onUpdated"></param> internal CorporationQueryMonitor(CCPCharacter character, Enum method, Action <T> onSuccess, NotifyErrorCallback onFailure) : base(method, (result) => { // Character may have been set to not be monitored if (character.Monitored) { if (character.ShouldNotifyError(result, method)) { onFailure.Invoke(character, result); } if (!result.HasError) { onSuccess.Invoke(result.Result); } } }) { m_character = character; }
/// <summary> /// Constructor. /// </summary> /// <param name="character">The character to monitor.</param> /// <param name="method">The method to use.</param> /// <param name="onSuccess">An action to call on success.</param> /// <param name="onFailure">The callback to use upon failure.</param> internal CorporationQueryMonitor(CCPCharacter character, Enum method, Action <T> onSuccess, NotifyErrorCallback onFailure) : base(character, method, (result) => { if (character.Monitored) { // "No corp role(s)" = 403 if (result.HasError) { // Do not invoke onFailure on corp roles error since we cannot actually // determine whether the key had the roles until we try if (result.ErrorCode != 403 && character.ShouldNotifyError(result, method)) { onFailure.Invoke(character, result); } } else if (result.HasData) { onSuccess.Invoke(result.Result); } } }) { }
/// <summary> /// Handles the response from an ESI query. /// </summary> /// <param name="character">The character to monitor.</param> /// <param name="method">The method to use.</param> /// <param name="ifNoData">Whether to invoke the success callback on a "No Data" /// response.</param> /// <param name="result">The result of the query.</param> /// <param name="onSuccess">An action to call on success.</param> /// <param name="onFailure">The callback to use upon failure.</param> private static void HandleQuery(CCPCharacter character, Enum method, bool ifNoData, EsiResult <T> result, Action <T> onSuccess, NotifyErrorCallback onFailure) { // Character may have been set to not be monitored if (character.Monitored) { bool hasData = result.HasData; if (character.ShouldNotifyError(result, method)) { onFailure.Invoke(character, result); } if (!result.HasError && (ifNoData || hasData)) { onSuccess.Invoke(hasData ? result.Result : null); } } foreach (var monitor in character.QueryMonitors) { if (monitor.Method.HasParent(method)) { character.QueryMonitors.Query(monitor.Method); } } }
/// <summary> /// Processed the queried character's character sheet information. /// </summary> /// <param name="result"></param> private void OnCharacterSheetUpdated(EsiResult <EsiAPICharacterSheet> result) { // Character may have been deleted or set to not be monitored since we queried if (m_ccpCharacter == null || !m_ccpCharacter.Monitored) { return; } // Notify an error occurred if (m_ccpCharacter.ShouldNotifyError(result, ESIAPICharacterMethods.CharacterSheet)) { EveMonClient.Notifications.NotifyCharacterSheetError(m_ccpCharacter, result); } // Quits if there is an error if (result.HasError) { return; } // Query the Character's data QueryCharacterData <EsiAPILocation>(ESIAPICharacterMethods.Location, OnCharacterLocationUpdated); QueryCharacterData <EsiAPIClones>(ESIAPICharacterMethods.Clones, OnCharacterClonesUpdated); QueryCharacterData <EsiAPIJumpFatigue>(ESIAPICharacterMethods.JumpFatigue, OnCharacterFatigueUpdated); QueryCharacterData <EsiAPIAttributes>(ESIAPICharacterMethods.Attributes, OnCharacterAttributesUpdated); QueryCharacterData <EsiAPIShip>(ESIAPICharacterMethods.Ship, OnCharacterShipUpdated); QueryCharacterData <EsiAPISkills>(ESIAPICharacterMethods.Skills, OnCharacterSkillsUpdated); QueryCharacterData <List <int> >(ESIAPICharacterMethods.Implants, OnCharacterImplantsUpdated); // Imports the data m_ccpCharacter.Import(result); // Notify for insufficient balance m_ccpCharacter.NotifyInsufficientBalance(); // Save the file to our cache LocalXmlCache.SaveAsync(result.Result.Name, Util.SerializeToXmlDocument(result.Result)).ConfigureAwait(false); }
/// <summary> /// Processed the queried character's skill queue information. /// </summary> /// <param name="result"></param> private void OnCharacterSheetUpdated(CCPAPIResult <SerializableAPICharacterSheet> result) { // Character may have been deleted or set to not be monitored since we queried if (m_ccpCharacter == null || !m_ccpCharacter.Monitored) { return; } // Notify an error occurred if (m_ccpCharacter.ShouldNotifyError(result, CCPAPICharacterMethods.CharacterSheet)) { EveMonClient.Notifications.NotifyCharacterSheetError(m_ccpCharacter, result); } // Quits if there is an error if (result.HasError) { return; } // Query the Character's info QueryCharacterInfo(); // Imports the data m_ccpCharacter.Import(result); // Notify for insufficient balance m_ccpCharacter.NotifyInsufficientBalance(); // Save the file to our cache LocalXmlCache.SaveAsync(result.Result.Name, result.XmlDocument).ConfigureAwait(false); }