public List <PriceRecord> GetPrices(List <UInt32> a_TypeIDs)
        {
            StringBuilder marketXmlUrl = new StringBuilder();

            marketXmlUrl.AppendFormat("http://api.eve-central.com/api/marketstat?hours={0:d}", m_Settings.HistoryDays * 24);

            if (0 != m_Settings.SolarID)
            {
                marketXmlUrl.Append("&usesystem=");
                marketXmlUrl.Append(m_Settings.SolarID.ToString());
            }
            else if (0 != m_Settings.RegionID)
            {
                marketXmlUrl.Append("&regionlimit=");
                marketXmlUrl.Append(m_Settings.RegionID.ToString());
            }

            foreach (UInt32 currTypeID in a_TypeIDs)
            {
                marketXmlUrl.AppendFormat("&typeid={0:d}", currTypeID);
            }

            XmlDocument xmlReply = Engine.LoadXmlWithUserAgent(marketXmlUrl.ToString());

            return(ParseReplyXML(xmlReply));
        }
Esempio n. 2
0
        public static XmlDocument MakeRequest(String a_ApiUrl, Settings.V1._ApiKey a_ApiKey, UInt32 a_ApiUser, String a_FailMessage)
        {
            try
            {
                XmlDocument xmlReply = Engine.LoadXmlWithUserAgent(MakeUrl(a_ApiUrl, a_ApiKey, a_ApiUser));

                XmlNodeList errorNodes = xmlReply.GetElementsByTagName("error");
                if (0 != errorNodes.Count)
                {
                    Engine.ShowXmlRequestErrors(a_FailMessage + ":\n", errorNodes);
                    return(null);
                }

                return(xmlReply);
            }
            catch (System.Net.WebException a_Exception)
            {
                String errorHint = "";

                if (a_Exception.Response is HttpWebResponse)
                {
                    HttpWebResponse httpResponse = (HttpWebResponse)a_Exception.Response;
                    switch (httpResponse.StatusCode)
                    {
                    case HttpStatusCode.Forbidden:
                        errorHint = "(Did you provide API key with insufficient access?)";
                        break;
                    }
                }

                String errorMessage = a_FailMessage + ":\n" + a_Exception.Message;
                if ("" != errorHint)
                {
                    errorMessage += "\n";
                    errorMessage += errorHint;
                }

                SpecialFNs.ErrorMessageBox.Show(errorMessage);
                return(null);
            }
            catch (System.Exception a_Exception)
            {
                SpecialFNs.ErrorMessageBox.Show(a_FailMessage + ":\n" + a_Exception.Message);
                return(null);
            }
        }
Esempio n. 3
0
        public List <PriceRecord> GetPrices(List <UInt32> a_TypeIDs)
        {
            StringBuilder marketUrl = new StringBuilder();

            marketUrl.Append("http://eve-marketdata.com/api/item_prices2.xml?char_name=EveRefinery_Program");

            if (0 != m_Settings.StationID)
            {
                marketUrl.AppendFormat("&station_ids={0}", m_Settings.StationID);
            }
            else if (0 != m_Settings.SolarID)
            {
                marketUrl.AppendFormat("&solarsystem_ids={0}", m_Settings.SolarID);
            }
            else if (0 != m_Settings.RegionID)
            {
                marketUrl.AppendFormat("&region_ids={0}", m_Settings.RegionID);
            }

            marketUrl.Append("&buysell=a&type_ids=");
            for (int i = 0; i < a_TypeIDs.Count; i++)
            {
                UInt32 currTypeID = a_TypeIDs[i];

                if (0 != i)
                {
                    marketUrl.Append(",");
                }

                marketUrl.AppendFormat("{0:d}", currTypeID);
            }

            XmlDocument xmlReply = Engine.LoadXmlWithUserAgent(marketUrl.ToString());

            return(ParseReplyXML(xmlReply));
        }