Exemple #1
0
        public IActionResult Face(string image)
        {
            var imageArray = image.Split(',');

            if (imageArray.Length <= 1)
            {
                return(BadRequest());
            }

            var webrootPath = _env.WebRootPath;
            var path        = Path.Combine(webrootPath, "face.png");
            var face        = Convert.FromBase64String(imageArray[1]);

            using (var fs = new FileStream(path, FileMode.Create))
            {
                using (var bw = new BinaryWriter(fs))
                {
                    var data = face;
                    bw.Write(data);
                    bw.Close();
                }
            }

            //submit to UI service
            var faceToPost = new FaceToPost()
            {
                Face = face, RequesterId = RequesterId
            };

            var response = PostToApi(faceToPost, _uIApiConfiguration.FaceApi).Result;

            return(response.IsSuccessStatusCode ? Ok() : StatusCode(500));
        }
Exemple #2
0
        public async Task <HttpResponseMessage> Index(FaceToPost face)
        {
            var retryPolicy = _policyRegistry.Get <IAsyncPolicy <HttpResponseMessage> >(PolicyNames.BasicRetry) ?? Policy.NoOpAsync <HttpResponseMessage>();
            var context     = new Context($"GetSomeData-{Guid.NewGuid()}", new Dictionary <string, object>
            {
                { PolicyContextItems.Logger, _logger }, { "url", Request.GetUri() }
            });

            var response = await retryPolicy.ExecuteAsync((ctx) =>
            {
                return(_requisicaoService.PostAsync(new UserToPostMoc(), Request.GetUri(), "User"));
            }, context);

            //return Ok(new FaceToProcessing());
            return(response);
        }