Beispiel #1
0
 public Params ParamsMerge(Model.URLReWriter modelurl, FileInfo path_templet, FileInfo path_target)
 {
     return(new Params()
     {
         URLReWriter = modelurl,
         PathTemplet = path_templet,
         PathTarget = path_target,
     });
 }
Beispiel #2
0
        /// <summary>
        /// 重写 URL 路径
        /// </summary>
        /// <param name="uri">用户原始请求信息</param>
        /// <returns>重定向路径, 如果为空则不处理</returns>
        private string ReWriteURLPath(Uri uri)
        {
            BLL.WebSite bllsite   = new BLL.WebSite();
            string      site_name = bllsite.MatchSiteName(uri.AbsolutePath);

            Model.WebSite modelsite = bllsite.GetModel(site_name);
            if (CheckData.IsObjectNull(modelsite))
            {
                return(string.Empty);
            }

            BLL.URLReWriter   bllurl   = new BLL.URLReWriter(modelsite);
            Model.URLReWriter modelurl = bllurl.GetItem_RequestURI(uri.AbsolutePath);

            if (CheckData.IsObjectNull(modelurl))
            {
                string resource_file     = bllurl.GetResourceFilePath(uri.AbsolutePath, bllsite);
                string abs_resource_file = PathHelp.ToAbsolute(resource_file);
                if (File.Exists(abs_resource_file))
                {
                    return(resource_file);
                }

                // 当得到的对象 为空的时候,证明没有此数据内容,当然也就不用生成了
                return(string.Empty);
            }

            FileInfo FItemp = new FileInfo(bllurl.GetFilePath_Templet(modelurl));

            if (!FItemp.Exists)
            {
                // 模板文件都不存在的话,就不用生成了
                return(string.Empty);
            }

            SystemConfig sys_config = GlobalSystemService.GetInstance().Config.Get <SystemConfig>();
            FileInfo     FItarget   = new FileInfo(bllurl.GetFilePath_Target(modelurl));

            if (sys_config.Is_DeBug || !FItarget.Exists || FItemp.LastWriteTime > FItarget.LastWriteTime)
            {
                // 生成模板
                HtmlToAspx        hta = new HtmlToAspx();
                HtmlToAspx.Params par = hta.ParamsMerge(modelurl, FItemp, FItarget);
                hta.Generate(par);
            }

            return(bllurl.HTTPRedirectPath(uri, modelurl));
        }