/// <summary>
        /// Goes to the results page once the key has been received from the server.
        /// </summary>
        private void GoToResults(AccessResponse response)
        {
            // Fail if an empty response is received
            bool failed = string.IsNullOrEmpty(response?.AccessToken) || string.IsNullOrEmpty(
                response?.RefreshToken);

            // If the arguments have not been invalidated since the last time...
            if (m_creationArgs != null)
            {
                MultiPanel.SelectedPage = ResultPage;
            }
            else if (failed)
            {
                // Error when fetching the key
                KeyPicture.Image               = Resources.KeyWrong32;
                KeyLabel.Text                  = Properties.Resources.ErrorNoToken;
                CharactersGroupBox.Text        = @"Error report";
                ResultsMultiPanel.SelectedPage = ESITokenFailedErrorPage;
                MultiPanel.SelectedPage        = ResultPage;
                m_keyValid = false;
            }
            else
            {
                long newID = DateTime.UtcNow.ToFileTime();
                // Are we updating existing API key?
                if (m_updateMode)
                {
                    m_esiKey.TryUpdateAsync(response, OnUpdated);
                }
                else
                {
                    ESIKey.TryAddOrUpdateAsync(newID, response, OnUpdated);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Goes to the results page once the key has been received from the server.
        /// </summary>
        private void GoToResults(JsonResult <AccessResponse> result)
        {
            bool           failed   = result.HasError;
            AccessResponse response = null;

            // Fail if an empty response is received
            if (!failed)
            {
                response = result.Result;
                if (string.IsNullOrEmpty(response?.AccessToken) || string.IsNullOrEmpty(
                        response?.RefreshToken))
                {
                    failed = true;
                }
            }

            // If the args have not been invalidated since the last time...
            if (m_creationArgs != null)
            {
                MultiPanel.SelectedPage = ResultPage;
                return;
            }

            if (failed)
            {
                Exception e = result.Exception;
                if (e != null)
                {
                    ExceptionHandler.LogException(e, true);
                }

                // Error when fetching the key
                KeyPicture.Image               = Resources.KeyWrong32;
                KeyLabel.Text                  = @"ESI token could not be obtained.";
                CharactersGroupBox.Text        = @"Error report";
                ResultsMultiPanel.SelectedPage = ESITokenFailedErrorPage;
                MultiPanel.SelectedPage        = ResultPage;
                return;
            }

            // Are we updating existing API key?
            if (m_updateMode)
            {
                m_esiKey.TryUpdateAsync(response, OnUpdated);
            }
            else
            {
                ESIKey.TryAddOrUpdateAsync(DateTime.UtcNow.ToFileTime(), response, OnUpdated);
            }
        }