示例#1
0
        /// <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;
        }
示例#2
0
        /// <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);
        }
示例#3
0
        /// <summary>
        /// Creates a XML format file for character exportation.
        /// </summary>
        /// <param name="character"></param>
        private static string ExportAsCCPXML(Character character)
        {
            // Try to use the last XML character sheet downloaded from CCP
            XmlDocument doc = (XmlDocument)LocalXmlCache.GetCharacterXml(character);

            return(doc != null?Util.GetXmlStringRepresentation(doc) : null);
        }
示例#4
0
        /// <summary>
        /// Processes the conquerable station list.
        /// </summary>
        private static void OnUpdated(CCPAPIResult <SerializableAPIConquerableStationList> result)
        {
            // Checks if EVE database is out of service
            if (result.EVEDatabaseError)
            {
                // Reset query pending flag
                s_queryPending = false;
                return;
            }

            // Was there an error ?
            if (result.HasError)
            {
                // Reset query pending flag
                s_queryPending = false;

                EveMonClient.Notifications.NotifyConquerableStationListError(result);
                return;
            }

            EveMonClient.Notifications.InvalidateAPIError();

            // Import the list
            Import(result.Result.Outposts);

            // Reset query pending flag
            s_queryPending = false;

            // Notify the subscribers
            EveMonClient.OnConquerableStationListUpdated();

            // Save the file to our cache
            LocalXmlCache.SaveAsync(Filename, result.XmlDocument).ConfigureAwait(false);
        }
示例#5
0
        /// <summary>
        /// Processes the queried character's kill log.
        /// </summary>
        /// <param name="result"></param>
        private void OnKillLogUpdated(EsiResult <EsiAPIKillLog> result)
        {
            // Character may have been deleted or set to not be monitored since we queried
            if (m_ccpCharacter == null || !m_ccpCharacter.Monitored)
            {
                return;
            }

            // Notify an error occurred
            if (m_ccpCharacter.ShouldNotifyError(result, ESIAPICharacterMethods.KillLog))
            {
                EveMonClient.Notifications.NotifyCharacterKillLogError(m_ccpCharacter, result);
            }

            // Quits if there is an error
            if (result.HasError)
            {
                return;
            }

            // Import the data
            var kills = result.Result;

            // TODO m_ccpCharacter.KillLog.Import(kills.Kills);

            // Fires the event regarding kill log update
            EveMonClient.OnCharacterKillLogUpdated(m_ccpCharacter);

            // Save the file to our cache
            string filename = $"{m_ccpCharacter.Name}-{ESIAPICharacterMethods.KillLog}";

            LocalXmlCache.SaveAsync(filename, Util.SerializeToXmlDocument(kills)).ConfigureAwait(false);
        }
示例#6
0
        /// <summary>
        /// Processes the faction war statistics list.
        /// </summary>
        private static void OnUpdated(EsiResult <EsiAPIEveFactionalWarfareStats> result,
                                      object wars)
        {
            var factionWars = wars as EsiAPIEveFactionWars;

            // Was there an error ?
            if (result.HasError)
            {
                // Reset query pending flag
                s_queryPending = false;

                EveMonClient.Notifications.NotifyEveFactionalWarfareStatsError(result);
                return;
            }

            EveMonClient.Notifications.InvalidateAPIError();

            // Deserialize the result
            var fwStats = result.Result.ToXMLItem(factionWars);

            Import(fwStats);

            // Set the next update to be after downtime
            s_nextCheckTime = DateTime.Today.AddHours(EveConstants.DowntimeHour).AddMinutes(
                EveConstants.DowntimeDuration);
            s_queryPending = false;

            // Notify the subscribers
            EveMonClient.OnEveFactionalWarfareStatsUpdated();

            // Save the file to our cache
            LocalXmlCache.SaveAsync(Filename, Util.SerializeToXmlDocument(fwStats)).ConfigureAwait(false);
        }
示例#7
0
        /// <summary>
        /// Processed the queried character's skill queue information.
        /// </summary>
        /// <param name="result"></param>
        private void OnCharacterSheetUpdated(CCPAPIResult <SerializableAPICharacterSheet> result)
        {
            // Character may have been deleted or set to not be monitored since we queried
            if (m_ccpCharacter == null || !m_ccpCharacter.Monitored)
            {
                return;
            }

            // Notify an error occurred
            if (m_ccpCharacter.ShouldNotifyError(result, CCPAPICharacterMethods.CharacterSheet))
            {
                EveMonClient.Notifications.NotifyCharacterSheetError(m_ccpCharacter, result);
            }

            // Quits if there is an error
            if (result.HasError)
            {
                return;
            }

            // Query the Character's info
            QueryCharacterInfo();

            // Imports the data
            m_ccpCharacter.Import(result);

            // Notify for insufficient balance
            m_ccpCharacter.NotifyInsufficientBalance();

            // Save the file to our cache
            LocalXmlCache.SaveAsync(result.Result.Name, result.XmlDocument).ConfigureAwait(false);
        }
示例#8
0
        /// <summary>
        /// Downloads the conquerable station list,
        /// while doing a file up to date check.
        /// </summary>
        private static void UpdateList()
        {
            // Quit if we already checked a minute ago or query is pending
            if (s_nextCheckTime > DateTime.UtcNow || s_queryPending)
            {
                return;
            }

            // Set the update time and period
            DateTime updateTime = DateTime.Today
                                  .AddHours(EveConstants.DowntimeHour).AddMinutes(EveConstants.DowntimeDuration);
            TimeSpan updatePeriod = TimeSpan.FromDays(1);

            // Check to see if file is up to date
            bool fileUpToDate = LocalXmlCache.CheckFileUpToDate(Filename, updateTime, updatePeriod);

            s_nextCheckTime = DateTime.UtcNow.AddMinutes(1);

            // Quit if file is up to date
            if (fileUpToDate)
            {
                return;
            }

            s_queryPending = true;

            EveMonClient.APIProviders.CurrentProvider
            .QueryMethodAsync <SerializableAPIConquerableStationList>(CCPAPIGenericMethods.ConquerableStationList, OnUpdated);
        }
示例#9
0
        /// <summary>
        /// Imports the WalletTransactions from a cached file.
        /// </summary>
        internal void ImportFromCacheFile()
        {
            var result = LocalXmlCache.Load <SerializableAPIWalletTransactions>(m_character.Name + "-" +
                                                                                ESIAPICharacterMethods.WalletTransactions);

            if (result != null)
            {
                Import(result.WalletTransactions);
            }
        }
示例#10
0
        /// <summary>
        /// Imports the kill logs from a cached file.
        /// </summary>
        public void ImportFromCacheFile()
        {
            var result = LocalXmlCache.Load <SerializableAPIKillLog>(m_ccpCharacter.Name + "-" +
                                                                     ESIAPICharacterMethods.KillLog);

            if (result != null)
            {
                Import(result.Kills);
            }
        }
示例#11
0
        /// <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();
            }
        }
示例#12
0
        /// <summary>
        /// Processes the queried character's kill log.
        /// </summary>
        /// <param name="result"></param>
        private void OnKillLogUpdated(EsiAPIKillLog result)
        {
            var target = m_ccpCharacter;

            // Character may have been deleted since we queried
            if (target != null)
            {
                target.KillLog.Import(result);
                EveMonClient.OnCharacterKillLogUpdated(m_ccpCharacter);
                // Save the file to the cache
                string filename = $"{target.Name}-{ESIAPICharacterMethods.KillLog}";
                LocalXmlCache.SaveAsync(filename, Util.SerializeToXmlDocument(result)).
                ConfigureAwait(false);
            }
        }
示例#13
0
        /// <summary>
        /// Exports the kill logs to the cached file.
        /// </summary>
        public void ExportToCacheFile()
        {
            // Save the file to the cache
            string filename = m_ccpCharacter.Name + "-" + ESIAPICharacterMethods.KillLog;
            var    exported = new SerializableAPIKillLog();

            foreach (KillLog killMail in Items)
            {
                exported.Kills.Add(killMail.Export());
            }
            LocalXmlCache.SaveAsync(filename, Util.SerializeToXmlDocument(exported)).
            ConfigureAwait(false);
            // Fire event to update the UI
            EveMonClient.OnCharacterKillLogUpdated(m_ccpCharacter);
        }
示例#14
0
        /// <summary>
        /// Exports the WalletTransactions to the cached file.
        /// </summary>
        internal void ExportToCacheFile()
        {
            // Save the file to the cache
            string filename = m_character.Name + "-" + ESIAPICharacterMethods.WalletTransactions;
            var    exported = new SerializableAPIWalletTransactions();

            foreach (WalletTransaction tx in Items)
            {
                exported.WalletTransactions.Add(tx.Export());
            }

            LocalXmlCache.SaveAsync(filename, Util.SerializeToXmlDocument(exported)).
            ConfigureAwait(false);

            // TODO Fire event to update the UI ?
            // EveMonClient.OnCharacterKillLogUpdated(m_ccpCharacter);
        }
示例#15
0
        /// <summary>
        /// Processed the queried character's character sheet information.
        /// </summary>
        /// <param name="result"></param>
        private void OnCharacterSheetUpdated(EsiResult <EsiAPICharacterSheet> result)
        {
            // Character may have been deleted or set to not be monitored since we queried
            if (m_ccpCharacter == null || !m_ccpCharacter.Monitored)
            {
                return;
            }

            // Notify an error occurred
            if (m_ccpCharacter.ShouldNotifyError(result, ESIAPICharacterMethods.CharacterSheet))
            {
                EveMonClient.Notifications.NotifyCharacterSheetError(m_ccpCharacter, result);
            }

            // Quits if there is an error
            if (result.HasError)
            {
                return;
            }

            // Query the Character's data
            QueryCharacterData <EsiAPILocation>(ESIAPICharacterMethods.Location,
                                                OnCharacterLocationUpdated);
            QueryCharacterData <EsiAPIClones>(ESIAPICharacterMethods.Clones,
                                              OnCharacterClonesUpdated);
            QueryCharacterData <EsiAPIJumpFatigue>(ESIAPICharacterMethods.JumpFatigue,
                                                   OnCharacterFatigueUpdated);
            QueryCharacterData <EsiAPIAttributes>(ESIAPICharacterMethods.Attributes,
                                                  OnCharacterAttributesUpdated);
            QueryCharacterData <EsiAPIShip>(ESIAPICharacterMethods.Ship,
                                            OnCharacterShipUpdated);
            QueryCharacterData <EsiAPISkills>(ESIAPICharacterMethods.Skills,
                                              OnCharacterSkillsUpdated);
            QueryCharacterData <List <int> >(ESIAPICharacterMethods.Implants,
                                             OnCharacterImplantsUpdated);

            // Imports the data
            m_ccpCharacter.Import(result);

            // Notify for insufficient balance
            m_ccpCharacter.NotifyInsufficientBalance();

            // Save the file to our cache
            LocalXmlCache.SaveAsync(result.Result.Name, Util.SerializeToXmlDocument(result.Result)).ConfigureAwait(false);
        }
示例#16
0
        /// <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>
 /// 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)
     {
         var result = LocalXmlCache.Load <SerializableAPIEveFactionalWarfareStats>(
             Filename, true);
         if (result == null)
         {
             s_nextCheckTime = DateTime.UtcNow;
         }
         else
         {
             // Deserialize the result
             Import(result);
         }
     }
 }
示例#18
0
        /// <summary>
        /// Processes the queried character's wallet balance.
        /// </summary>
        /// <param name="result"></param>
        private void OnWalletBalanceUpdated(string result)
        {
            var target = m_ccpCharacter;

            // Character may have been deleted since we queried
            if (target != null)
            {
                target.Import(result);
                // Notify for insufficient balance
                target.NotifyInsufficientBalance();
                // Finally all done!
                EveMonClient.Notifications.InvalidateCharacterAPIError(target);
                EveMonClient.OnCharacterUpdated(target);
                EveMonClient.OnCharacterInfoUpdated(target);
                // Save character information locally
                var doc = Util.SerializeToXmlDocument(target.Export());
                LocalXmlCache.SaveAsync(target.Name, doc).ConfigureAwait(false);
            }
        }
示例#19
0
        /// <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();
            }
        }
示例#20
0
        /// <summary>
        /// Processes the queried character's character sheet information.
        /// </summary>
        /// <param name="result"></param>
        private void OnCharacterSheetUpdated(EsiAPICharacterSheet result)
        {
            var target = m_ccpCharacter;

            // Character may have been deleted since we queried
            if (target != null)
            {
                var notifiers = EveMonClient.Notifications;

                // Query remaining character data
                QueryCharacterData <EsiAPILocation>(ESIAPICharacterMethods.Location,
                                                    notifiers.NotifyCharacterLocationError, target.Import);
                QueryCharacterData <EsiAPIClones>(ESIAPICharacterMethods.Clones,
                                                  notifiers.NotifyCharacterClonesError, target.Import);
                QueryCharacterData <EsiAPIJumpFatigue>(ESIAPICharacterMethods.JumpFatigue,
                                                       notifiers.NotifyCharacterFatigueError, target.Import);
                QueryCharacterData <EsiAPIAttributes>(ESIAPICharacterMethods.Attributes,
                                                      notifiers.NotifyCharacterAttributesError, target.Import);
                QueryCharacterData <EsiAPIShip>(ESIAPICharacterMethods.Ship,
                                                notifiers.NotifyCharacterShipError, target.Import);
                QueryCharacterData <EsiAPISkills>(ESIAPICharacterMethods.Skills,
                                                  notifiers.NotifyCharacterSkillsError, target.Import);
                QueryCharacterData <List <int> >(ESIAPICharacterMethods.Implants,
                                                 notifiers.NotifyCharacterImplantsError, target.Import);
                QueryCharacterData <EsiAPIEmploymentHistory>(ESIAPICharacterMethods.EmploymentHistory,
                                                             notifiers.NotifyCharacterEmploymentError, target.Import);
                QueryCharacterData <string>(ESIAPICharacterMethods.AccountBalance,
                                            notifiers.NotifyCharacterBalanceError, target.Import);

                target.Import(result);
                // Notify for insufficient balance
                target.NotifyInsufficientBalance();
                // Save results to XML cache
                var doc = Util.SerializeToXmlDocument(result);
                LocalXmlCache.SaveAsync(result.Name, doc).ConfigureAwait(false);
            }
        }
示例#21
0
 /// <summary>
 /// Check if any character sheet related query monitors are still running, and trigger
 /// events if they are all completed.
 /// </summary>
 private void FinishCharacterSheetUpdated()
 {
     // Check if all CharacterSheet related query monitors have completed
     if (!m_characterQueryMonitors.Any(monitor => (ESIAPICharacterMethods.
                                                   CharacterSheet.Equals(monitor.Method) || monitor.Method.HasParent(
                                                       ESIAPICharacterMethods.CharacterSheet)) && monitor.Status == QueryStatus.
                                       Updating))
     {
         m_characterSheetUpdating = false;
         var target = m_ccpCharacter;
         // Character may have been deleted since we queried
         if (target != null)
         {
             // Finally all done!
             EveMonClient.Notifications.InvalidateCharacterAPIError(target);
             EveMonClient.OnCharacterUpdated(target);
             EveMonClient.OnCharacterInfoUpdated(target);
             EveMonClient.OnCharacterImplantSetCollectionChanged(target);
             // Save character information locally
             var doc = Util.SerializeToXmlDocument(target.Export());
             LocalXmlCache.SaveAsync(target.Name, doc).ConfigureAwait(false);
         }
     }
 }
示例#22
0
 /// <summary>
 /// Saves the xml document to the specified filename.
 /// </summary>
 /// <param name="filename">The filename.</param>
 /// <param name="xdoc">The xdoc.</param>
 protected static Task SaveAsync(string filename, IXPathNavigable xdoc)
 => LocalXmlCache.SaveAsync(filename, xdoc);