Hello!

Today the post is a simple reminder of a piece of code I’ve written from scratch several times, and that’s it, I’m writing this down here! The scenario is simple:

In a PowerBI Instance I have a pair of Streaming Datasets and I want to send information to them from a Windows Store App.

Well, in Hands On Labs that has shared Ozzie (see references), describes the steps to create the Streaming Dataset from scratch and to feed it. However, a bit of code is pending for Windows 10 and C#.

My Streaming DataSet value definition is very simple:

i!

And the source code is even simpler!


private async void ReportVisitorsAsync(string pushUrl, int totalVisitors, int totalVisitorsIdentified, string centerName)
{
var visitorsMeasurement = new
{
TotalVisitors = totalVisitors,
TotalRecognizedVisitors = totalVisitorsIdentified,
timeStamp = DateTime.Now,
CenterName = centerName
};
var jsonString = JsonConvert.SerializeObject(visitorsMeasurement);
var request = WebRequest.Create(pushUrl);
request.Method = "POST";
request.ContentType = "application/json";
using (var requestWriter = new StreamWriter(await request.GetRequestStreamAsync()))
{
requestWriter.Write(jsonString);
requestWriter.Flush();
}
await request.GetResponseAsync();
}

Happy Coding!

Greetings @ Toronto

El Bruno

References

Leave a comment

Discover more from El Bruno

Subscribe now to keep reading and get access to the full archive.

Continue reading