public void Run(IWebClient client) { Console.WriteLine("==> Demo - 数据集操作 <=="); Console.WriteLine("See https://api-doc.productai.cn/doc/pai.html#向数据集增加多条数据 for details.\r\n"); var request = new DataSetBatchAddRequest("lqn2jj6z") { CsvFile = new System.IO.FileInfo(@".\dataset\example.csv") }; try { var response = client.GetResponse(request); Console.WriteLine("==========================Result=========================="); Console.WriteLine("LastModifiedTime: {0}", response.LastModifiedTime); Console.WriteLine("==========================Result=========================="); } catch (ServerException ex) { Console.WriteLine("ServerException happened: \r\n\tErrorCode: {0}\r\n\tErrorMessage: {1}", ex.ErrorCode, ex.ErrorMessage); } catch (ClientException ex) { Console.WriteLine("ClientException happened: \r\n\tRequestId: {0}\r\n\tErrorCode: {1}\r\n\tErrorMessage: {2}", ex.RequestId, ex.ErrorCode, ex.ErrorMessage); } catch (Exception ex) { Console.WriteLine("Unknown Exception happened: {0}\r\n{1}", ex.Message, ex.StackTrace); } }
static void Main(string[] args) { var profile = new DefaultProfile { Version = "1", AccessKeyId = "XXXXXXXXXXXXXXXXXXXXX", SecretKey = "XXXXXXXXXXXXXXXXXXXXXX" }; var client = new DefaultProductAIClient(profile); //var request = new Detect3CElectronicsByImageFileRequest //{ // ImageFile = new System.IO.FileInfo(@".\phone.jpg") //}; //var request = new ImageSearchByImageUrlRequest("ffhqzkee") //{ // Url = "http://www.softsew.com/images/Moved%20from%20Main/More_Clothes.jpg", // Count = 2, // Threshold = 0.8, // SearchTags = new List<string> { "上衣", "短袖" } //}; //var request = new ImageSearchByImageFileRequest("ffhqzkee") //{ // ImageFile = new System.IO.FileInfo(@".\phone.jpg"), // Count = 2, // Threshold = 0.8, // SearchTags = new List<string> { "上衣", "短袖" } //}; //Single Add //var request = new DataSetSingleAddByImageUrlRequest("bd7nvc27") //{ // ImageUrl = "http://www.softsew.com/images/Moved%20from%20Main/More_Clothes.jpg", // SearchTags = new List<string> { "上衣" } //}; //Batch Add var request = new DataSetBatchAddRequest("bd7nvc27") { CsvFile = new System.IO.FileInfo(@".\example.csv") }; var response = client.Execute(request); if (response.StatusCode == System.Net.HttpStatusCode.OK) { //foreach(var r in response.Results) //{ // Console.WriteLine("{0}\t{1}", r.Url, r.Score); //} Console.WriteLine(response.LastModifiedTime); } else { Console.WriteLine("Request failed! " + response.Message); } Console.WriteLine("Done"); Console.ReadLine(); }