Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
        public IEnumerable <ApiKeyInfo> Load(int keyID, string vCode)
        {
            var result = new ApiKeyInfo();

            var response = EveApiLoader.Load(string.Format("http://api.eve-online.com/account/APIKeyInfo.xml.aspx?keyID={0}&vCode={1}", keyID, vCode));

            if (!response.Success)
            {
                throw new Exception(response.ErrorMessage);
            }
            var key = response.Result.Element("key");

            Debug.Assert(key != null, "key != null");
            result.AccessMask = int.Parse(key.Attribute("accessMask").Value);
            result.ApiKeyType = GetKeyType(key.Attribute("type").Value);

            var rowset = key.Element("rowset");

            if (rowset == null)
            {
                return new List <ApiKeyInfo>
                       {
                           result
                       }
            }
            ;
            var rows = rowset.Elements("row");

            foreach (var row in rows)
            {
                var id = int.Parse(row.Attribute("characterID").Value);

                var name     = row.Attribute("characterName").Value;
                var corpid   = int.Parse(row.Attribute("corporationID").Value);
                var corpname = row.Attribute("corporationName").Value;
                result.Characters.Add(new Character
                {
                    ID              = id,
                    Name            = name,
                    CorporationID   = corpid,
                    CorporationName = corpname
                });
            }
            return(new List <ApiKeyInfo>
            {
                result
            });
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        public ApiLoadResponse <WalletTransaction> Load(ApiKeyType keyType, int apiKeyId, string vCode, int eveApiID, int maxAge, long lastTransactionId)
        {
            var  done   = false;
            long?before = null;
            var  result = new ApiLoadResponse <WalletTransaction>
            {
                Data = new List <WalletTransaction>(),
            };
            var enough = false;

            while (!done)
            {
                var kt      = keyType == ApiKeyType.Character ? "char" : "corp";
                var service = string.Format("http://api.eve-online.com/{0}/WalletTransactions.xml.aspx?keyID={1}&vCode={2}&characterID={3}", kt, apiKeyId, vCode, eveApiID);
                if (before != null)
                {
                    service += string.Format("&beforeTransID={0}", before);
                }

                var response = EveApiLoader.Load(service);
                if (!response.Success)
                {
                    throw new Exception(response.ErrorMessage);
                }
                var xElement = response.Result.Element("rowset");
                if (xElement != null)
                {
                    result.CachedUntil = response.CachedUntil;
                    if (keyType == ApiKeyType.Character)
                    {
                        result.Data.AddRange(
                            xElement
                            .Elements("row")
                            .Where(f => f.Attribute("transactionFor").Value == "personal")
                            .Select(f => new WalletTransaction
                        {
                            ID       = long.Parse(f.Attribute("transactionID").Value),
                            DateTime = DateTime.Parse(f.Attribute("transactionDateTime").Value),
                            Quantity = int.Parse(f.Attribute("quantity").Value),
                            TypeID   = int.Parse(f.Attribute("typeID").Value),
                            Type     = f.Attribute("transactionType").Value,
                            Price    = Decimal.Parse(f.Attribute("price").Value)
                        }));
                    }
                    else
                    {
                        result.Data.AddRange(
                            xElement
                            .Elements("row")
                            .Select(f => new WalletTransaction
                        {
                            ID       = long.Parse(f.Attribute("transactionID").Value),
                            DateTime = DateTime.Parse(f.Attribute("transactionDateTime").Value),
                            Quantity = int.Parse(f.Attribute("quantity").Value),
                            TypeID   = int.Parse(f.Attribute("typeID").Value),
                            Type     = f.Attribute("transactionType").Value,
                            Price    = Decimal.Parse(f.Attribute("price").Value)
                        }));
                    }
                    if (xElement.Elements("row").Any())
                    {
                        var first = xElement.Elements("row").Min(f => long.Parse(f.Attribute("transactionID").Value));
                        enough = xElement.Elements("row").Min(f => DateTime.Parse(f.Attribute("transactionDateTime").Value)) < DateTime.Now.AddDays(-maxAge);
                        before = first;
                    }
                    else
                    {
                        enough = true;
                    }
                }
                done = enough || result.Data.Count == 0 || result.Data[0].ID <= lastTransactionId;
            }
            return(result);
        }