示例#1
0
        public static decimal GetSellOrderValue(long ownerID, short walletID)
        {
            decimal retVal = 0;
            EMMADataSet.OrdersDataTable table = new EMMADataSet.OrdersDataTable();

            lock (tableAdapter)
            {
                tableAdapter.FillByAnySingle(table, ownerID, walletID, 0, 0,
                    (int)OrderState.Active, "Sell");
            }
            foreach (EMMADataSet.OrdersRow order in table)
            {
                retVal += order.Price * order.RemainingVol;
            }

            table.Clear();
            lock (tableAdapter)
            {
                tableAdapter.FillByAnySingle(table, ownerID, walletID, 0, 0,
                    (int)OrderState.OverbidAndUnacknowledged, "Sell");
            }
            foreach (EMMADataSet.OrdersRow order in table)
            {
                retVal += order.Price * order.RemainingVol;
            }

            return retVal;
        }
示例#2
0
        /// <summary>
        /// Get the order used for the specified transaction. 
        /// Note that many transactions will not have orders related to them. In this case
        /// the return value will be false and the two out parameters will be null.
        /// </summary>
        /// <param name="trans"></param>
        /// <returns></returns>
        public static bool GetOrder(Transaction trans, out Order buyOrder, out Order sellOrder)
        {
            bool retVal = false;
            bool buyerForCorp = false, sellerForCorp = false;
            long buyerID =0, sellerID = 0;
            buyOrder = null;
            sellOrder = null;

            buyerID = trans.BuyerID;
            sellerID = trans.SellerID;
            APICharacter buyChar = UserAccount.CurrentGroup.GetCharacter(buyerID, ref buyerForCorp);
            APICharacter sellChar = UserAccount.CurrentGroup.GetCharacter(sellerID, ref sellerForCorp);

            EMMADataSet.OrdersDataTable table = new EMMADataSet.OrdersDataTable();
            if (buyChar != null)
            {
                if (buyerID == _lastBuyerID && trans.ItemID == _lastItemID)
                {
                    table = _lastBuyerOrders;
                }
                else
                {
                    lock (tableAdapter)
                    {
                        tableAdapter.FillByAnySingle(table, trans.BuyerID, 0, trans.ItemID, 0, 0, "Any");
                        _lastBuyerID = buyerID;
                        _lastItemID = trans.ItemID;
                        _lastBuyerOrders = table;
                    }
                }
                buyOrder = MatchOrder(table, trans);
            }
            if (sellChar != null)
            {
                table.Clear();
                if (sellerID == _lastSellerID && trans.ItemID == _lastItemID)
                {
                    table = _lastSellerOrders;
                }
                else
                {
                    lock (tableAdapter)
                    {
                        tableAdapter.FillByAnySingle(table, sellerID, 0, trans.ItemID, 0, 0, "Any");
                        _lastSellerID = sellerID;
                        _lastItemID = trans.ItemID;
                        _lastSellerOrders = table;
                    }
                }
                sellOrder = MatchOrder(table, trans);
            }

            retVal = buyOrder != null || sellOrder != null;
            return retVal;
        }