#918 Request for input on .NET client library

Chris Breederveld Tue 18 May 2021

Hi .NET developers,

I need input on the .NET ProjectHaystack.Client package.

This libraries Java origins have long since bothered me (lack of support for many of the .NET feature we have come to love) and the library has gradually been moving more towards a version that feels like the ones you are used to.

However, many features were still only half-done and support on the many versions of the logic was making it harder to do the more important things. Therefore I am working on a major refactoring of the library to go towards a full .NET 5.0 implementation, but I need your input!

Please have a look at the new branch and/or download the pre-release NuGet package 2.0.0-beta and let me know what you like, dislike or are missing.

The library is by choice not backward-compatible, but if there is a great need to port older projects to this library I might consider creating a backcompat NuGet to accompany this one.

J Verwaal Fri 2 Jul 2021

Hello Chris,

You did quite a job there. I'm currently trying to build some kind of proxy to be able to use the REST-API import of power-BI. We get a lot of request for this. The SkySpark REST-API Authentication is not supported in power-BI. So my first idea is to have a RES-API that power-BI can access and from there get the data from SkySpark. I was trying to use your lib that offers a lot of functionality. However using this:

var user = "someone";
    var pass = "secret";
    var uri = new Uri("http://host:8080/api/demo/");
    var auth = new AutodetectAuthenticator(user, pass);
    var client = new HaystackClient(auth, uri);

    await client.OpenAsync();

    Task<HaystackGrid> task = client.ReadAllAsync("site", 20);
    HaystackGrid test = task.Result;

   Gives back a grid but all values are empty:
[{"id":{},"area":{},"dis":{},"geoAddr":{},"geoCity":{},"geoCoord":{},"geoCountry":{},"geoPostalCode":{},"geoState":{},"geoStreet":{},"hq":{},"metro":{},"occupiedEnd":{},"occupiedStart":{},"primaryFunction":{},"regionRef":{},"site":{},"store":null,"storeNum":null,"tz":{},"weatherStationRef":{},"yearBuilt":{},"mod":{}},
{"id":{},"area":{},"dis":{},"geoAddr":{},"geoCity":{},"geoCoord":{},"geoCountry":{},"geoPostalCode":{},"geoState":{},"geoStreet":{},"hq":null,"metro":{},"occupiedEnd":{},"occupiedStart":{},"primaryFunction":{},"regionRef":{},"site":{},"store":{},"storeNum":{},"tz":{},"weatherStationRef":{},"yearBuilt":{},"mod":{}},
{"id":{},"area":{},"dis":{},"geoAddr":{},"geoCity":{},"geoCoord":{},"geoCountry":{},"geoPostalCode":{},"geoState":{},"geoStreet":{},"hq":null,"metro":{},"occupiedEnd":{},"occupiedStart":{},"primaryFunction":{},"regionRef":{},"site":{},"store":{},"storeNum":{},"tz":{},"weatherStationRef":{},"yearBuilt":{},"mod":{}},
{"id":{},"area":{},"dis":{},"geoAddr":{},"geoCity":{},"geoCoord":{},"geoCountry":{},"geoPostalCode":{},"geoState":{},"geoStreet":{},"hq":null,"metro":{},"occupiedEnd":{},"occupiedStart":{},"primaryFunction":{},"regionRef":{},"site":{},"store":{},"storeNum":{},"tz":{},"weatherStationRef":{},"yearBuilt":{},"mod":{}}]

Any Idea? I tried to debug your code but I'm not a high lever C# guy like you.

Chris Breederveld Fri 2 Jul 2021

Hi J,

It looks like you are doing everything right, but I wonder a bit how you get to that output?

Can you try this code and see what you get then? This code formats the data as Hayson and should yield actual data. I just ran this code on my SkySpark project using ProjectHaystack.Client v2.0.5 and it worked as expected.

await client.OpenAsync();
var result = await client.ReadAllAsync("site", 20);
string data = null;
using (var stringWriter = new StringWriter())
using (var haysonWriter = new HaysonWriter(stringWriter))
{
    haysonWriter.WriteGrid(result);
    data = stringWriter.ToString();
}

J Verwaal Mon 5 Jul 2021

Hi Chris,

You are right, my problem was not in your lib, but in the part that has to convert the Haystackgrid to the requested JSON output by the client. It does not know how to do that. Your piece of code above does exactly what I was missing. Thanks

Login or Signup to reply.