These forums have been archived and are now read-only.

The new forums are live and can be found at https://forums.eveonline.com/

EVE Technology Lab

 
  • Topic is locked indefinitely.
 

[EveLib] A .NET library for EveXML, CREST, EveCentral, and more

First post
Author
Icahmura Hasaki
Perkone
Caldari State
#321 - 2016-02-20 10:28:56 UTC
Xiaou Bijoun wrote:
Still learning how to use the library. I have used the Query MarketTypes to get a list of the market types. Each MarketTypeCollection Item has has two properties MarketGroup and Type.

I would like to get an ItemType object from the Type's Uri and the icon from the Icon's Uri. How do I run a query on these and what type of object do I put it in?

For example Plagioclase (note it won't let me put more explicit text because it says no html even though I see links in previous posts),
I would like to get an ItemType object so I can access the properties and attributes of items and an Image object.

Also, the MargetGroup property for Plagioclase has it's Uri set correctly, but it's Name property is null. Is this intentional and I would have to put the correct name string in this object by getting it from either the endpoint itself or my MarketGroup list retrieved from a Query of MarketGroups, or is this a bug and it should be populated. The Type property has it's Name is set to "Plagioclase".



I'll have a look tonight

Quote:
Another question, does your web access abide by the 120 request per second with 400 request per seconds burst and 20 open connections limits specified for Crest?


The RequestHandler has a threadpool of 20 threads for public and 10 for authenticated crest, and that is the only limit the library imposes. From what I can remember that amounts to roughly 50 requests per second. The size is configurable through the RequestHandler object on your EveCrest object. I might implement more sophisticated control some time, eg. bursts, but that's far down the road.


Developer of EveLib and EveAuthUtility

Icahmura Hasaki
Perkone
Caldari State
#322 - 2016-02-20 19:34:23 UTC
Here is a short example of achieving what you want, if I understand you correctly:


      var marketType =
                (await crest.GetRoot().QueryAsync(r => r.MarketTypes)).Items.Single(i => i.Type.Name == "Plagioclase");
            var itemType = await crest.LoadAsync(marketType.Type);
            var marketGroup = await crest.LoadAsync(marketType.MarketGroup);
            var itemIcon = await crest.LoadImageAsync(marketType.Type.Icon);


crest.LoadAsync() is the same as calling someresource.QueryAsync(), I know the naming is unfortunate. Notice how we cannot Query/Load the marketType object directly, because the marketType itself isn't a resource, and does not link anywhere. It does however contain two linked resources, Type and MarketGroup, which can be queried. crest.LoadImage() returns the image as a simple byte array.
About the missing name, CREST does unfortunately not provide the MarketGroup name in the collection, so you will have to query the MarketGroup link for that. I have used the same base class as I use for all resource links, and I believe all others has a Name property but this one. I will probably remove the Name property in the next major version.

Developer of EveLib and EveAuthUtility

Xiaou Bijoun
Imperial Academy
Amarr Empire
#323 - 2016-02-21 17:39:27 UTC
Thank you for that information. I had discovered the Load function but LoadAsync is better. I tried to put the Async functions in but with the await keyword, it wants the calls in a seperate async function, which I have not wrapped my head around yet. I removed the await keywords and it works, but the icon task never completes. I know the href is working, I can copy it from a watch window into a browser and get the image.

Here is my function...

        
MarketTypeInformation GetMarketTypeInformation(MarketTypeCollection.Item marketType)
        {
            MarketTypeInformation info = new MarketTypeInformation();

            var itemType = eveCrest.LoadAsync(marketType.Type);
            var marketGroup = eveCrest.LoadAsync(marketType.MarketGroup);
            var itemIcon = eveCrest.LoadImageAsync(marketType.Type.Icon);

            while (itemType.IsCompleted == false || marketGroup.IsCompleted == false || itemIcon.IsCompleted == false) ;

            info.itemType = itemType.Result;
            info.marketGroup = marketGroup.Result;

            using (var ms = new MemoryStream(itemIcon.Result))
            {
                info.icon = Image.FromStream(ms);
            }           

            return (info);
        }
Xiaou Bijoun
Imperial Academy
Amarr Empire
#324 - 2016-02-21 18:06:21 UTC  |  Edited by: Xiaou Bijoun
When I get the ItemType information of an item that contains DogmaAttribute and DogmaEffects, the Href parameters on those are null. How are you supposed to get the information for those?
Icahmura Hasaki
Perkone
Caldari State
#325 - 2016-02-21 22:46:54 UTC  |  Edited by: Icahmura Hasaki
Xiaou Bijoun wrote:
When I get the ItemType information of an item that contains DogmaAttribute and DogmaEffects, the Href parameters on those are null. How are you supposed to get the information for those?


Those are not supposed to be null. I'll have a look tomorrow. I'll look at the icon too. If you want to use async, it should use async/await all the way up to your top level event handler or whatever is the topmost caller of your code. You might want to read up on async/await for that :)

edit: Nevermind what I said about async, you can use it like you have, but you should understand what's going on :) There are many benefits of using the full await/async API tho, especially if you are using it with a GUI.

Edit2: The IsCompleted check isn't necessary, because .Result forces synchronization internally, basically waiting for IsCompleted.

Developer of EveLib and EveAuthUtility

Xiaou Bijoun
Imperial Academy
Amarr Empire
#326 - 2016-02-22 00:13:11 UTC
Thank you, I will read up more on the await/async. If you do fully use await/async do you need the IsCompleted?
Icahmura Hasaki
Perkone
Caldari State
#327 - 2016-02-22 07:46:15 UTC
Xiaou Bijoun wrote:
Thank you, I will read up more on the await/async. If you do fully use await/async do you need the IsCompleted?


No, then you would use the await keyword, or Task.AwaitAll().

Developer of EveLib and EveAuthUtility

NullBy7e
Artemis Superiority Conclave
Firestorm Vanguard
#328 - 2016-02-22 08:20:35 UTC
Xiaou Bijoun wrote:
Thank you, I will read up more on the await/async. If you do fully use await/async do you need the IsCompleted?


http://pastebin.com/U8JRNG7J


public async Task MarketTypeInformation GetMarketTypeInformationAsync(MarketTypeCollection.Item marketType)
{
    var info = new MarketTypeInformation();

    var itemType = eveCrest.LoadAsync(marketType.Type);
    var marketGroup = eveCrest.LoadAsync(marketType.MarketGroup);
    var itemIcon = eveCrest.LoadImageAsync(marketType.Type.Icon);
   
    using (var ms = new MemoryStream(await itemIcon))
    {
        info.icon = Image.FromStream(ms);
    }           

    info.itemType = await itemType;
    info.marketGroup = await marketGroup;
   
    return info;
}

public async void DoStuffAsync()
{
    var marketTypeInfo = GetMarketTypeInformationAsync();
   
    //
    //do stuff here that doesn't require the value/result of marketTypeInfo
    //
   
   
    //
    //await for the result
    //
   
    var marketTypeInfoResult = await marketTypeInfo;
}
Icahmura Hasaki
Perkone
Caldari State
#329 - 2016-02-22 17:37:33 UTC
I've fixed bugs with the DogmaAttribute and DogmaEffect on ItemTypes, and they are now parsed correctly, I'll update EveCrest shortly.

I tested LoadImage and it's working fine, tested using the following code:


public async Task GetIcon() {
            var item = (await crest.GetRoot().QueryAsync(r => r.MarketTypes)).Items.First();
            var icon = await crest.LoadImageAsync(item.Type.Icon);
}


And I also did the same using the synchronous methods, both load the image data correctly.

Developer of EveLib and EveAuthUtility

Icahmura Hasaki
Perkone
Caldari State
#330 - 2016-02-22 19:08:18 UTC
Xiaou Bijoun
Imperial Academy
Amarr Empire
#331 - 2016-02-23 15:24:19 UTC
The latest build of Crest v3.2.2 has caused previously compiling code to error.

I have been trying to post some details, but no matter what I do it thinks I am posting html.
Icahmura Hasaki
Perkone
Caldari State
#332 - 2016-02-23 15:27:32 UTC
Xiaou Bijoun wrote:
The latest build of Crest v3.2.2 has caused previously compiling code to error.

I have been trying to post some details, but no matter what I do it thinks I am posting html.


Post it on github or somewhere else, I can't do much without more information.

Developer of EveLib and EveAuthUtility

Xiaou Bijoun
Imperial Academy
Amarr Empire
#333 - 2016-02-23 15:27:53 UTC
Basically, I created a list of MarketGroup by Querying the root which returns a MarketGroupCollection and converting to a List with ToList() function, but it now says that it can't convert from MarketGroupCollection.MarketGroupItem to MarketGroup. If I change my list to a MarketGroupCollection.MarketGroupItem I can get that code to compile but later on when I am building the Market Group TreeView (basically a clone of the Eve Market Window) the ParentGroup field is not available in the MarketGroupCollection.MarketGroupItem. I use the ParentGroup field to build the tree from the out of order list of MarketGroup items. This probably a misunderstanding of what classes I should be using to do this, but it did previously work with Crest 3.2.1.

Thank you
Icahmura Hasaki
Perkone
Caldari State
#334 - 2016-02-23 15:32:56 UTC
Xiaou Bijoun wrote:
Basically, I created a list of MarketGroup by Querying the root which returns a MarketGroupCollection and converting to a List with ToList() function, but it now says that it can't convert from MarketGroupCollection.MarketGroupItem to MarketGroup. If I change my list to a MarketGroupCollection.MarketGroupItem I can get that code to compile but later on when I am building the Market Group TreeView (basically a clone of the Eve Market Window) the ParentGroup field is not available in the MarketGroupCollection.MarketGroupItem. I use the ParentGroup field to build the tree from the out of order list of MarketGroup items. This probably a misunderstanding of what classes I should be using to do this, but it did previously work with Crest 3.2.1.

Thank you


Got it, and I know why, I'll fix it in a few hours. I should probably spend more time testing before releasing, but I'm trying to push things out as quickly as possible now that I've got some time for it :)

Developer of EveLib and EveAuthUtility

Xiaou Bijoun
Imperial Academy
Amarr Empire
#335 - 2016-02-23 15:59:03 UTC
No problem, your code has saved me hours of programming. I have worked on a library for months with barely a fraction of the functionality that you provide in this library. I appreciate your work and your timely addressing of issues. I know of professional companies that take longer to address issues.

I wish my skills were a little better because I might be able to help with the debugging of the library, but alas I am just a hacker and not the type everyone thinks are cool.

Do you have any idea why I have issues posting source code? I can get some stuff to go through and see it in the preview then all of a sudden it says it cannot contain html and erases everything I have tried to enter. I copied the code I posted from the other day and it went in with no problems. It would be so much easier to post source code examples.

By the way, I am also trying to do the same thing with Regions and run into a similar issue, but I will wait until I have the MarketGroups working again and see if I can figure it out on my own before I spring that on you.

I think some of my problem is visualizing the difference between the objects with Crest endpoints and the actual resource objects.
Icahmura Hasaki
Perkone
Caldari State
#336 - 2016-02-23 18:07:49 UTC
EveCrest 3.2.3, reverting the model changes to MarketGroupCollection and MarketGroupItem in previous release.
https://www.nuget.org/packages/eZet.EveLib.EveCrest/3.2.3
https://github.com/ezet/evelib/releases/tag/EveCrest_v3.2.3

Developer of EveLib and EveAuthUtility

Xiaou Bijoun
Imperial Academy
Amarr Empire
#337 - 2016-02-23 18:55:44 UTC
Don't think me a pain, but just tried Crest v3.2.3 and the initial call to create an EveCrest object causes an exception.

eveCrest = new EveCrest();

From my log text...

Creating EveCrest object.
Exception: System.MissingMethodException: Method not found: 'System.String eZet.EveLib.Core.Config.get_AppData()'.
   at eZet.EveLib.EveCrestModule.RequestHandlers.CachedCrestRequestHandler..ctor(ISerializer serializer)
   at eZet.EveLib.EveCrestModule.EveCrest..ctor()
   at EveCrestContest.frmMarketItems.frmMarketItems_Shown(Object sender, EventArgs e) in C:\EveCrestContest v1.0.0.4\EveCrestContest\frmMarketItems.cs:line 49


Icahmura Hasaki
Perkone
Caldari State
#338 - 2016-02-23 19:33:30 UTC
Xiaou Bijoun wrote:
Don't think me a pain, but just tried Crest v3.2.3 and the initial call to create an EveCrest object causes an exception.

eveCrest = new EveCrest();

From my log text...

Creating EveCrest object.
Exception: System.MissingMethodException: Method not found: 'System.String eZet.EveLib.Core.Config.get_AppData()'.
   at eZet.EveLib.EveCrestModule.RequestHandlers.CachedCrestRequestHandler..ctor(ISerializer serializer)
   at eZet.EveLib.EveCrestModule.EveCrest..ctor()
   at EveCrestContest.frmMarketItems.frmMarketItems_Shown(Object sender, EventArgs e) in C:\EveCrestContest v1.0.0.4\EveCrestContest\frmMarketItems.cs:line 49




Not sure how that has happened, but try updating EveLib.Core in a few minutes, to v3.0.3, and let me know if that works.

Developer of EveLib and EveAuthUtility

Xiaou Bijoun
Imperial Academy
Amarr Empire
#339 - 2016-02-23 19:43:04 UTC
Now the exception is

Creating EveCrest object.
Exception: System.MissingFieldException: Field not found: 'eZet.EveLib.Core.Config.Separator'.
   at eZet.EveLib.EveCrestModule.RequestHandlers.CachedCrestRequestHandler..ctor(ISerializer serializer)
   at eZet.EveLib.EveCrestModule.EveCrest..ctor()
   at EveCrestContest.frmMarketItems.frmMarketItems_Shown(Object sender, EventArgs e) in D:\EveCrestContest v1.0.0.4\EveCrestContest\frmMarketItems.cs:line 49


Icahmura Hasaki
Perkone
Caldari State
#340 - 2016-02-23 19:45:16 UTC
Yeah, I know, update to EveCrest coming shortly, that will be the last one for tonight :P

Developer of EveLib and EveAuthUtility