Skip to content

Commit

Permalink
Fix AnalyseAsset task output
Browse files Browse the repository at this point in the history
  • Loading branch information
mnicolescu authored and mnicolescu committed Nov 26, 2018
1 parent c3641bc commit 04df78e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
2 changes: 1 addition & 1 deletion ProcessMyMedia.Samples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static void Main(string[] args)

IConfigurationRoot configuration = builder.Build();

new Samples.IngestFromContainer(configuration).Execute();
new Samples.AnalyseAsset(configuration).Execute();
}
}
}
2 changes: 2 additions & 0 deletions ProcessMyMedia.Samples/Samples/Analyzing/AnalyzeAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ public void Build(IWorkflowBuilder<AnalyzeAssetWorkflowData> builder)
.Input(task => task.AssetName, data => data.InputAssetName)
.If(data => !string.IsNullOrEmpty(data.OutputAssetName))
.Do(then =>
//Get the analysing result
then.StartWith<Tasks.DownloadAssetTask>()
.Input(task => task.AssetName, data => data.OutputAssetName)
.Input(task => task.DirectoryToDownload, data => data.DirectoryToDownload)
//Delete output asset (analysing result)
.Then< Tasks.DeleteAssetTask>()
.Input(task => task.AssetName, data => data.OutputAssetName));
}
Expand Down
22 changes: 5 additions & 17 deletions ProcessMyMedia/Services/AzureMediaServiceV3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public async Task<JobEntity> StartAnalyseAsync(string assetName, AnalyzingParame

try
{
AssetEntity outputAsset = await this.CreateOrUpdateAssetAsync($"{assetName}{Guid.NewGuid()}",
AssetEntity outputAsset = await this.CreateOrUpdateAssetAsync(Guid.NewGuid().ToString(),
assetDescription: $"Media Analysing for {assetName}");

TransformOutput[] outputs = new TransformOutput[]
Expand Down Expand Up @@ -319,7 +319,7 @@ public async Task<JobEntity> StartAnalyseAsync(string assetName, AnalyzingParame
/// </summary>
/// <param name="job">The job associated to the analyse.</param>
/// <returns></returns>
public async Task<AnalyzingResult> EndAnalyseAsync(JobEntity job)
public Task<AnalyzingResult> EndAnalyseAsync(JobEntity job)
{
var result = new AnalyzingResult();

Expand All @@ -330,27 +330,15 @@ public async Task<AnalyzingResult> EndAnalyseAsync(JobEntity job)

try
{
string workingDirectory = Path.Combine(Path.GetTempPath(), "Analysing", job.Name);

if (job.Outputs.Count() > 0)
return Task.FromResult(new AnalyzingResult()
{
var assetToDownload = job.Outputs.First();
await this.DownloadFilesAsync(assetToDownload.Name, workingDirectory);
result.OutputAssetName = assetToDownload.Name;
}

//TODO:analyse result

Directory.Delete(workingDirectory, true);

return result;
OutputAssetName = job.Outputs.First().Name
});
}
catch (ApiErrorException exc)
{
throw GetApiException(exc);
}


}

/// <summary>
Expand Down

0 comments on commit 04df78e

Please sign in to comment.