📄 viewchatlog.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;
using System.Text;
using System.IO;
using System.Xml.Xsl;
public partial class ViewChatLog : System.Web.UI.Page
{
int step = 0;
string sortBy = "Name";
protected void Page_Load(object sender, EventArgs e)
{
// if (!IsPostBack)
// {
if (Request["Act"] != null)
{
switch (Request["Act"].ToUpper())
{
case "LIST":
step = 1;
break;
case "READ":
step = 2;
break;
case "LOGIN":
if (clogin())
step = 1;
else
step = 0;
break;
default:
step = 0;
break;
}
}
if (Request["Sort"] == null)
{
sortBy = "Name";
}
else
{
if (Request["Sort"].ToString() == "Date")
sortBy = "Date";
}
if (Session["ChatLogin"] == null)
{
step = 0;
}
Response.Write(TransForm(buildDefaultXML(), "xslt/ViewChatLog.xsl", "<?xml version=\"1.0\" encoding=\"utf-8\"?>", "", Page));
//Response.Write(buildDefaultXML().InnerXml);
//Response.Write(Request["pass"]);
//Response.Write( list());
//}
}
private XmlDocument buildDefaultXML()
{
StringBuilder sb = new StringBuilder();
sb.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
sb.Append("<log>");
sb.Append(" <Global>");
sb.Append(" <Step>" + step.ToString() + "</Step>");
sb.Append(" <Sort>" + sortBy + "</Sort>");
sb.Append(" </Global>");
if (step != 0)
{
sb.Append("<FileList>");
sb.Append(getNameList());
sb.Append("</FileList>");
}
if (step == 2)
{
sb.Append("<fileContent>");
sb.Append(viewLog());
sb.Append("</fileContent>");
}
sb.Append("<CustType>" + getType() + "</CustType>");
sb.Append("</log>");
XmlDocument xd = new XmlDocument();
xd.LoadXml (sb.ToString());
return xd;
}
private bool clogin()
{
if (Request["name"] != null && Request["pass"] != null)
{
if (Request["name"].ToUpper() == "VCSALE" && Request["pass"].ToUpper() == "VCSALEADMIN")
{
Session["ChatLogin"] = true;
return true;
}
}
return false;
}
private string getType()
{
XmlDocument xd = new XmlDocument();
xd.Load(ConfigurationManager.AppSettings["path"].ToString() + "\\..\\CustServiceType.xml");
return xd.SelectSingleNode("//LH").InnerXml;
}
private string viewLog()
{
if (Request["f"] == null)
{
return "";
}
else
{
XmlDocument xd = new XmlDocument();
xd.Load(ConfigurationManager.AppSettings["path"].ToString() + "\\" + Request["f"].ToString());
return xd.SelectSingleNode("//root").InnerXml;
}
}
private string getNameList()
{
DirectoryInfo driInfo = new DirectoryInfo(ConfigurationManager.AppSettings["path"].ToString());
FileSystemInfo[] files = driInfo.GetFileSystemInfos();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < files.Length; i++)
{
string fileNameFULL = ((FileInfo)files[i]).FullName;
string fileName = fileNameFULL.Substring(fileNameFULL.LastIndexOf("\\")+1);
sb.Append(" <file Name=\"" + fileName.Substring(0,fileName.IndexOf("_")) + "\" Date=\"" + ((FileInfo)files[i]).CreationTime.ToShortDateString() + "\">" + fileName + "</file>");
}
return sb.ToString();
}
private static string TransForm(XmlDocument xd, string xslURL, string str, string replacestr,System.Web.UI.Page page)
{
XslTransform xsl = new XslTransform();
xsl.Load(page.Server.MapPath(xslURL));
System.IO.MemoryStream t = new System.IO.MemoryStream();
xsl.Transform(xd, null, t, null);
string resultString = System.Text.UTF8Encoding.UTF8.GetString(t.ToArray());
return resultString.Replace(str, replacestr);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -