|
@@ -7,73 +7,50 @@ using System.Threading.Tasks;
|
|
|
|
|
|
namespace Hotline.Application.Bulletin
|
|
|
{
|
|
|
- public class BulletinApplication: IBulletinApplication
|
|
|
+ public class BulletinApplication : IBulletinApplication
|
|
|
{
|
|
|
|
|
|
public string GetSiteUrls(string sHtmlText)
|
|
|
{
|
|
|
-
|
|
|
- ////临时内容
|
|
|
- //System.Text.StringBuilder sb = new StringBuilder();
|
|
|
- //sb.Append(sHtmlText);
|
|
|
- //// 定义正则表达式用来匹配 img 标签
|
|
|
- //Regex regImg = new Regex(@"<img\b[^<>]*?\bsrc[\s\t\r\n]*=[\s\t\r\n]*[""']?[\s\t\r\n]*(?<imgUrl>[^\s\t\r\n""'<>]*)[^<>]*?/?[\s\t\r\n]*>", RegexOptions.IgnoreCase);
|
|
|
- //// 搜索匹配的字符串
|
|
|
- //MatchCollection matches = regImg.Matches(sHtmlText);
|
|
|
-
|
|
|
-
|
|
|
- //// 定义正则表达式用来匹配 video 标签
|
|
|
- //Regex regvideo = new Regex(@"<video\b[^<>]*?\bsrc[\s\t\r\n]*=[\s\t\r\n]*[""']?[\s\t\r\n]*(?<imgUrl>[^\s\t\r\n""'<>]*)[^<>]*?/?[\s\t\r\n]*>", RegexOptions.IgnoreCase);
|
|
|
- //// 搜索匹配的字符串
|
|
|
- //MatchCollection matchesvideo = regvideo.Matches(sHtmlText);
|
|
|
-
|
|
|
- //// 获取服务器地址配置
|
|
|
- //string strSiteUrl = BaseClass.SysBase.e_GetXMLValue("SysWebSite");
|
|
|
- //string getfileurl = BaseClass.SysBase.e_GetXMLValue("getfileurl");
|
|
|
- //// 取得匹配项列表 视频
|
|
|
- //foreach (Match match in matchesvideo)
|
|
|
- //{
|
|
|
- // if (-1 < match.Groups["imgUrl"].Value.IndexOf(getfileurl))
|
|
|
- // {
|
|
|
- // string imgUrlId = match.Groups["imgUrl"].Value;
|
|
|
- // int idStart = imgUrlId.IndexOf("?id=");
|
|
|
- // if (idStart > 0)
|
|
|
- // {
|
|
|
- // var fileid = imgUrlId.Substring(idStart + 4, 36);
|
|
|
- // string newfileurl = GetFileUrl(imgUrlId.Substring(idStart + 4, 36));
|
|
|
- // sb = sb.Replace(match.Groups["imgUrl"].Value, newfileurl);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // else if (-1 == match.Groups["imgUrl"].Value.IndexOf("http"))
|
|
|
- // {
|
|
|
- // sb.Replace(match.Groups["imgUrl"].Value, strSiteUrl + match.Groups["imgUrl"].Value);
|
|
|
- // sb.Replace(strSiteUrl + strSiteUrl + match.Groups["imgUrl"].Value, strSiteUrl + match.Groups["imgUrl"].Value);
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
- //// 取得匹配项列表
|
|
|
- //foreach (Match match in matches)
|
|
|
- //{
|
|
|
- // if (-1 < match.Groups["imgUrl"].Value.IndexOf(getfileurl))
|
|
|
- // {
|
|
|
- // string imgUrlId = match.Groups["imgUrl"].Value;
|
|
|
- // int idStart = imgUrlId.IndexOf("?id=");
|
|
|
- // if (idStart > 0)
|
|
|
- // {
|
|
|
- // var fileid = imgUrlId.Substring(idStart + 4, 36);
|
|
|
- // string newfileurl = GetFileUrl(imgUrlId.Substring(idStart + 4, 36));
|
|
|
- // sb = sb.Replace(match.Groups["imgUrl"].Value, newfileurl);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // else if (-1 == match.Groups["imgUrl"].Value.IndexOf("http"))
|
|
|
- // {
|
|
|
- // sb.Replace(match.Groups["imgUrl"].Value, strSiteUrl + match.Groups["imgUrl"].Value);
|
|
|
- // sb.Replace(strSiteUrl + strSiteUrl + match.Groups["imgUrl"].Value, strSiteUrl + match.Groups["imgUrl"].Value);
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
- //return sb.ToString();
|
|
|
- return "";
|
|
|
+ sHtmlText = sHtmlText.Replace("<", "<").Replace(">", ">");
|
|
|
+
|
|
|
+ //临时内容
|
|
|
+ System.Text.StringBuilder sb = new StringBuilder();
|
|
|
+ sb.Append(sHtmlText);
|
|
|
+ // 定义正则表达式用来匹配 img 标签
|
|
|
+ Regex regImg = new Regex(@"<img\b[^<>]*?\bsrc[\s\t\r\n]*=[\s\t\r\n]*[""']?[\s\t\r\n]*(?<imgUrl>[^\s\t\r\n""'<>]*)[^<>]*?/?[\s\t\r\n]*>", RegexOptions.IgnoreCase);
|
|
|
+ // 搜索匹配的字符串
|
|
|
+ MatchCollection matches = regImg.Matches(sHtmlText);
|
|
|
+
|
|
|
+ // 定义正则表达式用来匹配 video 标签
|
|
|
+ Regex regvideo = new Regex(@"<video\b[^<>]*?\bsrc[\s\t\r\n]*=[\s\t\r\n]*[""']?[\s\t\r\n]*(?<imgUrl>[^\s\t\r\n""'<>]*)[^<>]*?/?[\s\t\r\n]*>", RegexOptions.IgnoreCase);
|
|
|
+ // 搜索匹配的字符串
|
|
|
+ MatchCollection matchesvideo = regvideo.Matches(sHtmlText);
|
|
|
+
|
|
|
+ // 获取服务器地址配置
|
|
|
+ string strSiteUrl = "OldFilesUrls";// BaseClass.SysBase.e_GetXMLValue("OldFilesUrls");
|
|
|
+
|
|
|
+ // 取得匹配项列表 视频
|
|
|
+ foreach (Match match in matchesvideo)
|
|
|
+ {
|
|
|
+ if (-1 == match.Groups["imgUrl"].Value.IndexOf("http"))
|
|
|
+ {
|
|
|
+ sb.Replace(match.Groups["imgUrl"].Value, strSiteUrl + match.Groups["imgUrl"].Value);
|
|
|
+ sb.Replace(strSiteUrl + strSiteUrl + match.Groups["imgUrl"].Value, strSiteUrl + match.Groups["imgUrl"].Value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 取得匹配项列表
|
|
|
+ foreach (Match match in matches)
|
|
|
+ {
|
|
|
+ if (-1 == match.Groups["imgUrl"].Value.IndexOf("http"))
|
|
|
+ {
|
|
|
+ sb.Replace(match.Groups["imgUrl"].Value, strSiteUrl + match.Groups["imgUrl"].Value);
|
|
|
+ sb.Replace(strSiteUrl + strSiteUrl + match.Groups["imgUrl"].Value, strSiteUrl + match.Groups["imgUrl"].Value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return sb.ToString();
|
|
|
}
|
|
|
}
|
|
|
}
|