Example #1
0
        private static async Task <ConversationItemModel> QueryQnABot(string Query)
        {
            ConversationItemModel QnAQueryResult = new ConversationItemModel();

            using (System.Net.Http.HttpClient client =
                       new System.Net.Http.HttpClient())
            {
                string RequestURI = String.Format("{0}{1}",
                                                  "https://wispero.azurewebsites.net/qnamaker",
                                                  "/knowledgebases/0e778adf-9dad-4c40-8199-78cf7d3a69ca/generateAnswer");

                var httpContent =
                    new StringContent($"{{\"question\": \"{Query}\"}}",
                                      Encoding.UTF8, "application/json");

                var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, RequestURI);
                httpRequestMessage.Headers.Add("Authorization", "EndpointKey ba505028-2b0b-4630-a8e5-d32a04efdb6a");
                httpRequestMessage.Content = httpContent;
                var msg = await client.SendAsync(httpRequestMessage);

                if (msg.IsSuccessStatusCode)
                {
                    var JsonDataResponse =
                        await msg.Content.ReadAsStringAsync();

                    var response =
                        JsonConvert.DeserializeObject <QnAResponse>(JsonDataResponse);

                    QnAQueryResult.Question = Query;
                    QnAQueryResult.Answer   = response.Answers.FirstOrDefault()?.Answer;
                }
            }
            return(QnAQueryResult);
        }
Example #2
0
 private void RaiseOnInfiniteScrollWhenItemIsLastInList(ConversationItemModel currentItem, ConversationViewHolder viewHolder)
 {
     if (this.ConversationItems.IndexOf(currentItem) == (this.ConversationItems.Count - 1) && !InfiniteScrollDisabled)
     {
         this.infiniteScrollListener.OnInfiniteScroll();
     }
 }
Example #3
0
        private void ConversationsListAdapter_ConversationItemClick(object sender, ConversationItemModel e)
        {
            var intent = new Intent(this, typeof(ConversationActivity));
            var conversationInfoModel = new ConversationInfoModel
            {
                ConversationId           = e.Id,
                InterlocutorId           = e.InterLocutorId,
                InterlocutorName         = e.InterlocutorName,
                InterlocutorPrifileImage = e.InterLocutorProfileImage
            };

            intent.PutExtra(ExtrasKeys.CONVERSATION_INFO_MODEL, JsonConvert.SerializeObject(conversationInfoModel));

            StartActivity(intent);
        }
Example #4
0
        private async Task <List <ConversationItemModel> > MapToViewModels(string userId, List <DB.Models.Chat.ConversationReadModel> conversations)
        {
            var list = new List <ConversationItemModel>();

            foreach (var conversation in conversations)
            {
                var model = new ConversationItemModel();
                model.Id                       = conversation.ConversationId;
                model.InterLocutorId           = conversation.Users.First(u => u.Id != userId).Id;
                model.InterlocutorName         = conversation.Users.First(u => u.Id != userId).UserName;
                model.LastMessage              = conversation.Messages[0].Content;
                model.LastMessageDate          = GetDateString(conversation.Messages[0].Date);
                model.InterLocutorProfileImage = await this.photosService.GetUserProfilePhotoInBytes(conversation.Users.First(u => u.Id != userId).UserProfilePhotoName);

                list.Add(model);
            }

            return(list);
        }