Example #1
0
        public MarketSituation GetMarketSituation()
        {
            Log.WriteLog("Trying to get the market situation of  \"" + this.Type.ToString() + "\".");

            List <EVE.ISXEVE.MarketOrder> retrivedOrders = null;
            MarketSituation result = null;

            bool success;

            using (new FrameLock(true))
            {
                EVE.ISXEVE.EVE eve = new EVE.ISXEVE.EVE();

                success = eve.FetchMarketOrders(this.TypeID);
            }

            if (success)
            {
                Log.WriteLog("Fired fetching orders request, wait to get result.");

                int counter = 0;

                while (retrivedOrders == null && counter < 100)
                {
                    Frame.Wait(false);
                    using (new FrameLock(true))
                    {
                        counter++;

                        EVE.ISXEVE.EVE eve = new EVE.ISXEVE.EVE();

                        // IMPORTANT: This is shallow copy, we need to finish all DEEP copy value operations while locked, otherwise the memory will be flushed;
                        retrivedOrders = eve.GetMarketOrders(this.TypeID);

                        if (retrivedOrders != null)
                        {
                            if (MarketOrderSet.ValidateOrderData(retrivedOrders))
                            {
                                // Prepare my own order id list to speed up the combine.
                                List <long> MyOwnOrderIds = new List <long>();
                                foreach (MyMarketOrder mmo in _orderList)
                                {
                                    if (mmo.TypeID == TypeID)
                                    {
                                        MyOwnOrderIds.Add(mmo.ID);
                                    }
                                }

                                result = new MarketSituation(retrivedOrders, MyOwnOrderIds);
                            }
                            else
                            {
                                Log.WriteLog("Found invalid data in retrived order, retrying.");
                                // Enter next loop;
                                retrivedOrders = null;
                            }
                        }
                    }
                }
                if (retrivedOrders != null)
                {
                    Log.WriteLog("Got " + retrivedOrders.Count.ToString() + " orders with (" + counter.ToString() + ") attempts.");
                }
                else
                {
                    Log.WriteLog("Failed to load orders with (" + counter.ToString() + ") attempts.");
                }
            }
            else
            {
                Log.WriteLog("Failed to send update order request.");
            }

            Log.WriteLog("Done loading market orders.");

            return(result);
        }
        public MarketSituation GetMarketSituation()
        {
            Log.WriteLog("Trying to get the market situation of  \"" + this.Type.ToString() + "\".");

            List<EVE.ISXEVE.MarketOrder> retrivedOrders = null;
            MarketSituation result = null;

            bool success;
            using (new FrameLock(true))
            {
                EVE.ISXEVE.EVE eve = new EVE.ISXEVE.EVE();

                success = eve.FetchMarketOrders(this.TypeID);
            }

            if (success)
            {
                Log.WriteLog("Fired fetching orders request, wait to get result.");

                int counter = 0;

                while (retrivedOrders == null && counter < 100)
                {
                    Frame.Wait(false);
                    using (new FrameLock(true))
                    {
                        counter++;

                        EVE.ISXEVE.EVE eve = new EVE.ISXEVE.EVE();

                        // IMPORTANT: This is shallow copy, we need to finish all DEEP copy value operations while locked, otherwise the memory will be flushed;
                        retrivedOrders = eve.GetMarketOrders(this.TypeID);

                        if (retrivedOrders != null)
                        {
                            if (MarketOrderSet.ValidateOrderData(retrivedOrders))
                            {
                                // Prepare my own order id list to speed up the combine.
                                List<long> MyOwnOrderIds = new List<long>();
                                foreach (MyMarketOrder mmo in _orderList)
                                {
                                    if (mmo.TypeID == TypeID)
                                    {
                                        MyOwnOrderIds.Add(mmo.ID);
                                    }
                                }

                                result = new MarketSituation(retrivedOrders, MyOwnOrderIds);
                            }
                            else
                            {
                                Log.WriteLog("Found invalid data in retrived order, retrying.");
                                // Enter next loop;
                                retrivedOrders = null;
                            }
                        }
                    }
                }
                if (retrivedOrders != null)
                {
                    Log.WriteLog("Got " + retrivedOrders.Count.ToString() + " orders with (" + counter.ToString() + ") attempts.");
                }
                else
                {
                    Log.WriteLog("Failed to load orders with (" + counter.ToString() + ") attempts.");
                }
            }
            else
            {
                Log.WriteLog("Failed to send update order request.");
            }

            Log.WriteLog("Done loading market orders.");

            return result;
        }