Esempio n. 1
0
        public static async void Run([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer, ILogger log, ExecutionContext context)
        {
            log.LogInformation($"QnAPublish function executed at: {DateTime.Now}");

            var config = new ConfigurationBuilder()
                         .SetBasePath(context.FunctionAppDirectory)
                         .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
                         .AddEnvironmentVariables()
                         .Build();
            // Get courses from database
            var cs = config.GetConnectionString("QBotEntities");

            var courses = ModelMapper.MapToCourseModels(SQLAdapter.GetCourses(cs));

            foreach (var course in courses)
            {
                // For each course, get keys
                var qnaService = new QnAService(course.PredictiveQnAKnowledgeBaseId, course.PredictiveQnAHttpEndpoint, course.PredictiveQnAHttpKey);

                // For each course, call publish
                var result = await qnaService.PublishQnA();

                if (result)
                {
                    log.LogInformation($"PublishQnA SUCCEEDED for courseId: {course.Id}, courseName: {course.Name}");
                }
                else
                {
                    log.LogInformation($"PublishQnA FAILED for courseId: {course.Id}, courseName: {course.Name}");
                }

                log.LogInformation($"QnAPublish function completed at: {DateTime.Now}");
            }
        }
Esempio n. 2
0
 public static List <Course> GetCourses()
 {
     try
     {
         return(SQLAdapter.GetCourses());
     }
     catch (Exception e)
     {
         return(null);
     }
 }