private void bwAsync_Worker(object sender, DoWorkEventArgs e)
        {
            ProcessingType type = (ProcessingType)e.Argument;

            e.Result = type;

            switch (type)
            {
            case ProcessingType.SaveData:
            {
                if (mIntent_Response.Intent_ResponseID > 0)
                {
                    Intent_ResponsePresenter.UpdateIntent_Response(mIntent_Response);
                }
                else
                {
                    Intent_ResponsePresenter.InsertIntent_Response(mIntent_Response);
                }
            }
            break;

            default:
                break;
            }
        }
        private void btnXoa_Click(object sender, EventArgs e)
        {
            Intent_Response data = mListViewData.SelectedObject as Intent_Response;

            if (data != null && data.Intent_ResponseID > 0)
            {
                if (SanitaMessageBox.Show("Bạn có chắc chắn muốn xóa không ?", "Thông Báo", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    if (Intent_ResponsePresenter.DeleteIntent_Response(data) > 0)
                    {
                        DoRefresh();
                    }
                }
            }
        }
Beispiel #3
0
        public String ExecuteCommand(Intent_Request data)
        {
            if (data.DM_Entity_TypeID == 0)
            {
                data.DM_Entity_TypeID = DM_Entity_Type.KE_CHUYEN_CUOI;
            }

            //Lấy response
            Intent_Response mIntent_Response = Intent_ResponsePresenter.GetIntent_Response_Request(data);
            String          response_data    = mIntent_Response.Data;

            response_data = response_data ?? "";

            //Response
            return(response_data);
        }
Beispiel #4
0
        public API_TroLyAoData_Out TroLyAo_Execute(API_TroLyAoData_In data)
        {
            //Output
            API_TroLyAoData_Out mAPI_TroLyAoData_Out = new API_TroLyAoData_Out();

            mAPI_TroLyAoData_Out.Language = "vi-VN";

            //Kiểm tra data
            if (data == null)
            {
                mAPI_TroLyAoData_Out.Data = "Bạn hãy hỏi gì đi...";
                mAPI_TroLyAoData_Out.ID   = Sanita.Utility.Encryption.CryptorEngine.CreateMD5Hash(mAPI_TroLyAoData_Out.Data);
                return(mAPI_TroLyAoData_Out);
            }

            //Kiểm tra device
            Device mDevice = DevicePresenter.GetDevice(data.DeviceID);

            if (mDevice.DeviceID <= 0)
            {
                mAPI_TroLyAoData_Out.Data = "Thiết bị của bạn chưa được đăng ký.";
                mAPI_TroLyAoData_Out.ID   = Sanita.Utility.Encryption.CryptorEngine.CreateMD5Hash(mAPI_TroLyAoData_Out.Data);
                return(mAPI_TroLyAoData_Out);
            }

            //Kiểm tra user
            User mUser = UserPresenter.GetUser(mDevice.UserID);

            if (mUser.APIKey != data.API_Key)
            {
                mAPI_TroLyAoData_Out.Data = "API key không đúng.";
                mAPI_TroLyAoData_Out.ID   = Sanita.Utility.Encryption.CryptorEngine.CreateMD5Hash(mAPI_TroLyAoData_Out.Data);
                return(mAPI_TroLyAoData_Out);
            }

            if (!MyVar.mListDevice.Any(p => p.DeviceID == mDevice.DeviceID))
            {
                MyVar.mListDevice.Add(mDevice);
            }
            mDevice       = MyVar.mListDevice.FirstOrDefault(p => p.DeviceID == mDevice.DeviceID);
            mDevice.mUser = mUser;

            //Xử lý input
            data.Data = XuLyDuLieu(data.Data);

            //Lấy danh sách request
            IList <Intent_Request> mListRequest = Intent_RequestPresenter.GetIntent_Requests(data.Data);

            //Lọc theo bối cảnh hiện tại
            IList <Intent_Request> mListRequest_Current = mListRequest.Where(p => p.Current_DM_Entity_TypeID == mDevice.Current_DM_Entity_TypeID && p.Current_DM_Intent_TypeID == mDevice.Current_DM_Intent_TypeID).ToList();

            if (mListRequest_Current.Count == 0)
            {
                mListRequest_Current = mListRequest.Where(p => p.Current_DM_Entity_TypeID == 0 && p.Current_DM_Intent_TypeID == 0).ToList();
            }
            if (mListRequest_Current.Count > 0)
            {
                mListRequest = mListRequest_Current;
            }

            //Sắp xếp
            IList <Intent_Request> mListRequest_NoneParam = mListRequest.Where(p => !p.Data.Contains("<") && !p.Data.Contains(">")).OrderByDescending(p => p.Data.Length).ToList();
            IList <Intent_Request> mListRequest_Param     = mListRequest.Where(p => p.Data.Contains("<") && p.Data.Contains(">")).OrderByDescending(p => p.Data.Length).ToList();

            mListRequest = mListRequest_NoneParam.Concat(mListRequest_Param).ToList();

            Intent_Request mIntent_Request = new Intent_Request();

            foreach (Intent_Request request in mListRequest)
            {
                String request_data = request.Data;
                request_data = request_data ?? "";
                request_data = request_data.Replace("<*>", "(.*)");
                request_data = request_data.Replace("<", "(?<");
                request_data = request_data.Replace(">", ">(.+))");
                request_data = "^" + request_data + "$";

                Regex mRegex = new Regex(request_data, RegexOptions.IgnoreCase | RegexOptions.Singleline);

                if (mRegex.IsMatch(data.Data))
                {
                    mIntent_Request = request;
                    mDevice.Current_DM_Intent_TypeID = mIntent_Request.DM_Intent_TypeID;
                    mDevice.Current_DM_Entity_TypeID = mIntent_Request.DM_Entity_TypeID;

                    GroupCollection groups = mRegex.Match(data.Data).Groups;

                    foreach (string groupName in mRegex.GetGroupNames())
                    {
                        EntityParam mEntityParam = new EntityParam();
                        mEntityParam.Name  = groupName;
                        mEntityParam.Value = groups[groupName].Value;
                        mIntent_Request.mListParam.Add(mEntityParam);
                    }
                }
            }

            //Set device
            mIntent_Request.mDevice = mDevice;

            //Xử lý request
            String response_request = XuLyRequest(mIntent_Request);

            if (!String.IsNullOrEmpty(response_request))
            {
                mAPI_TroLyAoData_Out.Data = response_request;
                mAPI_TroLyAoData_Out.ID   = Sanita.Utility.Encryption.CryptorEngine.CreateMD5Hash(mAPI_TroLyAoData_Out.Data);
                return(mAPI_TroLyAoData_Out);
            }

            //Get response
            Intent_Response mIntent_Response = Intent_ResponsePresenter.GetIntent_Response_Request(mIntent_Request);

            if (String.IsNullOrEmpty(mIntent_Response.Data))
            {
                mIntent_Response.Data = "Xin lỗi... Tôi không hiểu !";
            }

            //Update global
            if (mIntent_Response.Data.Contains("<") && mIntent_Response.Data.Contains(">"))
            {
                mIntent_Response.Data.Replace("<thoi_gian_hien_tai>", String.Format("{0:HH:mm}", SystemInfo.NOW));
                mIntent_Response.Data.Replace("<ngay_hien_tai>", String.Format("{0:dd/MM/yyyy}", SystemInfo.NOW));
                mIntent_Response.Data.Replace("<thu_hien_tai>", String.Format("{0}", SystemInfo.NOW.GetThu()));
                mIntent_Response.Data.Replace("<ngay_mai>", String.Format("{0:dd/MM/yyyy}", SystemInfo.NOW.AddDays(1)));
                mIntent_Response.Data.Replace("<thu_mai>", String.Format("{0}", SystemInfo.NOW.AddDays(1).GetThu()));
            }

            //Return
            mAPI_TroLyAoData_Out.Data = mIntent_Response.Data;
            mAPI_TroLyAoData_Out.ID   = Sanita.Utility.Encryption.CryptorEngine.CreateMD5Hash(mAPI_TroLyAoData_Out.Data);
            return(mAPI_TroLyAoData_Out);

#if false
            //Check
            if (data.Data.Contains("thời tiết") && data.Data.Contains("hôm nay"))
            {
                String thu = "";
                if (SystemInfo.NOW.DayOfWeek == DayOfWeek.Sunday)
                {
                    thu = String.Format("chủ nhật");
                }
                else
                {
                    thu = String.Format("thứ {0}", (int)SystemInfo.NOW.DayOfWeek + 1);
                }

                mAPI_TroLyAoData_Out.Data = String.Format("Dự báo thời tiết hôm nay ở Quan Khê, Hải Dương {0} ngày {1:dd/MM} có mưa rào nhẹ, nhiệt độ từ 26 đến 32 độ, độ ẩm 94%", thu, SystemInfo.NOW);
            }
            else if ((data.Data.Contains("thời tiết") && data.Data.Contains("ngày mai")) || data.Data.Contains("còn ngày mai"))
            {
                String thu = "";
                if (SystemInfo.NOW.AddDays(1).DayOfWeek == DayOfWeek.Sunday)
                {
                    thu = String.Format("chủ nhật");
                }
                else
                {
                    thu = String.Format("thứ {0}", (int)SystemInfo.NOW.AddDays(1).DayOfWeek + 1);
                }

                mAPI_TroLyAoData_Out.Data = String.Format("Dự báo thời tiết ngày mai ở Quan Khê, Hải Dương {0} ngày {1:dd/MM} trời nhiều mây và nắng nhẹ, nhiệt độ từ 26 đến 33 độ, độ ẩm 76%", thu, SystemInfo.NOW.AddDays(1));
            }
            else if (data.Data.Contains("mấy giờ rồi") || data.Data.Contains("bây giờ là mấy giờ"))
            {
                mAPI_TroLyAoData_Out.Data = String.Format("Thời gian là {0:HH:mm} phút", SystemInfo.NOW);
            }
            else if (data.Data.Contains("hôm nay") && data.Data.Contains("thứ mấy"))
            {
                if (SystemInfo.NOW.DayOfWeek == DayOfWeek.Sunday)
                {
                    mAPI_TroLyAoData_Out.Data = String.Format("Hôm nay là chủ nhật");
                }
                else
                {
                    mAPI_TroLyAoData_Out.Data = String.Format("Hôm nay là thứ {0}", (int)SystemInfo.NOW.DayOfWeek + 1);
                }
            }
            else if (data.Data.Contains("ngày mai") && data.Data.Contains("thứ mấy"))
            {
                if (SystemInfo.NOW.AddDays(1).DayOfWeek == DayOfWeek.Sunday)
                {
                    mAPI_TroLyAoData_Out.Data = String.Format("Ngày mai là chủ nhật");
                }
                else
                {
                    mAPI_TroLyAoData_Out.Data = String.Format("Ngày mai là thứ {0}", (int)SystemInfo.NOW.AddDays(1).DayOfWeek + 1);
                }
            }
            else if (data.Data.EqualText("bạn là ai") || data.Data.EqualText("bạn là cái gì"))
            {
                mAPI_TroLyAoData_Out.Data = "Tôi là trợ lý ảo của bạn đây";
            }
            else if (data.Data.EqualText("tên bạn là gì"))
            {
                mAPI_TroLyAoData_Out.Data = "Tôi chưa tự giới thiệu sao ? Tên tôi là Daisy !";
            }
            else if (data.Data.Contains("bạn biết hát không") || data.Data.Contains("bạn có biết hát không") || data.Data.Contains("hát cho tôi nghe"))
            {
                mAPI_TroLyAoData_Out.Data += "<speak>";
                mAPI_TroLyAoData_Out.Data += "<p>";

                mAPI_TroLyAoData_Out.Data += "<s>Xin lỗi, giờ tôi vẫn chưa biết hát.</s>";
                mAPI_TroLyAoData_Out.Data += "<s>Thay vào đó, tôi có thể đọc lời bài hát cho bạn tự tưởng tượng theo.</s>";
                mAPI_TroLyAoData_Out.Data += "<break time=\"300ms\"/>";

                mAPI_TroLyAoData_Out.Data += "<s>Kìa con bướm vàng.</s>";
                mAPI_TroLyAoData_Out.Data += "<s>Kìa con bướm vàng.</s>";

                mAPI_TroLyAoData_Out.Data += "<s>Xòe đôi cánh.</s>";
                mAPI_TroLyAoData_Out.Data += "<s>Xòe đôi cánh.</s>";

                mAPI_TroLyAoData_Out.Data += "<s>Tung cánh bay năm ba vòng.</s>";
                mAPI_TroLyAoData_Out.Data += "<s>Tung cánh bay năm ba vòng.</s>";

                mAPI_TroLyAoData_Out.Data += "<s>Em ngồi xem...</s>";
                mAPI_TroLyAoData_Out.Data += "<s>Em ngồi xem...</s>";

                mAPI_TroLyAoData_Out.Data += "</p>";
                mAPI_TroLyAoData_Out.Data += "</speak>";
            }
            else if (data.Data.Contains("bạn đang ở đâu"))
            {
                mAPI_TroLyAoData_Out.Data += "<speak>";
                mAPI_TroLyAoData_Out.Data += "<p>";

                mAPI_TroLyAoData_Out.Data += "<s>Tôi ở trong thiết bị này.</s>";
                mAPI_TroLyAoData_Out.Data += "<s>cả máy tính bảng có ngay khi cần.</s>";
                mAPI_TroLyAoData_Out.Data += "<s>Google home cũng có phần.</s>";
                mAPI_TroLyAoData_Out.Data += "<s>Ôi nhiều nhà quá phân vân chọn hoài.</s>";

                mAPI_TroLyAoData_Out.Data += "</p>";
                mAPI_TroLyAoData_Out.Data += "</speak>";
            }
            else if (data.Data.Contains("truyện cười") || data.Data.Contains("chuyện cười"))
            {
                mAPI_TroLyAoData_Out.Data += "<speak>";
                mAPI_TroLyAoData_Out.Data += "<p>";

                mAPI_TroLyAoData_Out.Data += "<s>Được, bạn nghe nhé !</s>";
                mAPI_TroLyAoData_Out.Data += "<break time=\"300ms\"/>";

                mAPI_TroLyAoData_Out.Data += "<s>Trong giờ địa lý, thầy hỏi trò.</s>";
                mAPI_TroLyAoData_Out.Data += "<s>Em hãy nói ba lý do khiến em chắc rằng trái đất hình cầu.</s>";
                mAPI_TroLyAoData_Out.Data += "<s>Thưa thầy, bố em nói thế, mẹ em nói thế và thầy cũng nói thế ạ !</s>";

                mAPI_TroLyAoData_Out.Data += "<audio src=\"https://ia601507.us.archive.org/31/items/google_cuoi/google_cuoi.ogg\"/>";

                mAPI_TroLyAoData_Out.Data += "</p>";
                mAPI_TroLyAoData_Out.Data += "</speak>";
            }
            else if (data.Data.Contains("truyện khác") || data.Data.Contains("chuyện khác"))
            {
                mAPI_TroLyAoData_Out.Data += "<speak>";
                mAPI_TroLyAoData_Out.Data += "<p>";

                mAPI_TroLyAoData_Out.Data += "<s>Được, nghe tôi kể đây này !</s>";
                mAPI_TroLyAoData_Out.Data += "<break time=\"300ms\"/>";

                mAPI_TroLyAoData_Out.Data += "<s>Ngày đầu tiên bé đi học về, bố mẹ hỏi. Ở lớp thế nào con ?</s>";
                mAPI_TroLyAoData_Out.Data += "<s>Vui lắm bố ạ, cô giáo con xinh lắm !</s>";
                mAPI_TroLyAoData_Out.Data += "<s>Thế cô dạy con những gì ?</s>";
                mAPI_TroLyAoData_Out.Data += "<s>Cô chẳng biết gì cả ! Cái gì cũng phải hỏi : Em nào cho cô biết nào.</s>";

                mAPI_TroLyAoData_Out.Data += "<audio src=\"https://ia601507.us.archive.org/31/items/google_cuoi/google_cuoi.ogg\"/>";

                mAPI_TroLyAoData_Out.Data += "</p>";
                mAPI_TroLyAoData_Out.Data += "</speak>";
            }
            else if (data.Data.EqualText("bật đèn phòng khách"))
            {
                mAPI_TroLyAoData_Out.Data = "OK, đã bật đèn phòng khách";
            }
            else if (data.Data.EqualText("tắt đèn phòng khách"))
            {
                mAPI_TroLyAoData_Out.Data = "OK, đã tắt đèn phòng khách";
            }
            else if (data.Data.EqualText("bật điều hòa") || data.Data.EqualText("tôi nóng quá"))
            {
                mAPI_TroLyAoData_Out.Data = "OK, đã bật điều hòa";
            }
            else if (data.Data.EqualText("để điều hòa 26 độ"))
            {
                mAPI_TroLyAoData_Out.Data = "OK, đã để điều hòa 26 độ C";
            }

            //Return
            if (String.IsNullOrEmpty(mAPI_TroLyAoData_Out.Data))
            {
                mAPI_TroLyAoData_Out.Data = "Xin lỗi... Tôi không hiểu !";
            }

            mAPI_TroLyAoData_Out.ID       = Sanita.Utility.Encryption.CryptorEngine.CreateMD5Hash(mAPI_TroLyAoData_Out.Data);
            mAPI_TroLyAoData_Out.Language = "vi-VN";

            return(mAPI_TroLyAoData_Out);
#endif
        }
Beispiel #5
0
        public String ExecuteCommand(Intent_Request data)
        {
            String thoi_gian      = "";
            String thoi_gian_gio  = "";
            String thoi_gian_phut = "";

            //Check entity
            if (data.DM_Entity_TypeID == 0)
            {
                EntityParam mEntityParam_ThoiGian = data.mListParam.FirstOrDefault(p => p.Name == "thoi_gian");
                if (mEntityParam_ThoiGian != null)
                {
                    if (mEntityParam_ThoiGian.Value == "theo can chi")
                    {
                        data.DM_Entity_TypeID = DM_Entity_Type.THOI_GIAN_AM_LICH_HOM_NAY;
                    }
                }
            }
            if (data.DM_Entity_TypeID == 0)
            {
                data.DM_Entity_TypeID = DM_Entity_Type.THOI_GIAN_HOM_NAY;
            }

            //Lấy response
            Intent_Response mIntent_Response = Intent_ResponsePresenter.GetIntent_Response_Request(data);
            String          response_data    = mIntent_Response.Data;

            response_data = response_data ?? "";

            //Cập nhật biến
            switch (data.DM_Entity_TypeID)
            {
            case DM_Entity_Type.THOI_GIAN_HOM_NAY:
            {
                thoi_gian      = String.Format("{0:HH:mm}", SystemInfo.NOW);
                thoi_gian_gio  = String.Format("{0:HH}", SystemInfo.NOW);
                thoi_gian_phut = String.Format("{0:mm}", SystemInfo.NOW);
            }
            break;

            case DM_Entity_Type.THOI_GIAN_HOM_NAY_DIA_DIEM:
            {
                EntityParam dia_diem = data.mListParam.FirstOrDefault(p => p.Name == "dia_diem");
                if (dia_diem != null)
                {
                    thoi_gian = GetThoiGian_DiaDiem(dia_diem.Value);
                    IList <String> list_time = thoi_gian.Split(':').ToList();
                    if (list_time.Count == 2)
                    {
                        thoi_gian_gio  = list_time[0];
                        thoi_gian_phut = list_time[1];
                    }
                }
            }
            break;

            default:
                break;
            }

            //Update biến
            if (!String.IsNullOrEmpty(thoi_gian))
            {
                response_data = response_data.Replace("<thoi_gian>", thoi_gian);
                response_data = response_data.Replace("<thoi_gian_gio>", thoi_gian_gio);
                response_data = response_data.Replace("<thoi_gian_phut>", thoi_gian_phut);
            }
            else
            {
                response_data         = "";
                data.DM_Intent_TypeID = DM_Intent_Type.KHONG_HIEU;
            }

            //Update biến đầu vào
            foreach (EntityParam param in data.mListParam)
            {
                response_data = response_data.Replace("<" + param.Name + ">", param.Value);
            }

            //Response
            return(response_data);
        }
        private void bwAsync_Worker(object sender, DoWorkEventArgs e)
        {
            ProcessingType type = (ProcessingType)e.Argument;

            e.Result = type;

            switch (type)
            {
            case ProcessingType.LoadData:
            {
                mListData_Flat = Intent_ResponsePresenter.GetIntent_Responses();

                //Update dữ liệu
                mListData = new List <Intent_Response>();
                foreach (DM_Intent_Type nhom in DM_Intent_Type.GetDefaultList(0))
                {
                    if (mListData_Flat.Any(p => p.DM_Intent_TypeID == nhom.DM_Intent_TypeID))
                    {
                        Intent_Response group_Intent_Response = new Intent_Response();
                        group_Intent_Response.DM_Intent_TypeID  = nhom.DM_Intent_TypeID;
                        group_Intent_Response.Intent_ResponseID = -1;
                        group_Intent_Response.Data         = nhom.DM_Intent_TypeName;
                        group_Intent_Response.mListSubData = new List <Intent_Response>();
                        mListData.Add(group_Intent_Response);

                        IList <DM_Entity_Type> ListDM_Entity_Type = DM_Entity_Type.GetDefaultList(0).Where(p => p.DM_Intent_TypeID == nhom.DM_Intent_TypeID).ToList();
                        if (ListDM_Entity_Type.Count == 0)
                        {
                            group_Intent_Response.mListSubData = mListData_Flat.Where(p => p.DM_Intent_TypeID == nhom.DM_Intent_TypeID).ToList();
                            group_Intent_Response.mListSubData = group_Intent_Response.mListSubData.Select(p => { p.mParent = group_Intent_Response; return(p); }).ToList();
                        }
                        else
                        {
                            foreach (DM_Entity_Type loai_dichvu in ListDM_Entity_Type)
                            {
                                if (mListData_Flat.Any(p => p.DM_Entity_TypeID == loai_dichvu.DM_Entity_TypeID && p.DM_Intent_TypeID == loai_dichvu.DM_Intent_TypeID))
                                {
                                    Intent_Response type_service = new Intent_Response();
                                    type_service.DM_Intent_TypeID  = nhom.DM_Intent_TypeID;
                                    type_service.DM_Entity_TypeID  = loai_dichvu.DM_Entity_TypeID;
                                    type_service.Intent_ResponseID = -2;
                                    type_service.Data         = loai_dichvu.DM_Entity_TypeName;
                                    type_service.mListSubData = mListData_Flat.Where(p => p.DM_Entity_TypeID == loai_dichvu.DM_Entity_TypeID && p.DM_Intent_TypeID == loai_dichvu.DM_Intent_TypeID).ToList();
                                    type_service.mListSubData = type_service.mListSubData.Select(p => { p.mParent = type_service; return(p); }).ToList();
                                    if (type_service.mListSubData.Count > 0)
                                    {
                                        group_Intent_Response.mListSubData.Add(type_service);
                                    }
                                }
                            }
                        }
                    }
                }

                //Update danh sách
                {
                    mListThongTinDanhSachIntent_Response      = new List <ThongTinDanhSachIntent_Response>();
                    mListThongTinDanhSachIntent_Response_Flat = new List <ThongTinDanhSachIntent_Response>();
                    ThongTinDanhSachIntent_Response.ThongTinDanhSachIntent_ResponseID_Index = 1;

                    //Add tất cả nhóm dịch vụ
                    ThongTinDanhSachIntent_Response root = new ThongTinDanhSachIntent_Response();
                    root.ThongTinDanhSachIntent_ResponseType = (int)ThongTinDanhSachIntent_Response.TYPE.ROOT;
                    root.mListData = mListData;
                    root.ThongTinDanhSachIntent_ResponseName = String.Format("Tất cả ({0})".Translate(), mListData_Flat.Count());
                    mListThongTinDanhSachIntent_Response.Add(root);
                    mListThongTinDanhSachIntent_Response_Flat.Add(root);

                    foreach (DM_Intent_Type nhom_dich_vu in DM_Intent_Type.GetDefaultList(1))
                    {
                        Intent_Response group_service = mListData.FirstOrDefault(p => p.DM_Intent_TypeID == nhom_dich_vu.DM_Intent_TypeID && p.Intent_ResponseID == -1);
                        if (group_service != null)
                        {
                            ThongTinDanhSachIntent_Response mData = new ThongTinDanhSachIntent_Response();
                            mData.ThongTinDanhSachIntent_ResponseType = (int)ThongTinDanhSachIntent_Response.TYPE.GROUP;
                            mData.DM_Intent_TypeID = nhom_dich_vu.DM_Intent_TypeID;
                            mData.mListSubData     = new List <ThongTinDanhSachIntent_Response>();
                            mData.mListData        = group_service.mListSubData;
                            mData.ThongTinDanhSachIntent_ResponseName = DM_Intent_Type.GetDefault(mData.DM_Intent_TypeID).DM_Intent_TypeName + " (" + mListData_Flat.Where(p => p.DM_Intent_TypeID == mData.DM_Intent_TypeID).Count() + ")";
                            mListThongTinDanhSachIntent_Response.Add(mData);
                            mListThongTinDanhSachIntent_Response_Flat.Add(mData);

                            //Add loại dịch vụ
                            {
                                IList <DM_Entity_Type> list_sub = DM_Entity_Type.GetDefaultList(0).Where(p => p.DM_Intent_TypeID == nhom_dich_vu.DM_Intent_TypeID).ToList();
                                list_sub = list_sub.OrderBy(p => p.DM_Intent_TypeID).ThenBy(p => p.DM_Entity_TypeID).ToList();

                                foreach (DM_Entity_Type sub_data in list_sub)
                                {
                                    Intent_Response type_service = group_service.mListSubData.FirstOrDefault(p => p.DM_Entity_TypeID == sub_data.DM_Entity_TypeID && p.Intent_ResponseID == -2 && p.DM_Intent_TypeID == sub_data.DM_Intent_TypeID);
                                    if (type_service != null)
                                    {
                                        ThongTinDanhSachIntent_Response mSubData = new ThongTinDanhSachIntent_Response();
                                        mSubData.ThongTinDanhSachIntent_ResponseType = (int)ThongTinDanhSachIntent_Response.TYPE.SUB_GROUP;
                                        mSubData.DM_Intent_TypeID = mData.DM_Intent_TypeID;
                                        mSubData.DM_Entity_TypeID = sub_data.DM_Entity_TypeID;
                                        mSubData.mListData        = group_service.mListSubData.Where(p => p.DM_Entity_TypeID == sub_data.DM_Entity_TypeID && p.DM_Intent_TypeID == sub_data.DM_Intent_TypeID).ToList();
                                        mSubData.ThongTinDanhSachIntent_ResponseName = DM_Entity_Type.GetDefault(mSubData.DM_Entity_TypeID).DM_Entity_TypeName + " (" + mListData_Flat.Where(p => p.DM_Entity_TypeID == mSubData.DM_Entity_TypeID && p.DM_Intent_TypeID == mSubData.DM_Intent_TypeID).Count() + ")";
                                        if (mSubData.mListData.Count > 0)
                                        {
                                            mData.mListSubData.Add(mSubData);
                                            mListThongTinDanhSachIntent_Response_Flat.Add(mSubData);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            break;

            default:
                break;
            }
        }