示例#1
0
        public static async Task OnQueryClassificationHandler([EventGridTrigger] EventGridEvent eventGridEvent)
        {
            if (eventGridEvent != null)
            {
                // Get the data from the event that describes what classification is requested
                ClassifierRequestedEventGridEventData classifierRequestData = eventGridEvent.Data as ClassifierRequestedEventGridEventData;
                if (classifierRequestData != null)
                {
                    // handle the classifier request
                    ClassificationResponse response   = null;
                    Classification         classifier = new Classification(
                        new ClassificationAttribute(
                            classifierRequestData.ClassifierRequest.DomainName,
                            classifierRequestData.ClassifierRequest.EntityTypeName,
                            classifierRequestData.ClassifierRequest.InstanceKey,
                            classifierRequestData.ClassifierRequest.ClassifierTypeName
                            ));

                    if (classifier != null)
                    {
                        // get the classifier class - must implement TClassification : IClassification, new()
                        IClassification classificationToRun = Classification.GetClassifierByName(classifier.ClassifierTypeName);
                        if (classificationToRun != null)
                        {
                            response = await classifier.Classify(classificationToRun, null);
                        }
                    }

                    if (response != null)
                    {
                        // and post the result back to the query that asked for it
                        Query qrySource = new Query(classifierRequestData.DomainName,
                                                    classifierRequestData.EntityTypeName,
                                                    classifierRequestData.InstanceKey);


                        if (qrySource != null)
                        {
                            await qrySource.PostClassifierResponse(classifierRequestData.ClassifierRequest.DomainName,
                                                                   classifierRequestData.ClassifierRequest.EntityTypeName,
                                                                   classifierRequestData.ClassifierRequest.InstanceKey,
                                                                   classifierRequestData.ClassifierRequest.ClassifierTypeName,
                                                                   response.AsOfDate,
                                                                   classifierRequestData.ClassifierRequest.CorrelationIdentifier,
                                                                   response.AsOfSequence,
                                                                   response.Result
                                                                   );
                        }
                    }
                }
            }
        }