Пример #1
0
        /// <summary>
        /// 生成后台的单个文件
        /// </summary>
        /// <param name="Path">生成文件名已经路径</param>
        /// <param name="Content"></param>
        /// <param name="WebPath"></param>
        /// <returns></returns>
        public static void CreatAdminAspx(string Path, string Content, string type, string mediapath)
        {
            if (Content == "")
            {
                return;
            }
            string     FileName   = "";
            BaseConfig bf         = ShopCache.GetBaseConfig();
            string     WebPath    = Site.Instance.WebPath;
            string     serverpath = "";

            if (System.Web.HttpContext.Current == null)
            {
                serverpath = System.Web.HttpRuntime.AppDomainAppPath;
            }
            else
            {
                serverpath = System.Web.HttpContext.Current.Server.MapPath(@"~/");
            }
            try
            {
                Path     = ThemeUrl.GetFullPath(Path);
                FileName = ThemeUrl.GetFileName(Path);
                Path     = ThemeUrl.GetPath(Path);
                string PhysicsPath = serverpath + Path;
                if (!Directory.Exists(PhysicsPath))
                {
                    Directory.CreateDirectory(PhysicsPath);
                }
                string PhysicsFileName = serverpath + Path + FileName;
                if (System.IO.File.Exists(PhysicsFileName))
                {
                    System.IO.File.Delete(PhysicsFileName);
                }
                Content = DoCodeConvert(Content, type, WebPath, mediapath);
                //=============================================================
                //处理特殊页面引用

                string cs = RegexTool.GetRegValue(Content, @"{[Cc][Ll][Aa][Ss][Ss]:(.*?)}");
                if (cs != "")
                {
                    string pagehead = "<%@ Page Language=\"C#\" AutoEventWireup=\"true\" Inherits=\"" + cs + "\" validateRequest=\"false\"%>";
                    Content = RegexTool.ReplaceRegValue(Content, @"<%@ Page .*? %>", "");
                    Content = pagehead + Content;
                    //if (type == "supplier")
                    //    Content = Content.Replace("Shop.Bussiness.SupplierPageBase", cs);
                    //else
                    //    Content = Content.Replace("Shop.Bussiness.AdminPageBase", cs);
                }
                //处理资源路径
                string Path_JS    = WebPath + "/system/systempage/" + type + "/js";
                string Path_Image = WebPath + "/system/systempage/" + type + "/images";
                string Path_CSS   = WebPath + "/system/systempage/" + type + "/css";
                Path_JS    = RegexTool.ReplaceRegValue(Path_JS, @"//*/", "/");
                Path_Image = RegexTool.ReplaceRegValue(Path_Image, @"//*/", "/");
                Path_CSS   = RegexTool.ReplaceRegValue(Path_CSS, @"//*/", "/");
                Content    = RegexTool.ReplaceRegValue(Content, @"{/[Jj][Ss]}", Path_JS);
                Content    = RegexTool.ReplaceRegValue(Content, @"{/[Cc][Ss][Ss]}", Path_CSS);
                Content    = RegexTool.ReplaceRegValue(Content, @"{/[Ii][Mm][Aa][Gg][eE]}", Path_Image);
                Content    = RegexTool.ReplaceRegValue(Content, @"<!--.*?-->", "");
                Content    = RegexTool.ReplaceRegValue(Content, @"{[Cc][Ll][Aa][Ss][Ss]:.*?}", "");

                HtmlEngine.Instance.WriteFile(PhysicsFileName, Content);
            }
            catch (Exception ex)
            {
            }
        }