public static CognitiveFile ValidateForSubmission(CognitiveFileDTO file, IUserAccountRepository usersRepo)
        {
            //TODO: Add attribute values validation + user db validation

            var newId  = Guid.NewGuid().ToString();
            var result = new CognitiveFile
            {
                Id          = newId,
                IsProcessed = false,
                CreatedAt   = DateTime.UtcNow,
                FileName    = $"{newId}{Path.GetExtension(file.FileName)}",
                IsDeleted   = false,
                MediaType   = FileMediaType.Image,
                Origin      = file.Origin,
                OwnerId     = file.OwnerId,
                Status      = "Submitted"
            };

            foreach (var step in file.CognitivePipelineActions)
            {
                result.CognitivePipelineActions.Add(new CognitiveStep
                {
                    ServiceType  = step.ServiceType,
                    Status       = "Processing",
                    Confidence   = 0,
                    IsSuccessful = false,
                });
            }

            //TODO: Add mapper configuration for successful automated mapping between the DTO and business objects
            //result.CognitivePipelineActions = Mapper.Map<List<CognitiveStep>>(file.CognitivePipelineActions);

            return(result);
        }
Ejemplo n.º 2
0
        public async Task <CognitiveFile> CognitivePipeline_Callback([ActivityTrigger] CognitiveFile file, ILogger log)
        {
            log.LogInformation($"******* Starting Callback");

            file.IsProcessed = true;
            file.Status      = "Processed";

            await cognitiveFilesRepo.UpdateAsync(file);

            return(file);
        }
Ejemplo n.º 3
0
        public async Task QueueStart(
            //Trigger
            [QueueTrigger("newreq", Connection = "cognitivePipelineStorageConnection")] CognitiveFile cognitiveFile,

            //Orchestrator Client
            [OrchestrationClient] DurableOrchestrationClient starter,

            ILogger log)
        {
            try
            {
                // Function input comes from the new queue message.
                //Adding contrable instance id. This would be used easily to retrieve the orchestrator context
                var    instanceId = $"{cognitiveFile.Id}-cp";
                string returnedId = await starter.StartNewAsync("CognitivePipelineOrchestrator", instanceId, cognitiveFile);

                log.LogInformation($"******* Started orchestration with ID = '{instanceId}'.");
            }
            catch (Exception e)
            {
                log.LogError($"####### Failed to start via queue trigger: {e.Message}");
            }
        }
 public Task UpdateAsync(CognitiveFile entity)
 {
     return(Task.CompletedTask);
 }
 public Task <CognitiveFile> AddAsync(CognitiveFile entity)
 {
     return(Task.FromResult <CognitiveFile>(entity));
 }