public override IEnumerable <Clue> DoProcess(ExecutionContext context, WebhookDataCommand command) { try { if (ConfigurationManager.AppSettings.GetFlag("Feature.Webhooks.Log.Posts", false)) { context.Log.Debug(() => command.HttpPostData); } var configurationDataStore = context.ApplicationContext.Container.Resolve <IConfigurationRepository>(); if (command.WebhookDefinition.ProviderDefinitionId != null) { var providerDefinition = context.Organization.Providers.GetProviderDefinition(context, command.WebhookDefinition.ProviderDefinitionId.Value); var jobDataCheck = context.ApplicationContext.Container.ResolveAll <IProvider>().FirstOrDefault(providerInstance => providerDefinition != null && providerInstance.Id == providerDefinition.ProviderId); var configStoreData = configurationDataStore.GetConfigurationById(context, command.WebhookDefinition.ProviderDefinitionId.Value); // If you have stopped the provider then don't process the webhooks if (providerDefinition?.WebHooks != null) { if (providerDefinition.WebHooks == false || providerDefinition.IsEnabled == false) { return(new List <Clue>()); } } if (jobDataCheck != null) { var crawlJobData = new AdventureWorksCrawlJobData(); var clues = new List <Clue>(); IAgentJobProcessorArguments jobArgs = new DebugAgentJobProcessorArguments { TaskScheduler = TaskScheduler.Default, Job = new AgentJob(Guid.NewGuid(), AgentJobPriority.Normal, "CluedIn" + AdventureWorksConstants.ProviderName, ProcessingRestriction.Any, null, null) }; var processorState = new AgentJobProcessorState <AdventureWorksCrawlJobData>(jobArgs, AppContext) { JobData = crawlJobData, Status = new AgentJobStatus { Statistics = new AgentJobStatusStatistics() } }; throw new NotImplementedException($"TODO: Implement this to populate '{clues.GetType()}' with '{processorState}'"); } } } catch (Exception exception) { context.Log.Error(new { command.HttpHeaders, command.HttpQueryString, command.HttpPostData, command.WebhookDefinitionId }, () => "Could not process web hook message", exception); } return(new List <Clue>()); }
public AdventureWorksClient(ILogger log, AdventureWorksCrawlJobData adventureworksCrawlJobData) // TODO: pass on any extra dependencies { if (adventureworksCrawlJobData == null) { throw new ArgumentNullException(nameof(adventureworksCrawlJobData)); } _jobData = adventureworksCrawlJobData; _log = log ?? throw new ArgumentNullException(nameof(log)); }