/// <summary> /// Sets the NCBI API key from the field on the form /// </summary> /// <returns> /// True if the API key file in the field is found or empty, false if the API it's invalid /// </returns> private bool SetApiKeyFromFormField() { if (!string.IsNullOrWhiteSpace(apiKeyFileTextBox.Text.Trim())) { if (File.Exists(apiKeyFileTextBox.Text.Trim())) { NCBI.GetApiKey(apiKeyFileTextBox.Text.Trim()); } else { MessageBox.Show($"API key file not found: {apiKeyFileTextBox.Text.Trim()}"); return(false); } } if (NCBI.ApiKeyExists) { Trace.WriteLine("Using API key: " + NCBI.ApiKeyPath); } else { Trace.WriteLine("Performance is limited to under 3 requests per second."); Trace.WriteLine("Consider pasting an API key into " + NCBI.ApiKeyPath); Trace.WriteLine("Or set the NCBI_API_KEY_FILE environemnt variable to the API key file path"); Trace.WriteLine("For more information, see https://ncbiinsights.ncbi.nlm.nih.gov/2017/11/02/new-api-keys-for-the-e-utilities/"); } return(true); }
/// <summary> /// Sets the NCBI API key from the field on the form /// </summary> /// <returns> /// True if the API key file in the field is found or empty, false if the API it's invalid /// </returns> private bool SetApiKeyFromFormField() { if (!string.IsNullOrWhiteSpace(ApiKeyFile.Text.Trim())) { if (File.Exists(ApiKeyFile.Text.Trim())) { NCBI.GetApiKey(ApiKeyFile.Text.Trim()); } else { MessageBox.Show($"API key file not found: {ApiKeyFile.Text.Trim()}"); return(false); } } return(true); }