本文整理汇总了C#中RestServiceClient.DownloadResult方法的典型用法代码示例。如果您正苦于以下问题:C# RestServiceClient.DownloadResult方法的具体用法?C# RestServiceClient.DownloadResult怎么用?C# RestServiceClient.DownloadResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RestServiceClient
的用法示例。
在下文中一共展示了RestServiceClient.DownloadResult方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CallOcrWebService
private static string CallOcrWebService(FileInfo pngFile, int topLeftX, int topLeftY, int bottomRightX, int bottomRightY)
{
var restClient = new RestServiceClient
{
Proxy = { Credentials = CredentialCache.DefaultCredentials },
ApplicationId = ConfigurationManager.AppSettings["ApplicationId"].ToString(),
Password = ConfigurationManager.AppSettings["Password"].ToString()
};
var textFieldProcessingSettings = new TextFieldProcessingSettings
{
CustomOptions = "region=" + topLeftX + "," + topLeftY + "," + bottomRightX + "," + bottomRightY,
Language = "english"
};
if (pngFile.DirectoryName == null)
throw new Exception("png file directory name is blank");
var outputXmlFile = Path.Combine(pngFile.DirectoryName, GetFileNameWithoutExtension(pngFile) + ".xml");
// call the REST service
var task = restClient.ProcessTextField(pngFile.ToString(), textFieldProcessingSettings);
System.Threading.Thread.Sleep(4000);
task = restClient.GetTaskStatus(task.Id);
//Console.WriteLine("Task status: {0}", task.Status);
while (task.IsTaskActive())
{
// Note: it's recommended that your application waits
// at least 2 seconds before making the first getTaskStatus request
// and also between such requests for the same task.
// Making requests more often will not improve your application performance.
// Note: if your application queues several files and waits for them
// it's recommended that you use listFinishedTasks instead (which is described
// at http://ocrsdk.com/documentation/apireference/listFinishedTasks/).
System.Threading.Thread.Sleep(4000);
task = restClient.GetTaskStatus(task.Id);
//Console.WriteLine("Task status: {0}", task.Status);
}
if (task.Status == TaskStatus.Completed)
{
//Console.WriteLine("Processing completed.");
restClient.DownloadResult(task, outputXmlFile);
//Console.WriteLine("Download completed.");
}
else
{
//Console.WriteLine("Error while processing the task");
return outputXmlFile;
}
return outputXmlFile;
}