Exemplo n.º 1
0
        /// <summary>
        /// Processes the queried calendar event attendees.
        /// </summary>
        /// <param name="result">The result.</param>
        private void OnCalendarEventAttendeesDownloaded(EsiResult <EsiAPICalendarEventAttendees> result, object ignore)
        {
            m_queryPending = false;

            // Notify an error occured
            if (m_ccpCharacter.ShouldNotifyError(result, ESIAPICharacterMethods.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.Count < 1)
            {
                return;
            }

            var attendees = result.Result.ToXMLItem().EventAttendees.Select(attendee =>
                                                                            new CalendarEventAttendee(attendee));

            // Import the data
            m_eventAttendees.Clear();
            m_eventAttendees.AddRange(attendees);

            EveMonClient.OnCharacterCalendarEventAttendeesDownloaded(m_ccpCharacter);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Processes the queried EVE mail message mail body.
        /// </summary>
        /// <param name="result">The result.</param>
        private void OnEVEMailBodyDownloaded(EsiResult <EsiAPIMailBody> result, object forMessage)
        {
            long messageID = (forMessage as long?) ?? 0L;

            m_queryPending = false;

            // Notify an error occured
            if (m_ccpCharacter.ShouldNotifyError(result, ESIAPICharacterMethods.MailBodies))
            {
                EveMonClient.Notifications.NotifyEVEMailBodiesError(m_ccpCharacter, result);
            }

            // Quits if there is an error
            if (result.HasError || messageID == 0L)
            {
                return;
            }

            // Quit if for any reason there is no text
            if (string.IsNullOrEmpty(result.Result.Body))
            {
                return;
            }

            // Import the data
            EVEMailBody = new EveMailBody(messageID, result.Result);

            EveMonClient.OnCharacterEVEMailBodyDownloaded(m_ccpCharacter);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Processes the queried EVE mail message mail body.
        /// </summary>
        /// <param name="result">The result.</param>
        private void OnEVEMailBodyDownloaded(EsiResult <EsiAPIMailBody> result, object forMessage)
        {
            long messageID = (forMessage as long?) ?? 0L;

            m_queryPending = false;
            // Notify if an error occured
            if (m_ccpCharacter.ShouldNotifyError(result, ESIAPICharacterMethods.MailBodies))
            {
                EveMonClient.Notifications.NotifyEVEMailBodiesError(m_ccpCharacter, result);
            }
            if (!result.HasError && messageID != 0L && !string.IsNullOrEmpty(result.Result.Body))
            {
                EVEMailBody = new EveMailBody(messageID, result.Result);
                EveMonClient.OnCharacterEVEMailBodyDownloaded(m_ccpCharacter);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Processes the queried calendar event attendees.
        /// </summary>
        /// <param name="result">The result.</param>
        private void OnCalendarEventAttendeesDownloaded(EsiResult <EsiAPICalendarEventAttendees> result, object ignore)
        {
            m_queryPending = false;

            // Notify if an error occured
            if (m_ccpCharacter.ShouldNotifyError(result, ESIAPICharacterMethods.CalendarEventAttendees))
            {
                EveMonClient.Notifications.NotifyCharacterCalendarEventAttendeesError(
                    m_ccpCharacter, result);
            }
            if (!result.HasError && result.Result.Count > 0)
            {
                var attendees = result.Result.ToXMLItem().EventAttendees.Select(attendee =>
                                                                                new CalendarEventAttendee(attendee));
                m_eventAttendees.Clear();
                m_eventAttendees.AddRange(attendees);
                EveMonClient.OnCharacterCalendarEventAttendeesDownloaded(m_ccpCharacter);
            }
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
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;
        }