/// <summary> /// Deserialize the file and import the stats. /// </summary> private static void Import() { // Exit if we have already imported or are in the process of importing the list if (s_loaded || s_queryPending || s_isImporting) { return; } string filename = LocalXmlCache.GetFileInfo(Filename).FullName; // Abort if the file hasn't been obtained for any reason if (!File.Exists(filename)) { return; } CCPAPIResult <SerializableAPIEveFactionalWarfareStats> result = Util.DeserializeAPIResultFromFile <SerializableAPIEveFactionalWarfareStats>(filename, APIProvider.RowsetsTransform); // In case the file has an error we prevent the importation if (result.HasError) { FileHelper.DeleteFile(filename); s_nextCheckTime = DateTime.UtcNow; return; } // Deserialize the result Import(result.Result); }
/// <summary> /// Occurs on "update" button click. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUpdate_Click(object sender, EventArgs e) { DialogResult result = DialogResult.Yes; int changedFilesCount = m_args.ChangedFiles.Count; // Delete the EVE Flags xml file from cache to force a refetch on next startup FileHelper.DeleteFile(LocalXmlCache.GetFileInfo(EveFlag.Filename).FullName); while (m_args.ChangedFiles.Count != 0 && result == DialogResult.Yes) { if (m_formClosing) { break; } DownloadUpdates(); if (m_args.ChangedFiles.Count == 0) { break; } // One or more files failed string message = $"{m_args.ChangedFiles.Count} " + $"file{(m_args.ChangedFiles.Count == 1 ? String.Empty : "s")} " + "failed to download, do you wish to try again?"; result = MessageBox.Show(message, @"Failed Download", MessageBoxButtons.YesNo); } // If no files were updated, abort the update process DialogResult = m_args.ChangedFiles.Count == changedFilesCount ? DialogResult.Abort : DialogResult.OK; }
/// <summary> /// Ensures the list has been imported. /// </summary> private void EnsureImportation() { // Quit if query is pending if (s_queryPending) { return; } // Check the selected provider if (!String.IsNullOrWhiteSpace(SelectedProviderName)) { if (SelectedProviderName != Name) { Loaded = false; CachedUntil = DateTime.MinValue; SelectedProviderName = Name; } } else { SelectedProviderName = Name; } string file = LocalXmlCache.GetFileInfo(Filename).FullName; // Update the file if we don't have it or the data have expired if ((!Loaded && !File.Exists(file)) || (Loaded && CachedUntil < DateTime.UtcNow)) { Task.WhenAll(GetPricesAsync()); return; } // Exit if we have already imported the list if (Loaded) { return; } if (File.Exists(file)) { LoadFromFile(file); } else { Loaded = true; CachedUntil = DateTime.UtcNow.AddHours(1); PriceByItemID.Clear(); } }
/// <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; } var result = Util.DeserializeAPIResultFromFile <SerializableAPIKillLog>( filename, APIProvider.RowsetsTransform); if (!result.HasError) { Import(result.Result.Kills); } }
/// <summary> /// Ensures the importation. /// </summary> private void EnsureImportation() { // Quit if query is pending if (s_queryPending) { return; } // Check the selected provider if (!string.IsNullOrWhiteSpace(SelectedProviderName)) { if (SelectedProviderName != Name) { Loaded = false; SelectedProviderName = Name; } } else { SelectedProviderName = Name; } string file = LocalXmlCache.GetFileInfo(Filename).FullName; // Exit if we have already imported the list if (Loaded) { return; } if (File.Exists(file)) { LoadFromFile(file); } else { Loaded = true; PriceByItemID.Clear(); } }