/// <summary> /// 新聞公告 聲明 /// </summary> /// <param name="qry"></param> /// <param name="langCode"></param> /// <param name="model"></param> private void SearchAnnouncement(string qry, string langCode, ref List <SearchListDataModel> model) { using (var db = new TCGDB(_connectionString)) { var source = db.NEWS .AsEnumerable() .Where(s => (string.IsNullOrEmpty(langCode) ? true : s.LANG_ID == langCode) && (s.N_TITLE == qry || s.N_DESC.RemoveHtmlAllTags() == qry || s.N_TITLE.Contains(qry) || s.N_DESC.RemoveHtmlAllTags().Contains(qry))) .Where(x => x.STATUS == "Y") .ToList(); foreach (var news in source) { SearchListDataModel temp = new SearchListDataModel(); temp.Title = news.N_TITLE; temp.Content = news.N_DESC.RemoveHtmlAllTags(); temp.UpDateTime = (DateTime)news.UPD_DT; temp.LinkAddr = string.Format("/News/AnnouncementContent?ID={0}&typeID={1}", news.ID, news.CATE_ID); temp.BD_DTString = (DateTime)news.BD_DT; temp.Sort = (news.SORT) ?? 0; model.Add(temp); } } }
/// <summary> /// 加入台灣民政府 /// </summary> /// <param name="qry"></param> /// <param name="langCode"></param> /// <param name="model"></param> private void SearchJoinUs(string qry, string langCode, ref List <SearchListDataModel> model) { using (var db = new TCGDB(_connectionString)) { Dictionary <int, List <int> > cateGroup = new Dictionary <int, List <int> >(); cateGroup.Add(0, new List <int>() { 1, 4, 5 }); cateGroup.Add(1, new List <int>() { 2, 6, 7 }); var source = db.JOINUS .AsEnumerable() .Where(s => (string.IsNullOrEmpty(langCode) ? true : s.LANG_ID == langCode) && (s.C_TITLE == qry || s.C_DESC.RemoveHtmlAllTags() == qry || s.C_TITLE.Contains(qry) || s.C_DESC.RemoveHtmlAllTags().Contains(qry))) .Where(x => x.STATUS == "Y") .ToList(); foreach (var join in source) { var cate = cateGroup.Where(s => s.Value.Contains((int)join.CATE_ID)).ToDictionary(d => d.Key, d => d.Value.ToList()); if (cate.Count == 0) { throw new Exception("無法取得對應的JOINUS分類,請聯絡系統管理員"); } SearchListDataModel temp = new SearchListDataModel(); temp.Title = join.C_TITLE; temp.Content = join.C_DESC.RemoveHtmlAllTags(); temp.UpDateTime = (DateTime)join.UPD_DT; temp.BD_DTString = (DateTime)join.BD_DT; temp.Sort = (join.SORT) ?? 0; switch (cate.Keys.First()) { case 0: temp.LinkAddr = string.Format("/JoinUs/Apply"); break; case 1: temp.LinkAddr = string.Format("/JoinUs/Consult?id={0}", join.ID); break; default: break; } model.Add(temp); } } }
/// <summary> /// 關於我們 /// </summary> /// <param name="qry"></param> /// <param name="langCode"></param> /// <param name="model"></param> private void SearchAbout(string qry, string langCode, ref List <SearchListDataModel> model) { using (var db = new TCGDB(_connectionString)) { Dictionary <int, List <int> > cateGroup = new Dictionary <int, List <int> >(); cateGroup.Add(0, new List <int>() { 1, 10, 11 }); cateGroup.Add(1, new List <int>() { 2, 12, 13 }); cateGroup.Add(2, new List <int>() { 3, 14, 15 }); cateGroup.Add(3, new List <int>() { 4, 16, 17 }); cateGroup.Add(4, new List <int>() { 5, 18, 19 }); cateGroup.Add(5, new List <int>() { 6, 20, 21 }); cateGroup.Add(6, new List <int>() { 7, 22, 23 }); cateGroup.Add(7, new List <int>() { 8, 24, 25 }); cateGroup.Add(8, new List <int>() { 9, 26, 27 }); var source = db.ABOUTUS .AsEnumerable() .Where(s => (string.IsNullOrEmpty(langCode) ? true : s.LANG_ID == langCode) && (s.C_TITLE == qry || s.C_DESC.RemoveHtmlAllTags() == qry || s.C_TITLE.Contains(qry) || s.C_DESC.RemoveHtmlAllTags().Contains(qry))) .Where(x => x.STATUS == "Y") .ToList(); foreach (var about in source) { var cate = cateGroup.Where(s => s.Value.Contains((int)about.CATE_ID)).ToDictionary(d => d.Key, d => d.Value.ToList()); if (cate.Count == 0) { throw new Exception("無法取得對應ABOUTAS的分類,請聯絡系統管理員"); } SearchListDataModel temp = new SearchListDataModel(); temp.Title = about.C_TITLE; temp.Content = about.C_DESC.RemoveHtmlAllTags(); temp.UpDateTime = (DateTime)about.UPD_DT; temp.BD_DTString = (DateTime)about.BD_DT; temp.Sort = (about.SORT) ?? 0; switch (cate.Keys.First()) { case 0: temp.LinkAddr = string.Format("/AboutUs/TCG?id={0}", about.ID); break; case 1: temp.LinkAddr = string.Format("/AboutUs/Position?id={0}", about.ID); break; case 2: temp.LinkAddr = string.Format("/AboutUs/Statement?id={0}", about.ID); break; case 3: temp.LinkAddr = string.Format("/AboutUs/Law?cate_id={0}&id={1}", about.CATE_ID, about.ID); break; case 4: temp.LinkAddr = string.Format("/AboutUs/Law?cate_id={0}&id={1}", about.CATE_ID, about.ID); break; case 5: temp.LinkAddr = string.Format("/AboutUs/Law?cate_id={0}&id={1}", about.CATE_ID, about.ID); break; case 6: temp.LinkAddr = string.Format("/AboutUs/Organization?cate_id={0}&id={1}", about.CATE_ID, about.ID); break; case 7: temp.LinkAddr = string.Format("/AboutUs/Organization?cate_id={0}&id={1}", about.CATE_ID, about.ID); break; case 8: temp.LinkAddr = string.Format("/AboutUs/Organization?cate_id={0}&id={1}", about.CATE_ID, about.ID); break; default: break; } model.Add(temp); } } }