示例#1
0
        public void SearchInventory()
        {
            _backupInventory = ItemsInInventory;

            var loopList = new ObservableCollection <PackItem>();

            foreach (var item in ItemsInInventory)
            {
                if (item.ItemName.ToLower().Contains(SearchItemName.ToLower()))
                {
                    loopList.Add(item);
                }
            }

            ItemsInInventory = loopList;
        }
示例#2
0
        public string ParseStashData(string next_id)
        {
            string APIData = GetAPIData();

            if (APIData != "")
            {
                StashAPIData jsonString = JsonConvert.DeserializeObject <StashAPIData>(APIData);

                var ByteCount = ASCIIEncoding.ASCII.GetByteCount(APIData);
                BytesTransferred += ByteCount;

                window.AddToLog(String.Format("Parsing Id: {0} (this: {1} kB, total: {2} MB, average: {3} kB/s)", next_id, ByteCount / 1024, BytesTransferred / 1024 / 1024, Math.Round(BytesTransferred / watch.Elapsed.TotalSeconds / 1024, 2)));

                foreach (StashData stash in jsonString.Stashes)
                {
                    if (SearchAccountName == "" || (stash.AccountName != null && stash.AccountName.ToLower() == SearchAccountName.ToLower()))
                    {
                        foreach (ItemData item in stash.Items)
                        {
                            ModList = ModExtractor.ParseItem(ModList, item);
                            Debug.Print(ModList.Count.ToString());

                            if (item.League == SearchLeague &&
                                (SearchItemName != "" &&
                                 (item.Name.ToLower().Contains(SearchItemName.ToLower()) ||
                                  item.TypeLine.ToLower().Contains(SearchItemName.ToLower()))))
                            {
                                string price = ParsePrice(item.Note);

                                if (price == "")
                                {
                                    price = ParsePrice(stash.Stash);
                                }

                                var itemName = item.Name;

                                if (itemName != null && itemName != "")
                                {
                                    itemName = itemName.Substring(28, itemName.Length - 28);
                                }

                                if (itemName == null || itemName == "")
                                {
                                    itemName = item.TypeLine;
                                }

                                window.AddToLog("Item found:");

                                window.AddToLog(String.Format("@{0} Hi, I would like to buy your {1} listed for {2} in {3} (stash tab \"{4}\"; position: left {5}, top {6})",
                                                              stash.AccountName,
                                                              itemName,
                                                              price,
                                                              SearchLeague,
                                                              stash.Stash,
                                                              item.X,
                                                              item.Y));

                                if (item.Corrupted == true)
                                {
                                    window.AddToLog("### CORRUPTED ###");
                                }

                                string sockets   = "";
                                int    lastGroup = 0;
                                if (item.Sockets != null)
                                {
                                    foreach (Socket socket in item.Sockets)
                                    {
                                        if (socket.Group != lastGroup)
                                        {
                                            sockets += " | ";
                                        }

                                        switch (socket.Attr)
                                        {
                                        case "S":
                                            sockets += "R";
                                            break;

                                        case "I":
                                            sockets += "B";
                                            break;

                                        case "D":
                                            sockets += "G";
                                            break;

                                        case "G":
                                            sockets += "W";
                                            break;
                                        }
                                    }
                                }

                                if (sockets != "")
                                {
                                    window.AddToLog(String.Format("Sockets: {0}", sockets));
                                }

                                if (item.ImplicitMods != null && item.ImplicitMods[0] != null)
                                {
                                    window.AddToLog(String.Format("implicitMod: {0}", item.ImplicitMods[0]));
                                }

                                if (item.ExplicitMods != null)
                                {
                                    foreach (var mod in item.ExplicitMods)
                                    {
                                        window.AddToLog(String.Format("explicitMod: {0}", mod));
                                    }
                                }
                            }
                        }
                    }
                }

                if (ByteCount < 1024 * 1024)
                {
                    window.AddToLog("Throttle protection. File Size < 1MB. Waiting 1 second...");
                    Thread.Sleep(1000);
                }

                next_id = jsonString.Next_change_id;
            }
            else
            {
                Thread.Sleep(10000);
            }

            return(next_id);
        }