Pages: 1 [2] 3 4 5 6 7 8 9 10 11 12 13 14 15 .. 15 :: one page |
|
Author |
Thread Statistics | Show CCP posts - 2 post(s) |
Cryten Jones
Chill Cabal The Serenity Initiative
109
|
Posted - 2014.05.08 13:22:00 -
[31] - Quote
That's done it! I could not work out the link between the key object and the character object where all the methods live :-)
I am doing most of my data heavy lifting on the SQL side as I know this so your library is all about raw data into database tables where it can be processed with stored procedures.
For multiple accounts should I be creating a new key / char pair for each specifically of is there a neat way to loop though reusing the same objects by just modifying the values?
I was thinking key.vcode = 1234 would allow me to reset the vcode so something new but it seems to be only a get option
Thanks for all the help |
Icahmura Hasaki
Brave Newbies Inc. Brave Collective
3
|
Posted - 2014.05.08 13:31:00 -
[32] - Quote
You need to create a new key object for each API key you want to use, for various design reasons. They are lightweight though and has no impact on anything really :)
You can loop through all characters available for a key by iterating key.Characters, as a normal list. Or you can select a specific one by ID or Name like I showed above. |
Cryten Jones
Chill Cabal The Serenity Initiative
109
|
Posted - 2014.05.08 13:37:00 -
[33] - Quote
So if I am pulling a list of chars with their key data from the database and then looping though the x number I have .. do you have any advice on how to programatically create x number of new key objects?
Totally understand if you have had enough at this point :-)
|
Icahmura Hasaki
Brave Newbies Inc. Brave Collective
3
|
Posted - 2014.05.08 13:44:00 -
[34] - Quote
Place the key data in some enumerable structure, like a List[KeyData] of KeyData objects with a Id and vcode property, or a Dictionary[int, string] with id and vcode respectively.
Then iterate through it like so:
Quote: foreach (KeyData data in KeyDataList) { var key = new CharacterKey(data.Id, data.vCode); foreach (Character character in key.Characters) { EveApiResponse[AssetList] assets = character.GetAssetList(); // process assets } }
Just keep asking questions, I dont mind helping. I'm sure there are others that can use the information aswell :) |
Icahmura Hasaki
Brave Newbies Inc. Brave Collective
3
|
Posted - 2014.05.08 13:57:00 -
[35] - Quote
I should add that you shouldn't hammer the Eve API though. Doing this for a few characters/keys is fine, but don't do it for a 5000 man corporation.
Creating CorporationKey or CharacterKey is lightweight, and you can creates millionsof these. But as soon as you query key.Characters or any other property on the key (besides KeyId or VCode obviously), the API lazily loads all it's properties and available characters. So if you need to query a lot of keys or characters you should follow CCPs guidelines for amount of queries. |
Icahmura Hasaki
Brave Newbies Inc. Brave Collective
3
|
Posted - 2014.05.08 14:10:00 -
[36] - Quote
And another thing, depending on if you check the validity of the keys beforehand or not, you should add checks for that too.
If you have few keys, you can check it by using key.IsValidKey which returns a bool value. Keep in mind though that this DOES query the api endpoint immediately.
If you have many keys, or a few keys that are expected to be correct, you can catch InvalidRequestException instead, and check if the InnerException.Response.StatusCode == HttpStatusCode.Forbidden instead, which means the key is invalid or doesn't have the right permissions. |
Cryten Jones
Chill Cabal The Serenity Initiative
109
|
Posted - 2014.05.08 14:35:00 -
[37] - Quote
This is for personal use on 4 toons over 4 accounts so it should be light.. I hope...
I am trying to do a foreach(AssetsList.Asset item in assets) where assets is my EveApiResponse[AssetList]
This is saying that your type does not have a getEnumerator so I guess that's a no show.. how else can I loop thought the data ?
edit: eg. I am going to get an asset list for a specific character not looping though for the characters |
Icahmura Hasaki
Brave Newbies Inc. Brave Collective
3
|
Posted - 2014.05.08 14:53:00 -
[38] - Quote
The assets structure is somewhat complicated as assets can contain other assets and so on.
First off, you have to get response.Result to get to the request specific data, for all EveApiResponses objects.
EveApiResponse[AssetList].Result has a a property Assets, which is a collection of Asset objects. Asset objects are a top level object, which is bound to a location in eve. Each Asset object can be a regular item, or a container. It has a property called Items, which is a list of contained Item objects. Each Item object can again have a list of contained Item objects, available in a list called Items.
So basically it's a tree with unknown depth, and you need to navigate it as such.
To find the top level assets you simply iterate response.Result.Assets, where response is the EveApiResponse.
foreach (AssetList.Asset asset in response.Result.Assets) { // do work }
|
Cryten Jones
Chill Cabal The Serenity Initiative
109
|
Posted - 2014.05.08 14:57:00 -
[39] - Quote
So if I don't care about WHERE an item is but only how many I own and other things like singleton status etc will that get me everything or do I HAVE to itterate though
Are you a container > Yes> OK what do you have in you ?
All I am trying to get to is a dataTable that lists all the things that I own across all the characters. |
Icahmura Hasaki
Brave Newbies Inc. Brave Collective
3
|
Posted - 2014.05.08 15:01:00 -
[40] - Quote
All the data is in there, but you do have to iterate through to get it all. You can check if something contains something by checking if Items.Count == 0 or not, on any Item or Asset.
If you have previously done this in your own code, it's basically exactly the same structure, since it reflects the structure of the returned XML. |
|
Icahmura Hasaki
Brave Newbies Inc. Brave Collective
3
|
Posted - 2014.05.08 15:15:00 -
[41] - Quote
Ok, so I have changed structure of the AssetList class slightly. I won't normally make changes to the public API, but I don't think many are using it yet and the change does make quite a few things a lot easier.
response.Result.Assets is now response.Result.Items, and everything is Item objects now, with a LocationId of 0 unless it's a top level object. Also all contained items are in a list called Items.
I've also made a few other updates and fixes that doesn't change the public API, so if you want to download the newest version you should, before implementing too much using the old asset structure.
I can write you a way to flatten the assets as well if you want ? |
Cryten Jones
Chill Cabal The Serenity Initiative
109
|
Posted - 2014.05.08 15:16:00 -
[42] - Quote
All I did was to read the API return into an IXMLDom and then just ask for each [row] element disregarding the [rowset] so getting a flat list
|
Icahmura Hasaki
Brave Newbies Inc. Brave Collective
3
|
Posted - 2014.05.08 15:20:00 -
[43] - Quote
I see, that is indeed much simpler. Anyways, I'll implement a flatten function as I imagine that could be useful for others as well. The previous change to the structure is on git, and I'll have the flatten function ready in a bit. |
Icahmura Hasaki
Brave Newbies Inc. Brave Collective
3
|
Posted - 2014.05.08 15:59:00 -
[44] - Quote
Added a function Flatten() to AssetList that returns a flat list with all the assets. Let me know if there are any issues :) |
Cryten Jones
Chill Cabal The Serenity Initiative
109
|
Posted - 2014.05.08 17:46:00 -
[45] - Quote
Cool, will have a play!
Do I just download the 1.2 zip file again? never understood git :-)
|
Cryten Jones
Chill Cabal The Serenity Initiative
109
|
Posted - 2014.05.08 17:50:00 -
[46] - Quote
Also, on a totally new topic...
I want to have reasonably up to date prices in my app, and am planning a scheduled pull for what is effectively everything. This is because I then use this to generate a regular build price calculation for everything.
I have created an eve central class of my own that build multi item url's so that I am doing 10 * 90 item calls rather than 900 single item calls..
How what I don't know is:-
a: have a wasted my time again and you already do this b: am I going to get the ban hammer :-)
I do make sure that I only check for items that exist & have a market group & are published so I think I follow the rules but I would love to know your view!
|
Icahmura Hasaki
Brave Newbies Inc. Brave Collective
3
|
Posted - 2014.05.08 18:32:00 -
[47] - Quote
Don't use the zip under releases, they are very old. If you go to the main page of the repo, you can click Download ZIP on the right side, that will give you the newest version. It would make it a lot simpler if you used a git client though, as you could automatically get the newest versions and such. But that's up to you.
The library does not automatically segment requests. For evecentral requests you pass in an EveCentralOptions object, which has a List of itemIDs. If you want to segment, you add x amount of IDs to the lis and make a request. Clear the list and add the next X ids, repeat. |
Cryten Jones
Chill Cabal The Serenity Initiative
109
|
Posted - 2014.05.08 21:28:00 -
[48] - Quote
Thanks for all the help, I'll leave you in peace for now :-)
|
Icahmura Hasaki
Brave Newbies Inc. Brave Collective
3
|
Posted - 2014.05.10 16:00:00 -
[49] - Quote
Another few updates. I've cleaned up the separation between http requests, deserialization and caching. It should be very easy to add your own cache implementation if you want to cache using eg. a database.
I'm also currently working on providing a range of methods for retrieving some basic of the data from the static database export. This is also done through http requests though, and is not meant for heavy usage. If you need to perform complex or many queries you should use a local database.
This is however a very lightweight alternative if you only need to request some basic data every now and again. I only just implemented GetInvTypes and GetInvType as a test, more should be coming shortly.
|
Icahmura Hasaki
Brave Newbies Inc. Brave Collective
3
|
Posted - 2014.05.31 13:10:00 -
[50] - Quote
I am currently working on version 2 of the library. This version will be fully async, conforming to the Task-Based Asynchronous Pattern (TAP). I'm not sure whether to leave the sync methods in or not, as there is really no reason not to use the async versions. It will also include much improved tracing and debugging functionality, using System.Diagnostics. I will also use the major version update as an opportunity to make a few minor changes to the public API, as I don't want to change the api of the version 1.
Version 1.x has a new branch called "v1", so feel free up do with that as you please. Currently, EveMarketData has been implemented as async on master, and the others will follow soon.
I would also like to say that I appreciate any thanks, input, or other comments. It would be great to get an idea of who and how many are actually using this, to keep me motivated for further development :)
|
|
|
CCP FoxFour
C C P C C P Alliance
3278
|
Posted - 2014.05.31 13:40:00 -
[51] - Quote
Hey man,
Awesome to see all the work you have been doing on this library. I have added it to the Wiki list of EVE API libraries here: https://wiki.eveonline.com/en/wiki/EVE_API_Libraries
You probably wont want to do it until you are done your v2 of the library but consider also adding a basic example of it's usage here: https://wiki.eveonline.com/en/wiki/EVE_API_Getting_Started
Since you are also about the only one doing .NET stuff it would be great to see a raw .NET example there as well. :D CCP FoxFour // Game Designer // @regnerba
|
|
Lien Rollard
Universalis Imperium The Bastion
0
|
Posted - 2014.05.31 14:49:00 -
[52] - Quote
Very nice work. I have a few question.
1) Do you expect alot of changes to the method names or the global structure of the library with the Async changes? (I suspect not but I'd rather ask)
2) Do you have a specific reason as to why you're not throwing Exceptions on the Contracts?
Quote:Example: - Contract.Requires(options.Stations != null);
Why not (general exception, could be more specific): Contract.Requires < EveLibException > (options.Stations != null);
I'm asking this because the current way doesn't allow for easy feedback when something goes wrong. I've been thinking of implementing these exceptions on the version I'm using. I'll probably fork / pull request
Keep up the good work anyway. You're encouraging me to actually begin coding on a market/corp application. |
Icahmura Hasaki
Brave Newbies Inc. Brave Collective
4
|
Posted - 2014.05.31 15:19:00 -
[53] - Quote
Funny you'd ask about the library changes, I've been contemplating this exact issue for the past few hours. By convention the new methods have to be named using an "Async" postfix. So the question is whether I should remove the old synchronous methods or not. And if I keep them, do I just wrap the async methods and block, or do I keep a separate fully sync implementation.
From a maintenance and clarity perspective, removing the synchronous methods would be much easier. If someone really wants to avoid using async, they can still use SomeMethodAsync().Result with the implications that causes.
I really can't seem to decide how to do it. If anyone has any input, that would be greatly appreciated.
About the code contracts, MS recommends using the non-generic version of Requires unless backward compatibility with old DataContracts versions force you use the generic one. I have to admit I haven't used CodeContracts much, and I've been considering removing it all together but haven't had the time to look into it further. The non-generic one does however also throw an Exception if the contract is violated, just not a user specified one. |
Icahmura Hasaki
Brave Newbies Inc. Brave Collective
4
|
Posted - 2014.05.31 15:30:00 -
[54] - Quote
Hey, that's greatly appreciated!
I will make sure to add some examples there, once I get the public API for 2.0 finalized. I should also add that there is a pretty comprehensive readme on github, with details and code examples.
And I'll have a look at the raw example, but C# can be quite verbose at times, compared to the neater php and python examples. I could add something simple for querying an endpoint, any sensible XML parsing might take too much space though. |
Lien Rollard
Universalis Imperium The Bastion
0
|
Posted - 2014.05.31 15:31:00 -
[55] - Quote
To be honest, multithreading is the way most applications run these days. Due to the Await-Async implementation it has made the usage of multithreading alot easier. I hardly use non-async methods these days.
However I understand some people refraining from the multithreading. Personally I would go with the "Async" postfix with the non-async methods being blocked versions of the async ones. It allows for easier debugging & testing since you're basically testing the same in 2 seperate "methods".
I feel a user of a library is still responsable for how he/she handles the return of the methods exposed inside it. If the user feels like using the non-Async methods, the user should know the implications. Same for the async methods.
About the Code Contracts, thanks for the information. I never used Contracts before mostly due to never hearing about it till now. If you go about removing it, would you go back to the normal if-else clauses or search for different solution? |
Icahmura Hasaki
Brave Newbies Inc. Brave Collective
4
|
Posted - 2014.05.31 15:43:00 -
[56] - Quote
Yes, I will probably keep the old methods, and just add Async versions of them.
About the contracts, I'm not entirely sure the library needs it. The parameters aren't very complex, and are well documented by both the relevant API documentation (eve central, eve marketdata and so on) and in the comments for each method.
If you want to use code contracts however, you should probably download http://visualstudiogallery.msdn.microsoft.com/1ec7db13-3363-46c9-851f-1ce455f66970 if you're using visual studio.
I'll probably keep them around for version 2 at least, but as always feedback is welcome. |
Icahmura Hasaki
Brave Newbies Inc. Brave Collective
4
|
Posted - 2014.05.31 17:23:00 -
[57] - Quote
I've updated all modules, except EveOnline.Image, to include Async versions of all methods. What is available on the master now will be the final API for version 2.0, bar minor bugs that might have passed the unit tests.
I might add support for progress reporting and task cancellation, but in a way that doesn't affect the current api.
I would greatly appreciate any feedback or help with debugging the async methods, as well as the regular ones.
Also, keep in mind that async does not mean that the library is automagically multithreaded. Some methods may still be CPU bound during deserialization. However, the library shouldn't block on any IO operations (disk access, web requests) if you use the async api. |
Lien Rollard
Universalis Imperium The Bastion
0
|
Posted - 2014.05.31 17:56:00 -
[58] - Quote
I have forked your Library and am adding a small module for EMDR (for those who want to have the data directly instead of via Eve-Central/Market/Etc)
Very nice work on the v2.0 api. That was quick! |
Icahmura Hasaki
Brave Newbies Inc. Brave Collective
4
|
Posted - 2014.05.31 22:34:00 -
[59] - Quote
It seems I was a bit too quick on the trigger regarding the final API. I need to figure out how to deal with the lazy loading of properties in CharacterKey and CorporationKey.
My current options are: Provide a separate method, InitAsync(), which loads all properties in async fashion. Accessing any properties for the first time without first calling InitAsync(), will load the properties synchronously.
Provide properties which lazy loads synchronously (as it is currently), and a separate method named GetSomePropertyAsync(), which provides the async behaviour. I don't like the fact that I'll have to mix properties and methods for accessing the same fields though.
Provide properties named SomePropertyAsync, which lazy loads asynchronously. This might be the most elegant solution, but it also seems to go against many conventions for properties, and isn't directly supported so I'd have to use some dirty code.
Remove all properties, and only provide methods, like GetSomeProperty() and GetSomePropertyAsync(). This will make the API more consistent than mixing properties for sync and methods for async operations, but will break backwards compatibility for this part of the api.
Any input would be welcome |
Icahmura Hasaki
Brave Newbies Inc. Brave Collective
4
|
Posted - 2014.06.01 11:46:00 -
[60] - Quote
So I've narrowed it down to option 1 or 4, unless someone has any other ideas.
Option 1 would preserve current functionality, but with an added InitAsync() method. So if you want to use it synchronously it would be used as it is now, and if you want async, you would need to call this explicitly before accessing any properties. So following InitAsync, all access to properties will be instant without the need for any async methodology. And obviously you don't have to call InitAsync on object creation, you can defer it to a point where you are certain you will have to load the data.
Quote:CharacterKey key = await new CharacterKey(keyId, vCode).InitAsync(); string accessMask = key.AccessMask; Character c = key.Characters.First();
Or the other option, which avoids the explicit initiation and allows lazy loading of the data on demand, but also requires async methodology for access to each property on the key.
Quote:CharacterKey key = new CharacterKey(keyId, vCode); string accessMask = await key.GetAccessMaskAsync(); Character c = (await key.GetCharactersAsync()).First();
I've currently implemented both, but this makes the API unnecessarily complex, so I'll be removing one of them. I'm currently leaning towards using the first option, but I'm fairly new to TAP and .NET in general so any input would be welcome :) |
|
|
|
|
Pages: 1 [2] 3 4 5 6 7 8 9 10 11 12 13 14 15 .. 15 :: one page |
First page | Previous page | Next page | Last page |