Esempio n. 1
0
 public void SetMarketItem(int typeId, MarketItem info)
 {
     try
     {
         _marketItems[typeId] = info;
     }
     catch (Exception ex)
     {
         Logging.Log("Cache:SellOrders", "Exception [" + ex + "]", Logging.Debug);
     }
 }
Esempio n. 2
0
        public void Process()
        {
            if (!Status.Instance.InStation)
                return;

            if (Status.Instance.InSpace)
                return;

            DirectMarketWindow marketWindow = Cache.Instance.DirectEve.Windows.OfType<DirectMarketWindow>().FirstOrDefault();

            switch (_state)
            {
                case State.Idle:
                    break;
                case State.Done:
                    _done = true;

                    if (OnMarketInfoFinished != null)
                        OnMarketInfoFinished(_marketItem);
                    break;

                case State.Begin:

                    // Don't close the market window if its already up
                    if (marketWindow != null)
                        Logging.Log("MarketItemInfo:Process", "Market already open no need to open the market", Logging.White);

                    _state = State.OpenMarket;
                    break;

                case State.OpenMarket:

                    if (marketWindow == null)
                    {
                        Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.OpenMarket);
                        Logging.Log("MarketItemInfo:Process", "Opening Market", Logging.White);
                        break;
                    }

                    if (!marketWindow.IsReady)
                    {
                        Logging.Log("MarketItemInfo:Process", "Market window is not ready", Logging.White);
                        break;
                    }

                    _state = State.LoadItem;
                    break;

                case State.LoadItem:

                    if (DateTime.UtcNow.Subtract(_lastAction).TotalSeconds < 2)
                        break;

                    _lastAction = DateTime.UtcNow;

                    if (marketWindow != null)
                    {
                        Logging.Log("MarketItemInfo:Process", "Load orders for TypeId - " + TypeId.ToString(), Logging.White);

                        if (marketWindow.DetailTypeId != TypeId)
                        {
                            if(marketWindow.LoadTypeId(TypeId) == true)
                                _state = State.CacheInfo;
                        }

                        break;
                    }
                    else
                    {
                        Logging.Log("MarketItemInfo:Process", "MarketWindow is not open, going back to open market state", Logging.White);

                        _state = State.OpenMarket;
                    }

                    break;

                case State.CacheInfo:

                    if (DateTime.UtcNow.Subtract(_lastAction).TotalSeconds < 2)
                        break;

                    _lastAction = DateTime.UtcNow;

                    if (marketWindow != null)
                    {
                        if (!marketWindow.IsReady)
                        {
                            Logging.Log("MarketItemInfo:Process", "Market window is not ready", Logging.White);
                            break;
                        }

                        if (marketWindow.DetailTypeId != TypeId)
                            _state = State.LoadItem;

                        Logging.Log("MarketItemInfo:Process", "Get list of orders for Item - " + TypeId.ToString(), Logging.White);

                        _marketItem = new MarketItem();

                        if (_marketItem != null)
                        {
                            Logging.Log("MarketItemInfo:Process", "Get list of orders successful", Logging.White);

                            _marketItem.SellOrders = marketWindow.SellOrders;
                            _marketItem.BuyOrders = marketWindow.BuyOrders;
                            _marketItem.TypeId = TypeId;

                            Cache.Instance.SetMarketItem(TypeId, _marketItem);

                            _state = State.Done;
                        }
                    }
                    else
                    {
                        _state = State.OpenMarket;
                    }
                    break;
            }
        }
Esempio n. 3
0
 public void SetMarketItem(int typeId, MarketItem info)
 {
     try
     {
         _marketItems[typeId] = info;
     }
     catch (Exception ex)
     {
         Logging.Log("Cache:SellOrders", "Exception [" + ex + "]", Logging.Debug);
     }
 }