private bool LoadCached() { String cacheFilePath = GetCacheFilePath(); if (!File.Exists(cacheFilePath)) { return(false); } XmlDocument xml = new XmlDocument(); try { xml.Load(cacheFilePath); ParseXml(xml); } catch (System.Exception a_Exception) { // Don't nag user if cached file is bad System.Diagnostics.Debug.WriteLine(a_Exception.Message); return(false); } // Cached data is always loaded. That helps if update fails, and while it's still working. // Outposts don't change so often, and even if they do, it's not too important. return(!EveApi.IsCacheExpired(xml)); }
private void UpdateSingleUser(string a_KeyID, string a_Verification) { Settings.V1._ApiKey tempKey = new Settings.V1._ApiKey(); UInt32.TryParse(a_KeyID, out tempKey.KeyID); tempKey.Verification = a_Verification; string errorHeader = "Failed to update user " + a_KeyID; XmlDocument xmlReply = EveApi.MakeRequest("account/Characters.xml.aspx", tempKey, 0, errorHeader); if (null == xmlReply) { return; } XmlNodeList characterNodes = xmlReply.GetElementsByTagName("row"); if (0 == characterNodes.Count) { ErrorMessageBox.Show(errorHeader + "No characters found"); return; } DeleteCharactersFromUser(a_KeyID); foreach (XmlNode characterNode in characterNodes) { ListViewItem newItem = LstCharacters.Items.Add(a_KeyID); newItem.SubItems.Add(characterNode.Attributes["characterID"].Value); newItem.SubItems.Add(characterNode.Attributes["name"].Value); newItem.SubItems.Add(characterNode.Attributes["corporationName"].Value); } }
private bool LoadSkills(Settings.V1._ApiKey a_ApiKey, UInt32 a_UserID, Dictionary <UInt32, UInt32> a_Result) { String errorHeader = "Failed to load skills"; XmlDocument xmlReply = EveApi.MakeRequest("char/CharacterSheet.xml.aspx", a_ApiKey, a_UserID, errorHeader); if (null == xmlReply) { return(false); } try { XmlNodeList skillNodes = xmlReply.SelectNodes("/eveapi/result/rowset[@name='skills']/row"); foreach (XmlNode currNode in skillNodes) { UInt32 typeID = UInt32.Parse(currNode.Attributes["typeID"].Value); UInt32 level = UInt32.Parse(currNode.Attributes["level"].Value); a_Result[typeID] = level; } } catch (System.Exception a_Exception) { ErrorMessageBox.Show(errorHeader + ":\n" + "Failed to parse EVE API reply:\n" + a_Exception.Message); return(false); } // Safety check for possible XML format change if (0 == a_Result.Count) { return(false); } return(true); }
private void ParseAssetsXML(XmlDocument a_AssetsXml) { UnloadAssets(); XmlNodeList globalNodes = a_AssetsXml.SelectNodes("//eveapi/result/rowset/row"); foreach (XmlNode currNode in globalNodes) { UInt32 locationID = Convert.ToUInt32(currNode.Attributes["locationID"].Value); UInt32 typeID = Convert.ToUInt32(currNode.Attributes["typeID"].Value); UInt32 quantity = Convert.ToUInt32(currNode.Attributes["quantity"].Value); bool isPacked = (0 == Convert.ToUInt32(currNode.Attributes["singleton"].Value)); ItemAssets currLocAssets = GetOrInsert_LocationAssets(locationID); ItemAssets currAsset = GetOrInsert_ItemAssets(currLocAssets, typeID, isPacked); currAsset.Quantity += quantity; if (currNode.HasChildNodes) { ParseNestedAssets(currNode, currAsset); } } m_CacheTime = EveApi.GetCacheTime(a_AssetsXml); }
public Boolean LoadAssets(UInt32 a_CharID) { string assetsCachePath = GetAssetsCacheFilePath(a_CharID); try { if (LoadAssetsXml(assetsCachePath, true)) { return(true); } } catch (System.Exception a_Exception) { System.Diagnostics.Debug.WriteLine(a_Exception.Message); } Settings.V1._ApiKey apiKey = m_Engine.GetCharacterKey(a_CharID); if (null == apiKey) { return(false); } string errorHeader = "Failed to update assets"; XmlDocument assetsXml = EveApi.MakeRequest("char/AssetList.xml.aspx", apiKey, a_CharID, errorHeader); if (null == assetsXml) { return(false); } ParseAssetsXML(assetsXml); // Ignore saving errors try { assetsXml.Save(assetsCachePath); } catch (System.Exception a_Exception) { System.Diagnostics.Debug.WriteLine(a_Exception.Message); } return(true); }
private void UpdateFromApi() { string errorHeader = "Failed to load outpost information from EVE API"; XmlDocument xml = EveApi.MakeRequest("eve/ConquerableStationList.xml.aspx", null, 0, errorHeader); if (null == xml) { return; } try { xml.Save(GetCacheFilePath()); ParseXml(xml); } catch (System.Exception a_Exception) { System.Diagnostics.Debug.WriteLine(a_Exception.Message); } }
private Boolean LoadAssetsXml(string a_FilePath, bool a_TestCacheDate) { if (!File.Exists(a_FilePath)) { return(false); } XmlDocument assetsXml = new XmlDocument(); assetsXml.Load(a_FilePath); if (a_TestCacheDate && EveApi.IsCacheExpired(assetsXml)) { if (DialogResult.No != MessageBox.Show("Your assets information expired. Would you like to update now?\nWARNING: Due to CCP limitations, you can only update assets once every 7 hours.", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { return(false); } } ParseAssetsXML(assetsXml); return(true); }