예제 #1
0
        protected override void InnerExcute(IJobExecutionContext context)
        {
            try
            {
                SLogger.Info(string.Format("{0}: Starting Push question to QnA job", JobFriendlyName));

                var lastRunTime = SystemReader.GetLastPushQnAJobRunTime();

                var lstQuestion = _qnaService.GetQnAByDate(lastRunTime);

                // call stand alone to execute QnA
                var data = new PushLatestQnA {
                    ListQuestionAndAnswers = lstQuestion.ToList()
                };

                ApiHelper.PostAsyncNoEncrypt(WebApiConstant.XoomPushQuestionStandAloneEndPoint, data).GetAwaiter().GetResult();

                SLogger.Info(string.Format("{0} : - End Push question to QnA job", JobFriendlyName));

                SystemReader.SetLastPushQnAJobRunTime(DateTime.Now);
            }
            catch (Exception ex)
            {
                SLogger.Error(string.Format("{0}: InnerExcute. Push question to QnA job", JobFriendlyName), ex);
            }
        }
예제 #2
0
        public async Task <bool> PushLatestQnA(PushLatestQnA data)
        {
            QnAHelper qnaHelper = new QnAHelper {
                ProxyObj           = ProxyHelper.GetProxyForQnA(),
                QnAHost            = WebApiConstants.QnAHost,
                QnAKey             = WebApiConstants.QnAKey,
                QnAService         = WebApiConstants.QnAService,
                QnAKnowledgeBaseId = WebApiConstants.QnAKnowledgeBaseId
            };

            var lstQnaQuestion = await qnaHelper.GetAllQnAFromKB(WebApiConstants.QnAKnowledgeBaseId);

            logger.Info("Start Push QnAs to QnA Maker");

            var result = await qnaHelper.PushLatestQuestionToQnA(WebApiConstants.QnAKnowledgeBaseId, data.ListQuestionAndAnswers, lstQnaQuestion.qnaDocuments);

            logger.Info("Finish Push QnAs to QnA Maker");

            if (result)
            {
                logger.Info("Start Publish QnA Knowledge Base");

                result = await qnaHelper.PublishQnAKnowledgeBase(WebApiConstants.QnAKnowledgeBaseId);

                logger.Info("Finish Publish QnA Knowledge Base");
            }

            return(await Task.FromResult(result));
        }