Пример #1
0
        public string Request(InkRecognizerRequest request)
        {
            RestClient  client      = new RestClient(endpoint);
            RestRequest restRequest = new RestRequest(inkRecognitionUrl, Method.PUT);

            restRequest.Timeout = (int)TimeSpan.FromMilliseconds(1000 * 10).TotalMilliseconds;
            restRequest.AddHeader("Content-Type", "application/json");
            restRequest.AddHeader("Ocp-Apim-Subscription-Key", apiKey);
            restRequest.AddJsonBody(request);

            var response = client.Execute(restRequest);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                return(AnalyseResult(JsonConvert.DeserializeObject <RootObject>(response.Content)));
            }
            else if (response.StatusCode == 0)
            {
                return("Error timeout");
            }
            else
            {
                return($"Error : {response.StatusCode} - {response.Content}");
            }
        }
Пример #2
0
        private InkRecognizerRequest GetRequest()
        {
            InkRecognizerRequest r = new InkRecognizerRequest();

            r.language = "fr-FR";
            r.version  = 1;
            int id = 1;


            foreach (var c in this.canvas.Strokes)
            {
                r.AddStroke(id++, c);
            }

            return(r);
        }