marketSvc.py (2939B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\marketSvc.py 2 from carbon.common.script.sys.service import Service 3 from utillib import KeyVal 4 5 class Market(Service): 6 __guid__ = 'svc.market' 7 __servicename__ = 'Market' 8 __displayname__ = 'Market Service' 9 __dependencies__ = [] 10 __notifyevents__ = ['OnOwnOrdersChanged', 'OnSessionReset'] 11 12 def Run(self, memStream = None): 13 self.personalMarketTransactionCache = {} 14 15 def GetPersonalMarketTransactions(self, fromDate = None): 16 if fromDate in self.personalMarketTransactionCache: 17 return self.personalMarketTransactionCache[fromDate] 18 transactions = sm.GetService('marketQuote').GetMarketProxy().CharGetTransactions(fromDate) 19 transactions = [ self._GetPersonalTransactionKeyVal(transaction) for transaction in transactions ] 20 self.personalMarketTransactionCache[fromDate] = transactions 21 return transactions 22 23 def GetCorpMarketTransactions(self, fromDate = None, accountKey = None): 24 transactions = sm.GetService('marketQuote').GetMarketProxy().CorpGetTransactions(fromDate, accountKey) 25 transactions = [ self._GetCorpTransactionKeyVal(transaction) for transaction in transactions ] 26 return transactions 27 28 def OnOwnOrdersChanged(self, orders, reason, isCorp): 29 self.personalMarketTransactionCache = {} 30 31 def OnSessionReset(self): 32 self.personalMarketTransactionCache = {} 33 34 def _GetCorpTransactionKeyVal(self, transaction): 35 transaction = KeyVal(transaction) 36 transaction.isBuyTransaction = transaction.accountID == transaction.buyerAccountID 37 transaction.characterID = transaction.buyerID if transaction.isBuyTransaction else transaction.sellerID 38 transaction.clientID = transaction.sellerID if transaction.isBuyTransaction else transaction.buyerID 39 transaction.totalPrice = transaction.price * transaction.quantity 40 transaction.isForCorp = False 41 if transaction.isBuyTransaction: 42 transaction.totalPrice *= -1 43 return transaction 44 45 def _GetPersonalTransactionKeyVal(self, transaction): 46 transaction = KeyVal(transaction) 47 transaction.isBuyTransaction = transaction.buyerID == session.charid 48 if transaction.isBuyTransaction: 49 transaction.isForCorp = transaction.accountID != transaction.buyerAccountID 50 else: 51 transaction.isForCorp = transaction.accountID != transaction.sellerAccountID 52 transaction.characterID = transaction.buyerID if transaction.isBuyTransaction else transaction.sellerID 53 transaction.clientID = transaction.sellerID if transaction.isBuyTransaction else transaction.buyerID 54 transaction.totalPrice = transaction.price * transaction.quantity 55 if transaction.isBuyTransaction: 56 transaction.totalPrice *= -1 57 return transaction