Ejemplo n.º 1
0
 /// <summary>
 /// 封装shtml请求,如果是主页,找到其频道Guid,找到其主页,否则直接调用请求
 /// </summary>
 public static void AnyShtmlHeadBody(string index, Stream ns)
 {
     if (Path.GetFileName(index) != ConstService.INDEXSHTML)
     {
         ShtmlHeadBody(index, ns);
     }
     else
     {
         string channelStr  = PathService.GetUrlPath(index);;
         string channelGuid = PathService.GetChannelGuid(channelStr);
         if (!string.IsNullOrEmpty(channelGuid))
         {
             string shtmlIndex = TmpltAndPageService.GetIndexPath(channelGuid);
             if (!string.IsNullOrEmpty(shtmlIndex))
             {
                 shtmlIndex = EncodingService.EncodingUTF8(shtmlIndex.Substring(1));
                 ShtmlHeadBody(shtmlIndex, ns);
             }
             else
             {
                 WrongHeadBody(ns);
             }
         }
         else
         {
             WrongHeadBody(ns);
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 处理除shtml、php外的其他所有类型
 /// </summary>
 public static void OtherHeadBody(string index, string content_Type, Stream putoutStream)
 {
     try
     {
         string fileName = Path.GetFileName(index);
         string fileType = Path.GetExtension(index).Substring(1);
         //判断是否为CSS请求有责单独处理
         if (content_Type == HttpRequestType.Css.MimeType)
         {
             CssRequestHeadBody(index, putoutStream);
         }
         else
         {
             //判断是否为资源请求,有责找到资源路径(此时请求应均为资源)
             if (index.Substring(0, 2).Contains("Re"))
             {
                 index = PathService.GetResourcesFilePath(index);
             }
             else
             {
                 WrongHeadBody(putoutStream);
             }
             //先进行UTF8解码,再进行Gb2312转吗
             index = EncodingService.EncodingUTF8Change(index);
             if (File.Exists(index))
             {
                 LongFileHeadBody(index, putoutStream, content_Type);
             }
             else
             {
                 index = EncodingService.EncodingGB2312Change(index);
                 if (File.Exists(index))
                 {
                     LongFileHeadBody(index, putoutStream, content_Type);
                 }
                 else
                 {
                     WrongHeadBody(putoutStream);
                 }
             }
         }
     }
     catch (Exception e)
     {
         WrongHeadBody(putoutStream);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 通过两种编码方式获得对应的PageID,有则返回ID,否则反回空
        /// </summary>
        internal static string GetPageGuid(string index)
        {
            string url  = EncodingService.EncodingUTF8Change(index);
            string guid = GetShtmlRequestGuid(url);

            if (!string.IsNullOrEmpty(guid))
            {
                return(guid);
            }
            else
            {
                url  = EncodingService.EncodingGB2312Change(index);
                guid = GetShtmlRequestGuid(url);
                if (!string.IsNullOrEmpty(guid))
                {
                    return(guid);
                }
                else
                {
                    return(null);
                }
            }
        }