62,046
社区成员
发帖
与我相关
我的任务
分享
public static string getContentBysystenkeyword(object obj)
{
string content = "";
if (obj == null || obj.ToString().Trim() == "")
{
return "";
}
content = obj.ToString();
List<MSystemKeyword> list = HttpContext.Current.Cache["SystemKeyword"] as List<MSystemKeyword>;
if (list == null)
{
BSystemKeyword syskeywordbll = new BSystemKeyword();
syskeywordbll.path = HttpContext.Current.Server.MapPath("/App_Data/SystemKeywords.xml");
list = syskeywordbll.getList("Enabled=True");
if (list == null)
list = new List<MSystemKeyword>();
System.Web.Caching.CacheDependency dep = new System.Web.Caching.CacheDependency(
HttpContext.Current.Server.MapPath("/App_Data/SystemKeywords.xml"));
HttpContext.Current.Cache.Insert("SystemKeyword", list, dep);
}
foreach (MSystemKeyword m in list)
{
string target = " target=\"_blank\"";
content = System.Text.RegularExpressions.Regex.Replace(content, "(?<=[^>]*)(" + m.LookExpression + ")(?![^<]*</a>)", "<a title=\"" + m.Title + "\""
+ "alt=\"" + m.Alt + "\"" + target + " href=\"" + m.Link + "\">$1</a>");
}
return content;
}