Example #1
0
        public ApiLoadResponse <Blueprint> Load(ApiKeyType keyType, int apiKeyId, string vCode, int eveApiID)
        {
            var kt       = keyType == ApiKeyType.Character ? "char" : "corp";
            var url      = string.Format("http://api.eve-online.com/{0}/Blueprints.xml.aspx?keyID={1}&vCode={2}&characterID={3}", kt, apiKeyId, vCode, eveApiID);
            var response = EveApiLoader.Load(url);

            if (!response.Success)
            {
                throw new Exception(response.ErrorMessage);
            }
            var result = new ApiLoadResponse <Blueprint>
            {
                CachedUntil = response.CachedUntil
            };
            var element = response.Result.Element("rowset");

            if (element != null)
            {
                result.Data.AddRange(element.Elements("row").Select(row => new Blueprint
                {
                    AssetID            = long.Parse(row.Attribute("itemID").Value),
                    BlueprintID        = long.Parse(row.Attribute("typeID").Value),
                    IsCopy             = int.Parse(row.Attribute("quantity").Value) == -2,
                    MaterialEfficiency = int.Parse(row.Attribute("materialEfficiency").Value),
                    TimeEfficiency     = int.Parse(row.Attribute("timeEfficiency").Value)
                }));
            }
            return(result);
        }
Example #2
0
        public ApiLoadResponse <AccountBalance> Load(ApiKeyType keyType, int keyID, string vCode, int eveApiID)
        {
            var url    = string.Format("http://api.eve-online.com/{0}/AccountBalance.xml.aspx?keyID={1}&vCode={2}&characterID={3}", keyType.ServiceBase(), keyID, vCode, eveApiID);
            var result = EveApiLoader.Load(url);

            if (!result.Success)
            {
                throw new Exception(result.ErrorMessage);
            }
            var xElement = result.Result.Element("rowset");
            var response = new ApiLoadResponse <AccountBalance>
            {
                Data        = new List <AccountBalance>(),
                CachedUntil = result.CachedUntil
            };

            if (xElement != null)
            {
                response.Data = xElement.Elements("row").Select(f => new AccountBalance
                {
                    AccountID  = (int)f.Attribute("accountID"),
                    AccountKey = (int)f.Attribute("accountKey"),
                    Balance    = (decimal)f.Attribute("balance")
                }).ToList();
            }
            return(response);
        }
Example #3
0
        public ApiLoadResponse <IndustryJob> Load(ApiKeyType keyType, int apiKeyId, string vCode, int eveApiID)
        {
            var kt       = keyType == ApiKeyType.Character ? "char" : "corp";
            var url      = string.Format("http://api.eve-online.com/{0}/IndustryJobsHistory.xml.aspx?keyID={1}&vCode={2}&characterID={3}", kt, apiKeyId, vCode, eveApiID);
            var response = EveApiLoader.Load(url);

            if (!response.Success)
            {
                throw new Exception(response.ErrorMessage);
            }
            if (!response.Success)
            {
                throw new Exception(response.ErrorMessage);
            }
            var xElement = response.Result.Element("rowset");
            var result   = new ApiLoadResponse <IndustryJob>
            {
                CachedUntil = response.CachedUntil
            };

            if (xElement == null)
            {
                return(result);
            }
            foreach (var job in xElement.Elements("row").Select(f => new IndustryJob
            {
                ID = int.Parse(f.Attribute("jobID").Value),
                InstalledItemID = long.Parse(f.Attribute("blueprintID").Value),
                InstallerID = int.Parse(f.Attribute("installerID").Value),
                Runs = int.Parse(f.Attribute("runs").Value),
                InstalledItemTypeID = int.Parse(f.Attribute("productTypeID").Value),
                LicensedRuns = int.Parse(f.Attribute("licensedRuns").Value),
                OutputTypeID = int.Parse(f.Attribute("productTypeID").Value),
                Completed = GetCompleted(f),
                ActivityID = int.Parse(f.Attribute("activityID").Value),
                BeginProductionTime = GetTime(f.Attribute("startDate")),
                EndProductionTime = GetTime(f.Attribute("endDate")),
                PauseProductionTime = GetTime(f.Attribute("pauseDate")),
                TeamID = int.Parse(f.Attribute("teamID").Value)
            }))
            {
                result.Data.Add(job);
            }
            return(result);
        }
Example #4
0
        public ApiLoadResponse <Asset> Load(ApiKeyType keyType, int apiKeyId, string vCode, int eveApiID)
        {
            var kt       = keyType == ApiKeyType.Character ? "char" : "corp";
            var service  = string.Format("http://api.eve-online.com/{0}/AssetList.xml.aspx?keyID={1}&vCode={2}&characterID={3}", kt, apiKeyId, vCode, eveApiID);
            var response = EveApiLoader.Load(service);

            if (!response.Success)
            {
                throw new Exception(response.ErrorMessage);
            }
            var result = new ApiLoadResponse <Asset>
            {
                Data        = new List <Asset>(),
                CachedUntil = response.CachedUntil
            };

            RecursiveLoad(result.Data, response.Result.Element("rowset"), (int?)response.Result.Attribute("locationID"));
            return(result);
        }
Example #5
0
        public ApiLoadResponse <MarketOrder> Load(ApiKeyType keyType, int apiKeyId, string vCode, int eveApiID)
        {
            var kt       = keyType == ApiKeyType.Character ? "char" : "corp";
            var url      = string.Format("http://api.eve-online.com/{0}/MarketOrders.xml.aspx?keyID={1}&vCode={2}&characterID={3}", kt, apiKeyId, vCode, eveApiID);
            var response = EveApiLoader.Load(url);

            if (!response.Success)
            {
                throw new Exception(response.ErrorMessage);
            }
            var result = new ApiLoadResponse <MarketOrder>
            {
                CachedUntil = response.CachedUntil
            };
            var element = response.Result.Element("rowset");

            if (element != null)
            {
                result.Data.AddRange(element.Elements("row").Select(f => new MarketOrder
                {
                    ID              = (long)f.Attribute("orderID"),
                    CharacterID     = (int)f.Attribute("charID"),
                    StationID       = (int)f.Attribute("stationID"),
                    VolumeEntered   = (int)f.Attribute("volEntered"),
                    VolumeRemaining = (int)f.Attribute("volRemaining"),
                    MinimumVolume   = (int)f.Attribute("minVolume"),
                    OrderState      = (OrderState)(int)f.Attribute("orderState"),
                    ItemID          = (int)f.Attribute("typeID"),
                    Range           = (short)f.Attribute("range"),
                    AccountKey      = (int)f.Attribute("accountKey"),
                    Duration        = (int)f.Attribute("duration"),
                    Escrow          = (decimal)f.Attribute("escrow"),
                    Price           = (decimal)f.Attribute("price"),
                    OrderType       = (bool)f.Attribute("bid") ? OrderType.Buy : OrderType.Sell,
                    WhenIssued      = (DateTime)f.Attribute("issued")
                }));
            }
            return(result);
        }