Example #1
0
        //Get a tile from a dashboard. In this sample, you get the first tile.
        protected void GetTile(string dashboardId, int index)
        {
            //Configure tiles request
            System.Net.WebRequest request = System.Net.WebRequest.Create(
                String.Format("{0}Dashboards/{1}/Tiles",
                              baseUri,
                              dashboardId)) as System.Net.HttpWebRequest;

            request.Method        = "GET";
            request.ContentLength = 0;
            request.Headers.Add("Authorization", String.Format("Bearer {0}", accessToken.Value));

            //Get tiles response from request.GetResponse()
            using (var response = request.GetResponse() as System.Net.HttpWebResponse)
            {
                //Get reader from response stream
                using (var reader = new System.IO.StreamReader(response.GetResponseStream()))
                {
                    //Deserialize JSON string
                    PBITiles tiles = JsonConvert.DeserializeObject <PBITiles>(reader.ReadToEnd());

                    //Sample assumes at least one Dashboard with one Tile.
                    //You could write an app that lists all tiles in a dashboard
                    if (tiles.value.Length > 0)
                    {
                        tileEmbedUrl.Text = tiles.value[index].embedUrl;
                    }
                }
            }
        }
Example #2
0
        private void getTilesForDashboard(string dashboardId)
        {
            string responseContent = string.Empty;

            //Configure datasets request
            System.Net.WebRequest request = System.Net.WebRequest.Create(String.Format("{0}Dashboards/{1}/Tiles", baseUri, dashboardId)) as System.Net.HttpWebRequest;
            request.Method        = "GET";
            request.ContentLength = 0;
            request.Headers.Add("Authorization", String.Format("Bearer {0}", authResult.AccessToken));

            //Get datasets response from request.GetResponse()
            using (var response = request.GetResponse() as System.Net.HttpWebResponse)
            {
                //Get reader from response stream
                using (var reader = new System.IO.StreamReader(response.GetResponseStream()))
                {
                    responseContent = reader.ReadToEnd();

                    //Deserialize JSON string
                    PBITiles PBITiles = JsonConvert.DeserializeObject <PBITiles>(responseContent);

                    //Find the NumDelays tile
                    foreach (PBITile tile in PBITiles.value)
                    {
                        if (tile.title.ToLower().Equals("numdelays"))
                        {
                            txtIFrameURL.Text = tile.embedUrl;
                        }
                    }
                }
            }
        }
Example #3
0
        //Embed
        protected void getTilesButton_Click(object sender, EventArgs e)
        {
            string responseContent = string.Empty;
            string dashboardId     = string.Empty;

            if (string.Empty == inDashboardID.Text)
            {
                tb_tilesResult.Text = "Please enter a dashboard id above";
                return;
            }

            dashboardId = inDashboardID.Text;

            //Configure datasets request
            System.Net.WebRequest request = System.Net.WebRequest.Create(String.Format("{0}Dashboards/{1}/Tiles", baseUri, dashboardId)) as System.Net.HttpWebRequest;
            request.Method        = "GET";
            request.ContentLength = 0;
            request.Headers.Add("Authorization", String.Format("Bearer {0}", authResult.AccessToken));

            //Get datasets response from request.GetResponse()
            using (var response = request.GetResponse() as System.Net.HttpWebResponse)
            {
                //Get reader from response stream
                using (var reader = new System.IO.StreamReader(response.GetResponseStream()))
                {
                    responseContent = reader.ReadToEnd();

                    //Deserialize JSON string
                    PBITiles PBITiles = JsonConvert.DeserializeObject <PBITiles>(responseContent);

                    tb_tilesResult.Text = string.Empty;
                    //Get each Dataset from
                    foreach (PBITile tile in PBITiles.value)
                    {
                        tb_tilesResult.Text += String.Format("{0}\t{1}\t{2}\n", tile.id, tile.title, tile.embedUrl);
                    }
                }
            }
        }