public static CharacterOrderCollection GetCharacterOrderList(Database db, EveApiId id, string CharID, bool bUseCache) { if (!id.IsFullKey()) { return(new CharacterOrderCollection()); // return empty } string url = String.Format("{0}{1}?userID={2}&characterID={3}&apiKey={4}", ApiSite, EveApi.CharMarketOrders, id.UserId, CharID, id.Key); string str = CheckRequestCache(db, RequestID.CharacterOrder, id.UserId, url); if (null == str) { str = new StreamReader(openUrl(url)).ReadToEnd(); WriteRequestCache(db, RequestID.CharacterOrder, id.UserId, url, str); } else if (!bUseCache) { return(new CharacterOrderCollection()); // not allowed to use caching } XmlDocument xmlDoc = GetXml(new StringReader(str)); if (null == xmlDoc) { return(new CharacterOrderCollection()); // error } return(new CharacterOrderCollection(CharID, xmlDoc)); }
public static CorporationTransactionCollection GetCorporationTransactionList( Database db, EveApiId id, string CharID, string CorpID, string beforeTransId, string CorpDivision, bool bAutoWalk, bool bAllDivisions, bool bUseCache) { if (!id.IsFullKey()) { return(new CorporationTransactionCollection()); // return empty } string url = String.Format("{0}{1}?userID={2}&characterID={3}&apiKey={4}&version=2", ApiSite, CorpWalletTransactions, id.UserId, CharID, id.Key); if (null != beforeTransId && 0 < long.Parse(beforeTransId)) { url += String.Format("&beforeTransID={0}", beforeTransId); } XmlDocument xmlDoc = GetXml(url); return(new CorporationTransactionCollection(CorpID, CorpDivision, xmlDoc)); }
public static CharacterJournalCollection GetCharacterJournalList(Database db, EveApiId id, string CharID, string beforeRefID, bool bAutoWalk, bool bUseCache) { if (!id.IsFullKey()) { return(new CharacterJournalCollection()); // return empty } CharacterJournalCollection journal = null; long remainder = 0; long lastCount = 0; do { string url = String.Format("{0}{1}?userID={2}&characterID={3}&apiKey={4}&accountKey=1000", ApiSite, CharJournalEntries, id.UserId, CharID, id.Key); if (null != beforeRefID && 0 < long.Parse(beforeRefID)) { url += String.Format("&beforeRefID={0}", beforeRefID); } string str = CheckRequestCache(db, RequestID.CharacterJournal, id.UserId, url); if (null == str) { Stream s = openUrl(url); if (null == s) { return((null != journal) ? journal : (new CharacterJournalCollection())); } str = new StreamReader(s).ReadToEnd(); WriteRequestCache(db, RequestID.CharacterJournal, id.UserId, url, str); } else if (!bUseCache) { break; // not allowed to use caching } XmlDocument xmlDoc = GetXml(new StringReader(str)); if (null == xmlDoc) { break; } if (null == journal) { journal = new CharacterJournalCollection(CharID, xmlDoc); } else { journal.AppendList(CharID, xmlDoc); } if (null == journal) { remainder = -1; } else { IDBCollectionContents con = (IDBCollectionContents)journal; if (0 == con.Count()) { remainder = -1; } else if (lastCount == con.Count()) { remainder = -1; } else { lastCount = con.Count(); remainder = con.Count() % 1000; if (0 == remainder) { IDBRecord rec1 = con.GetRecordInterface(con.Count() - 1000); JournalObject obj1 = (JournalObject)rec1.GetDataObject(); IDBRecord rec2 = con.GetRecordInterface(con.Count() - 1); JournalObject obj2 = (JournalObject)rec2.GetDataObject(); beforeRefID = Math.Min(obj1.refID, obj2.refID).ToString(); TimeSpan span = (obj2.date > obj1.date) ? obj2.date.Subtract(obj1.date) : obj1.date.Subtract(obj2.date); if (span.Days >= 7) { remainder = -1; // more than a week, so no more accessable } } } } } while (0 == remainder && bAutoWalk); if (null == journal) { return(new CharacterJournalCollection()); // create empty } return(journal); }