Beispiel #1
0
        /// <summary>
        /// Constructor for API Characters.
        /// </summary>
        /// <param name="uri">URI of the character</param>
        /// <param name="result">API Result</param>
        /// <exception cref="System.ArgumentNullException">result</exception>
        public UriCharacterEventArgs(Uri uri, CCPAPIResult<SerializableAPICharacterSheet> result)
        {
            result.ThrowIfNull(nameof(result));

            Uri = uri;
            m_apiResult = result;
            m_result = m_apiResult.Result;
            HasError = m_apiResult.HasError;
            Error = m_apiResult.ErrorMessage;
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="APIKeyCreationEventArgs"/> class.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="verificationCode">The verification code.</param>
        /// <param name="apiKeyInfo">The API key info.</param>
        /// <exception cref="System.ArgumentNullException">apiKeyInfo</exception>
        public APIKeyCreationEventArgs(long id, string verificationCode,
            CCPAPIResult<SerializableAPIKeyInfo> apiKeyInfo)
        {
            apiKeyInfo.ThrowIfNull(nameof(apiKeyInfo));

            ID = id;
            VerificationCode = verificationCode;
            KeyTestError = String.Empty;
            APIKeyInfo = apiKeyInfo;
            Identities = new Collection<CharacterIdentity>();

            // Determine the API key type
            Type = APIKey.GetCredentialsType(apiKeyInfo);

            // On error, retrieve the error message and quit
            if (Type == CCPAPIKeyType.Unknown)
            {
                KeyTestError = apiKeyInfo.ErrorMessage;
                CCPError = apiKeyInfo.CCPError ?? new CCPAPIError();
                return;
            }

            AccessMask = apiKeyInfo.Result.Key.AccessMask;
            Expiration = apiKeyInfo.Result.Key.Expiration;

            // Retrieves the characters list
            foreach (SerializableCharacterListItem character in apiKeyInfo.Result.Key.Characters)
            {
                // Look for an existing character ID and update its name
                CharacterIdentity identity = EveMonClient.CharacterIdentities[character.ID];
                if (identity != null)
                {
                    identity.CharacterName = character.Name;
                    identity.CorporationID = character.CorporationID;
                    identity.CorporationName = character.CorporationName;
                    identity.AllianceID = character.AllianceID;
                    identity.AllianceName = character.AllianceName;
                    identity.FactionID = character.FactionID;
                    identity.FactionName = character.FactionName;
                }
                else
                {
                    // Create an identity if necessary
                    identity = EveMonClient.CharacterIdentities.Add(character.ID, character.Name,
                                                                    character.CorporationID, character.CorporationName,
                                                                    character.AllianceID, character.AllianceName,
                                                                    character.FactionID, character.FactionName);
                }

                Identities.Add(identity);
            }
        }
        public CCPAPIResult <SerializableAPIContactList> Invoke(Dictionary <string, string> legacyPostData, string dataSource, string accessToken)
        {
            var characterId = int.Parse(legacyPostData["characterID"]);

            _factionNames = GetFactionNames(dataSource);

            var result = new CCPAPIResult <SerializableAPIContactList>
            {
                Result = new SerializableAPIContactList()
            };

            var characterInfo = _characterApi.GetCharactersCharacterId(characterId, dataSource, accessToken);

            result.Result.Contacts          = GetCharacterContacts(characterId, dataSource, accessToken);
            result.Result.CorporateContacts = GetCorpContacts(characterInfo.CorporationId.GetValueOrDefault(), dataSource, accessToken);
            result.Result.AllianceContacts  = GetAllianceContacts(characterInfo.AllianceId.GetValueOrDefault(), dataSource, accessToken);

            return(result);
        }
Beispiel #4
0
        /// <summary>
        /// Occurs when CCP returns new data.
        /// </summary>
        /// <param name="result"></param>
        private void OnServerStatusMonitorUpdated(CCPAPIResult <SerializableAPIServerStatus> result)
        {
            ServerStatus lastStatus = m_status;

            // Update the server date and time (in case of API server total failure use UTC time)
            m_serverDateTime = result.CurrentTime != DateTime.MinValue ? result.CurrentTime : DateTime.UtcNow;

            // Checks if EVE database is out of service
            if (result.EVEDatabaseError)
            {
                return;
            }

            // Was there an error ?
            if (result.HasError)
            {
                m_status = ServerStatus.Unknown;
                EveMonClient.Notifications.NotifyServerStatusError(result);

                // Notify subscribers about update
                EveMonClient.OnServerStatusUpdated(this, lastStatus, m_status);
                return;
            }

            // Update status and users
            m_users  = result.Result.Players;
            m_status = result.Result.Open ? ServerStatus.Online : ServerStatus.Offline;

            // Invalidate any error notifications
            EveMonClient.Notifications.InvalidateAPIError();

            // Notify subscribers about update
            EveMonClient.OnServerStatusUpdated(this, lastStatus, m_status);

            // Send a notification
            if (lastStatus != m_status)
            {
                EveMonClient.Notifications.NotifyServerStatusChanged(Name, m_status);
                return;
            }

            EveMonClient.Notifications.InvalidateServerStatusChange();
        }
Beispiel #5
0
        /// <summary>
        /// Updates the file.
        /// </summary>
        private static async Task UpdateFileAsync()
        {
            // Quit if query is pending
            if (s_queryPending)
            {
                return;
            }

            var url = new Uri(NetworkConstants.BitBucketWikiBase +
                              NetworkConstants.NotificationRefTypes);

            s_queryPending = true;

            CCPAPIResult <SerializableNotificationRefTypes> result = await Util.
                                                                     DownloadAPIResultAsync <SerializableNotificationRefTypes>(url, acceptEncoded : true,
                                                                                                                               transform : APIProvider.RowsetsTransform);

            OnDownloaded(result);
        }
Beispiel #6
0
        public CCPAPIResult <SerializableAPICharacterInfo> Invoke(Dictionary <string, string> legacyPostData, string dataSource, string accessToken)
        {
            var characterId = int.Parse(legacyPostData["characterID"]);

            var result = new CCPAPIResult <SerializableAPICharacterInfo>
            {
                Result = new SerializableAPICharacterInfo
                {
                    LastKnownLocation = GetCharacterLocation(characterId, dataSource, accessToken),
                    SecurityStatus    = GetSecurityStatus(characterId, dataSource),
                    ShipName          = GetShipName(characterId, dataSource, accessToken),
                    ShipTypeName      = GetShipTypeName(characterId, dataSource, accessToken)
                }
            };

            result.Result.EmploymentHistory.Clear();
            result.Result.EmploymentHistory.AddRange(GetCorporationHistory(characterId, dataSource));

            return(result);
        }
Beispiel #7
0
        public CCPAPIResult <SerializableAPIKeyInfo> Invoke(Dictionary <string, string> legacyPostData, string dataSource, string accessToken)
        {
            var result = new CCPAPIResult <SerializableAPIKeyInfo>
            {
                Result = new SerializableAPIKeyInfo
                {
                    Key = new SerializableAPIKeyItem
                    {
                        //Dont bother setting expiration its going to get wonky assume non expire
                        AccessMask = 133169114, //full access mask
                        Type       = "Account", //set to an account so it looks like an account key with one toon
                    }
                }
            };

            result.Result.Key.Characters.Clear();
            result.Result.Key.Characters.Add(GetCharacterFromToken(dataSource, accessToken));

            return(result);
        }
Beispiel #8
0
        public CCPAPIResult <SerializableAPIStandings> Invoke(Dictionary <string, string> legacyPostData, string dataSource, string accessToken)
        {
            var characterId = int.Parse(legacyPostData["characterID"]);

            var result = new CCPAPIResult <SerializableAPIStandings>
            {
                Result = new SerializableAPIStandings
                {
                    CharacterNPCStandings = new SerializableStandings()
                }
            };

            var standings = _characterApi.GetCharactersCharacterIdStandings(characterId, dataSource, accessToken);

            result.Result.CharacterNPCStandings.AgentStandings          = GetAgentStandings(standings, dataSource);
            result.Result.CharacterNPCStandings.NPCCorporationStandings = GetNpcCorpStandings(standings, dataSource);
            result.Result.CharacterNPCStandings.FactionStandings        = GetFactionStandings(standings, dataSource);

            return(result);
        }
Beispiel #9
0
        /// <summary>
        /// Imports the kill logs from a cached file.
        /// </summary>
        public void ImportFromCacheFile()
        {
            string filename = LocalXmlCache.GetFileInfo($"{m_ccpCharacter.Name}-{ESIAPICharacterMethods.KillLog}").FullName;

            // Abort if the file hasn't been obtained for any reason
            if (!File.Exists(filename))
            {
                return;
            }

            CCPAPIResult <SerializableAPIKillLog> result = Util.DeserializeAPIResultFromFile <SerializableAPIKillLog>(
                filename, APIProvider.RowsetsTransform);

            // In case the file has an error we prevent the deserialization
            if (result.HasError)
            {
                return;
            }

            Import(result.Result.Kills);
        }
Beispiel #10
0
        /// <summary>
        /// Used when the API key info (character list) has been queried.
        /// </summary>
        /// <param name="result"></param>
        private void OnAPIKeyInfoUpdated(CCPAPIResult <SerializableAPIKeyInfo> result)
        {
            m_queried = true;

            // Quit if the API key was deleted while it was updating
            if (!EveMonClient.APIKeys.Contains(this))
            {
                return;
            }

            // Checks if EVE database is out of service
            if (result.EVEDatabaseError)
            {
                return;
            }

            // Notify on error
            if (result.HasError)
            {
                // Fire the event in order to trigger the monitoring of a character's features
                // regardless of the result having error
                EveMonClient.OnAPIKeyInfoUpdated(this);

                // Notify the user
                EveMonClient.Notifications.NotifyCharacterListError(this, result);
                return;
            }

            // Invalidates the notification
            EveMonClient.Notifications.InvalidateAPIKeyInfoError(this);

            // Update
            Import(result);

            // Notifies for the API key expiration
            NotifyAPIKeyExpiration();

            // Fires the event regarding the API key info update
            EveMonClient.OnAPIKeyInfoUpdated(this);
        }
Beispiel #11
0
        /// <summary>
        /// Processes the queried character's factional warfare statistic information.
        /// </summary>
        /// <param name="result"></param>
        private void OnFactionalWarfareStatsUpdated(CCPAPIResult <SerializableAPIFactionalWarfareStats> 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.FactionalWarfareStats))
            {
                EveMonClient.Notifications.NotifyCharacterFactionalWarfareStatsError(m_ccpCharacter, result);
            }

            // Quits if there is an error
            if (result.HasError)
            {
                if (result.CCPError == null || !result.CCPError.IsFactionalWarfareEnlistedError)
                {
                    return;
                }

                // Update the enlisted in factional warfare flag
                m_ccpCharacter.IsFactionalWarfareNotEnlisted = true;

                // Fires the event regarding factional warfare stats update
                EveMonClient.OnCharacterFactionalWarfareStatsUpdated(m_ccpCharacter);
                return;
            }

            // Update the enlisted in factional warfare flag
            m_ccpCharacter.IsFactionalWarfareNotEnlisted = false;

            // Import the data
            m_ccpCharacter.FactionalWarfareStats = new FactionalWarfareStats(result.Result);

            // Fires the event regarding factional warfare stats update
            EveMonClient.OnCharacterFactionalWarfareStatsUpdated(m_ccpCharacter);
        }
Beispiel #12
0
        /// <summary>
        /// Called when planetary links updated.
        /// </summary>
        /// <param name="result">The result.</param>
        private void OnPlanetaryLinksUpdated(CCPAPIResult <SerializableAPIPlanetaryLinks> result)
        {
            m_queryPinsPending = false;

            // Notify an error occured
            if (Character.ShouldNotifyError(result, CCPAPIGenericMethods.PlanetaryLinks))
            {
                EveMonClient.Notifications.NotifyCharacterPlanetaryLinksError(Character, result);
            }

            // Quits if there is an error
            if (result.HasError)
            {
                return;
            }

            // Import the data
            Import(result.Result.Links);

            // Fires the event regarding planetary links updated
            EveMonClient.OnCharacterPlanetaryLinksUpdated(Character);
        }
Beispiel #13
0
        /// <summary>
        /// Occurs when a new result has been queried.
        /// </summary>
        /// <param name="result">The downloaded result</param>
        private void OnQueried(CCPAPIResult <T> result)
        {
            IsUpdating = false;
            Status     = QueryStatus.Pending;

            // Do we need to retry the force update ?
            m_forceUpdate = m_retryOnForceUpdateError && result.HasError;

            // Was it canceled ?
            if (m_isCanceled)
            {
                return;
            }

            // Updates the stored data
            m_retryOnForceUpdateError = false;
            LastUpdate = DateTime.UtcNow;
            LastResult = result;

            // Notify subscribers
            m_onUpdated?.Invoke(result);
        }
Beispiel #14
0
        /// <summary>
        /// Processes the queried EVE notification text.
        /// </summary>
        /// <param name="result">The result.</param>
        private void OnEVENotificationTextDownloaded(CCPAPIResult <SerializableAPINotificationTexts> result)
        {
            m_queryPending = false;

            // Notify an error occured
            if (m_ccpCharacter.ShouldNotifyError(result, CCPAPICharacterMethods.NotificationTexts))
            {
                EveMonClient.Notifications.NotifyEVENotificationTextsError(m_ccpCharacter, result);
            }

            // Quits if there is an error
            if (result.HasError)
            {
                return;
            }

            // If there is an error response on missing IDs inform the user
            if (!String.IsNullOrEmpty(result.Result.MissingMessageIDs))
            {
                result.Result.Texts.Add(
                    new SerializableNotificationTextsListItem
                {
                    NotificationID   = long.Parse(result.Result.MissingMessageIDs, CultureConstants.InvariantCulture),
                    NotificationText = "The text for this notification was reported missing."
                });
            }

            // Quit if for any reason there is no text
            if (!result.Result.Texts.Any())
            {
                return;
            }

            // Import the data
            EVENotificationText = new EveNotificationText(this, result.Result.Texts.First());

            EveMonClient.OnCharacterEVENotificationTextDownloaded(m_ccpCharacter);
        }
Beispiel #15
0
        /// <summary>
        /// Processes the queried character's EVE mailing lists.
        /// </summary>
        /// <param name="result">The result.</param>
        private void OnMailingListsUpdated(CCPAPIResult <SerializableAPIMailingLists> 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 occured
            if (m_ccpCharacter.ShouldNotifyError(result, CCPAPICharacterMethods.MailingLists))
            {
                EveMonClient.Notifications.NotifyMailingListsError(m_ccpCharacter, result);
            }

            // Quits if there is an error
            if (result.HasError)
            {
                return;
            }

            // Import the data
            m_ccpCharacter.EVEMailingLists.Import(result.Result.MailingLists);
        }
Beispiel #16
0
        /// <summary>
        /// Ensures the list has been imported.
        /// </summary>
        private static void EnsureImportation()
        {
            // Exit if we have already imported the list or are currently querying
            if (s_loaded)
            {
                return;
            }

            CCPAPIResult <SerializableAPIRefTypes> result =
                Util.DeserializeAPIResultFromString <SerializableAPIRefTypes>(Properties.Resources.RefTypes,
                                                                              APIProvider.RowsetsTransform);

            foreach (var type in result.Result.RefTypes)
            {
                int id = type.ID;
                if (!s_refTypes.ContainsKey(id))
                {
                    s_refTypes.Add(id, type);
                }
            }

            s_loaded = true;
        }
Beispiel #17
0
        /// <summary>
        /// Handles the NotificationSent event of the EveMonClient control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EVEMon.Common.Notifications.NotificationEventArgs"/> instance containing the event data.</param>
        private void EveMonClient_NotificationSent(object sender, NotificationEventArgs e)
        {
            APIErrorNotificationEventArgs notification = e as APIErrorNotificationEventArgs;

            if (notification == null)
            {
                return;
            }

            CCPAPIResult <SerializableAPIMailBodies>        eveMailBodiesResult    = notification.Result as CCPAPIResult <SerializableAPIMailBodies>;
            CCPAPIResult <SerializableAPINotificationTexts> notificationTextResult = notification.Result as CCPAPIResult <SerializableAPINotificationTexts>;

            if (eveMailBodiesResult == null && notificationTextResult == null)
            {
                return;
            }

            // In case there was an error, close the window
            if (notification.Result.HasError)
            {
                Close();
            }
        }
Beispiel #18
0
        /// <summary>
        /// Processes the refTypes list.
        /// </summary>
        /// <param name="result">The result.</param>
        private static void OnUpdated(CCPAPIResult<SerializableAPIRefTypes> result)
        {
            // Checks if EVE database is out of service
            if (result.EVEDatabaseError)
                return;

            // Was there an error ?
            if (result.HasError)
            {
                EveMonClient.Notifications.NotifyRefTypesError(result);
                return;
            }

            EveMonClient.Notifications.InvalidateAPIError();

            s_refTypes = result.Result.RefTypes;

            s_loaded = true;
            s_isQuerying = false;

            // Notify the subscribers
            EveMonClient.OnRefTypesUpdated();
        }
        /// <summary>
        /// Processes the queried character's corporation contracts.
        /// </summary>
        /// <param name="result"></param>
        /// <remarks>This method is sensitive to which contracts gets queried first</remarks>
        private void OnContractsUpdated(CCPAPIResult <SerializableAPIContracts> 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.CorporationContracts))
            {
                EveMonClient.Notifications.NotifyCorporationContractsError(m_ccpCharacter, result);
            }

            // Quits if there is an error
            if (result.HasError)
            {
                return;
            }

            // Query the contract bids
            QueryCorporationContractBids();

            result.Result.Contracts.ToList().ForEach(x =>
            {
                x.IssuedFor = IssuedFor.Corporation;
                x.APIMethod = CCPAPICorporationMethods.CorporationContracts;
            });

            // Import the data
            List <Contract> endedContracts = new List <Contract>();

            m_ccpCharacter.CorporationContracts.Import(result.Result.Contracts, endedContracts);

            // Fires the event regarding corporation contracts update
            EveMonClient.OnCorporationContractsUpdated(m_ccpCharacter, endedContracts);
        }
Beispiel #20
0
        /// <summary>
        /// Processes the queried character's skill queue information.
        /// </summary>
        /// <param name="result"></param>
        private void OnSkillQueueUpdated(CCPAPIResult <SerializableAPISkillQueue> 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.SkillQueue))
            {
                EveMonClient.Notifications.NotifySkillQueueError(m_ccpCharacter, result);
            }

            // Quits if there is an error
            if (result.HasError)
            {
                return;
            }

            // Import the data
            m_ccpCharacter.SkillQueue.Import(result.Result.Queue);

            // Check the account has a character in training (if API key of type "Account")
            APIKey apikey = m_ccpCharacter.Identity.FindAPIKeyWithAccess(CCPAPICharacterMethods.SkillInTraining);

            apikey?.CharacterInTraining();

            // Check the character has less than a day of training in skill queue
            if (m_ccpCharacter.IsTraining && m_ccpCharacter.SkillQueue.LessThanWarningThreshold)
            {
                EveMonClient.Notifications.NotifySkillQueueLessThanADay(m_ccpCharacter);
                return;
            }

            EveMonClient.Notifications.InvalidateSkillQueueLessThanADay(m_ccpCharacter);
        }
Beispiel #21
0
        /// <summary>
        /// Called when contract items downloaded.
        /// </summary>
        /// <param name="result">The result.</param>
        private void OnContractItemsDownloaded(CCPAPIResult <SerializableAPIContractItems> result)
        {
            m_queryPending = false;

            // Notify an error occured
            if (Character.ShouldNotifyError(result, m_apiMethod))
            {
                EveMonClient.Notifications.NotifyContractItemsError(Character, result);
            }

            // Quits if there is an error
            if (result.HasError)
            {
                return;
            }

            // Re-fetch the items if for any reason a previous attempt failed
            if (!result.Result.ContractItems.Any())
            {
                GetContractItems();
                return;
            }

            // Import the data
            Import(result.Result.ContractItems);

            // Fires the event regarding contract items downloaded
            if (m_apiMethod == CCPAPIGenericMethods.ContractItems)
            {
                EveMonClient.OnCharacterContractItemsDownloaded(Character);
            }
            else
            {
                EveMonClient.OnCorporationContractItemsDownloaded(Character);
            }
        }
Beispiel #22
0
        /// <summary>
        /// Processes the queried character's factional warfare statistic information.
        /// </summary>
        /// <param name="result"></param>
        private void OnFactionalWarfareStatsUpdated(CCPAPIResult<SerializableAPIFactionalWarfareStats> 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.FactionalWarfareStats))
                EveMonClient.Notifications.NotifyCharacterFactionalWarfareStatsError(m_ccpCharacter, result);

            // Quits if there is an error
            if (result.HasError)
            {
                if (result.CCPError == null || !result.CCPError.IsFactionalWarfareEnlistedError)
                    return;

                // Update the enlisted in factional warfare flag
                m_ccpCharacter.IsFactionalWarfareNotEnlisted = true;

                // Fires the event regarding factional warfare stats update
                EveMonClient.OnCharacterFactionalWarfareStatsUpdated(m_ccpCharacter);
                return;
            }

            // Update the enlisted in factional warfare flag
            m_ccpCharacter.IsFactionalWarfareNotEnlisted = false;

            // Import the data
            m_ccpCharacter.FactionalWarfareStats = new FactionalWarfareStats(result.Result);

            // Fires the event regarding factional warfare stats update
            EveMonClient.OnCharacterFactionalWarfareStatsUpdated(m_ccpCharacter);
        }
Beispiel #23
0
        /// <summary>
        /// Processes the queried character's personal industry jobs.
        /// </summary>
        /// <param name="result"></param>
        /// <remarks>This method is sensitive to which "issued for" jobs gets queried first</remarks>
        private void OnIndustryJobsUpdated(CCPAPIResult<SerializableAPIIndustryJobs> 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.IndustryJobs))
                EveMonClient.Notifications.NotifyCharacterIndustryJobsError(m_ccpCharacter, result);

            // Quits if there is an error
            if (result.HasError)
                return;

            result.Result.Jobs.ToList().ForEach(x => x.IssuedFor = IssuedFor.Character);

            // Import the data
            m_ccpCharacter.CharacterIndustryJobs.Import(result.Result.Jobs);

            // Fires the event regarding character industry jobs update
            EveMonClient.OnCharacterIndustryJobsUpdated(m_ccpCharacter);
        }
Beispiel #24
0
        /// <summary>
        /// Updates the API key info and characters list with the given CCP data.
        /// </summary>
        /// <param name="result"></param>
        private void Import(CCPAPIResult<SerializableAPIKeyInfo> result)
        {
            Type = GetCredentialsType(result);
            AccessMask = result.Result.Key.AccessMask;
            Expiration = result.Result.Key.Expiration;

            ImportIdentities(result.HasError ? null : result.Result.Key.Characters);
        }
Beispiel #25
0
        /// <summary>
        /// Processes the queried character's EVE mail messages.
        /// </summary>
        /// <param name="result"></param>
        private void OnEVEMailMessagesUpdated(CCPAPIResult<SerializableAPIMailMessages> 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 occured
            if (m_ccpCharacter.ShouldNotifyError(result, CCPAPICharacterMethods.MailMessages))
                EveMonClient.Notifications.NotifyEVEMailMessagesError(m_ccpCharacter, result);

            // Quits if there is an error
            if (result.HasError)
                return;

            // Each time we import a new batch of EVE mail messages,
            // query the mailing lists so that we are always up to date
            QueryCharacterMailingLists();

            // Import the data
            m_ccpCharacter.EVEMailMessages.Import(result.Result.Messages);

            // Notify on new messages
            if (m_ccpCharacter.EVEMailMessages.NewMessages != 0)
                EveMonClient.Notifications.NotifyNewEVEMailMessages(m_ccpCharacter, m_ccpCharacter.EVEMailMessages.NewMessages);
        }
Beispiel #26
0
        /// <summary>
        /// Called when the account status has been updated.
        /// </summary>
        /// <param name="result">The result.</param>
        private void OnAccountStatusUpdated(CCPAPIResult<SerializableAPIAccountStatus> result)
        {
            // Quit if the API key was deleted while it was updating
            if (!EveMonClient.APIKeys.Contains(this))
                return;

            // Checks if EVE database is out of service
            if (result.EVEDatabaseError)
                return;

            // Return on error
            if (result.HasError)
            {
                EveMonClient.Notifications.NotifyAccountStatusError(this, result);
                return;
            }

            EveMonClient.Notifications.InvalidateAccountStatusError(this);

            AccountCreated = result.Result.CreateDate;
            AccountExpires = result.Result.PaidUntil;

            // Notifies for the account expiration
            NotifyAccountExpiration();

            // Fires the event regarding the account status update
            EveMonClient.OnAccountStatusUpdated(this);
        }
Beispiel #27
0
        /// <summary>
        /// Processes the queried calendar event attendees.
        /// </summary>
        /// <param name="result">The result.</param>
        private void OnCalendarEventAttendeesDownloaded(CCPAPIResult<SerializableAPICalendarEventAttendees> result)
        {
            m_queryPending = false;

            // Notify an error occured
            if (m_ccpCharacter.ShouldNotifyError(result, CCPAPICharacterMethods.CalendarEventAttendees))
                EveMonClient.Notifications.NotifyCharacterCalendarEventAttendeesError(m_ccpCharacter, result);

            // Quits if there is an error
            if (result.HasError)
                return;

            // Quit if there are no attendees
            if (!result.Result.EventAttendees.Any())
                return;

            // Import the data
            m_eventAttendees.Clear();
            m_eventAttendees.AddRange(result.Result.EventAttendees.Select(attendee => new CalendarEventAttendee(attendee)));

            EveMonClient.OnCharacterCalendarEventAttendeesDownloaded(m_ccpCharacter);
        }
Beispiel #28
0
        /// <summary>
        /// Processes the queried character's skill queue information.
        /// </summary>
        /// <param name="result"></param>
        private void OnSkillQueueUpdated(CCPAPIResult<SerializableAPISkillQueue> 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.SkillQueue))
                EveMonClient.Notifications.NotifySkillQueueError(m_ccpCharacter, result);

            // Quits if there is an error
            if (result.HasError)
                return;

            // Import the data
            m_ccpCharacter.SkillQueue.Import(result.Result.Queue);

            // Check the account has a character in training (if API key of type "Account")
            APIKey apikey = m_ccpCharacter.Identity.FindAPIKeyWithAccess(CCPAPICharacterMethods.SkillInTraining);
            apikey?.CharacterInTraining();

            // Check the character has less than a day of training in skill queue
            if (m_ccpCharacter.IsTraining && m_ccpCharacter.SkillQueue.LessThanWarningThreshold)
            {
                EveMonClient.Notifications.NotifySkillQueueLessThanADay(m_ccpCharacter);
                return;
            }

            EveMonClient.Notifications.InvalidateSkillQueueLessThanADay(m_ccpCharacter);
        }
Beispiel #29
0
        /// <summary>
        /// Used when the API key info (character list) has been queried.
        /// </summary>
        /// <param name="result"></param>
        private void OnAPIKeyInfoUpdated(CCPAPIResult<SerializableAPIKeyInfo> result)
        {
            m_queried = true;

            // Quit if the API key was deleted while it was updating
            if (!EveMonClient.APIKeys.Contains(this))
                return;

            // Checks if EVE database is out of service
            if (result.EVEDatabaseError)
                return;

            // Notify on error
            if (result.HasError)
            {
                // Fire the event in order to trigger the monitoring of a character's features
                // regardless of the result having error
                EveMonClient.OnAPIKeyInfoUpdated(this);

                // Notify the user
                EveMonClient.Notifications.NotifyCharacterListError(this, result);
                return;
            }

            // Invalidates the notification
            EveMonClient.Notifications.InvalidateAPIKeyInfoError(this);

            // Update
            Import(result);

            // Notifies for the API key expiration
            NotifyAPIKeyExpiration();

            // Fires the event regarding the API key info update
            EveMonClient.OnAPIKeyInfoUpdated(this);
        }
Beispiel #30
0
        /// <summary>
        /// Processes the queried character's kill log.
        /// </summary>
        /// <param name="result"></param>
        private void OnKillLogUpdated(CCPAPIResult<SerializableAPIKillLog> 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.KillLog))
                EveMonClient.Notifications.NotifyCharacterKillLogError(m_ccpCharacter, result);

            // Quits if there is an error
            if (result.HasError)
                return;

            // Import the data
            m_ccpCharacter.KillLog.Import(result.Result.Kills);

            // Fires the event regarding kill log update
            EveMonClient.OnCharacterKillLogUpdated(m_ccpCharacter);

            // Save the file to our cache
            string filename = $"{m_ccpCharacter.Name}-{CCPAPICharacterMethods.KillLog}";
            LocalXmlCache.SaveAsync(filename, result.XmlDocument).ConfigureAwait(false);
        }
Beispiel #31
0
        /// <summary>
        /// Processes the queried character's market orders.
        /// </summary>
        /// <param name="result"></param>
        /// <remarks>This method is sensitive to which "issued for" orders gets queried first</remarks>
        private void OnMarketOrdersUpdated(CCPAPIResult<SerializableAPIMarketOrders> 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.MarketOrders))
                EveMonClient.Notifications.NotifyCharacterMarketOrdersError(m_ccpCharacter, result);

            // Quits if there is an error
            if (result.HasError)
                return;

            result.Result.Orders.ToList().ForEach(order => order.IssuedFor = IssuedFor.Character);

            // Import the data
            List<MarketOrder> endedOrders = new List<MarketOrder>();
            m_ccpCharacter.CharacterMarketOrders.Import(result.Result.Orders, endedOrders);

            // Fires the event regarding character market orders update
            EveMonClient.OnCharacterMarketOrdersUpdated(m_ccpCharacter, endedOrders);
        }
Beispiel #32
0
        /// <summary>
        /// Processes the queried character's corporation contract bids.
        /// </summary>
        private void OnCorporationContractBidsUpdated(CCPAPIResult<SerializableAPIContractBids> 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 occured
            if (m_ccpCharacter.ShouldNotifyError(result, CCPAPIGenericMethods.CorporationContractBids))
                EveMonClient.Notifications.NotifyCorporationContractBidsError(m_ccpCharacter, result);

            // Quits if there is an error
            if (result.HasError)
                return;

            // Import the data
            m_ccpCharacter.CorporationContractBids.Import(result.Result.ContractBids);

            // Fires the event regarding corporation contract bids update
            EveMonClient.OnCorporationContractBidsUpdated(m_ccpCharacter);
        }
        public CCPAPIResult <SerializableAPICharacterSheet> Invoke(Dictionary <string, string> legacyPostData, string dataSource, string accessToken)
        {
            var characterId = int.Parse(legacyPostData["characterID"]);

            var characterInfo       = _characterApi.GetCharactersCharacterId(characterId, dataSource);
            var characterAttributes = _skillsApi.GetCharactersCharacterIdAttributes(characterId, dataSource, accessToken);
            var characterClones     = _clonesApi.GetCharactersCharacterIdClones(characterId, dataSource, accessToken);
            var characterFatigue    = _characterApi.GetCharactersCharacterIdFatigue(characterId, dataSource, accessToken);
            var characterSkills     = _skillsApi.GetCharactersCharacterIdSkills(characterId, dataSource, accessToken);

            var result = new CCPAPIResult <SerializableAPICharacterSheet>
            {
                Result = new SerializableAPICharacterSheet
                {
                    ID                = characterId,
                    Name              = characterInfo.Name,
                    Gender            = characterInfo.Gender.ToString(),
                    CorporationID     = characterInfo.CorporationId.GetValueOrDefault(),
                    CorporationName   = GetCorpName(characterInfo.CorporationId.GetValueOrDefault(), dataSource),
                    Birthday          = characterInfo.Birthday.GetValueOrDefault(),
                    AllianceID        = characterInfo.AllianceId.GetValueOrDefault(),
                    AllianceName      = GetAllianceName(characterInfo.AllianceId.GetValueOrDefault(), dataSource),
                    FactionID         = characterInfo.FactionId.GetValueOrDefault(),
                    FactionName       = GetFactionName(characterInfo.FactionId.GetValueOrDefault(), dataSource),
                    Ancestry          = GetAncestryName(characterInfo.AncestryId.GetValueOrDefault(), dataSource),
                    BloodLine         = GetBloodLineName(characterInfo.BloodlineId.GetValueOrDefault(), dataSource),
                    Race              = GetRaceName(characterInfo.RaceId.GetValueOrDefault(), dataSource),
                    LastKnownLocation = GetCharacterLocation(characterId, dataSource, accessToken),
                    SecurityStatus    = GetSecurityStatus(characterId, dataSource),
                    ShipName          = GetShipName(characterId, dataSource, accessToken),
                    ShipTypeName      = GetShipTypeName(characterId, dataSource, accessToken),
                    Balance           = GetWalletBalance(characterId, dataSource, accessToken),
                    //This also handles boosters correctly
                    Attributes = new SerializableCharacterAttributes
                    {
                        Charisma     = characterAttributes.Charisma.GetValueOrDefault(),
                        Intelligence = characterAttributes.Intelligence.GetValueOrDefault(),
                        Memory       = characterAttributes.Memory.GetValueOrDefault(),
                        Perception   = characterAttributes.Perception.GetValueOrDefault(),
                        Willpower    = characterAttributes.Willpower.GetValueOrDefault()
                    },
                    FreeRespecs    = (short)characterAttributes.BonusRemaps.GetValueOrDefault(),
                    LastRespecDate = characterAttributes.LastRemapDate.GetValueOrDefault(),
                    //We cant tell the difference here (possibly by checking accrued remap cooldowndate?)
                    LastTimedRespec    = characterAttributes.LastRemapDate.GetValueOrDefault(),
                    HomeStationID      = characterClones.HomeLocation.LocationId.GetValueOrDefault(),
                    RemoteStationDate  = characterClones.LastStationChangeDate.GetValueOrDefault(),
                    CloneJumpDate      = characterClones.LastCloneJumpDate.GetValueOrDefault(),
                    JumpActivationDate = characterFatigue.LastJumpDate.GetValueOrDefault(),
                    JumpFatigueDate    = characterFatigue.JumpFatigueExpireDate.GetValueOrDefault(),
                    JumpLastUpdateDate = characterFatigue.LastUpdateDate.GetValueOrDefault(),
                    FreeSkillPoints    = characterSkills.UnallocatedSp.GetValueOrDefault(),
                }
            };

            //CorpHistory
            result.Result.EmploymentHistory.Clear();
            result.Result.EmploymentHistory.AddRange(GetCorporationHistory(characterId, dataSource));

            //Implants
            result.Result.Implants.Clear();
            result.Result.Implants.AddRange(GetImplants(characterId, dataSource, accessToken));

            //Skills
            result.Result.Skills.Clear();
            result.Result.Skills.AddRange(GetSkills(characterSkills.Skills));

            //JumpClones
            result.Result.JumpClones.Clear();
            result.Result.JumpClones.AddRange(GetJumpClones(characterClones.JumpClones));

            //JumpCloneImplants
            result.Result.JumpCloneImplants.Clear();
            result.Result.JumpCloneImplants.AddRange(GetJumpCloneImplants(characterClones.JumpClones));

            //Not supported
            result.Result.Certificates.Clear();

            return(result);
        }
Beispiel #34
0
 /// <summary>
 /// Imports data from the given character sheet informations.
 /// </summary>
 /// <param name="serial">The serialized character sheet</param>
 internal void Import(CCPAPIResult<SerializableAPICharacterSheet> serial)
 {
     Import(serial.Result);
     EveMonClient.OnCharacterUpdated(this);
 }
Beispiel #35
0
        /// <summary>
        /// Called when character's skill in training gets updated.
        /// </summary>
        /// <param name="result">The result.</param>
        /// <param name="characterName">The character's name.</param>
        private void OnSkillInTrainingUpdated(CCPAPIResult<SerializableAPISkillInTraining> result, string characterName)
        {
            // Quit if the API key was deleted while it was updating
            if (!EveMonClient.APIKeys.Contains(this))
                return;

            CCPCharacter ccpCharacter = EveMonClient.Characters.OfType<CCPCharacter>().FirstOrDefault(x => x.Name == characterName);

            // Checks if EVE database is out of service
            if (result.EVEDatabaseError)
                return;

            // Return on error
            if (result.HasError)
            {
                if (ccpCharacter != null && ccpCharacter.ShouldNotifyError(result, CCPAPICharacterMethods.SkillInTraining))
                    EveMonClient.Notifications.NotifySkillInTrainingError(ccpCharacter, result);

                m_skillInTrainingCache[characterName].State = ResponseState.InError;
                return;
            }

            m_skillInTrainingCache[characterName].State = result.Result.SkillInTraining == 1
                                                              ? ResponseState.Training
                                                              : ResponseState.NotTraining;

            // In the event this becomes a very long running process because of latency
            // and characters have been removed from the API key since they were queried
            // remove those characters from the cache
            IEnumerable<KeyValuePair<string, SkillInTrainingResponse>> toRemove =
                m_skillInTrainingCache.Where(x => CharacterIdentities.All(y => y.CharacterName != x.Key));

            foreach (KeyValuePair<string, SkillInTrainingResponse> charToRemove in toRemove)
            {
                m_skillInTrainingCache.Remove(charToRemove.Key);
            }

            // If we did not get response from a character in API key yet
            // or there was an error in any responce,
            // we are not sure so wait until next time
            if (m_skillInTrainingCache.Any(x => x.Value.State == ResponseState.Unknown
                                                || x.Value.State == ResponseState.InError))
                return;

            // We have successful responces from all characters in API key,
            // so we notify the user and fire the event
            NotifyAccountNotInTraining();

            // Fires the event regarding the API key characters skill in training update
            EveMonClient.OnCharactersSkillInTrainingUpdated(this);

            // Reset update pending flag
            m_updatePending = false;
        }
Beispiel #36
0
        /// <summary>
        /// Called when contract items downloaded.
        /// </summary>
        /// <param name="result">The result.</param>
        private void OnContractItemsDownloaded(CCPAPIResult<SerializableAPIContractItems> result)
        {
            m_queryPending = false;

            // Notify an error occured
            if (Character.ShouldNotifyError(result, m_apiMethod))
                EveMonClient.Notifications.NotifyContractItemsError(Character, result);

            // Quits if there is an error
            if (result.HasError)
                return;

            // Re-fetch the items if for any reason a previous attempt failed
            if (!result.Result.ContractItems.Any())
            {
                GetContractItems();
                return;
            }

            // Import the data
            Import(result.Result.ContractItems);

            // Fires the event regarding contract items downloaded
            if (m_apiMethod == CCPAPIGenericMethods.ContractItems)
                EveMonClient.OnCharacterContractItemsDownloaded(Character);
            else
                EveMonClient.OnCorporationContractItemsDownloaded(Character);
        }
Beispiel #37
0
        /// <summary>
        /// Processes the queried character's EVE mailing lists.
        /// </summary>
        /// <param name="result">The result.</param>
        private void OnMailingListsUpdated(CCPAPIResult<SerializableAPIMailingLists> 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 occured
            if (m_ccpCharacter.ShouldNotifyError(result, CCPAPICharacterMethods.MailingLists))
                EveMonClient.Notifications.NotifyMailingListsError(m_ccpCharacter, result);

            // Quits if there is an error
            if (result.HasError)
                return;

            // Import the data
            m_ccpCharacter.EVEMailingLists.Import(result.Result.MailingLists);
        }
Beispiel #38
0
        /// <summary>
        /// Called when character's skill in training gets updated.
        /// </summary>
        /// <param name="result">The result.</param>
        /// <param name="characterName">The character's name.</param>
        private void OnSkillInTrainingUpdated(CCPAPIResult <SerializableAPISkillInTraining> result, string characterName)
        {
            // Quit if the API key was deleted while it was updating
            if (!EveMonClient.APIKeys.Contains(this))
            {
                return;
            }

            CCPCharacter ccpCharacter = EveMonClient.Characters.OfType <CCPCharacter>().FirstOrDefault(x => x.Name == characterName);

            // Checks if EVE database is out of service
            if (result.EVEDatabaseError)
            {
                return;
            }

            // Return on error
            if (result.HasError)
            {
                if (ccpCharacter != null && ccpCharacter.ShouldNotifyError(result, CCPAPICharacterMethods.SkillInTraining))
                {
                    EveMonClient.Notifications.NotifySkillInTrainingError(ccpCharacter, result);
                }

                m_skillInTrainingCache[characterName].State = ResponseState.InError;
                return;
            }

            m_skillInTrainingCache[characterName].State = result.Result.SkillInTraining == 1
                                                              ? ResponseState.Training
                                                              : ResponseState.NotTraining;

            // In the event this becomes a very long running process because of latency
            // and characters have been removed from the API key since they were queried
            // remove those characters from the cache
            IEnumerable <KeyValuePair <string, SkillInTrainingResponse> > toRemove =
                m_skillInTrainingCache.Where(x => CharacterIdentities.All(y => y.CharacterName != x.Key));

            foreach (KeyValuePair <string, SkillInTrainingResponse> charToRemove in toRemove)
            {
                m_skillInTrainingCache.Remove(charToRemove.Key);
            }

            // If we did not get response from a character in API key yet
            // or there was an error in any responce,
            // we are not sure so wait until next time
            if (m_skillInTrainingCache.Any(x => x.Value.State == ResponseState.Unknown ||
                                           x.Value.State == ResponseState.InError))
            {
                return;
            }

            // We have successful responces from all characters in API key,
            // so we notify the user and fire the event
            NotifyAccountNotInTraining();

            // Fires the event regarding the API key characters skill in training update
            EveMonClient.OnCharactersSkillInTrainingUpdated(this);

            // Reset update pending flag
            m_updatePending = false;
        }
Beispiel #39
0
        /// <summary>
        /// Processes the queried character's palnetary colonies.
        /// </summary>
        /// <param name="result"></param>
        private void OnPlanetaryColoniesUpdated(CCPAPIResult<SerializableAPIPlanetaryColonies> 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, CCPAPIGenericMethods.PlanetaryColonies))
                EveMonClient.Notifications.NotifyCharacterPlanetaryColoniesError(m_ccpCharacter, result);

            // Quits if there is an error
            if (result.HasError)
                return;

            // Invalidate previous notifications
            EveMonClient.Notifications.InvalidateCharacterPlanetaryPinCompleted(m_ccpCharacter);

            // Import the data
            m_ccpCharacter.PlanetaryColonies.Import(result.Result.Colonies);

            // Fires the event regarding planetary colonies update
            EveMonClient.OnCharacterPlanetaryColoniesUpdated(m_ccpCharacter);
        }
Beispiel #40
0
 /// <summary>
 /// Default constructor for new uri characters.
 /// </summary>
 /// <param name="identity">The identitiy for this character</param>
 /// <param name="uri">The uri the provided deserialization object was acquired from</param>
 /// <param name="source">A deserialization object for characters</param>
 internal UriCharacter(CharacterIdentity identity, Uri uri, CCPAPIResult<SerializableAPICharacterSheet> source)
     : base(identity, Guid.NewGuid())
 {
     m_uri = uri;
     Import(source);
 }
Beispiel #41
0
        /// <summary>
        /// Processes the queried character's wallet transactions information.
        /// </summary>
        /// <param name="result"></param>
        private void OnWalletTransactionsUpdated(CCPAPIResult<SerializableAPIWalletTransactions> 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.WalletTransactions))
                EveMonClient.Notifications.NotifyCharacterWalletTransactionsError(m_ccpCharacter, result);

            // Quits if there is an error
            if (result.HasError)
                return;

            // Import the data
            m_ccpCharacter.WalletTransactions.Import(result.Result.WalletTransactions);

            // Fires the event regarding wallet transactions update
            EveMonClient.OnCharacterWalletTransactionsUpdated(m_ccpCharacter);
        }
Beispiel #42
0
        /// <summary>
        /// Processes the queried EVE notification text.
        /// </summary>
        /// <param name="result">The result.</param>
        private void OnEVENotificationTextDownloaded(CCPAPIResult<SerializableAPINotificationTexts> result)
        {
            m_queryPending = false;

            // Notify an error occured
            if (m_ccpCharacter.ShouldNotifyError(result, CCPAPICharacterMethods.NotificationTexts))
                EveMonClient.Notifications.NotifyEVENotificationTextsError(m_ccpCharacter, result);

            // Quits if there is an error
            if (result.HasError)
                return;

            // If there is an error response on missing IDs inform the user
            if (!String.IsNullOrEmpty(result.Result.MissingMessageIDs))
            {
                result.Result.Texts.Add(
                    new SerializableNotificationTextsListItem
                    {
                        NotificationID = long.Parse(result.Result.MissingMessageIDs, CultureConstants.InvariantCulture),
                        NotificationText = "The text for this notification was reported missing."
                    });
            }

            // Quit if for any reason there is no text
            if (!result.Result.Texts.Any())
                return;

            // Import the data
            EVENotificationText = new EveNotificationText(this, result.Result.Texts.First());

            EveMonClient.OnCharacterEVENotificationTextDownloaded(m_ccpCharacter);
        }
Beispiel #43
0
        /// <summary>
        /// Called when the query updated.
        /// </summary>
        /// <param name="result">The result.</param>
        private static void OnQueryAPICharacterNameUpdated(CCPAPIResult<SerializableAPICharacterName> result)
        {
            // Checks if EVE database is out of service
            if (result.EVEDatabaseError)
                return;

            if (result.HasError)
            {
                EveMonClient.Notifications.NotifyCharacterNameError(result);
                return;
            }

            EveMonClient.Notifications.InvalidateAPIError();

            // Deserialize the result
            Import(result.Result.Entities);

            // Notify the subscribers
            EveMonClient.OnEveIDToNameUpdated();

            // We save the data to the disk
            Save();
        }
Beispiel #44
0
        /// <summary>
        /// Processes the conquerable station list.
        /// </summary>
        private static void OnUpdated(CCPAPIResult<SerializableAPIEveFactionalWarfareStats> result)
        {
            // Checks if EVE database is out of service
            if (result.EVEDatabaseError)
            {
                // Reset query pending flag
                s_queryPending = false;
                return;
            }

            // Was there an error ?
            if (result.HasError)
            {
                // Reset query pending flag
                s_queryPending = false;

                EveMonClient.Notifications.NotifyEveFactionalWarfareStatsError(result);
                return;
            }

            EveMonClient.Notifications.InvalidateAPIError();

            // Deserialize the result
            Import(result.Result);

            // Reset query pending flag
            s_queryPending = false;

            // Notify the subscribers
            EveMonClient.OnEveFactionalWarfareStatsUpdated();

            // Save the file to our cache
            LocalXmlCache.SaveAsync(Filename, result.XmlDocument).ConfigureAwait(false);
        }
Beispiel #45
0
 /// <summary>
 /// Manually updates this monitor with the provided data, like if it has just been updated from CCP.
 /// </summary>
 /// <param name="result">The result.</param>
 /// <remarks>
 /// This method does not fire any event.
 /// </remarks>
 internal void UpdateWith(CCPAPIResult <T> result)
 {
     LastResult = result;
     LastUpdate = DateTime.UtcNow;
 }
Beispiel #46
0
 /// <summary>
 /// Default constructor for new uri characters.
 /// </summary>
 /// <param name="identity">The identitiy for this character</param>
 /// <param name="uri">The uri the provided deserialization object was acquired from</param>
 /// <param name="source">A deserialization object for characters</param>
 internal UriCharacter(CharacterIdentity identity, Uri uri, CCPAPIResult <SerializableAPICharacterSheet> source)
     : base(identity, Guid.NewGuid())
 {
     m_uri = uri;
     Import(source);
 }
Beispiel #47
0
 /// <summary>
 /// Updates this character with the given informations
 /// </summary>
 /// <param name="identity"></param>
 /// <param name="uri"></param>
 /// <param name="result"></param>
 internal void Update(CharacterIdentity identity, Uri uri, CCPAPIResult<SerializableAPICharacterSheet> result)
 {
     CharacterID = identity.CharacterID;
     Identity = identity;
     m_uri = uri;
     Import(result);
 }
Beispiel #48
0
        /// <summary>
        /// Gets the credential level from the given result.
        /// </summary>
        internal static CCPAPIKeyType GetCredentialsType(CCPAPIResult<SerializableAPIKeyInfo> apiKeyInfo)
        {
            // An error occurred
            if (apiKeyInfo.HasError)
                return CCPAPIKeyType.Unknown;

            if (Enum.IsDefined(typeof(CCPAPIKeyType), apiKeyInfo.Result.Key.Type))
                return (CCPAPIKeyType)Enum.Parse(typeof(CCPAPIKeyType), apiKeyInfo.Result.Key.Type);

            // Another error occurred
            return CCPAPIKeyType.Unknown;
        }
Beispiel #49
0
 /// <summary>
 /// Imports data from the given character sheet informations.
 /// </summary>
 /// <param name="serial">The serialized character sheet</param>
 internal void Import(CCPAPIResult <SerializableAPICharacterSheet> serial)
 {
     Import(serial.Result);
     EveMonClient.OnCharacterUpdated(this);
 }
Beispiel #50
0
        /// <summary>
        /// Processes the queried character's assets information.
        /// </summary>
        /// <param name="result"></param>
        private void OnAssetsUpdated(CCPAPIResult<SerializableAPIAssetList> 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.AssetList))
                EveMonClient.Notifications.NotifyCharacterAssetsError(m_ccpCharacter, result);

            // Quits if there is an error
            if (result.HasError)
                return;

            // Import the data
            TaskHelper.RunCPUBoundTaskAsync(() => m_ccpCharacter.Assets.Import(result.Result.Assets))
                .ContinueWith(_ =>
                {
                    // Fires the event regarding assets update
                    EveMonClient.OnCharacterAssetsUpdated(m_ccpCharacter);

                }, EveMonClient.CurrentSynchronizationContext);
        }
Beispiel #51
0
        /// <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);
        }
Beispiel #52
0
        /// <summary>
        /// Processes the queried character's contracts.
        /// </summary>
        /// <param name="result"></param>
        /// <remarks>This method is sensitive to which "issued for" contracts gets queried first</remarks>
        private void OnContractsUpdated(CCPAPIResult<SerializableAPIContracts> 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.Contracts))
                EveMonClient.Notifications.NotifyCharacterContractsError(m_ccpCharacter, result);

            // Quits if there is an error
            if (result.HasError)
                return;

            // Query the contract bids
            QueryCharacterContractBids();

            result.Result.Contracts.ToList().ForEach(x =>
            {
                x.IssuedFor = IssuedFor.Character;
                x.APIMethod = CCPAPICharacterMethods.Contracts;
            });

            // Import the data
            List<Contract> endedContracts = new List<Contract>();
            m_ccpCharacter.CharacterContracts.Import(result.Result.Contracts, endedContracts);

            // Fires the event regarding character contracts update
            EveMonClient.OnCharacterContractsUpdated(m_ccpCharacter, endedContracts);
        }
Beispiel #53
0
        /// <summary>
        /// Process XML document.
        /// </summary>
        /// <typeparam name="T">The type to deserialize from the document</typeparam>
        /// <param name="transform">The XSL transformation to apply. May be <c>null</c>.</param>
        /// <param name="doc">The XML document to deserialize from.</param>
        /// <returns>The result of the deserialization.</returns>
        private static CCPAPIResult <T> DeserializeAPIResultCore <T>(IXPathNavigable doc, XslCompiledTransform transform = null)
        {
            CCPAPIResult <T> result;

            try
            {
                // Deserialization with a transform
                using (XmlNodeReader reader = new XmlNodeReader((XmlDocument)doc))
                {
                    XmlSerializer xs = new XmlSerializer(typeof(CCPAPIResult <T>));

                    if (transform != null)
                    {
                        MemoryStream stream = GetMemoryStream();
                        using (XmlTextWriter writer = new XmlTextWriter(stream, Encoding.UTF8))
                        {
                            // Apply the XSL transform
                            writer.Formatting = Formatting.Indented;
                            transform.Transform(reader, writer);
                            writer.Flush();

                            // Deserialize from the given stream
                            stream.Seek(0, SeekOrigin.Begin);
                            result = (CCPAPIResult <T>)xs.Deserialize(stream);
                        }
                    }
                    // Deserialization without transform
                    else
                    {
                        result = (CCPAPIResult <T>)xs.Deserialize(reader);
                    }
                }

                // Fix times
                if (result.Result is ISynchronizableWithLocalClock)
                {
                    DateTime requestTime = DateTime.UtcNow;
                    double   offsetCCP   = result.CurrentTime.Subtract(requestTime).TotalMilliseconds;
                    result.SynchronizeWithLocalClock(offsetCCP);
                }
            }
            // An error occurred during the XSL transform
            catch (XsltException exc)
            {
                ExceptionHandler.LogException(exc, true);
                result = new CCPAPIResult <T>(exc);
            }
            // An error occurred during the deserialization
            catch (InvalidOperationException exc)
            {
                ExceptionHandler.LogException(exc, true);
                result = new CCPAPIResult <T>(exc);
            }
            catch (XmlException exc)
            {
                ExceptionHandler.LogException(exc, true);
                result = new CCPAPIResult <T>(exc);
            }

            // Stores XMLDocument
            result.XmlDocument = doc;
            return(result);
        }
Beispiel #54
0
        /// <summary>
        /// Processes the queried notification ref type.
        /// </summary>
        /// <param name="result">The result.</param>
        private static void OnDownloaded(CCPAPIResult<SerializableNotificationRefTypes> result)
        {
            if (!String.IsNullOrEmpty(result.ErrorMessage))
            {
                // Reset query pending flag
                s_queryPending = false;

                EveMonClient.Trace(result.ErrorMessage);

                // Fallback
                EnsureInitialized();
                return;
            }

            s_cachedUntil = DateTime.UtcNow.AddDays(1);

            // Import the list
            Import(result.Result);

            // Reset query pending flag
            s_queryPending = false;

            // Notify the subscribers
            EveMonClient.OnNotificationRefTypesUpdated();

            // Save the file in cache
            LocalXmlCache.SaveAsync(Filename, result.XmlDocument).ConfigureAwait(false);
        }