public static string Load_DynamicDataLanguage_Page(HttpContext Context, string SYSTEM) { string PageHTML = Context.Request["filename"].ToString(); LanguagesBO aLanguagesBO = new LanguagesBO(); ConfigsBO aConfigsBO = new ConfigsBO(); List<Configs> ListConfigsCMS = new List<Configs>(); List<string> ListCodeCMS = new List<string>(); ListConfigsCMS = aConfigsBO.Sel_ByAccessKey(key_DEF_LANG_CMS); for (int i = 0; i < ListConfigsCMS.Count; i++) { ListCodeCMS.Add(ListConfigsCMS[i].Value.ToString()); } string ListCodeTemptCMS = String.Join(",", ListCodeCMS); List<Configs> ListConfigsWEB = new List<Configs>(); List<string> ListCodeWEB = new List<string>(); ListConfigsWEB = aConfigsBO.Sel_ByAccessKey(key_DEF_LANG_WEB); for (int i = 0; i < ListConfigsCMS.Count; i++) { ListCodeWEB.Add(ListConfigsWEB[i].Value.ToString()); } string ListCodeTemptWEB = String.Join(",", ListCodeWEB); sys_NUM_LANG = aLanguagesBO.Sel().ToList().Count; if (SYSTEM == "CMS") { sys_DEF_LANG = int.Parse(ListCodeTemptCMS); } else if (SYSTEM == "WEB") { sys_DEF_LANG = int.Parse(ListCodeTemptWEB); } if (!string.IsNullOrEmpty(Context.Request.QueryString["IDLang"])) { sys_CUR_LANG = Convert.ToInt32(Context.Request.QueryString["IDLang"]); } else { if (Context.GetSection(key_CUR_LANG) != null) { sys_CUR_LANG = Convert.ToInt32(Context.GetSection(key_CUR_LANG).ToString()); } // Cuoi cung moi lay den ngon ngu mac dinh else { sys_CUR_LANG = int.Parse(ListCodeTemptCMS); } } string PhysicalPath = Context.Server.MapPath(@"\\Languages\\" + aLanguagesBO.Sel_ByID(sys_CUR_LANG).NameLang + "\\" + PageHTML + ".xml"); XmlDocument doc = new XmlDocument(); doc.Load(PhysicalPath); XmlElement element = doc.DocumentElement; XmlNodeList attr_coll = doc.SelectNodes("//item"); List<LanguagesItem> List_ItemLang = new List<LanguagesItem>(); LanguagesItem Item; foreach (XmlNode node in attr_coll) { Item = new LanguagesItem(); Item.Text = node.InnerText; Item.Key = node.Attributes["Index"].Value; List_ItemLang.Add(Item); } String jSonString = ""; InfoLang aInfoLang = new InfoLang(); aInfoLang.DATA_LANG = List_ItemLang; aInfoLang.sys_CUR_LANG = sys_CUR_LANG; aInfoLang.sys_DEF_LANG = sys_DEF_LANG; aInfoLang.sys_NUM_LANG = sys_NUM_LANG; _converter.DateTimeFormat = "dd/MM/yyyy"; jSonString = JsonConvert.SerializeObject(aInfoLang, _converter); CORE_Language.aInfoLang.DATA_LANG = List_ItemLang; // Chỗ chứa dữ liệu cho cách thức truy cập từ trang aspx return jSonString; }
public static string Load_StaticDataLanguage_Page(HttpContext Context, string SYSTEM) { LanguagesBO aLanguagesBO = new LanguagesBO(); ConfigsBO aConfigsBO = new ConfigsBO(); List <Configs> ListConfigsCMS = new List <Configs>(); List <string> ListCodeCMS = new List <string>(); ListConfigsCMS = aConfigsBO.Sel_ByAccessKey(key_DEF_LANG_CMS); for (int i = 0; i < ListConfigsCMS.Count; i++) { ListCodeCMS.Add(ListConfigsCMS[i].Value.ToString()); } string ListCodeTemptCMS = String.Join(",", ListCodeCMS); List <Configs> ListConfigsWEB = new List <Configs>(); List <string> ListCodeWEB = new List <string>(); ListConfigsWEB = aConfigsBO.Sel_ByAccessKey(key_DEF_LANG_WEB); for (int i = 0; i < ListConfigsCMS.Count; i++) { ListCodeWEB.Add(ListConfigsWEB[i].Value.ToString()); } string ListCodeTemptWEB = String.Join(",", ListCodeWEB); sys_NUM_LANG = aLanguagesBO.Sel().ToList().Count; if (SYSTEM == "CMS") { sys_DEF_LANG = int.Parse(ListCodeTemptCMS); } else if (SYSTEM == "WEB") { sys_DEF_LANG = int.Parse(ListCodeTemptWEB); } if (!string.IsNullOrEmpty(Context.Request.QueryString["IDLang"])) { sys_CUR_LANG = Convert.ToInt32(Context.Request.QueryString["IDLang"]); } else { if (Context.GetSection(key_CUR_LANG) != null) { sys_CUR_LANG = Convert.ToInt32(Context.GetSection(key_CUR_LANG).ToString()); } // Cuoi cung moi lay den ngon ngu mac dinh else { sys_CUR_LANG = int.Parse(ListCodeTemptCMS); } } string PhysicalPath = Context.Server.MapPath(@"\\Languages\\" + aLanguagesBO.Sel_ByID(sys_CUR_LANG).NameLang + "\\FRAMEWORK\\StaticLanguage.xml"); XmlDocument doc = new XmlDocument(); doc.Load(PhysicalPath); XmlElement element = doc.DocumentElement; XmlNodeList attr_coll = doc.SelectNodes("//item"); List <LanguagesItem> List_ItemLang = new List <LanguagesItem>(); LanguagesItem Item; foreach (XmlNode node in attr_coll) { Item = new LanguagesItem(); Item.Text = node.InnerText; Item.Key = node.Attributes["Index"].Value; List_ItemLang.Add(Item); } String jSonString = ""; InfoLang aInfoLang = new InfoLang(); aInfoLang.DATA_LANG = List_ItemLang; aInfoLang.sys_CUR_LANG = sys_CUR_LANG; aInfoLang.sys_DEF_LANG = sys_DEF_LANG; aInfoLang.sys_NUM_LANG = sys_NUM_LANG; _converter.DateTimeFormat = "dd/MM/yyyy"; jSonString = JsonConvert.SerializeObject(aInfoLang, _converter); // CORE_Language.CurrentPage.Session[key_LANG_DATA] = List_ItemLang; // Ngôn ngữ dành cho trang ASPX return(jSonString); }