Пример #1
0
        public int Nettogewinn(int input, int win)
        {
            int    a      = input - win;
            EaMath eaMath = new EaMath();
            int    b      = eaMath.ValueDown(a);

            return(b);
        }
Пример #2
0
        public void Pricecheck()
        {
            EaWebApi eaWebApi = new EaWebApi();

            //Pricecheck
            for (int j = 0; j < dG_list.Rows.Count - 1; j++)
            {
                int price = 0;
                try
                {
                    price = eaWebApi.Pricecheck(
                        dG_list.Rows[j].Cells[4].Value.ToString(),
                        dG_list.Rows[j].Cells[5].Value.ToString(),
                        dG_list.Rows[j].Cells[0].Value.ToString(),
                        dG_list.Rows[j].Cells[3].Value.ToString(),
                        dG_list.Rows[j].Cells[6].Value.ToString(),
                        dG_list.Rows[j].Cells[2].Value.ToString(),
                        dG_list.Rows[j].Cells[9].Value.ToString());
                }
                catch (Exception)
                {
                    lbStandardLog.Items.Add(DateTime.Now.ToLongTimeString() + ": Error bei Pricecheck bei " + dG_list.Rows[j].Cells[1].Value);
                }
                Thread.Sleep(550);
                EaMath math = new EaMath();

                int sellprice = (price * Convert.ToInt32(tb_SellPercent.Text) / 100);
                sellprice = math.RoundPrice(Convert.ToDouble(sellprice));
                dG_list.Rows[j].Cells[7].Value = sellprice.ToString();

                if (chBnetto.Checked == false)
                {
                    int buyprice = (price * Convert.ToInt32(tb_BuyPercent.Text) / 100);
                    buyprice = math.RoundPrice(Convert.ToDouble(buyprice));
                    dG_list.Rows[j].Cells[6].Value = buyprice.ToString();
                }
                else
                {
                    int hilf = Nettogewinn(sellprice, Convert.ToInt32(tB_nettogewinn.Text));
                    dG_list.Rows[j].Cells[6].Value = hilf.ToString();
                }
            }
        }
        //Hilfmethoden

        public int Pricecheck(string pos, string cS, string lev, string team, string maxb, string nat, string resId)
        {
            int           hilf   = 0;
            string        type   = "player";
            List <string> iD     = new List <string>();
            List <int>    prices = new List <int>();

            //1.Abfrage
            string response = PlayerSearch(pos, cS, "", lev, team, "", type, "", "", "", nat, "0", "12");

            SResponse.SResonseRootObject returnedResponse = new JavaScriptSerializer().Deserialize <SResponse.SResonseRootObject>(response);
            try
            {
                foreach (var item in returnedResponse.auctionInfo)
                {
                    if (item.itemData.resourceId == resId)
                    {
                        iD.Add(item.itemData.id);
                        prices.Add(item.buyNowPrice);
                    }
                    hilf += 1;
                }
            }
            catch (Exception)
            {
                // ignored
            }

            int durchläufe = 1;

            //Bis ins unendliche
            while (hilf != 0)
            {
                hilf = 0;
                string start = (durchläufe * 12).ToString();
                response = PlayerSearch(pos, cS, "", lev, team, "", type, "", "", "", nat, start, "13");
                SResponse.SResonseRootObject ret = new JavaScriptSerializer().Deserialize <SResponse.SResonseRootObject>(response);
                try
                {
                    foreach (var item in ret.auctionInfo)
                    {
                        if (item.itemData.resourceId == resId)
                        {
                            prices.Add(item.buyNowPrice);
                            iD.Add(item.itemData.id);
                        }
                        hilf += 1;
                    }
                }
                catch (Exception)
                {
                    // ignored
                }
                durchläufe += 1;
                Thread.Sleep(700);
            }
            DataTable d = new DataTable();

            d.Columns.Add("iD", typeof(string));
            d.Columns.Add("buyNowPrice", typeof(int));

            for (var i = 0; i < prices.Count; i++)
            {
                if (prices[i] != 0)
                {
                    d.Rows.Add(iD[i], prices[i]);
                }
            }
            EaMath math  = new EaMath();
            int    price = math.AvgPrice(d);

            d.Rows.Add("Durchschnittspreis", price);
            return(price);
        }