예제 #1
0
        /// <summary>
        /// Uploads the settings file.
        /// </summary>
        /// <returns></returns>
        public async Task <bool> UploadSettingsFileOnExitAsync()
        {
            if (!CloudStorageServiceSettings.Default.UploadAlways || !HasCredentialsStored)
            {
                return(true);
            }

            //var isValid = CheckAPIAuthIsValid();

            // Quit if user is not authenticated
            if (!IsAuthenticated && !CheckAPIAuthIsValid())
            {
                MessageBox.Show($"The {Name} API credentials could not be authenticated.", $"{Name} API Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);

                return(false);
            }

            EveMonClient.Trace("Initiated");

            // Ask for user action if uploading fails
            while (true)
            {
                SerializableAPIResult <CloudStorageServiceAPIFile> result = await UploadFileAsync().ConfigureAwait(false);

                FileUploaded?.ThreadSafeInvoke(this, new CloudStorageServiceProviderEventArgs(result.Error?.ErrorMessage));

                if (!result.HasError)
                {
                    EveMonClient.Trace("CloudStorageServiceProvider.UploadSettingsFileOnExitAsync - Completed", printMethod: false);
                    return(true);
                }

                DialogResult dialogResult = MessageBox.Show(result.Error?.ErrorMessage, $"{Name} API Error",
                                                            MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);

                switch (dialogResult)
                {
                case DialogResult.Abort:
                    EveMonClient.Trace("Failed and Aborted");
                    return(false);

                case DialogResult.Retry:
                    continue;
                }

                EveMonClient.Trace("Failed and Ignored");
                return(true);
            }
        }
예제 #2
0
        /// <summary>
        /// Uploads the settings file asynchronously.
        /// </summary>
        public async Task UploadSettingsFileAsync()
        {
            if (m_queryPending)
            {
                return;
            }

            m_queryPending = true;

            EveMonClient.Trace("Initiated");

            SerializableAPIResult <CloudStorageServiceAPIFile> result = await UploadFileAsync().ConfigureAwait(false);

            FileUploaded?.ThreadSafeInvoke(this, new CloudStorageServiceProviderEventArgs(result.Error?.ErrorMessage));
            m_queryPending = false;

            string resultText = result.HasError ? "Failed" : "Completed";

            EveMonClient.Trace($"CloudStorageServiceProvider.UploadSettingsFileAsync - {resultText}", printMethod: false);
        }