コード例 #1
0
ファイル: EDCommodityView.cs プロジェクト: mlof/ED-IBE
        private void cmdCommodity_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                m_NoRefresh = true;

                EDCommoditiesExt currentCommodity = CurrentCommodity;
                if (currentCommodity == null)
                {
                    return;
                }

                txtId.Text             = currentCommodity.Id.ToString();
                txtCategory.Text       = currentCommodity.Category.NToString();
                txtAveragePrice.Text   = currentCommodity.AveragePrice.ToString();
                txtDemandSellLow.Text  = currentCommodity.PriceWarningLevel_Demand_Sell_Low.ToString();
                txtDemandSellHigh.Text = currentCommodity.PriceWarningLevel_Demand_Sell_High.ToString();
                txtDemandBuyLow.Text   = currentCommodity.PriceWarningLevel_Demand_Buy_Low.ToString();
                txtDemandBuyHigh.Text  = currentCommodity.PriceWarningLevel_Demand_Buy_High.ToString();

                txtSupplySellLow.Text  = currentCommodity.PriceWarningLevel_Supply_Sell_Low.ToString();
                txtSupplySellHigh.Text = currentCommodity.PriceWarningLevel_Supply_Sell_High.ToString();
                txtSupplyBuyLow.Text   = currentCommodity.PriceWarningLevel_Supply_Buy_Low.ToString();
                txtSupplyBuyHigh.Text  = currentCommodity.PriceWarningLevel_Supply_Buy_High.ToString();

                m_NoRefresh = false;
            }
            catch (Exception ex)
            {
                throw new Exception("error in cmdCommodity_SelectedIndexChanged method", ex);
            }
        }
コード例 #2
0
ファイル: EDCommodityView.cs プロジェクト: mlof/ED-IBE
        private void txtField_TextChanged(object sender, EventArgs e)
        {
            if (!m_NoRefresh)
            {
                int     IntValue;
                TextBox currentTextBox = ((TextBox)sender);

                if (int.TryParse(currentTextBox.Text, out IntValue))
                {
                    m_DataChanged = true;

                    EDCommoditiesExt currentCommodity = CurrentCommodity;
                    if (currentCommodity == null)
                    {
                        return;
                    }

                    currentCommodity.PriceWarningLevel_Demand_Sell_Low  = int.Parse(txtDemandSellLow.Text);
                    currentCommodity.PriceWarningLevel_Demand_Sell_High = int.Parse(txtDemandSellHigh.Text);
                    currentCommodity.PriceWarningLevel_Demand_Buy_Low   = int.Parse(txtDemandBuyLow.Text);
                    currentCommodity.PriceWarningLevel_Demand_Buy_High  = int.Parse(txtDemandBuyHigh.Text);

                    currentCommodity.PriceWarningLevel_Supply_Sell_Low  = int.Parse(txtSupplySellLow.Text);
                    currentCommodity.PriceWarningLevel_Supply_Sell_High = int.Parse(txtSupplySellHigh.Text);
                    currentCommodity.PriceWarningLevel_Supply_Buy_Low   = int.Parse(txtSupplyBuyLow.Text);
                    currentCommodity.PriceWarningLevel_Supply_Buy_High  = int.Parse(txtSupplyBuyHigh.Text);
                }
                else
                {
                    currentTextBox.Text = m_OldValue;
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// saves the RN-specific commodity data to a file
        /// </summary>
        /// <param name="File">json-file to save</param>
        /// <param name="Stationtype"></param>
        public void saveRNCommodityData(string Filename, bool BackupOldFile)
        {
            List <EDCommoditiesWarningLevels> WarningLevels = EDCommoditiesExt.extractWarningLevels(m_Commodities);

            string newFile, backupFile;


            newFile    = String.Format("{0}_new{1}", Path.Combine(Path.GetDirectoryName(Filename), Path.GetFileNameWithoutExtension(Filename)), Path.GetExtension(Filename));
            backupFile = String.Format("{0}_bak{1}", Path.Combine(Path.GetDirectoryName(Filename), Path.GetFileNameWithoutExtension(Filename)), Path.GetExtension(Filename));

            File.WriteAllText(newFile, JsonConvert.SerializeObject(WarningLevels));

            // we delete the current file not until the new file is written without errors

            rotateSaveFiles(Filename, newFile, backupFile, BackupOldFile);
        }
コード例 #4
0
        /// <summary>
        /// loads the commodity data from the files
        /// </summary>
        /// <param name="EDDBCommodityDatafile"></param>
        /// <param name="RNCommodityDatafile"></param>
        /// <param name="createNonExistingFile"></param>
        internal bool loadCommodityData(string EDDBCommodityDatafile, string RNCommodityDatafile, bool createNonExistingFile, bool CheckOnly = false)
        {
            bool notExisting = false;
            List <EDCommoditiesWarningLevels> RNCommodities;
            List <EDCommodities> EDDBCommodities = JsonConvert.DeserializeObject <List <EDCommodities> >(File.ReadAllText(EDDBCommodityDatafile));

            if (CheckOnly)
            {
                if (File.Exists(RNCommodityDatafile))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            if (File.Exists(RNCommodityDatafile))
            {
                RNCommodities = JsonConvert.DeserializeObject <List <EDCommoditiesWarningLevels> >(File.ReadAllText(RNCommodityDatafile));
            }
            else
            {
                notExisting   = true;
                RNCommodities = new List <EDCommoditiesWarningLevels>();
            }

            m_Commodities = EDCommoditiesExt.mergeCommodityData(EDDBCommodities, RNCommodities);

            if (notExisting)
            {
                calculateNewPriceLimits();
            }

            saveRNCommodityData(RNCommodityDatafile, true);

            return(true);
        }
コード例 #5
0
        /// <summary>
        /// calculating the market prices and save them as min and max values for new OCR_ed data,
        /// if "FileName" is not nothing the new data will is saves in this file
        ///
        /// </summary>
        /// <param name="FileName">name of the file to save to</param>
        public void calculateNewPriceLimits(string FileName = "")
        {
            Dictionary <int, MarketData> collectedData = calculateAveragePrices();

            foreach (MarketData Commodity in collectedData.Values)
            {
                EDCommoditiesExt CommodityBasedata = m_Commodities.Find(x => x.Id == Commodity.Id);

                if (CommodityBasedata != null)
                {
                    if (Commodity.BuyPrices_Demand.Count() > 0)
                    {
                        CommodityBasedata.PriceWarningLevel_Demand_Buy_Low = Commodity.BuyPrices_Demand.Min();
                    }
                    else
                    {
                        CommodityBasedata.PriceWarningLevel_Demand_Buy_Low = -1;
                    }

                    if (Commodity.BuyPrices_Demand.Count() > 0)
                    {
                        CommodityBasedata.PriceWarningLevel_Demand_Buy_High = Commodity.BuyPrices_Demand.Max();
                    }
                    else
                    {
                        CommodityBasedata.PriceWarningLevel_Demand_Buy_High = -1;
                    }

                    if (Commodity.BuyPrices_Supply.Count() > 0)
                    {
                        CommodityBasedata.PriceWarningLevel_Supply_Buy_Low = Commodity.BuyPrices_Supply.Min();
                    }
                    else
                    {
                        CommodityBasedata.PriceWarningLevel_Supply_Buy_Low = -1;
                    }

                    if (Commodity.BuyPrices_Supply.Count() > 0)
                    {
                        CommodityBasedata.PriceWarningLevel_Supply_Buy_High = Commodity.BuyPrices_Supply.Max();
                    }
                    else
                    {
                        CommodityBasedata.PriceWarningLevel_Supply_Buy_High = -1;
                    }

                    if (Commodity.BuyPrices_Demand.Count() > 0)
                    {
                        CommodityBasedata.PriceWarningLevel_Demand_Sell_Low = Commodity.SellPrices_Demand.Min();
                    }
                    else
                    {
                        CommodityBasedata.PriceWarningLevel_Demand_Sell_Low = -1;
                    }

                    if (Commodity.SellPrices_Demand.Count() > 0)
                    {
                        CommodityBasedata.PriceWarningLevel_Demand_Sell_High = Commodity.SellPrices_Demand.Max();
                    }
                    else
                    {
                        CommodityBasedata.PriceWarningLevel_Demand_Sell_High = -1;
                    }

                    if (Commodity.SellPrices_Supply.Count() > 0)
                    {
                        CommodityBasedata.PriceWarningLevel_Supply_Sell_Low = Commodity.SellPrices_Supply.Min();
                    }
                    else
                    {
                        CommodityBasedata.PriceWarningLevel_Supply_Sell_Low = -1;
                    }

                    if (Commodity.SellPrices_Supply.Count() > 0)
                    {
                        CommodityBasedata.PriceWarningLevel_Supply_Sell_High = Commodity.SellPrices_Supply.Max();
                    }
                    else
                    {
                        CommodityBasedata.PriceWarningLevel_Supply_Sell_High = -1;
                    }
                }
                else
                {
                    Debug.Print("STOP");
                }

                //if (CommodityBasedata.Name == "Palladium")
                //    Debug.Print("STOP, doppelt belegt  " + CommodityBasedata.Name);
                //    Debug.Print("STOP");

                //Debug.Print("");
                //Debug.Print("");
                //Debug.Print(CommodityBasedata.Name + " :");
                //Debug.Print("Demand Buy Min \t\t" + Commodity_Class.BuyPrices_Demand.Min().ToString("F0"));
                //Debug.Print("Demand Buy Average\t" + Commodity_Class.BuyPrices_Demand.Average().ToString("F0") + " (" + Commodity_Class.BuyPrices_Demand.Count() + " values)");
                //Debug.Print("Demand Buy Max\t\t" + Commodity_Class.BuyPrices_Demand.Max().ToString("F0"));
                //Debug.Print("");
                //Debug.Print("Demand Sell Min\t\t" + Commodity_Class.SellPrices_Demand.Min().ToString("F0"));
                //Debug.Print("Demand Sell Average\t" + Commodity_Class.SellPrices_Demand.Average().ToString("F0") + " (" + Commodity_Class.SellPrices_Demand.Count() + " values)");
                //Debug.Print("Demand Sell Max\t\t" + Commodity_Class.SellPrices_Demand.Max().ToString("F0"));
                //Debug.Print("");
                //Debug.Print("Supply Buy Min\t\t" + Commodity_Class.BuyPrices_Supply.Min().ToString("F0"));
                //Debug.Print("Supply Buy Average\t" + Commodity_Class.BuyPrices_Supply.Average().ToString("F0") + " (" + Commodity_Class.BuyPrices_Supply.Count() + " values)");
                //Debug.Print("Supply Buy Max\t\t" + Commodity_Class.BuyPrices_Supply.Max().ToString("F0"));
                //Debug.Print("");
                //Debug.Print("Supply Sell Min\t\t" + Commodity_Class.SellPrices_Supply.Min().ToString("F0"));
                //Debug.Print("Supply Sell Average\t" + Commodity_Class.SellPrices_Supply.Average().ToString("F0") + " (" + Commodity_Class.SellPrices_Supply.Count() + " values)");
                //Debug.Print("Supply Sell Max\t\t" + Commodity_Class.SellPrices_Supply.Max().ToString("F0"));
            }

            if (!String.IsNullOrEmpty(FileName))
            {
                saveRNCommodityData(FileName, true);
            }
        }