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:
And the source code is even simpler!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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