static void Main(string[] args) { string datasetName = "Words"; PowerBIClient.Do(api => { //Create if not exist bool datasetExist = api.IsDatasetExist(datasetName); if (!datasetExist) { Console.WriteLine("Creating dataset."); bool created = api.CreateDataset(datasetName, false, typeof(Data.WordCount)); if (created) { Console.WriteLine("Successfully created."); } else { Console.WriteLine("Unable to create dataset."); } } else { Console.WriteLine("Dataset already exists."); } }); Console.Write("Press any key to continue."); Console.ReadKey(); }
public static void Main(string[] args) { if (args.Length != 0) { if (args[0].Equals("delete")) { var isDelete = PowerBIClient.Do <bool>(api => api.Delete <Order>(api.GetDatasetId("XamarinPowerShop"))); if (isDelete) { Console.WriteLine("Xamarin Power Shop, order rows deleted !"); } else { Console.WriteLine("Xamarin Power Shop, failed to delete all rows !"); } } } else { var isCreated = PowerBIClient.Do <bool>(api => api.CreateDataset("XamarinPowerShop", typeof(Order))); if (isCreated) { Console.WriteLine("Xamarin Power Shop, dataset created !"); } else { Console.WriteLine("Xamarin Power Shop, failed to create dataset !"); } } Console.ReadKey(); }
/// <summary> /// Initializes a new instance of the <see cref="XamarinPowerShop.OrderViewModel"/> class. /// </summary> /// <param name="tshirt">Tshirt.</param> public OrderViewModel(TShirt tshirt) { Current = tshirt; OrderCommand = new Command(x => { var now = DateTime.Now; var order = new Order { IsMen = IsMen, OrderDate = now, ProductName = Current.Name, ProductReference = Current.Reference, Size = Sizes[SizeIndex], HourSlots = now.Hour, TimeSlots = new DateTime(now.Year, now.Month, now.Day) }; var isOrdered = PowerBIClient.Do <bool>(api => api.Insert(api.GetDatasetId(DatasetName), order)); if (isOrdered) { OnOrdered(order); } else { OnFailed(); } }); }
public void Execute(SCPTuple tuple) { PowerBIClient.Do(api => { var isObjectInsert = api.Insert(datasetId, new Data.WordCount { Word = tuple.GetString(0), Count = tuple.GetInteger(1) }); }); }
void GetDataset() { PowerBIClient.Do(api => { //Create if not exist bool datasetExist = api.IsDatasetExist(datasetName); if (!datasetExist) { bool created = api.CreateDataset(datasetName, false, typeof(Data.WordCount)); } //Set the ID to use for the dataset datasetId = api.GetDatasetId(datasetName); }); }
public MainViewModel() { InsertCommand = new Command(x => { var isInsert = PowerBIClient.Do <bool>(api => { var isDatasetExist = api.IsDatasetExist(DatasetName); if (isDatasetExist) { var datasetId = api.GetDatasetId(DatasetName); var isObjectInsert = api.Insert(datasetId, new Product { CreationDate = DateTime.Now, Id = Id, IsAvaible = true, Name = "Computer" + Id, Price = 500.00 }); if (isObjectInsert) { Id++; } return(isObjectInsert); } else { return(false); } }); if (isInsert) { OnInsert(); } }); }
public static void Main() { Console.WriteLine("PowerBI api client test client"); Console.WriteLine("Version : {0}", Assembly.GetExecutingAssembly().GetName().Version); Console.WriteLine(); try { PowerBIClient.Initialize("https://api.powerbi.com/v1.0/myorg/dataset/", "https://login.windows.net/common/oauth2/authorize", "https://analysis.windows.net/powerbi/api", "e24d4bbb-1c0a-4324-a0f8-08683084a3e0", "*****@*****.**", "Spo060492"); PowerBIClient.Do(api => { var datasets = api.GetDatasets(); var isCreated = api.CreateDataset(DatasetName, true, typeof(Product)); if (isCreated) { Console.WriteLine("Dataset created"); Console.WriteLine("Dataset avaible : {0}", datasets.Select(x => x.Name).Aggregate((current, next) => current + ", " + next)); var datasetId = api.GetDatasetId(DatasetName); Console.WriteLine("Dataset Identifier for MyProductCatalog : {0}", datasetId); var isDatasetExist = api.IsDatasetExist(DatasetName); Console.WriteLine("Dataset MyProductCatalog exists : {0}", isDatasetExist); var isDatasetIdExist = api.IsDatasetIdExist(datasetId); Console.WriteLine("Dataset MyProductCatalog Identifier exists : {0}", isDatasetIdExist); var isObjectInsert = api.Insert(datasetId, new Product { CreationDate = DateTime.Now, Id = 1, IsAvaible = true, Name = "Computer", Price = 500.00 }); Console.WriteLine("Dataset Product insersion : {0}", isObjectInsert); var isListInsert = api.InsertAll(datasetId, new List <object> { new Product { CreationDate = DateTime.Now, Id = 2, IsAvaible = true, Name = "Screen", Price = 120.00 }, new Product { CreationDate = DateTime.Now, Id = 3, IsAvaible = false, Name = "External HDD", Price = 75.00 } }); Console.WriteLine("Dataset Product list insersion : {0}", isListInsert); var isDelete = api.Delete <Product>(datasetId); Console.WriteLine("Dataset Product rows deleted : {0}", isDelete); } else { Console.WriteLine("Failed to create the dataset"); } }); } catch (Exception e) { Console.WriteLine("{0} => {1} :\n{2}", e.Source, e.Message, e.StackTrace); } Console.WriteLine(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }