📄 loginfo.cs
字号:
using System;
using System.Xml.Serialization;
using DotNetNuke.Services.Exceptions;
//
// DotNetNuke - http://www.dotnetnuke.com
// Copyright (c) 2002-2005
// by Shaun Walker ( sales@perpetualmotion.ca ) of Perpetual Motion Interactive Systems Inc. ( http://www.perpetualmotion.ca )
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions
// of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
namespace DotNetNuke.Services.Log.EventLog
{
[XmlRoot("log", IsNullable=false)]
public class LogInfo
{
#region "Private Members"
private string logGuid;
private string logFileID;
private string logTypeKey;
private int logUserID;
private string logUserName;
private int logPortalID;
private string logPortalName;
private DateTime logCreateDate;
private long logCreateDateNum;
private bool bypassBuffering;
private string logServerName;
private LogProperties logProperties;
private string logConfigID;
#endregion
#region "Constructors"
public LogInfo()
{
this.logGuid = Guid.NewGuid().ToString();
this.bypassBuffering = false;
this.logProperties = new LogProperties();
this.logPortalID = - 1;
this.logPortalName = string.Empty;
this.logUserID = - 1;
this.logUserName = string.Empty;
}
#endregion
#region "Properties"
[XmlAttribute("LogGUID")]
public string LogGUID
{
get { return this.logGuid; }
set { this.logGuid = value; }
}
[XmlAttribute("LogFileID")]
public string LogFileID
{
get { return this.logFileID; }
set { this.logFileID = value; }
}
[XmlAttribute("LogTypeKey")]
public string LogTypeKey
{
get { return this.logTypeKey; }
set { this.logTypeKey = value; }
}
[XmlAttribute("LogUserID")]
public int LogUserID
{
get { return this.logUserID; }
set { this.logUserID = value; }
}
[XmlAttribute("LogUserName")]
public string LogUserName
{
get { return this.logUserName; }
set { this.logUserName = value; }
}
[XmlAttribute("LogPortalID")]
public int LogPortalID
{
get { return this.logPortalID; }
set { this.logPortalID = value; }
}
[XmlAttribute("LogPortalName")]
public string LogPortalName
{
get { return this.logPortalName; }
set { this.logPortalName = value; }
}
[XmlAttribute("LogCreateDate")]
public DateTime LogCreateDate
{
get { return this.logCreateDate; }
set { this.logCreateDate = value; }
}
[XmlAttribute("LogCreateDateNum")]
public long LogCreateDateNum
{
get { return this.logCreateDateNum; }
set { this.logCreateDateNum = value; }
}
[XmlArray("properties"), XmlArrayItem(ElementName="property", Type=typeof(LogDetailInfo))]
public LogProperties LogProperties
{
get { return this.logProperties; }
set { this.logProperties = value; }
}
[XmlAttribute("BypassBuffering")]
public bool BypassBuffering
{
get { return this.bypassBuffering; }
set { this.bypassBuffering = value; }
}
[XmlAttribute("LogServerName")]
public string LogServerName
{
get { return this.logServerName; }
set { this.logServerName = value; }
}
[XmlAttribute("LogConfigID")]
public string LogConfigID
{
get { return this.logConfigID; }
set { this.logConfigID = value; }
}
#endregion
#region "Public Methods"
public void AddProperty (string propertyName, string propertyValue)
{
try
{
if (propertyName.Length > 50)
{
propertyName = propertyName.Substring(0, 50);
}
if (propertyValue.Length > 500)
{
propertyValue = "(TRUNCATED TO 500 CHARS): " + propertyValue.Substring(0, 500);
}
LogDetailInfo logDetailInfo = new LogDetailInfo();
logDetailInfo.PropertyName = propertyName;
logDetailInfo.PropertyValue = propertyValue;
logProperties.Add(logDetailInfo);
}
catch (Exception exception)
{
Exceptions.Exceptions.ProcessPageLoadException(exception);
}
}
public static bool IsSystemType(string propertyName)
{
switch (propertyName)
{
case "LogGUID":
case "LogFileID":
case "LogTypeKey":
case "LogCreateDate":
case "LogCreateDateNum":
case "LogPortalID":
case "LogPortalName":
case "LogUserID":
case "LogUserName":
case "BypassBuffering":
case "LogServerName":
return true;
default:
return false;
}
}
public override string ToString()
{
System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
stringBuilder.Append("<b>LogGUID:</b> " + this.logGuid + "<br>");
stringBuilder.Append("<b>LogType:</b> " + this.logTypeKey + "<br>");
stringBuilder.Append("<b>UserID:</b> " + this.logUserID.ToString() + "<br>");
stringBuilder.Append("<b>Username:</b> " + this.logUserName + "<br>");
stringBuilder.Append("<b>PortalID:</b> " + this.logPortalID.ToString() + "<br>");
stringBuilder.Append("<b>PortalName:</b> " + this.logPortalName + "<br>");
stringBuilder.Append("<b>CreateDate:</b> " + this.logCreateDate.ToString() + "<br>");
stringBuilder.Append("<b>ServerName:</b> " + this.logServerName + "<br>");
stringBuilder.Append(this.logProperties.ToString());
return stringBuilder.ToString();
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -