Exemplo n.º 1
0
        public async Task <string> notifyMessenger(bool isInSaved = false)
        {
            //  var listUser = _detailOutWordService.
            ListUserNofity         listUserNotify = new ListUserNofity();
            List <ApplicationUser> listUser       = _service.listUserID();
            List <int>             listIDWord     = new List <int>();

            foreach (var userDetail in listUser)
            {
                //Kiem tra xem thoi gian co trung voi thoi gian bieu hay khong
                if (_eventService.IsFreeTime(userDetail.Email) || isInSaved)
                {
                    listIDWord = _detailOutWordService.listIdOutWord(userDetail.Id, 0);
                    //Update thoi gian
                    //
                    try
                    {
                        if (listIDWord != null || listIDWord.Count != 0)
                        {
                            await sendNotificationEnlishVoca(listIDWord, userDetail.Id_Messenger);
                        }
                    }
                    catch (Exception e)
                    {
                    }
                }
            }

            return(JsonConvert.SerializeObject(listUserNotify));
        }
Exemplo n.º 2
0
        protected async Task <string> sendNotificationEnlish()
        {
            string     paramChatfuel = "";
            HttpClient client        = new HttpClient();

            client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
            var            responseVoca = notifyMessenger().Result;
            ListUserNofity listNofity   = JsonConvert.DeserializeObject <ListUserNofity>(responseVoca);

            foreach (var userNoti in listNofity.reminduser)
            {
                paramChatfuel = "https://api.chatfuel.com/bots/59a43f64e4b03a25b73c0ebd/users/" + userNoti.IdMess + "/" + "send?chatfuel_token=vnbqX6cpvXUXFcOKr5RHJ7psSpHDRzO1hXBY8dkvn50ZkZyWML3YdtoCnKH7FSjC&chatfuel_block_id=5a28393be4b0d0e6fdab76b3";
                for (int i = 1; i <= 5; i++)
                {
                    paramChatfuel += "&word" + i.ToString() + "=" + ((i <= userNoti.vocainfo.Count) ? userNoti.vocainfo[i - 1].voca : "");
                    paramChatfuel += "&pron" + i.ToString() + "=" + ((i <= userNoti.vocainfo.Count) ? userNoti.vocainfo[i - 1].pron : "");
                    paramChatfuel += "&meanvn" + i.ToString() + "=" + ((i <= userNoti.vocainfo.Count) ? userNoti.vocainfo[i - 1].meanVN : "");
                    paramChatfuel += "&meanen" + i.ToString() + "=" + ((i <= userNoti.vocainfo.Count) ? userNoti.vocainfo[i - 1].usecase : "");
                }
                paramChatfuel += ChatBotMessenger.getNotiNull();
                var response = await client.PostAsync(paramChatfuel, null);
            }
            return("");
        }