Last post Jul 21, 2014 06:31 AM by Mikesdotnetting
Member
55 Points
435 Posts
Jul 21, 2014 06:18 AM|Mohammed Saleh|LINK
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Xml; internal static class Util { internal static string SitePath; internal static List<string> getContent(string code, string lang) { List<string> rt = new List<string>(); string setFile = SitePath + "\\Content\\contents.xml"; if (File.Exists(setFile)) { XmlDocument xDoc = new XmlDocument(); xDoc.Load(setFile); XmlNode root = xDoc.DocumentElement; XmlNode xNode = root.SelectSingleNode(code); rt.Add(xNode.Attributes[lang].Value.Trim()); //caption rt.Add(xNode.InnerText.Trim()); //content } else { rt.Add(""); rt.Add("No Content File Exists. Please Contact Technical Support"); } return rt; } internal static string getMenuList(out XmlNodeList Lst) { Lst = null; string setFile = SitePath + "\\Content\\menu.xml"; if (File.Exists(setFile)) { XmlDocument xDoc = new XmlDocument(); xDoc.Load(setFile); XmlNode root = xDoc.DocumentElement; Lst = root.ChildNodes; return ""; } else return "No Content File Exists. Please Contact Technical Support"; } internal static string getSilderData(string folder, string lang) { string rt = "<div class='slider-wrapper theme-default'><div class='nivoSlider'>SLD-DIVS</div></div>"; string[] fns = Directory.GetFiles(SitePath + "\\img\\banners\\" + folder); Array.Sort(fns); string dv = ""; foreach (string fname in fns) { dv += "<img src='img/banners/" + folder + "/" + Path.GetFileName(fname).Trim() + "' alt='' />"; } rt = rt.Replace("SLD-DIVS", dv); return rt; } internal static string getEventsInfo(string lang, out List<xEventInfo> inf) { inf = new List<xEventInfo>(); try { string setFile = SitePath + "\\img\\banners\\events.xml"; if (File.Exists(setFile)) { XmlDocument xDoc = new XmlDocument(); xDoc.Load(setFile); XmlNode root = xDoc.DocumentElement; XmlNodeList nodes = root.SelectNodes("/events/event"); foreach (XmlNode nod in nodes) { xEventInfo xev = new xEventInfo(); xev.Title = nod.Attributes[lang.Trim() + "t"].Value.Trim(); xev.ExternalUrl = nod.Attributes["url"].Value.Trim(); xev.Image = "img/banners/events/" + nod.Attributes["img"].Value.Trim(); xev.ID = Path.GetFileNameWithoutExtension(xev.Image).Trim(); xev.ShortInfo = nod.SelectSingleNode(lang.Trim() + "note").InnerXml.Trim(); string fil = SitePath + "\\Content\\events\\" + nod.SelectSingleNode(lang.Trim() + "des").Attributes["file"].Value.Trim(); if (File.Exists(fil)) { StreamReader sr = new StreamReader(fil); xev.Description = sr.ReadToEnd(); sr.Close(); sr.Dispose(); } else xev.Description = ""; inf.Add(xev); } return ""; } else { return "No Content File Exists. Please Contact Technical Support"; } } catch (Exception ex) { return ex.Message; } } internal static string getPageContents(string lang, string name) { string fil = SitePath + "\\Content\\pages\\" + lang + "_" + name + ".txt"; string rt = ""; if (File.Exists(fil)) { StreamReader sr = new StreamReader(fil); rt = sr.ReadToEnd(); sr.Close(); sr.Dispose(); } return rt; } internal static string getMapLinksScript(string lang, out Hashtable alinks) { alinks = new Hashtable(); string setFile = SitePath + "\\Content\\maplinks.xml"; if (File.Exists(setFile)) { XmlDocument xDoc = new XmlDocument(); xDoc.Load(setFile); XmlNode root = xDoc.DocumentElement; XmlNodeList mlst = root.ChildNodes; string lFrame = "'<table cellpadding=\"0\" cellspacing=\"0\" class=\"tblMaplink\"><tr><td colspan=\"2\" class=\"tdmlTitle\">LST-TIT</td></tr>LST-TAB</table>'"; foreach (XmlNode mlnk in mlst) //mLink { string key = mlnk.Attributes["id"].Value.Trim(); string tab = lFrame.Replace("LST-TIT", mlnk.Attributes[lang].Value.Trim()); string sTemp = "<tr><td class=\"tdmlIcon\"><img alt=\"\" src=\"LNK-IMG\" /></td><td class=\"tdmlLink\"><a LNK-HREF '>LNK-CAPT</a></td></tr>"; string s = "\"\" ' + 'onclick=\"getMap(LNK-LAT, LNK-LNG, \\'LNK-TIT\\', \\'LNK-DES\\',\\'LNK-CAPT\\')\"' + "; XmlNodeList llst = mlnk.ChildNodes; string rows = ""; foreach (XmlNode lnk in llst) { string a = s.Replace("LNK-LAT", lnk.Attributes["lat"].Value.Trim()); a = a.Replace("LNK-LNG", lnk.Attributes["lng"].Value.Trim()); a = a.Replace("LNK-CAPT", lnk.Attributes[lang].Value.Trim()); XmlNodeList tlst = lnk.ChildNodes; foreach (XmlNode t in tlst) { if(t.Name.Trim() == "title") a = a.Replace("LNK-TIT", t.Attributes[lang].Value.Trim()); if(t.Name.Trim() == "ardesc" && lang == "ar") a = a.Replace("LNK-DES", t.InnerXml.Trim()); if (t.Name.Trim() == "endesc" && lang == "en") a = a.Replace("LNK-DES", t.InnerXml.Trim()); } string r = sTemp.Replace("LNK-IMG", "img/icons/map/" + lnk.Attributes["img"].Value.Trim()); r = r.Replace("LNK-HREF", a); r = r.Replace("LNK-CAPT", lnk.Attributes[lang].Value.Trim()); rows += r; } tab = tab.Replace("LST-TAB", rows); //add to hash alinks.Add(key, tab); } return ""; } else return "No Map Links File Exists. Please Contact Technical Support"; } internal static string[] getMainContsLinks(string lang, out string err) { err = ""; try { string[] rt = new string[2]; string setFile = SitePath + "\\Content\\mainContLinks.xml"; if (File.Exists(setFile)) { XmlDocument xDoc = new XmlDocument(); xDoc.Load(setFile); XmlNode root = xDoc.DocumentElement; XmlNodeList mlst = root.ChildNodes; string xxl = ""; foreach (XmlNode nod in mlst) { int rnk = int.Parse(nod.Attributes["cnt"].Value.Trim()); XmlNodeList lst = nod.ChildNodes; string xl = ""; foreach (XmlNode lnod in lst) { string id = lnod.Attributes["id"].Value.Trim(); string tit = lnod.Attributes[lang.ToLower()].Value.Trim(); string hasslid = lnod.Attributes["hasSlid"].Value.Trim(); string hasimg = lnod.Attributes["hasImg"].Value.Trim(); string hascont = lnod.Attributes["contlnk"].Value.Trim(); if (rnk == 1) { //firs row string l = "<td><div class='lnkDiv'>HT-CON</div></td>"; string s = ""; if (hascont == "Y") s = "<h4><a href='content.aspx?id=" + id + "&sl=" + hasslid + "&im=" + hasimg + "'>" + tit + "</a></h4>" + getContShortDesc(lang, id); else s = "<h4>" + tit + "</h4>" + getContShortDesc(lang, id); l = l.Replace("HT-CON", s); rt[0] += l; } else { string l = "<td><div class='lnkDiv'>HT-CON</div></td>"; string s = ""; if (hascont == "Y") s = "<h4><a href='content.aspx?id=" + id + "&sl=" + hasslid + "&im=" + hasimg + "'>" + tit + "</a></h4>" + getContShortDesc(lang, id); else s = "<h4>" + tit + "</h4>" + getContShortDesc(lang, id); l = l.Replace("HT-CON", s); xl += l; } } xxl += "<tr>" + xl + "</tr>"; } xxl = xxl.Replace("<tr></tr>", ""); rt[1] = xxl; } else { rt = new string[] { "" }; err = "There are no Contents Specified. Please Contact Technical Support"; } return rt; } catch (Exception ex) { err = "Error: " + ex.Message; return new string[] { "" }; } } private static string getContShortDesc(string lang,string id) { string ret = ""; string fil = SitePath + "\\Content\\contlinks\\" + lang + "\\s\\" + id.Trim() + ".txt"; if (File.Exists(fil)) { StreamReader sr = new StreamReader(fil); ret = sr.ReadToEnd(); sr.Close(); sr.Dispose(); } else { if (lang == "ar") ret = "لايوجد ملف المختصر الدليل"; else ret = "No Short Description file for the link"; } return ret; } } internal struct xEventInfo { internal string Title; internal string ExternalUrl; internal string Image; internal string ShortInfo; internal string Description; internal string ID; }
please convert to vb.net
All-Star
193986 Points
28020 Posts
Moderator
Jul 21, 2014 06:31 AM|Mikesdotnetting|LINK
Try this: http://converter.telerik.com
Member
55 Points
435 Posts
Please convert code from c# to vb for load xml
Jul 21, 2014 06:18 AM|Mohammed Saleh|LINK
please convert to vb.net
All-Star
193986 Points
28020 Posts
Moderator
Re: Please convert code from c# to vb for load xml
Jul 21, 2014 06:31 AM|Mikesdotnetting|LINK
Try this: http://converter.telerik.com