Exemple #1
0
        private LogElementInfo BuildLogElementInfo(string filePath)
        {
            var fileName = System.IO.Path.GetFileName(filePath);
            var r        = new Regex("^([^_]+)_+([^_]+)_+([^_]+)_+([^_]+).+$");
            var m        = r.Match(fileName);

            if (m.Success)
            {
                var timestamp   = DateTime.ParseExact(m.Groups[1].Value, "yyyyMMddHHmmssffffff", null);
                var sessionGUID = new Guid(m.Groups[2].Value);
                var pageGUID    = new Guid(m.Groups[3].Value);

                LogType logType;
                if (m.Groups[4].Value == "OnAjaxRequestSend")
                {
                    logType = LogType.OnHandlerRequestSend;
                }
                else if (m.Groups[4].Value == "OnAjaxRequestReceived")
                {
                    logType = LogType.OnHandlerRequestReceived;
                }
                else if (m.Groups[4].Value == "OnAjaxResponseSend")
                {
                    logType = LogType.OnHandlerResponseSend;
                }
                else if (m.Groups[4].Value == "OnAjaxResponseReceived")
                {
                    logType = LogType.OnHandlerResponseReceived;
                }
                else
                if (!LogType.TryParse(m.Groups[4].Value, false, out logType))
                {
                    throw new Exception($"Unknown logtype ({m.Groups[4].Value})");
                }

                return(new LogElementInfo()
                {
                    FilePath = filePath,
                    Timestamp = timestamp,
                    SessionGUID = sessionGUID,
                    PageGUID = pageGUID,
                    LogType = logType
                });
            }

            throw new Exception("Invalid logelement ({fileName})");
        }