示例#1
0
        /// <summary>
        /// Initialises a new instance of the FieldLogExceptionItem class.
        /// </summary>
        /// <param name="priority">The priority of the new log item.</param>
        /// <param name="type">The scope type.</param>
        /// <param name="name">The scope name.</param>
        /// <param name="webRequestData">The web request data. This parameter is required for the WebRequestStart scope type.</param>
        public FieldLogScopeItem(FieldLogPriority priority, FieldLogScopeType type, string name, FieldLogWebRequestData webRequestData)
            : base(priority)
        {
            Type  = type;
            Level = FL.ScopeLevel;
            Name  = name;

            if (Type == FieldLogScopeType.ThreadStart)
            {
                IsBackgroundThread = Thread.CurrentThread.IsBackground;
                IsPoolThread       = Thread.CurrentThread.IsThreadPoolThread;

                Thread = Thread.CurrentThread;
            }
            if (Type == FieldLogScopeType.LogStart)
            {
                EnvironmentData = FieldLogEventEnvironment.Current();
                Size           += EnvironmentData.Size;
            }
            if (Type == FieldLogScopeType.WebRequestStart)
            {
                if (webRequestData == null)
                {
                    throw new ArgumentNullException("webRequestData", "The webRequestData parameter is required for the WebRequestStart scope type.");
                }
                WebRequestData = webRequestData;
                Size          += WebRequestData.Size;
            }

            Size += 4 + 4 +
                    (Name != null ? Name.Length * 2 : 0) +
                    4 + 4 + 4 + 4 + 4;
        }
示例#2
0
        /// <summary>
        /// Reads the log item fields from the specified log file reader.
        /// </summary>
        /// <param name="reader">The log file reader to read from.</param>
        /// <param name="isRepeated">true if the log item is repeated from a previous file, false if it is written for the first time.</param>
        /// <returns>The read log item.</returns>
        internal static FieldLogScopeItem Read(FieldLogFileReader reader, bool isRepeated)
        {
            FieldLogScopeItem item = new FieldLogScopeItem();

            item.ReadBaseData(reader);
            item.IsRepeated = isRepeated;
            item.Type       = (FieldLogScopeType)reader.ReadByte();
            item.Level      = reader.ReadInt32();
            item.Name       = reader.ReadString();

            if (item.Type == FieldLogScopeType.ThreadStart)
            {
                byte flags = reader.ReadByte();
                item.IsBackgroundThread = (flags & 1) != 0;
                item.IsPoolThread       = (flags & 2) != 0;
            }
            if (item.Type == FieldLogScopeType.LogStart)
            {
                item.EnvironmentData = FieldLogEventEnvironment.Read(reader);
            }
            if (item.Type == FieldLogScopeType.WebRequestStart && reader.FormatVersion >= 2)
            {
                item.WebRequestData = FieldLogWebRequestData.Read(reader);
            }
            return(item);
        }
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="source">The FieldLogWebRequestData instance to copy from.</param>
 public FieldLogWebRequestData(FieldLogWebRequestData source)
 {
     RequestUrl = source.RequestUrl;
     Method = source.Method;
     ClientAddress = source.ClientAddress;
     ClientHostName = source.ClientHostName;
     Referrer = source.Referrer;
     UserAgent = source.UserAgent;
     AcceptLanguages = source.AcceptLanguages;
     Accept = source.Accept;
     WebSessionId = source.WebSessionId;
     AppUserId = source.AppUserId;
     AppUserName = source.AppUserName;
 }
示例#4
0
 /// <summary>
 /// Updates the current instance with data from another instance.
 /// </summary>
 /// <param name="source">The FieldLogWebRequestData instance to copy from.</param>
 public void UpdateFrom(FieldLogWebRequestData source)
 {
     RequestUrl      = source.RequestUrl;
     Method          = source.Method;
     ClientAddress   = source.ClientAddress;
     ClientHostName  = source.ClientHostName;
     Referrer        = source.Referrer;
     UserAgent       = source.UserAgent;
     AcceptLanguages = source.AcceptLanguages;
     Accept          = source.Accept;
     WebSessionId    = source.WebSessionId;
     AppUserId       = source.AppUserId;
     AppUserName     = source.AppUserName;
 }
示例#5
0
        /// <summary>
        /// Reads the FieldLogWebRequestData data from a log file reader.
        /// </summary>
        /// <param name="reader">Log file reader.</param>
        /// <returns>The web request data.</returns>
        internal static FieldLogWebRequestData Read(FieldLogFileReader reader)
        {
            FieldLogWebRequestData data = new FieldLogWebRequestData();

            data.RequestUrl      = reader.ReadString();
            data.Method          = reader.ReadString();
            data.ClientAddress   = reader.ReadString();
            data.ClientHostName  = reader.ReadString();
            data.Referrer        = reader.ReadString();
            data.UserAgent       = reader.ReadString();
            data.AcceptLanguages = reader.ReadString();
            data.Accept          = reader.ReadString();
            data.WebSessionId    = reader.ReadString();
            data.AppUserId       = reader.ReadString();
            data.AppUserName     = reader.ReadString();

            // Check if the environment is actually empty
            if (string.IsNullOrEmpty(data.RequestUrl))
            {
                return(FieldLogWebRequestData.Empty);
            }

            return(data);
        }
        /// <summary>
        /// Reads the FieldLogWebRequestData data from a log file reader.
        /// </summary>
        /// <param name="reader">Log file reader.</param>
        /// <returns>The web request data.</returns>
        internal static FieldLogWebRequestData Read(FieldLogFileReader reader)
        {
            FieldLogWebRequestData data = new FieldLogWebRequestData();
            data.RequestUrl = reader.ReadString();
            data.Method = reader.ReadString();
            data.ClientAddress = reader.ReadString();
            data.ClientHostName = reader.ReadString();
            data.Referrer = reader.ReadString();
            data.UserAgent = reader.ReadString();
            data.AcceptLanguages = reader.ReadString();
            data.Accept = reader.ReadString();
            data.WebSessionId = reader.ReadString();
            data.AppUserId = reader.ReadString();
            data.AppUserName = reader.ReadString();

            // Check if the environment is actually empty
            if (string.IsNullOrEmpty(data.RequestUrl))
                return FieldLogWebRequestData.Empty;

            return data;
        }
 /// <summary>
 /// Indicates whether the specified data variable is null or the Empty object.
 /// </summary>
 /// <param name="value">The variable to test.</param>
 /// <returns>true if the value parameter is null or the empty object; otherwise, false.</returns>
 public static bool IsNullOrEmpty(FieldLogWebRequestData value)
 {
     return value == null || value == FieldLogWebRequestData.Empty;
 }
示例#8
0
 /// <summary>
 /// Indicates whether the specified data variable is null or the Empty object.
 /// </summary>
 /// <param name="value">The variable to test.</param>
 /// <returns>true if the value parameter is null or the empty object; otherwise, false.</returns>
 public static bool IsNullOrEmpty(FieldLogWebRequestData value)
 {
     return(value == null || value == FieldLogWebRequestData.Empty);
 }
 public FieldLogWebRequestDataViewModel(FieldLogWebRequestData webRequestData, FieldLogItemViewModel itemVM)
 {
     this.WebRequestData = webRequestData;
     this.ItemVM = itemVM;
 }
示例#10
0
        /// <summary>
        /// Initialises a new instance of the FieldLogExceptionItem class.
        /// </summary>
        /// <param name="priority">The priority of the new log item.</param>
        /// <param name="type">The scope type.</param>
        /// <param name="name">The scope name.</param>
        /// <param name="webRequestData">The web request data. This parameter is required for the WebRequestStart scope type.</param>
        public FieldLogScopeItem(FieldLogPriority priority, FieldLogScopeType type, string name, FieldLogWebRequestData webRequestData)
            : base(priority)
        {
            Type = type;
            Level = FL.ScopeLevel;
            Name = name;

            if (Type == FieldLogScopeType.ThreadStart)
            {
                IsBackgroundThread = Thread.CurrentThread.IsBackground;
                IsPoolThread = Thread.CurrentThread.IsThreadPoolThread;

                Thread = Thread.CurrentThread;
            }
            if (Type == FieldLogScopeType.LogStart)
            {
                EnvironmentData = FieldLogEventEnvironment.Current();
                Size += EnvironmentData.Size;
            }
            if (Type == FieldLogScopeType.WebRequestStart)
            {
                if (webRequestData == null) throw new ArgumentNullException("webRequestData", "The webRequestData parameter is required for the WebRequestStart scope type.");
                WebRequestData = webRequestData;
                Size += WebRequestData.Size;
            }

            Size += 4 + 4 +
                (Name != null ? Name.Length * 2 : 0) +
                4 + 4 + 4 + 4 + 4;
        }