示例#1
0
 public CustomVision(IExtractHttpContent extract, IStoreFileProvider storeProvider, IRetrieveFileProvider retrieveProvider)
 {
     this.extractFileHttp  = extract;
     this.readCustonVision = extract as ReadCustonVisionContent;
     this.storeProvider    = storeProvider;
     this.retrieveProvider = retrieveProvider;
 }
示例#2
0
        private async Task ProcessarImagemAsync(IDialogContext contexto) //IAwaitable<IMessageActivity> argument

        {
            var activity                = contexto.Activity as Activity;
            var hasAttachment           = activity.Attachments?.Any() == true;
            var uri                     = string.Empty;
            IExtractHttpContent content = null;

            if (hasAttachment)
            {
                uri     = activity.Attachments[0].ContentUrl;
                content = new StreamFileContent(uri);
            }
            else
            {
                uri     = activity.Text;
                content = new UriFileContent(uri);
            }
            try
            {
                customVision = new CustomVision(content, StorageProvider, RetrievalProvider);
                var reply = await customVision.ProcessImage();

                await contexto.PostAsync(reply);

                contexto.Wait((c, a) => customVision.StoreImage());
            }
            catch (Exception)
            {
                await contexto.PostAsync("Ops! Deu algo errado na hora de analisar sua imagem!");
            }
        }