Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
        /// <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);
        }
Exemplo n.º 4
0
        /// <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
            }));
        }
Exemplo n.º 5
0
        /// <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);
                }
            }
        }
Exemplo n.º 6
0
        /// <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;
        }
Exemplo n.º 7
0
        /// <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);
            }
        }
Exemplo n.º 8
0
        /// <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);
        }
Exemplo n.º 9
0
 /// <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);
     }
 }
Exemplo n.º 10
0
        /// <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);
        }
Exemplo n.º 11
0
        /// <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)");
        }
Exemplo n.º 12
0
        /// <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);
            }
        }