public async Task <IActionResult> WebhookCallback([FromBody] JObject body) { // catch any errors, we don't want to return 500 try { string eventType = body["hook"]["event"].ToString(); string userId = body["hook"]["createdBy"].ToString(); string projectId = "b." + body["payload"]["project"].ToString();//body["hook"]["hookAttribute"]["projectId"].ToString(); string versionId = body["resourceUrn"].ToString(); string hubId = "b." + body["payload"]["tenant"].ToString(); string fileName = body["payload"]["name"].ToString(); string extension = fileName.Split(".").Last(); string folderUrn = body["hook"]["tenant"].ToString(); string itemUrn = body["payload"]["lineageUrn"].ToString(); // do you want to filter events?? if (eventType != "dm.version.added") { return(Ok()); } if (Config.SupportedFormats.IndexOf(extension) == -1) { return(Ok()); } // use Hangfire to schedule a job BackgroundJobClient metadataQueue = new BackgroundJobClient(); IState state = new EnqueuedState("metadata"); metadataQueue.Create(() => ModelDerivativeController.ProcessFileAsync(userId, hubId, projectId, folderUrn, itemUrn, versionId, fileName, null), state); } catch { } // ALWAYS return ok (200) return(Ok()); }
public async Task ProcessFile(string userId, string hubId, string projectId, string folderUrn, string itemUrn, string versionUrn, string fileName, PerformContext console) { await ModelDerivativeController.ProcessFileAsync(userId, hubId, projectId, folderUrn, itemUrn, versionUrn, fileName, console); await ModelDerivativeHub.NotifyFileComplete(_hubContext, hubId); }