コード例 #1
0
        static void CreateDataset()
        {
            Console.Write("Checking dataset {0}...", datasetName);
            //In a production application, use more specific exception handling.
            try
            {
                //Create a POST web request to list all datasets
                HttpWebRequest request = DatasetRequest(datasetsUri, "POST", AccessToken);

                var datasets = GetAllDatasets().Datasets(datasetName);

                if (!datasets.Any())
                {
                    Console.Write("does not exist.\n");
                    Console.Write("Creating dataset {0}...", datasetName);
                    var tables = new List <object> {
                        new RealTimeVehicleHealthAnomalyReport()
                    };

                    string jsonString = JSONBuilder.CreateTableSchema(datasetName, tables);

                    PostRequest(request, jsonString);
                    //POST request using the json schema from Product
                    Console.Write("created.\n");
                }
                else
                {
                    Console.Write("exists.\n");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }