Esempio n. 1
0
        /// <summary>
        /// Loads the report list.
        /// </summary>
        private void LoadReportList()
        {
            var accessToken = PowerBiUtilities.GetAccessToken(ddlSettingPowerBiAccount.SelectedValue.AsGuid());
            var reports     = PowerBiUtilities.GetReports(accessToken, ddlSettingPowerBiGroup.SelectedValue);

            ddlSettingPowerBiReportUrl.Items.Clear();
            ddlSettingPowerBiReportUrl.Items.Add(new ListItem());
            foreach (var report in reports)
            {
                ddlSettingPowerBiReportUrl.Items.Add(new ListItem(report.name, report.embedUrl));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Loads the group list.
        /// </summary>
        private void LoadGroupList()
        {
            var accessToken = PowerBiUtilities.GetAccessToken(ddlSettingPowerBiAccount.SelectedValue.AsGuid());
            var groups      = PowerBiUtilities.GetGroups(accessToken);

            ddlSettingPowerBiGroup.Items.Clear();
            ddlSettingPowerBiGroup.Items.Add(new ListItem());
            foreach (var group in groups)
            {
                ddlSettingPowerBiGroup.Items.Add(new ListItem(group.Name, group.Id));
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Shows the view.
        /// </summary>
        private void ShowView()
        {
            pnlEditModal.Visible = false;
            pnlView.Visible      = true;

            fullsizer.Visible = GetAttributeValue("ShowFullsizeBtn").AsBoolean();

            string reportUrl     = GetAttributeValue("ReportUrl");
            bool   showRightPane = GetAttributeValue("ShowRightPane").AsBoolean();
            bool   showNavPane   = GetAttributeValue("ShowNavPane").AsBoolean();

            nbError.Text = string.Empty;

            if (reportUrl.IsNullOrWhiteSpace())
            {
                pnlView.Visible             = false;
                nbError.NotificationBoxType = NotificationBoxType.Warning;
                nbError.Text = "No report has been configured.";
                return;
            }

            hfReportEmbedUrl.Value = reportUrl +
                                     (showRightPane ? "" : "&filterPaneEnabled=false") +
                                     (showNavPane ? "" : "&navContentPaneEnabled=false");

            if (!string.IsNullOrWhiteSpace(GetAttributeValue("PowerBiAccount")))
            {
                // ensure that the account still exists as a defined value
                var accountValue = DefinedValueCache.Get(GetAttributeValue("PowerBiAccount"));

                if (accountValue != null)
                {
                    hfAccessToken.Value = PowerBiUtilities.GetAccessToken(accountValue.Guid);

                    if (string.IsNullOrWhiteSpace(hfAccessToken.Value))
                    {
                        pnlView.Visible  = false;
                        pnlLogin.Visible = true;
                    }
                }
                else
                {
                    pnlView.Visible             = false;
                    nbError.NotificationBoxType = NotificationBoxType.Warning;
                    nbError.Text = "The account configured for this block no longer exists.";
                    return;
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Shows the view.
        /// </summary>
        private void ShowView()
        {
            pnlEditModal.Visible = false;
            pnlView.Visible      = true;

            nbError.Text           = string.Empty;
            hfReportEmbedUrl.Value = GetAttributeValue("ReportUrl");

            if (hfReportEmbedUrl.Value.IsNullOrWhiteSpace())
            {
                pnlView.Visible             = false;
                nbError.NotificationBoxType = NotificationBoxType.Warning;
                nbError.Text = "No report has been configured.";
                return;
            }

            if (!string.IsNullOrWhiteSpace(GetAttributeValue("PowerBiAccount")))
            {
                // ensure that the account still exists as a defined value
                var accountValue = DefinedValueCache.Read(GetAttributeValue("PowerBiAccount"));

                if (accountValue != null)
                {
                    hfAccessToken.Value = PowerBiUtilities.GetAccessToken(accountValue.Guid);

                    if (string.IsNullOrWhiteSpace(hfAccessToken.Value))
                    {
                        pnlView.Visible  = false;
                        pnlLogin.Visible = true;
                    }
                }
                else
                {
                    pnlView.Visible             = false;
                    nbError.NotificationBoxType = NotificationBoxType.Warning;
                    nbError.Text = "The account configured for this block no longer exists.";
                    return;
                }
            }
        }
 /// <summary>
 /// Handles the Click event of the btnRegister control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 protected void btnRegister_Click(object sender, EventArgs e)
 {
     // Authenticate
     PowerBiUtilities.CreateAccount(txtAccountName.Text, txtAccountDescription.Text, txtClientId.Text, txtClientSecret.Text, txtRedirectUrl.Text, Request.Url.AbsoluteUri);
 }
Esempio n. 6
0
 /// <summary>
 /// Handles the Click event of the btnLogin control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 protected void btnLogin_Click(object sender, EventArgs e)
 {
     // Authenticate
     PowerBiUtilities.AuthenticateAccount(GetAttributeValue("PowerBiAccount").AsGuid(), Request.UrlProxySafe().AbsoluteUri);
 }