Esempio n. 1
0
        private void LoadMarketPrices(bool a_Silent, bool a_DeleteOld)
        {
            try
            {
                Settings.V2._PriceSettings settings = m_Engine.m_Settings.PriceLoad.Items;
                IPriceProvider             provider = PriceProviderAuto.GetPriceProvider(settings);

                if (a_DeleteOld)
                {
                    m_MarketPrices.DropPrices(provider);
                }

                m_MarketPrices.LoadPrices(provider, settings, a_Silent);
            }
            catch (System.Exception a_Exception)
            {
                ErrorMessageBox.Show("Failed to load market prices:\n" + a_Exception.Message);
            }

            UpdateLstRefinery();
            UpdateStatus();

            if (0 != m_MarketPrices.GetQueueSize())
            {
                m_RunningListUpdates = ListUpdates.Prices;
            }
        }
Esempio n. 2
0
        public FrmPriceType(EveDatabase a_EveDatabase, Settings.V2._PriceSettings a_Settings)
        {
            m_EveDatabase = a_EveDatabase;
            m_Settings    = a_Settings;

            InitializeComponent();
        }
Esempio n. 3
0
            private static Settings.V2._PriceSettings       Convert_PriceSettings(Settings.V1._PriceSettings a_OldPriceSettings)
            {
                Settings.V2._PriceSettings result = new Settings.V2._PriceSettings();
                result.EveCentralCom.RegionID  = a_OldPriceSettings.RegionID;
                result.EveCentralCom.SolarID   = a_OldPriceSettings.SolarID;
                result.EveCentralCom.StationID = a_OldPriceSettings.StationID;
                result.EveCentralCom.PriceType = a_OldPriceSettings.PriceType;

                return(result);
            }
Esempio n. 4
0
        public static IPriceProvider    GetPriceProvider(Settings.V2._PriceSettings a_Settings)
        {
            switch (a_Settings.Provider)
            {
            case PriceProviders.EveCentral:
                return(new PriceProviderEveCentralCom(a_Settings.EveCentralCom));

            case PriceProviders.FuzzworkCoUk:
                return(new PriceProviderFuzzworkCoUk(a_Settings.FuzzworkCoUk));

            case PriceProviders.EveMarketdataCom:
                return(new PriceProviderEveMarketdataCom(a_Settings.EveMarketdataCom));
            }

            Debug.Assert(false, "Invalid price provider");
            return(null);
        }
Esempio n. 5
0
        public void                                     LoadPrices(IPriceProvider a_PriceProvider, Settings.V2._PriceSettings a_Settings, bool a_Silent)
        {
            StopUpdaterThread();

            m_ItemsDB.ResetItemPrices();

            ItemPrices.PricesDataTable pricesTable = new ItemPrices.PricesDataTable();

            string selectSQL = "Select * from " + pricesTable.TableName + " where " +
                               "(" + pricesTable.ProviderIDColumn.ColumnName + " = @ProviderID) AND " +
                               "(" + pricesTable.RegionIDColumn.ColumnName + " = @RegionID) AND " +
                               "(" + pricesTable.SolarIDColumn.ColumnName + " = @SolarID) AND " +
                               "(" + pricesTable.StationIDColumn.ColumnName + " = @StationID) AND" +
                               "(" + pricesTable.PriceTypeColumn.ColumnName + " = @PriceType)";

            SQLiteCommand sqlCommand  = new SQLiteCommand(selectSQL, m_DbConnection);
            PriceRecord   priceFilter = a_PriceProvider.GetCurrentFilter();

            sqlCommand.Parameters.AddWithValue("@ProviderID", (UInt32)priceFilter.Provider);
            sqlCommand.Parameters.AddWithValue("@RegionID", priceFilter.RegionID);
            sqlCommand.Parameters.AddWithValue("@SolarID", priceFilter.SolarID);
            sqlCommand.Parameters.AddWithValue("@StationID", priceFilter.StationID);
            sqlCommand.Parameters.AddWithValue("@PriceType", (UInt32)priceFilter.PriceType);

            SQLiteDataAdapter adapter = new SQLiteDataAdapter(sqlCommand);

            adapter.Fill(pricesTable);

            foreach (ItemPrices.PricesRow currRow in pricesTable.Rows)
            {
                DbRecordToItemRecord(currRow);
            }

            TestMarketPrices(a_PriceProvider, a_Settings, a_Silent);
        }
Esempio n. 6
0
        private void                            TestMarketPrices(IPriceProvider a_PriceProvider, Settings.V2._PriceSettings a_Settings, bool a_Silent)
        {
            ItemFilter filter = new ItemFilter();

            filter.HasMarketGroup  = TristateFilter.Yes;
            filter.IsPricesOk      = TristateFilter.No;
            filter.PriceExpiryDays = a_Settings.ExpiryDays;

            UInt32[] badItems = m_ItemsDB.FilterItems(filter);
            if (0 == badItems.Count())
            {
                return;
            }

            if (!a_Silent)
            {
                if (DialogResult.Yes != MessageBox.Show("You have outdated market prices. Would you like to update them now?", Application.ProductName, MessageBoxButtons.YesNo))
                {
                    return;
                }
            }

            Queue <UInt32> pricesQueue = new Queue <UInt32>();

            foreach (UInt32 currItem in badItems)
            {
                pricesQueue.Enqueue(currItem);
            }

            StopUpdaterThread();

            UpdateThreadParam param = new UpdateThreadParam();

            param.PriceProvider = a_PriceProvider;
            param.UpdateQueue   = pricesQueue;

            ThreadWithParam paramThread = new ThreadWithParam();

            paramThread.Function  = ThreadQueryMarketPrices;
            paramThread.Parameter = param;

            m_EndUpdateThread = false;
            m_UpdateQueue     = pricesQueue;

            m_UpdateThread = paramThread.CreateThread();
            m_UpdateThread.IsBackground = true;
            m_UpdateThread.Start();
        }