Beispiel #1
0
        private void TrackProgress(SteamLibrary.TrackingItem item)
        {
            Stopwatch stop = new Stopwatch();

            string gameid = SteamLibrary.GetApp(item.Game).AppID;

            try
            {
                stop.Start();
                SteamLibrary.StrParam price = SteamParseSite.ParseItemPrice(item.hashname, gameid, cookieCont);
                item.StartPrice     = Convert.ToSingle(price.P1);
                item.PreMedianPrice = item.MedianPrice;
                item.MedianPrice    = Convert.ToSingle(price.P2);
                stop.Stop();
            }
            catch { }
            try
            {
                if (((item.StartPrice / item.MedianPrice * 100) < item.BuyPercent) && (item.Buy) && (item.StartPrice > 0) && (item.MedianPrice / item.MedianPrice < 1.2))
                {
                    pricecheck = item.StartPrice;
                    BuyThreadExcute(item.Link, true, true, true);
                }
            }
            catch { }

            doMessage(flag.Track_progress, Convert.ToInt32(stop.ElapsedMilliseconds), item, true);
        }
Beispiel #2
0
        public void DoTrack(string name, string game, string hashname, int buyPer, int sellPer, int interval)
        {
            SteamLibrary.TrackingItem item = new SteamLibrary.TrackingItem(name, game, 0, 0, buyPer, sellPer, false, false, false, "", 0);

            item.hashname = hashname;

            string gameid = SteamLibrary.GetApp(game).AppID;

            try
            {
                SteamLibrary.StrParam price = SteamParseSite.ParseItemPrice(hashname, gameid, cookieCont);

                item.StartPrice  = Convert.ToSingle(price.P1);
                item.MedianPrice = Convert.ToSingle(price.P2);
            }
            catch { }

            item.Link = "http://steamcommunity.com/market/listings/" + SteamLibrary.GetApp(game).AppID + "/" + name;

            int index = TrackingList.Count;

            TrackingList.Add(item);

            item.index = index;

            doMessage(flag.Add_track, 0, item, true);

            item.Refresh           = new System.Timers.Timer();
            item.Refresh.Elapsed  += new System.Timers.ElapsedEventHandler(delegate { TrackProgress(item); });
            item.Refresh.Interval  = interval;
            item.Refresh.AutoReset = true;
            item.Refresh.Start();
        }
Beispiel #3
0
        public void DoAdvanceSearch(byte type, int searchResCount, string searchName, bool isGame, string game,
                                    bool isMin, string min, bool isMax, string max)
        {
            switch (type)
            {
            case 0:
                sppos    = new SteamLibrary.SearchPagePos(0, 1);
                lastSrch = searchName;
                break;

            case 1:
                if (sppos.CurrentPos < sppos.PageCount)
                {
                    sppos.CurrentPos += searchResCount;
                }
                else
                {
                    sppos.CurrentPos = 1;
                }

                break;

            case 2:
                if (sppos.CurrentPos > searchResCount)
                {
                    sppos.CurrentPos -= searchResCount;
                }
                else
                {
                    sppos.CurrentPos = sppos.PageCount;
                }
                break;

            default:
                break;
            }

            //search/render/?appid={0}&query={0}&start={1}&count={2}
            advancelinkTxt = string.Format(SteamLibrary._adsearch, SteamLibrary.GetApp(game).AppID, lastSrch, sppos.CurrentPos - 1, searchResCount);
            ThreadPool.QueueUserWorkItem(new WaitCallback(AdvanceSearchProgress), new object[]
                                         { isGame, game, isMin, min, isMax, max, searchResCount });
        }
Beispiel #4
0
        public string ParseAdvanceSearchRes(string content, List <SteamLibrary.SearchItem> lst, CookieContainer cookieCont,
                                            bool isGame, string game, bool isMin, string min, bool isMax, string max, int countRes)
        {
            if (searchDone == true)
            {
                lst.Clear();
            }
            searchDone = false;
            string totalFind = "0";

            try
            {
                var searchJS = JsonConvert.DeserializeObject <SteamLibrary.SearchBody>(content);

                if (searchJS.Success)
                {
                    totalFind       = searchJS.TotalCount;
                    sppos.PageCount = Convert.ToInt32(totalFind) / SearchResCount;

                    //content = File.ReadAllText(@"C:\dollar2.html");
                    MatchCollection matches = Regex.Matches(searchJS.HtmlRes,
                                                            "(?<=market_listing_row_link\" href)(.*?)(?<=</a>)",
                                                            RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Singleline);

                    if (matches.Count != 0)
                    {
                        foreach (Match match in matches)
                        {
                            string currmatch = match.Groups[1].Value;

                            //Fix for Steam update 5/01/14 4:00 PM PST
                            string ItemUrl = Regex.Match(currmatch, "(?<==\")(.*)(?=\" id)").ToString();

                            string[] input = ItemUrl.Split('/');
                            string   hash  = input[6];

                            string ItemQuan = Regex.Match(currmatch, "(?<=num_listings_qty\">)(.*)(?=</span>)").ToString();

                            //Fix for Steam update 3/26/14 4:00 PM PST
                            string ItemPrice = Regex.Match(currmatch,
                                                           "(?<=<span style=\"color:)(.*)(?=<div class=\"market_listing_right_cell)",
                                                           RegexOptions.Singleline).ToString();

                            if (SteamParsing.Currencies.NotSet)
                            {
                                SteamParsing.Currencies.GetType(ItemPrice);
                                //If not loggen in then
                                ItemPrice = Regex.Replace(ItemPrice, SteamParsing.Currencies.GetAscii(), string.Empty);
                                //currLst.NotSet = true;
                            }
                            else
                            {
                                ItemPrice = Regex.Replace(ItemPrice, SteamParsing.Currencies.GetAscii(), string.Empty);
                            }

                            ItemPrice = Regex.Replace(ItemPrice, @"[^\d\,\.]+", string.Empty);

                            bool pass = false;

                            if (isMin || isMax)
                            {
                                if (isMin && isMax)
                                {
                                    if (Convert.ToSingle(ItemPrice) > Convert.ToSingle(min) && (Convert.ToSingle(ItemPrice) < Convert.ToSingle(max)))
                                    {
                                        pass = true;
                                    }
                                }
                                else if (isMin)
                                {
                                    if (Convert.ToSingle(ItemPrice) > Convert.ToSingle(min))
                                    {
                                        pass = true;
                                    }
                                }
                                else
                                {
                                    if (Convert.ToSingle(ItemPrice) < Convert.ToSingle(max))
                                    {
                                        pass = true;
                                    }
                                }
                            }
                            else
                            {
                                pass = true;
                            }

                            if (pass)
                            {
                                //Fix fot Steam update 3/26/14 4:00 PM PST
                                string ItemName = Regex.Match(currmatch,
                                                              "(?<=listing_item_name\" style=\"color:)(.*)(?=</span>)").ToString();

                                ItemName = ItemName.Remove(0, ItemName.IndexOf(">") + 1);

                                string ItemGame = Regex.Match(currmatch, "(?<=game_name\">)(.*)(?=</span>)").ToString();

                                if (isGame)
                                {
                                    if (ItemGame.Equals(game))
                                    {
                                        string Median = "0";

                                        try
                                        {
                                            string gameid = SteamLibrary.GetApp(ItemGame).AppID;
                                            Median = SteamParseSite.ParseItemPrice(hash, gameid, cookieCont).P2;

                                            if (Median.Equals("Error"))
                                            {
                                                Median = "0";
                                            }
                                        }
                                        catch { }

                                        string ItemImg = Regex.Match(currmatch, "(?<=net/economy/image/)(.*)(/62fx62f)",
                                                                     RegexOptions.Singleline).ToString();

                                        SteamLibrary.SearchItem item = new SteamLibrary.SearchItem(ItemName, ItemGame, ItemUrl, ItemQuan,
                                                                                                   ItemPrice, ItemImg, Median);

                                        item.Hashname = hash;

                                        lst.Add(item);
                                    }
                                }
                                else
                                {
                                    string Median = "0";

                                    try
                                    {
                                        string gameid = SteamLibrary.GetApp(ItemGame).AppID;
                                        Median = SteamParseSite.ParseItemPrice(hash, gameid, cookieCont).P2;

                                        if (Median.Equals("Error"))
                                        {
                                            Median = "0";
                                        }
                                    }
                                    catch { }

                                    string ItemImg = Regex.Match(currmatch, "(?<=net/economy/image/)(.*)(/62fx62f)",
                                                                 RegexOptions.Singleline).ToString();

                                    SteamLibrary.SearchItem item = new SteamLibrary.SearchItem(ItemName, ItemGame, ItemUrl, ItemQuan,
                                                                                               ItemPrice, ItemImg, Median);

                                    item.Hashname = hash;

                                    lst.Add(item);
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("No item founded!", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception e)
            {
                SteamLibrary.AddtoLog(e.Message);
                MessageBox.Show("Error parsing search results.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (lst.Count < countRes)
            {
                DoAdvanceSearch(1, countRes, lastSrch, isGame, game, isMin, min, isMax, max);
            }
            else
            {
                doMessage(flag.Advance_search_success, 0, totalFind, true);
            }

            return(totalFind);
        }