📄 pagermanage.cs
字号:
item.Name = Path.GetFileNameWithoutExtension(info2.Name);
item.Type = document.SelectSingleNode("root/LabelType").InnerText;
item.Image = document.SelectSingleNode("root/LabelImage").InnerText;
item.Intro = document.SelectSingleNode("root/LabelIntro").InnerText;
if (string.IsNullOrEmpty(item.Image))
{
item.Image = "~/Admin/Images/LabelIco/def.ico";
}
item.UpDateTime = info2.LastWriteTime;
if (((type == item.Type) || string.IsNullOrEmpty(type)) || (type == "全部分类"))
{
list.Add(item);
}
}
}
catch (XmlException exception)
{
exception.ToString();
}
}
}
SiteCache.Insert(key, list, new CacheDependency(str2));
return list;
}
return (List<PagerManageInfo>) SiteCache.Get(key);
}
public static IList<PagerManageInfo> GetPagerList(string searchType, string keyword)
{
string str;
List<PagerManageInfo> list = new List<PagerManageInfo>();
if (HttpContext.Current != null)
{
str = HttpContext.Current.Server.MapPath("~/" + PagerLabelLibPath);
}
else
{
str = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, PagerLabelLibPath);
}
DirectoryInfo info = new DirectoryInfo(str);
if (info.Exists)
{
foreach (FileInfo info2 in info.GetFiles())
{
try
{
using (StreamReader reader = info2.OpenText())
{
XmlDocument document = new XmlDocument();
document.Load(reader);
PagerManageInfo item = new PagerManageInfo();
item.Name = Path.GetFileNameWithoutExtension(info2.Name);
item.Type = document.SelectSingleNode("root/LabelType").InnerText;
item.Image = document.SelectSingleNode("root/LabelImage").InnerText;
item.Intro = document.SelectSingleNode("root/LabelIntro").InnerText;
if (string.IsNullOrEmpty(item.Image))
{
item.Image = "~/Admin/Images/LabelIco/def.ico";
}
item.UpDateTime = info2.LastWriteTime;
if ((searchType == "0") && (item.Name.IndexOf(keyword, 0, StringComparison.CurrentCultureIgnoreCase) >= 0))
{
list.Add(item);
}
if ((searchType == "1") && (item.Template.ToString().IndexOf(keyword, 0, StringComparison.CurrentCultureIgnoreCase) >= 0))
{
list.Add(item);
}
}
}
catch (XmlException exception)
{
exception.ToString();
}
}
}
return list;
}
public static IList<PagerManageInfo> GetPagerTypeList()
{
string key = "CK_Label_PagerLabel_Type";
List<PagerManageInfo> list = new List<PagerManageInfo>();
if (SiteCache.Get(key) == null)
{
string str2;
List<string> list2 = new List<string>();
if (HttpContext.Current != null)
{
str2 = HttpContext.Current.Server.MapPath("~/" + PagerLabelLibPath);
}
else
{
str2 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, PagerLabelLibPath);
}
DirectoryInfo info = new DirectoryInfo(str2);
if (info.Exists)
{
foreach (FileInfo info2 in info.GetFiles())
{
XmlDocument document = new XmlDocument();
try
{
using (StreamReader reader = info2.OpenText())
{
document.Load(reader);
string innerText = document.SelectSingleNode("root/LabelType").InnerText;
if (!list2.Contains(innerText) && !string.IsNullOrEmpty(innerText))
{
list2.Add(innerText);
}
}
}
catch (XmlException exception)
{
exception.ToString();
}
}
}
foreach (string str4 in list2)
{
list.Add(new PagerManageInfo(str4));
}
SiteCache.Insert(key, list, new CacheDependency(str2));
return list;
}
return (List<PagerManageInfo>) SiteCache.Get(key);
}
public static bool Update(PagerManageInfo ainfo, string oldName)
{
string path = VirtualPathUtility.AppendTrailingSlash(HttpContext.Current.Server.MapPath("~/" + PagerLabelLibPath));
try
{
if (string.Compare(oldName, ainfo.Name, true) == 0)
{
path = path + ainfo.Name + ".config";
XmlDocument document = new XmlDocument();
XmlNode newChild = document.CreateNode(XmlNodeType.XmlDeclaration, "", "");
document.AppendChild(newChild);
XmlElement element = document.CreateElement("", "root", "");
XmlElement element2 = document.CreateElement("", "LabelType", "");
element2.InnerText = ainfo.Type;
element.AppendChild(element2);
XmlElement element3 = document.CreateElement("", "LabelImage", "");
element3.InnerText = ainfo.Image;
element.AppendChild(element3);
XmlElement element4 = document.CreateElement("", "LabelIntro", "");
element4.InnerText = ainfo.Intro;
element.AppendChild(element4);
XmlElement element5 = document.CreateElement("", "LabelTemplate", "");
element5.InnerText = ainfo.Template.ToString();
element.AppendChild(element5);
document.AppendChild(element);
using (StreamWriter writer = new StreamWriter(path, false, Encoding.GetEncoding("utf-8")))
{
writer.Write(document.InnerXml);
}
return true;
}
Delete(oldName);
return Add(ainfo);
}
catch (IOException)
{
return false;
}
catch (XmlException)
{
return false;
}
}
public static string PagerLabelLibPath
{
get
{
return SiteConfig.SiteOption.PagerLabelDir;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -