Ejemplo n.º 1
0
        public void Clone(string newReportName, PBIGroup targetGroup, PBIDataset targetDataset)
        {
            if (ParentPowerBIAPI == null)
            {
                throw new Exception("No PowerBI API Object was supplied!");
            }

            string body;

            body = "{\"name\": \"" + newReportName + "\", \"targetModelId\": \"" + targetDataset.Id + "\"";

            if (targetGroup != null)
            {
                body = body + ", \"targetWorkspaceId\": \"" + targetGroup.Id + "\"";
            }
            body = body + "}";

            using (HttpWebResponse response = ParentPowerBIAPI.SendPOSTRequest(ApiURL + "/Clone", body))
            {
                string result = response.ResponseToString();
            }
        }
Ejemplo n.º 2
0
        public PBIImport ImportPBIX(string displayName, string pbixPath)
        {
            string fullUrl = string.Format("{0}/{1}?datasetDisplayName={2}", ApiURL, PBIAPI.Imports.ToString().ToLower(), displayName);

            FileStream content = File.Open(pbixPath, FileMode.Open);

            using (HttpWebResponse response = ParentPowerBIAPI.SendPOSTRequest(fullUrl, content))
            {
                string result = response.ResponseToString();

                return(JsonConvert.DeserializeObject <PBIImport>(result));
            }

            /*
             * // create REST URL with import name in quer string
             * string restUrlImportPbix = ProgramConstants.PowerBiServiceRootUrl + "imports?datasetDisplayName=" + importName;
             * // load PBIX file into StreamContent object
             * var pbixBodyContent = new StreamContent(File.Open(pbixPath, FileMode.Open));
             * // add headers for request bod content
             * pbixBodyContent.Headers.Add("Content-Type", "application/octet-stream");
             * pbixBodyContent.Headers.Add("Content-Disposition",
             *                           @"form-data; name=""file""; filename=""" + pbixFilePath + @"""");
             * // load PBIX content into body using multi-part form data
             * MultipartFormDataContent requestBody = new MultipartFormDataContent(Guid.NewGuid().ToString());
             * requestBody.Add(pbixBodyContent);
             * // create and configure HttpClient
             * HttpClient client = new HttpClient();
             * client.DefaultRequestHeaders.Add("Accept", "application/json");
             * client.DefaultRequestHeaders.Add("Authorization", "Bearer " + AccessToken);
             * // post request
             * var response = client.PostAsync(restUrlImportPbix, requestBody).Result;
             * // check for success
             * if (response.StatusCode.ToString().Equals("Accepted"))
             * {
             *  Console.WriteLine("Import process complete: " + response.Content.ReadAsStringAsync().Result);
             * }
             */
        }
        public void LoadRefreshesFromPowerBI()
        {
            PBIObjectList <PBIRefresh> objList = JsonConvert.DeserializeObject <PBIObjectList <PBIRefresh> >(ParentPowerBIAPI.SendGETRequest(ApiURL, PBIAPI.Refreshes).ResponseToString());

            this._refreshes = objList.Items;
        }
        public void LoadGatewayDatasourcesFromPowerBI()
        {
            PBIObjectList <PBIGatewayDatasource> objList = JsonConvert.DeserializeObject <PBIObjectList <PBIGatewayDatasource> >(ParentPowerBIAPI.SendGETRequest(ApiURL + "/Default.GetBoundGatewayDataSources").ResponseToString());

            foreach (var item in objList.Items)
            {
                item.ParentGroup  = this.ParentGroup;
                item.ParentObject = this;
            }

            GatewayDatasources = objList.Items;
        }
        public void LoadDatasourcesFromPowerBI()
        {
            PBIObjectList <PBIDatasource> objList = JsonConvert.DeserializeObject <PBIObjectList <PBIDatasource> >(ParentPowerBIAPI.SendGETRequest(ApiURL, PBIAPI.Datasources).ResponseToString());

            foreach (var item in objList.Items)
            {
                item.ParentGroup  = this.ParentGroup;
                item.ParentObject = this;
            }

            Datasources = objList.Items;
        }
Ejemplo n.º 6
0
 public void Rebind(string newDatasetId)
 {
     Rebind(ParentPowerBIAPI.GetDatasetByID(newDatasetId));
 }