Пример #1
0
        public async Task AddScan(string userSessionId, byte[] imageData)
        {
            //var taskResult = await BatchAnalyzeAsync(imageData);
            //taskResult.EnsureSuccessStatusCode();
            File.WriteAllBytes("screenshot.png", imageData);

            var ocrResult = new OcrResult();

            // Analyze an image to get features and other properties.
            using (var client = Authenticate(GetOcrEndpoint(null), _azureSettings.ApiKey))
                using (var memStream = new MemoryStream(imageData))
                {
                    var recognizePrintedTextResult = await client.RecognizePrintedTextInStreamAsync(true, memStream);

                    ObjectId sessionId         = ObjectId.Parse(userSessionId);
                    var      userSessionResult = await _userSessionRepository.GetUserSessionByUserSessionId(sessionId);

                    ObjectId modifiedById  = userSessionResult.ModifiedById;
                    var      sessionDetail = new SessionDetail()
                    {
                        Id           = ObjectId.GenerateNewId(),
                        SessionId    = sessionId,
                        ModifiedById = modifiedById,

                        PrintedTextResult = recognizePrintedTextResult
                    };

                    await _sessionDetailRepository.UpsertSessionDetail(sessionDetail);
                }

            return;
        }