예제 #1
0
        private async static Task QueryDatasets()
        {
            var dataClient = new DatasetsClient(pbi);
            var datasets   = await dataClient.List();

            foreach (var dataset in datasets.value)
            {
                Console.WriteLine("{0}\t{1}", dataset.name, dataset.id);
            }

            Console.WriteLine("Create a data set?");
            Dataset created;

            if (Console.ReadKey().KeyChar == 'Y')
            {
                created = await dataClient.Create <resourceMeasures>("resourceManager", true);
            }
            else
            {
                created = (await dataClient.List()).value.First(ds => ds.name == "resourceManager");
            }

            var tables = await dataClient.ListTables(created.id);

            ListTables(tables);
            //var table = dataClient.GetTable(created.id, tables.value.First().name);
            //ListColumns(table.columns);

            var table = await dataClient.UpdateTableSchema <resourceMeasures2>(created.id, tables.value.First().name);
        }
예제 #2
0
        private async static Task QueryDatasets()
        {
            var dataClient = new DatasetsClient(pbi);
            var datasets = await dataClient.List();

            foreach (var dataset in datasets.value)
            {
                Console.WriteLine("{0}\t{1}", dataset.name, dataset.id);
            }

            Console.WriteLine("Create a data set?");
            Dataset created;
            if (Console.ReadKey().KeyChar == 'Y')
            {
                created = await dataClient.Create<resourceMeasures>("resourceManager", true);
            }
            else
            {
                created = (await dataClient.List()).value.First(ds => ds.name == "resourceManager");
            }

            var tables = await dataClient.ListTables(created.id);
            ListTables(tables);
            //var table = dataClient.GetTable(created.id, tables.value.First().name);
            //ListColumns(table.columns);

            var table = await dataClient.UpdateTableSchema<resourceMeasures2>(created.id, tables.value.First().name);
        }
예제 #3
0
        public async Task ListDatasets_AllGood_SetsAuthHeader()
        {
            Mock<IPowerBiAuthentication> mockPBi = new Mock<IPowerBiAuthentication>();
            mockPBi.Setup(t => t.GetAccessToken()).Returns("hello");

            var dashboardClient = new DatasetsClient(mockPBi.Object);
            await dashboardClient.List();

            mockPBi.Verify(pbi => pbi.GetAccessToken(), Times.Once);
        }
예제 #4
0
        public async Task ListDatasets_AllGood_SetsAuthHeader()
        {
            Mock <IPowerBiAuthentication> mockPBi = new Mock <IPowerBiAuthentication>();

            mockPBi.Setup(t => t.GetAccessToken()).Returns("hello");

            var dashboardClient = new DatasetsClient(mockPBi.Object);
            await dashboardClient.List();

            mockPBi.Verify(pbi => pbi.GetAccessToken(), Times.Once);
        }
예제 #5
0
        private static string CreateBIDataset(DatasetsClient client, Group g)
        {
            var datasets = client.List(g.id).Result;

            if (datasets.value.All(t => t.name != PowerByTheHour))
            {
                var result = client.Create(g.id, PowerByTheHour, false, /*typeof(Classes.FlightInfoTableEntry), typeof(Classes.PositionTableEntry), typeof(Classes.SensorTableEntry),*/ typeof(Classes.FlattenedFlightInfoTableEntry)).Result;
                return(result.id);
            }
            else
            {
                return(datasets.value.First(t => t.name == PowerByTheHour).id);
            }
        }
예제 #6
0
        private async static Task GenerateData()
        {
            var dataClient = new DatasetsClient(pbi);
            var created    = (await dataClient.List()).value.First(ds => ds.name == "resourceManager");
            var tables     = await dataClient.ListTables(created.id);

            var dataRows = new TableRows <resourceMeasures>();

            for (int i = 0; i < 1000; i++)
            {
                dataRows.rows.Add(new resourceMeasures()
                {
                    Id            = Guid.NewGuid().ToString("n"),
                    InServiceDate = DateTime.Now.AddYears(-4),
                    IsRunning     = true,
                    LastMeasure   = DateTime.Now,
                    Name          = "Engine" + i.ToString(),
                    RPM           = 6000,
                    Temperature   = 431.6
                });
            }
            await dataClient.ClearRows(created.id, tables.value.First().name);

            await dataClient.AddRows(created.id, tables.value.First().name, dataRows);

            while (true)
            {
                Console.Write(".");
                foreach (var row in dataRows.rows)
                {
                    row.RPM          = (int)(6000 * Math.Sin(Math.PI * (DateTime.Now.Second / 59D)));
                    row.Temperature += new Random((int)DateTime.Now.Ticks).Next(-5, 5);
                    row.LastMeasure  = DateTime.Now;
                    row.IsRunning    = row.RPM > 1;
                    Thread.Sleep(1);
                }

                await dataClient.AddRows(created.id, tables.value.First().name, dataRows);
            }
            await dataClient.ClearRows(created.id, tables.value.First().name);
        }
예제 #7
0
        //Groups: The Create Dataset operation can also create a dataset in a group
        //POST https://api.PowerBI.com/v1.0/myorg/groups/{group_id}/datasets
        //Create Dataset operation: https://msdn.microsoft.com/en-US/library/mt203562(Azure.100).aspx
        static async Task CreateDataset(string groupId)
        {
            try
            {
                var datasetsClient = new DatasetsClient(pbi);

                Dataset ds = (await datasetsClient.List(groupId)).value.First(d => d.name == datasetName);

                if (ds == null)
                {
                    //create a dataset using the schema from Product
                    await datasetsClient.Create <Product>(groupId, datasetName, false);
                }
                else
                {
                    Console.WriteLine("Dataset exists");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #8
0
        //The Create Dataset operation creates a new Dataset from a JSON schema definition and returns the Dataset ID
        //and the properties of the dataset created.
        //POST https://api.powerbi.com/v1.0/myorg/datasets
        //Create Dataset operation: https://msdn.microsoft.com/en-US/library/mt203562(Azure.100).aspx
        static async Task CreateDataset()
        {
            //In a production application, use more specific exception handling.
            try
            {
                var datasetsClient = new DatasetsClient(pbi);

                Dataset ds = (await datasetsClient.List()).value.FirstOrDefault(d => d.name == datasetName);

                if (ds == null)
                {
                    //create a dataset using the schema from Product
                    await datasetsClient.Create <Product>(datasetName, false);
                }
                else
                {
                    Console.WriteLine("Dataset exists");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #9
0
 //Groups: The Get Datasets operation can also get datasets in a group
 //GET https://api.powerbi.com/v1.0/myorg/groups/{group_id}/datasets
 //Get Dataset operation: https://msdn.microsoft.com/en-US/library/mt203567.aspx
 static async Task<Datasets> GetDatasets(string groupId)
 {
     DatasetsClient client = new DatasetsClient(pbi);
     return await client.List(groupId);
 }
예제 #10
0
 //The Get Datasets operation returns a JSON list of all Dataset objects that includes a name and id.
 //GET https://api.powerbi.com/v1.0/myorg/datasets
 //Get Dataset operation: https://msdn.microsoft.com/en-US/library/mt203567.aspx
 static async Task<Datasets> GetDatasets()
 {
     DatasetsClient client = new DatasetsClient(pbi);
     return await client.List();
 }
예제 #11
0
        //Groups: The Create Dataset operation can also create a dataset in a group
        //POST https://api.PowerBI.com/v1.0/myorg/groups/{group_id}/datasets
        //Create Dataset operation: https://msdn.microsoft.com/en-US/library/mt203562(Azure.100).aspx
        static async Task CreateDataset(string groupId)
        {
            try
            {
                var datasetsClient = new DatasetsClient(pbi);

                Dataset ds = (await datasetsClient.List(groupId)).value.First(d => d.name == datasetName);

                if (ds == null)
                {
                    //create a dataset using the schema from Product
                    await datasetsClient.Create<Product>(groupId, datasetName, false);
                }
                else
                {
                    Console.WriteLine("Dataset exists");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #12
0
        //The Create Dataset operation creates a new Dataset from a JSON schema definition and returns the Dataset ID 
        //and the properties of the dataset created.
        //POST https://api.powerbi.com/v1.0/myorg/datasets
        //Create Dataset operation: https://msdn.microsoft.com/en-US/library/mt203562(Azure.100).aspx
        static async Task CreateDataset()
        {
            //In a production application, use more specific exception handling.           
            try
            {
                var datasetsClient = new DatasetsClient(pbi);

                Dataset ds = (await datasetsClient.List()).value.FirstOrDefault(d=>d.name == datasetName);

                if (ds == null)
                {
                    //create a dataset using the schema from Product
                    await datasetsClient.Create<Product>(datasetName, false);
                }
                else
                {
                    Console.WriteLine("Dataset exists");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #13
0
        private async static Task GenerateData()
        {
            var dataClient = new DatasetsClient(pbi);
            var created = (await dataClient.List()).value.First(ds => ds.name == "resourceManager");
            var tables = await dataClient.ListTables(created.id);

            var dataRows = new TableRows<resourceMeasures>();

            for (int i = 0; i < 1000; i++)
            {
                dataRows.rows.Add(new resourceMeasures()
                {
                    Id = Guid.NewGuid().ToString("n"),
                    InServiceDate = DateTime.Now.AddYears(-4),
                    IsRunning = true,
                    LastMeasure = DateTime.Now,
                    Name = "Engine" + i.ToString(),
                    RPM = 6000,
                    Temperature = 431.6
                });
            }
            await dataClient.ClearRows(created.id, tables.value.First().name);
            await dataClient.AddRows(created.id, tables.value.First().name, dataRows);
            while (true)
            {
                Console.Write(".");
                foreach (var row in dataRows.rows)
                {
                    row.RPM = (int)(6000 * Math.Sin(Math.PI * (DateTime.Now.Second / 59D)));
                    row.Temperature += new Random((int)DateTime.Now.Ticks).Next(-5, 5);
                    row.LastMeasure = DateTime.Now;
                    row.IsRunning = row.RPM > 1;
                    Thread.Sleep(1);
                }

                await dataClient.AddRows(created.id, tables.value.First().name, dataRows);
            }
            await dataClient.ClearRows(created.id, tables.value.First().name);
        }
예제 #14
0
        //Groups: The Get Datasets operation can also get datasets in a group
        //GET https://api.powerbi.com/v1.0/myorg/groups/{group_id}/datasets
        //Get Dataset operation: https://msdn.microsoft.com/en-US/library/mt203567.aspx
        static async Task <Datasets> GetDatasets(string groupId)
        {
            DatasetsClient client = new DatasetsClient(pbi);

            return(await client.List(groupId));
        }
예제 #15
0
        //The Get Datasets operation returns a JSON list of all Dataset objects that includes a name and id.
        //GET https://api.powerbi.com/v1.0/myorg/datasets
        //Get Dataset operation: https://msdn.microsoft.com/en-US/library/mt203567.aspx
        static async Task <Datasets> GetDatasets()
        {
            DatasetsClient client = new DatasetsClient(pbi);

            return(await client.List());
        }