Пример #1
0
        public List <ManageThemeInfo> LoadThemes(long shopId = 0)
        {
            string imgPath = adminTemplateDic;

            if (shopId != 0)
            {
                imgPath = string.Format(sellerAdminTemplateDic, shopId);
            }
            XmlDocument            doc        = new XmlDocument();
            List <ManageThemeInfo> themesList = new List <ManageThemeInfo>();

            string[] temps = Directory.Exists(HttpContext.Current.Server.MapPath(imgPath))
                ? Directory.GetDirectories(HttpContext.Current.Server.MapPath(imgPath)) : null;
            if (temps == null)
            {
                return(themesList);
            }
            foreach (string dic in temps)
            {
                DirectoryInfo dirInfo = new DirectoryInfo(dic);
                string        dirName = dirInfo.Name.ToLower(CultureInfo.InvariantCulture);
                // 为了区分公共样式和专有样式,在公共样式前加"*"号加以区分
                //
                if ((dirName.Length > 0) && (!dirName.StartsWith("_")))
                {
                    FileInfo[] files = dirInfo.GetFiles("template.xml");
                    foreach (FileInfo file in files)
                    {
                        ManageThemeInfo theme  = new ManageThemeInfo();
                        FileStream      stream = file.OpenRead();
                        doc.Load(stream);
                        stream.Close();
                        theme.Name        = doc.SelectSingleNode("root/Name").InnerText;
                        theme.ThemeName   = dirName;
                        theme.ThemeImgUrl = string.Format("{0}{1}/{2}", imgPath, dirName, dirInfo.GetFiles("default.*")[0].Name);
                        if (dirName == tempLatePath)
                        {
                            templateCuName = doc.SelectSingleNode("root/Name").InnerText;
                        }
                        themesList.Add(theme);
                    }
                }
            }
            return(themesList);
        }
Пример #2
0
        /// <summary>
        /// 记在主题
        /// </summary>
        /// <param name="shopId"></param>
        /// <returns></returns>
        public List <ManageThemeInfo> LoadThemes(long shopId = 0L)
        {
            string path1 = "/Areas/Admin/Templates/vshop/";

            if (shopId != 0L)
            {
                path1 = string.Format("/Areas/SellerAdmin/Templates/vshop/{0}/", (object)shopId);
            }
            XmlDocument            xmlDocument = new XmlDocument();
            List <ManageThemeInfo> list        = new List <ManageThemeInfo>();

            foreach (string path2 in Directory.Exists(HttpContext.Current.Server.MapPath(path1)) ? Directory.GetDirectories(HttpContext.Current.Server.MapPath(path1)) : (string[])null)
            {
                DirectoryInfo directoryInfo = new DirectoryInfo(path2);
                string        str           = directoryInfo.Name.ToLower(CultureInfo.InvariantCulture);
                if (str.Length > 0 && !str.StartsWith("_"))
                {
                    foreach (FileInfo fileInfo in directoryInfo.GetFiles("template.xml"))
                    {
                        ManageThemeInfo manageThemeInfo = new ManageThemeInfo();
                        FileStream      fileStream      = fileInfo.OpenRead();
                        xmlDocument.Load((Stream)fileStream);
                        fileStream.Close();
                        manageThemeInfo.Name        = xmlDocument.SelectSingleNode("root/Name").InnerText;
                        manageThemeInfo.ThemeName   = str;
                        manageThemeInfo.ThemeImgUrl = string.Format("{0}{1}/{2}", (object)path1, (object)str, (object)directoryInfo.GetFiles("default.*")[0].Name);
                        if (str == this.tempLatePath)
                        {
                            this.templateCuName = xmlDocument.SelectSingleNode("root/Name").InnerText;
                        }
                        list.Add(manageThemeInfo);
                    }
                }
            }
            return(list);
        }