Example #1
0
        private List <WalletJournal.JournalEntry> GetEntriesById(WalletJournal journal, int id)
        {
            List <WalletJournal.JournalEntry> entries = new List <WalletJournal.JournalEntry>();

            entries.AddRange(journal.Journal.Where(c => c.RefTypeId == id));
            return(entries);
        }
        public static UserWalletJournalEntity ToEntity(this WalletJournal item)
        {
            if (null == item)
            {
                return(null);
            }

            var entity = new UserWalletJournalEntity(item);

            return(entity);
        }
Example #3
0
        private static PaymentResult ChangeBalance(Wallet wallet, TradeMode tradeMode, decimal totalFee, string tradeCode, string bizSource, long handlerId)
        {
            if (string.IsNullOrEmpty(bizSource))
            {
                throw new ArgumentNullException("bizSource");
            }

            if ((tradeMode == TradeMode.Payoff && totalFee < 0) || (tradeMode == TradeMode.Payout && totalFee > 0))
            {
                totalFee = 0 - totalFee;
            }

            var addWithdrawBalance = ModuleEnvironment.RealityMoneyBizSourceScopeList.Contains(bizSource);

            var journal = new WalletJournal();

            journal.WalletId        = wallet.WalletId;
            journal.TradeMode       = tradeMode;
            journal.TargetTradeCode = tradeCode;
            journal.BizSource       = bizSource;
            journal.TotalFee        = totalFee;
            journal.HandlerId       = handlerId;

            using (var scope = new System.Transactions.TransactionScope())
            {
                var changed = wallet.AddBalance(totalFee, addWithdrawBalance);
                if (changed)
                {
                    journal.Save();
                    scope.Complete();

                    var paidDetail = new Dictionary <string, object>();
                    paidDetail.Add("TradeCode", tradeCode);
                    paidDetail.Add("WalletId", wallet.WalletId);
                    paidDetail.Add("WalletType", wallet.WalletType);
                    paidDetail.Add("JournalId", journal.JournalId);
                    paidDetail.Add("BizSource", journal.BizSource);
                    paidDetail.Add("TotalFee", journal.TotalFee);
                    return(new PaymentResult()
                    {
                        Success = true, PaidDetail = paidDetail.ToJson()
                    });
                }
                return(new PaymentResult()
                {
                    Success = false
                });
            }
        }
Example #4
0
        public void GetCorpWalletJournalTest()
        {
            WalletJournal walletJournal = EveApi.GetWalletJournal(WalletJournalType.Corporation, 0, 0, "apiKey");

            WalletJournal.WalletJournalItem journalEntry = walletJournal.WalletJournalItems[0];
            Assert.AreEqual(new DateTime(2008, 08, 22, 03, 36, 00), journalEntry.Date);
            Assert.AreEqual(1578932679, journalEntry.RefId);
            Assert.AreEqual(54, journalEntry.RefTypeId);
            Assert.AreEqual("corpslave", journalEntry.OwnerName1);
            Assert.AreEqual(150337897, journalEntry.OwnerId1);
            Assert.AreEqual("Secure Commerce Commission", journalEntry.OwnerName2);
            Assert.AreEqual(1000132, journalEntry.OwnerId2);
            Assert.AreEqual("", journalEntry.ArgName1);
            Assert.AreEqual(0, journalEntry.ArgId1);
            Assert.AreEqual(-8396.99, journalEntry.Amount);
            Assert.AreEqual(576336941.61, journalEntry.Balance);
            Assert.AreEqual("", journalEntry.Reason);
        }
Example #5
0
        public void WalletJournalPersist()
        {
            ResponseCache.Clear();

            WalletJournal journalEntry = EveApi.GetWalletJournal(WalletJournalType.Corporation, 0, 0, "apiKey");

            ResponseCache.Save("ResponseCache.xml");
            ResponseCache.Clear();
            ResponseCache.Load("ResponseCache.xml");
            WalletJournal cachedJournalEntry = EveApi.GetWalletJournal(WalletJournalType.Corporation, 0, 0, "apiKey");

            Assert.AreEqual(journalEntry.CachedUntilLocal, cachedJournalEntry.CachedUntilLocal);


            for (int i = 0; i < journalEntry.WalletJournalItems.Length; i++)
            {
                Assert.AreEqual(journalEntry.WalletJournalItems[i].Date, cachedJournalEntry.WalletJournalItems[i].Date);
                Assert.AreEqual(journalEntry.WalletJournalItems[i].Amount, cachedJournalEntry.WalletJournalItems[i].Amount);
                Assert.AreEqual(journalEntry.WalletJournalItems[i].Balance, cachedJournalEntry.WalletJournalItems[i].Balance);
            }
        }
Example #6
0
        public static void WalletJournalExample()
        {
            bool done          = false;
            int  lastEntrySeen = 0;

            while (!done)
            {
                WalletJournal entries = EveApi.GetWalletJournal(WalletJournalType.Character, 0, 0, "fullApiKey", lastEntrySeen);
                foreach (WalletJournal.WalletJournalItem item in entries.WalletJournalItems)
                {
                    Console.WriteLine("Date: {0} Amount: {1} Balance: {2}", item.DateLocal, item.Amount, item.Balance);
                }
                lastEntrySeen += entries.JournalEntryItems.Length;
                if (entries.JournalEntryItems.Length < 1000)
                {
                    done = true;
                }
            }

            Console.WriteLine();
            done          = false;
            lastEntrySeen = 0;
            while (!done)
            {
                WalletJournal entries = EveApi.GetWalletJournal(WalletJournalType.Corporation, 0, 0, "fullApiKey", lastEntrySeen);
                foreach (WalletJournal.WalletJournalItem item in entries.WalletJournalItems)
                {
                    Console.WriteLine("Date: {0} Amount: {1} Balance: {2}", item.DateLocal, item.Amount, item.Balance);
                }
                lastEntrySeen += entries.JournalEntryItems.Length;
                if (entries.JournalEntryItems.Length < 1000)
                {
                    done = true;
                }
            }
        }
Example #7
0
        private List <Interaction> GetInteractions(Character character)
        {
            List <Interaction> interactions = new List <Interaction>();

            WalletJournal tempJournal = character.GetWalletJournal(2560, 0L).Result;
            int           entries     = tempJournal.Journal.Count;

            while (entries > 0)
            {
                long id = tempJournal.Journal.Min(x => x.RefId);

                // WalletJournal TypeIDs:
                // 10: Player Donation
                // 37: Corp Account Withdrawal
                // 1:  Direct Trade
                interactions.AddRange(GetEntriesById(tempJournal, 10).Select(j => new DonationInteraction
                {
                    Amount           = j.Amount,
                    Time             = j.Date,
                    Reason           = j.Reason,
                    PrimaryCharacter = new CharacterData {
                        Name = j.OwnerName, ID = j.OwnerId
                    },
                    SecondaryCharacter = new CharacterData {
                        Name = j.ParticipantName, ID = j.ParticipantId
                    },
                    ID = j.RefId
                }));

                interactions.AddRange(GetEntriesById(tempJournal, 37).Select(j => new CorpDonationInteraction
                {
                    Amount           = j.Amount,
                    Time             = j.Date,
                    Reason           = j.Reason,
                    PrimaryCharacter = new CharacterData {
                        Name = j.ArgumentName, ID = j.ArgumentId
                    },
                    SecondaryCharacter = new CharacterData {
                        Name = j.ParticipantName, ID = j.ParticipantId
                    },
                    Corporation = new CorporationData {
                        Name = j.OwnerName, ID = j.OwnerId
                    },
                    ID = j.RefId
                }));

                interactions.AddRange(GetEntriesById(tempJournal, 1).Select(j => new TradeInteraction
                {
                    Amount           = j.Amount,
                    Time             = j.Date,
                    PrimaryCharacter = new CharacterData {
                        Name = j.OwnerName, ID = j.OwnerId
                    },
                    SecondaryCharacter = new CharacterData {
                        Name = j.ParticipantName, ID = j.ParticipantId
                    },
                    Location = new StationData {
                        Name = j.ArgumentName, ID = j.ArgumentId
                    },
                    ID = j.RefId
                }));

                tempJournal = character.GetWalletJournal(2560, id).Result;
                entries     = tempJournal.Journal.Count;
            }
            return(interactions);
        }
 internal UserWalletJournalEntity(WalletJournal source)
 {
     this.SetPropertyValues(source.GetPropertyValues());
     this.Title = GetJournalTitle(this.BizSource);
 }