Exemplo n.º 1
0
        //Embed
        protected void getDashboardsButton_Click(object sender, EventArgs e)
        {
            string responseContent = string.Empty;

            //Configure datasets request
            System.Net.WebRequest request = System.Net.WebRequest.Create(String.Format("{0}dashboards", baseUri)) 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
                    PBIDashboards PBIDashboards = JsonConvert.DeserializeObject <PBIDashboards>(responseContent);

                    tb_dashboardsResult.Text = string.Empty;
                    //Get each Dataset from
                    foreach (PBIDashboard db in PBIDashboards.value)
                    {
                        tb_dashboardsResult.Text += String.Format("{0}\t{1}\n", db.id, db.displayName);
                    }
                }
            }
        }
Exemplo n.º 2
0
        //Get a dashbaord id.
        protected string GetDashboard(int index)
        {
            string dashboardId = string.Empty;

            //Configure tiles request
            System.Net.WebRequest request = System.Net.WebRequest.Create(
                String.Format("{0}Dashboards",
                              baseUri)) as System.Net.HttpWebRequest;

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

            //Get dashboards 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
                    PBIDashboards dashboards = JsonConvert.DeserializeObject <PBIDashboards>(reader.ReadToEnd());

                    //Sample assumes at least one Dashboard with one Tile.
                    //You could write an app that lists all tiles in a dashboard
                    dashboardId = dashboards.value[index].id;
                }
            }

            return(dashboardId);
        }
Exemplo n.º 3
0
        protected void getDashboardsButton_Click(object sender, EventArgs e)
        {
            string responseContent = string.Empty;

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

            //Get dashboards 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
                    PBIDashboards PBIDashboards = JsonConvert.DeserializeObject <PBIDashboards>(responseContent);

                    if (PBIDashboards != null)
                    {
                        var gridViewDashboards = PBIDashboards.value.Select(dashboard => new {
                            Id          = dashboard.id,
                            DisplayName = dashboard.displayName,
                            EmbedUrl    = dashboard.embedUrl
                        });

                        this.GridView1.DataSource = gridViewDashboards;
                        this.GridView1.DataBind();
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void getDashboards()
        {
            string responseContent = string.Empty;

            //Configure datasets request
            System.Net.WebRequest request = System.Net.WebRequest.Create(String.Format("{0}dashboards", baseUri)) 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
                    PBIDashboards PBIDashboards = JsonConvert.DeserializeObject <PBIDashboards>(responseContent);

                    //tb_dashboardsResult.Text = string.Empty;
                    //Find the AdventureWorks dashboard
                    foreach (PBIDashboard db in PBIDashboards.value)
                    {
                        if (db.displayName.ToLower().Equals("adventureworkstravel"))
                        {
                            getTilesForDashboard(db.id);
                        }
                        System.Diagnostics.Debug.Write(String.Format("{0}\t{1}\n", db.id, db.displayName));
                    }
                }
            }
        }
Exemplo n.º 5
0
        protected void getDashboardsButton_Click(object sender, EventArgs e)
        {
            string responseContent = string.Empty;

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

            //Get dashboards 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
                    PBIDashboards PBIDashboards = JsonConvert.DeserializeObject <PBIDashboards>(responseContent);
                    Table1.Visible = true;
                    Control myControl1 = FindControl("TableDiv");
                    //Get each dashboard
                    foreach (PBIDashboard dsb in PBIDashboards.value)
                    {
                        TableRow tRow = new TableRow();
                        Table1.Rows.Add(tRow);

                        TableCell idCell = new TableCell();
                        idCell.Text = dsb.id;
                        tRow.Cells.Add(idCell);

                        TableCell nameCell = new TableCell();
                        nameCell.Text = dsb.displayName;
                        tRow.Cells.Add(nameCell);

                        TableCell isReadOnlyCell = new TableCell();
                        isReadOnlyCell.Text = dsb.isReadOnly.ToString();
                        tRow.Cells.Add(isReadOnlyCell);

                        TableCell embedUrlCell = new TableCell();
                        embedUrlCell.Text = dsb.embedUrl;
                        tRow.Cells.Add(embedUrlCell);
                    }
                }
            }
        }