Exemplo n.º 1
0
        public SendGridMessage CreateAnalysisCompletedMessage(string userEmail, ImageAnalysisData analysisResult)
        {
            var message = new SendGridMessage();

            message.AddTo(userEmail);
            message.AddContent("text/html", string.Join(", ", analysisResult.Celebrities));
            message.SetFrom(new EmailAddress(ConfigurationManager.SendGrid.SystemEmailAddress));
            message.SetSubject("Results of automated image analysis");
            return(message);
        }
Exemplo n.º 2
0
        public async Task <ImageAnalysisData> StoreAnalysisData(ImageAnalysisData analysisData)
        {
            using (var client = new DocumentClient(new Uri(
                                                       ConfigurationManager.Repositories.ImagesProcessorCosmosDbEndpointUrl),
                                                   ConfigurationManager.Repositories.ImagesProcessorCosmosDbPrimaryAccessKey))
            {
                var documentResponse = await client.CreateDocumentAsync(
                    UriFactory.CreateDocumentCollectionUri("ImageProcessor", "ImageAnalysisResults"), analysisData);

                analysisData.id = Guid.Parse(documentResponse.Resource.Id);

                return(analysisData);
            }
        }
Exemplo n.º 3
0
        public async Task <FoxyResponse <ImageAnalysisData> > StoreAnalysisData(ImageAnalysisData imageAnalysisData, Guid imageId, Guid sessionId, string partitionKey)
        {
            try
            {
                imageAnalysisData.RelatedImageObjectId = imageId;
                imageAnalysisData.partitionKey         = partitionKey;
                var storeResult = await AnalysisDbGateway.StoreAnalysisData(imageAnalysisData);

                return(FoxyResponse <ImageAnalysisData> .Success(storeResult));
            }
            catch (Exception e)
            {
                ErrorReporting.StoreExceptionDetails(e, sessionId);
                return(FoxyResponse <ImageAnalysisData> .Failure("Could not store image analysis results"));
            }
        }
Exemplo n.º 4
0
        public async Task <FoxyEmptyResponse> RaiseAnalysisCompleteEvent(
            ImageAnalysisData imageAnalysisData, Guid sessionId, Guid commandId, string partitionKey)
        {
            try
            {
                var @event = EventsFactory.CreateAnalysisCompletedEvent(sessionId, commandId, imageAnalysisData.id, partitionKey);

                await EventPublisher.PublishEvent(@event, EventGridTopicType.ImageAnalysisTopic);

                return(FoxyEmptyResponse.Success());
            }
            catch (Exception e)
            {
                ErrorReporting.StoreExceptionDetails(e, sessionId);
                return(FoxyEmptyResponse.Failure("Could not store image analysis results"));
            }
        }
Exemplo n.º 5
0
 public async Task <FoxyResponse <SendGridMessage> > CreateAnalysisCompletedEmail(string userEmail, ImageAnalysisData analysisResult)
 {
     try
     {
         var message = SendGridMessageFactory.CreateAnalysisCompletedMessage(userEmail, analysisResult);
         return(FoxyResponse <SendGridMessage> .Success(message));
     }
     catch (Exception e)
     {
         ErrorReporting.StoreExceptionDetails(e, analysisResult.id);
         return(FoxyResponse <SendGridMessage> .Failure("Could not store image analysis results"));
     }
 }