Esempio n. 1
0
        public static void CacheAllIcons(Item[] items)
        {
            StatusMessaging.UpdateStatus("Cache Item Icons", "Caching all Item Icons");
            WebRequestWrapper webRequests      = new WebRequestWrapper();
            List <string>     filesDownloading = new List <string>();

            for (int i = 0; i < items.Length && !WebRequestWrapper.LastWasFatalError; i++)
            {
                string iconName = items[i].IconPath.Replace(".png", "").Replace(".jpg", "").ToLower();
                webRequests.DownloadItemIconAsync(iconName);
            }

            while (webRequests.RequestQueueCount > 0 && !WebRequestWrapper.LastWasFatalError)
            {
                Thread.Sleep(200);
            }

            //TODO: Display any error information appropriotly here,
            //such as, proxy information incorrect or network connection down. Can get pretty detailed about exactly what went
            //wrong by analyzing the exception.
            if (WebRequestWrapper.LastWasFatalError)
            {
                StatusMessaging.ReportError("Cache All Icons", null, "There was an error trying to retrieve images from the armory.  Please check your proxy settings and network connection.");
            }
            StatusMessaging.UpdateStatusFinished("Cache Item Icons");
        }
Esempio n. 2
0
        private void LoadItem(object state)
        {
            // check done status
            if (Done)
            {
                return;
            }

            // continue updating
            ItemToUpdate info = state as ItemToUpdate;
            Item         i    = null;

            try
            {
                if (useArmory)
                {
                    i = Item.LoadFromId(info.item.Id, true, false, false);
                }
                else
                {
                    i = Item.LoadFromId(info.item.Id, true, false, true, Rawr.Properties.GeneralSettings.Default.Locale, usePTR ? "ptr" : "www");
                }
            }
            catch (Exception ex)
            {
                StatusMessaging.ReportError("Load item", ex, string.Format("Unable to update '{0}' due to an error: {1}\r\n\r\n{2}", info.item.Name, ex.Message, ex.StackTrace));
            }

            bool completelyDone = false;

            lock (lockObject)
            {
                if (i != null /* && (i.Stats.ToString().Contains(",") || (i.Stats.Armor + i.Stats.BonusArmor == 0 && i.Stats.ToString().Length > 0))*/)
                {
                    newItems.Add(info.index, i);
                }
                itemsDone++;
                completelyDone = done = finishedInput && itemsDone == itemsToDo;
            }

            if (completelyDone)
            {
                eventDone.Set();
            }
        }
Esempio n. 3
0
        public string GetNameFromArmory(int id, string site)
        {
            string name = null;

            try
            {
                WebClient webClient = CreateWebClient();

                string URI = string.Format("http://{0}.wowarmory.com/item-tooltip.xml?i={1}", site, id);    //item-info.xml would be twice bigger
                if (site.Equals("tw"))
                {
                    webClient.Headers.Add("Accept-Language", "zh-tw");
                }
                if (site.Equals("cn"))
                {
                    webClient.Headers.Add("Accept-Language", "zh-cn");
                }
                if (site.Equals("kr"))
                {
                    webClient.Headers.Add("Accept-Language", "kr");
                }

                string xml = webClient.DownloadString(URI);
                if (!String.IsNullOrEmpty(xml) && xml.Contains("<itemTooltip>"))
                {
                    XmlDocument docItem = new XmlDocument();
                    docItem.XmlResolver = null;
                    docItem.LoadXml(xml.Replace("&", ""));
                    name = docItem.SelectSingleNode("page/itemTooltips/itemTooltip/name").InnerText;
                }
            }
            catch (Exception)
            {
                //do nothing
            }

            if (name == null)
            {
                StatusMessaging.ReportError("Get item name", null, string.Format("Cannot get item {0} on {1} server", id, site));
            }
            return(name);
        }
Esempio n. 4
0
        public void AddItem(int index, Item item)
        {
            if (!multiThreaded)
            {
                Item i = null;
                try
                {
                    if (useArmory)
                    {
                        i = Item.LoadFromId(item.Id, true, false, false);
                    }
                    else
                    {
                        i = Item.LoadFromId(item.Id, true, false, true, Rawr.Properties.GeneralSettings.Default.Locale, usePTR ? "ptr" : "www");
                    }
                }
                catch (Exception ex)
                {
                    StatusMessaging.ReportError("Load item", ex, string.Format("Unable to update '{0}' due to an error: {1}\r\n\r\n{2}", item.Name, ex.Message, ex.StackTrace));
                }
                if (i != null)
                {
                    newItems.Add(index, i);
                }
                return;
            }

            ItemToUpdate info = new ItemToUpdate()
            {
                index = index,
                item  = item
            };

            lock (lockObject)
            {
                itemsToDo++;
                itemQueue.Enqueue(info);
            }
        }