Пример #1
0
        public static void Load(string username)
        {
            try
            {
                db = new MPWebmasterEntities();
                db.Connection.Open();
                var setting = db.Settings.Single(s => s.Webmaster.Username == username);
                if (setting.Language == "VI")
                {
                    Lang = "VI";
                }
                else if (setting.Language == "EN")
                {
                    Lang = "EN";
                }

               
            }
            catch (Exception e)
            {
                Lang = "VI";//default languages
            }

            if(Lang == "EN")
                path = AppDomain.CurrentDomain.BaseDirectory + "\\Langs\\EN.xml";
            else if (Lang == "VI")
                path = AppDomain.CurrentDomain.BaseDirectory + "\\Langs\\VI.xml";

            //Load languages file
            XmlDocument doc = new XmlDocument();
                
            doc.Load(path);
            XmlElement root = doc.DocumentElement;
            XmlNodeList list = root.ChildNodes;
            if(Lang == "EN")
                ArrayEN = new TextName[list.Count];
            else if(Lang=="VI")
                ArrayVI = new TextName[list.Count];
            int i = 0;
            foreach (XmlNode n in list)
            {
                if (Lang == "EN")
                {
                    ArrayEN[i] = new TextName();
                    ArrayEN[i].Name = n.Attributes[0].InnerText;
                    ArrayEN[i].Value = n.Attributes[1].InnerText;
                }
                else if (Lang == "VI")
                {
                    ArrayVI[i] = new TextName();
                    ArrayVI[i].Name = n.Attributes[0].InnerText;
                    ArrayVI[i].Value = n.Attributes[1].InnerText;
 
                }
                i++;

            }
            currentLang = new TextName[list.Count];

            if (Lang == "EN")
            {
                currentLang = ArrayEN;
            }
            else
            {
                currentLang = ArrayVI;
            }

        }
Пример #2
0
 private string ReturnUserRole(string name)
 {
     MPWebmasterEntities db = new MPWebmasterEntities();
     UserInRole role = db.UserInRoles.Single(m=>m.Username==name);
     return role.Role.RoleName;
 }