/// <summary> /// Processes the queried notification ref type. /// </summary> /// <param name="result">The result.</param> private static void OnDownloaded(CCPAPIResult <SerializableNotificationRefTypes> result) { if (!String.IsNullOrEmpty(result.ErrorMessage)) { // Reset query pending flag s_queryPending = false; EveMonClient.Trace(result.ErrorMessage); // Fallback EnsureInitialized(); return; } s_cachedUntil = DateTime.UtcNow.AddDays(1); // Import the list Import(result.Result); // Reset query pending flag s_queryPending = false; // Notify the subscribers EveMonClient.OnNotificationRefTypesUpdated(); // Save the file in cache LocalXmlCache.SaveAsync(Filename, result.XmlDocument).ConfigureAwait(false); }
/// <summary> /// Processes the queried eve flags. /// </summary> /// <param name="result">The result.</param> private static void OnDownloaded(DownloadResult <SerializableEveFlags> result) { if (result.Error != null) { // Reset query pending flag s_queryPending = false; EveMonClient.Trace(result.Error.Message); // Fallback EnsureInitialized(); return; } // Import the list Import(result.Result); // Reset query pending flag s_queryPending = false; // Notify the subscribers EveMonClient.OnEveFlagsUpdated(); // Save the file in cache LocalXmlCache.SaveAsync(Filename, Util.SerializeToXmlDocument(result.Result)). ConfigureAwait(false); }
/// <summary> /// Initializes the cache from file. /// </summary> public static void InitializeFromFile() { // Quit if the client has been shut down if (EveMonClient.Closed) { return; } string file = LocalXmlCache.GetFileInfo(Filename).FullName; if (!File.Exists(file) || s_cacheList.Any()) { return; } // Deserialize the file SerializableStationList cache = Util.DeserializeXmlFromFile <SerializableStationList>(file); // Reset the cache if anything went wrong if (cache == null || cache.Stations.Any(x => x.StationID == 0) || cache.Stations.Any(x => x.StationName.Length == 0)) { EveMonClient.Trace("Station and citadel deserialization failed; deleting file."); FileHelper.DeleteFile(file); return; } // Add the data to the cache Import(cache.Stations); }
/// <summary> /// Initializes the cache from file. /// </summary> public static void InitializeFromFile() { // Quit if the client has been shut down if (EveMonClient.Closed) { return; } string file = LocalXmlCache.GetFileInfo(Filename).FullName; if (!File.Exists(file) || s_cacheList.Any()) { return; } // Deserialize the file SerializableEveIDToName cache = Util.DeserializeXmlFromFile <SerializableEveIDToName>(file); // Reset the cache if anything went wrong if (cache == null || cache.Entities.Any(x => x.ID == 0) || cache.Entities.Any(x => x.Name.Length == 0)) { EveMonClient.Trace("Deserializing failed. File may be corrupt. Deleting file."); FileHelper.DeleteFile(file); return; } // Add the data to the cache Import(cache.Entities.Select(entity => new SerializableCharacterNameListItem { ID = entity.ID, Name = entity.Name })); }
/// <summary> /// Ensures the importation. /// </summary> private static void EnsureImportation() { // Quit if we already checked a minute ago or query is pending if (s_nextCheckTime > DateTime.UtcNow || s_queryPending) { return; } s_nextCheckTime = DateTime.UtcNow.AddMinutes(1); var info = LocalXmlCache.GetFileInfo(Filename); var result = LocalXmlCache.Load <SerializableNotificationRefTypes>(Filename, true); // Update the file if we don't have it or the data have expired if (result == null || (s_loaded && s_cachedUntil < DateTime.UtcNow)) { Task.WhenAll(UpdateFileAsync()); } else if (!s_loaded) { s_cachedUntil = info.Exists ? info.LastWriteTimeUtc.AddDays(1) : DateTime. MinValue; if (result == null) { s_nextCheckTime = DateTime.UtcNow; } else { // Import the data Import(result); } } }
/// <summary> /// Saves this cache list to a file. /// </summary> public static async Task SaveImmediateAsync() { // Save in file await LocalXmlCache.SaveAsync(Filename, Util.SerializeToXmlDocument(Export())); // Reset savePending flag s_lastSaveTime = DateTime.UtcNow; s_savePending = false; }
/// <summary> /// Initializes the cache from file. /// </summary> public static void InitializeFromFile() { // Quit if the client has been shut down if (EveMonClient.Closed || s_cacheList.Any()) { return; } var cache = LocalXmlCache.Load <SerializableStationList>(Filename, true); // Add the data to the cache if (cache != null) { Import(cache.Stations); } }
/// <summary> /// Ensures the importation. /// </summary> private static void EnsureImportation() { // Quit if we already checked a minute ago or query is pending if (s_nextCheckTime > DateTime.UtcNow || s_queryPending) { return; } s_nextCheckTime = DateTime.UtcNow.AddMinutes(1); string filename = LocalXmlCache.GetFileInfo(Filename).FullName; // Update the file if we don't have it or the data have expired if (!File.Exists(filename) || (s_loaded && s_cachedUntil < DateTime.UtcNow)) { Task.WhenAll(UpdateFileAsync()); return; } // Exit if we have already imported the list if (s_loaded) { return; } s_cachedUntil = File.GetLastWriteTimeUtc(filename).AddDays(1); // Deserialize the xml file CCPAPIResult <SerializableNotificationRefTypes> result = Util. DeserializeAPIResultFromFile <SerializableNotificationRefTypes>(filename, APIProvider.RowsetsTransform); // In case the file has an error we prevent the importation if (result.HasError) { EveMonClient.Trace("Error importing EVE notification types, deleting file"); FileHelper.DeleteFile(filename); s_nextCheckTime = DateTime.UtcNow; return; } // Import the data Import(result.Result); }
/// <summary> /// Processes the queried notification ref type. /// </summary> /// <param name="result">The result.</param> private static void OnDownloaded(CCPAPIResult <SerializableNotificationRefTypes> result) { s_queryPending = false; if (!string.IsNullOrEmpty(result.ErrorMessage)) { EveMonClient.Trace("Error loading notification types: " + result.ErrorMessage); // Fallback EnsureInitialized(); } else { s_cachedUntil = DateTime.UtcNow.AddDays(1); Import(result.Result); EveMonClient.OnNotificationRefTypesUpdated(); // Save the file in cache LocalXmlCache.SaveAsync(Filename, result.XmlDocument).ConfigureAwait(false); } }
/// <summary> /// Ensures the importation. /// </summary> private static void EnsureImportation() { // Quit if we already checked a minute ago or query is pending if (s_nextCheckTime > DateTime.UtcNow || s_queryPending) { return; } s_nextCheckTime = DateTime.UtcNow.AddMinutes(1); string filename = LocalXmlCache.GetFileInfo(Filename).FullName; // Update the file if we don't have it if (!File.Exists(filename)) { Task.WhenAll(UpdateFileAsync()); return; } // Exit if we have already imported the list if (s_isLoaded) { return; } // Deserialize the xml file SerializableEveFlags result = Util.DeserializeXmlFromFile <SerializableEveFlags>(filename, APIProvider.RowsetsTransform); // In case the file has an error we prevent the importation if (result == null) { FileHelper.DeleteFile(filename); s_nextCheckTime = DateTime.UtcNow; return; } // Import the data Import(result); }
/// <summary> /// Initializes the cache from file. /// </summary> public static void InitializeFromFile() { // Quit if the client has been shut down if (EveMonClient.Closed || s_cacheList.Any()) { return; } // Deserialize the file var cache = LocalXmlCache.Load <SerializableEveIDToName>(Filename, true); if (cache != null) { // Add the data to the cache Import(cache.Entities.Select(entity => new SerializableCharacterNameListItem { ID = entity.ID, Name = entity.Name })); } // For blank corporations and alliances s_lookup.Prefill(0L, "(None)"); }
/// <summary> /// Ensures the importation. /// </summary> private static void EnsureImportation() { // Quit if we already checked a minute ago or query is pending if (s_nextCheckTime > DateTime.UtcNow || s_queryPending || s_isLoaded) { return; } s_nextCheckTime = DateTime.UtcNow.AddMinutes(1); // Deserialize the xml file var result = LocalXmlCache.Load <SerializableEveFlags>(Filename, true); if (result == null) { Task.WhenAll(UpdateFileAsync()); s_nextCheckTime = DateTime.UtcNow; } else { // Import the data Import(result); } }