public void Add(LoggedEntry loggedEntry) { using (DatabaseContext c = new DatabaseContext()) { c.LoggedEntries.Add(loggedEntry); c.SaveChanges(); } }
private string CreateUniqueKeyWithoutLocalTransactionId(LoggedEntry entry) { string backendTransactionId = entry.VirtualTransactionIdentifier ?? string.Empty; if (backendTransactionId.Contains("/")) { backendTransactionId = backendTransactionId.Substring(0, backendTransactionId.IndexOf("/") + 1); } return($"{entry.ApplicationName}_{entry.ProcessID}_{entry.RemoteHostAndPort}_{entry.SessionID}_{entry.UserName}_{backendTransactionId}"); }
public void AddLogForLogin(string username) { LoggedEntry newLog = new LoggedEntry(); newLog.TypeOfEntry = "Login"; newLog.Id = new Guid(); newLog.loggedUser = username; newLog.dateOfRegistration = DateTime.Now; LogRepository.Add(newLog); }
public void AddLogForFormatImport(string username) { LoggedEntry newLog = new LoggedEntry(); newLog.TypeOfEntry = "Import"; newLog.Id = Guid.NewGuid(); newLog.LoggedUser = username; newLog.DateOfRegistration = DateTime.Now; LogRepository.Add(newLog); }
private void FillResult(ref LoggedEntry result, LoggedEntry e) { if (!String.IsNullOrEmpty(e.ApplicationName)) { result.ApplicationName = e.ApplicationName; } if (!String.IsNullOrEmpty(e.DatabaseName)) { result.DatabaseName = e.DatabaseName; } if (e.Duration.TotalMilliseconds > 0) { result.Duration = e.Duration; } if (!String.IsNullOrEmpty(e.ProcessID)) { result.ProcessID = e.ProcessID; } if (!String.IsNullOrEmpty(e.RemoteHostAndPort)) { result.RemoteHostAndPort = e.RemoteHostAndPort; } if (!String.IsNullOrEmpty(e.SessionID)) { result.SessionID = e.SessionID; } if (!String.IsNullOrEmpty(e.Statement)) { result.Statement = e.Statement; } if (result.Timestamp == DateTime.MinValue) { result.Timestamp = e.Timestamp; } if (!String.IsNullOrEmpty(e.TransactionID)) { result.TransactionID = e.TransactionID; } if (!String.IsNullOrEmpty(e.UserName)) { result.UserName = e.UserName; } result.QueryTrees.AddRange(e.QueryTrees); result.PlanTrees.AddRange(e.PlanTrees); }
public IEnumerable <LoggedEntry> Provide() { List <LoggedEntry> result = new List <LoggedEntry>(); LoggedEntry currentResult = new LoggedEntry(); foreach (var e in entries) { FillResult(ref currentResult, e); if (!String.IsNullOrWhiteSpace(currentResult.Statement)) { result.Add(currentResult); currentResult = new LoggedEntry(); } } if (!result.Contains(currentResult) && !String.IsNullOrWhiteSpace(currentResult.Statement)) { result.Add(currentResult); } return(result.OrderBy(x => x.Timestamp)); }
public void Add(LoggedEntry entry) { entries.Add(entry); LastAccess = DateTime.Now; }
private string CreateUniqueKey(LoggedEntry entry) { return($"{entry.ApplicationName}_{entry.ProcessID}_{entry.RemoteHostAndPort}_{entry.SessionID}_{entry.UserName}_{entry.VirtualTransactionIdentifier}"); }
private LoggedEntry ProcessCache() { LoggedEntry result = null; if (this.cache.Count > 0) { var columns = String.Join("", this.cache).Split(new string[] { "ยค" }, StringSplitOptions.None); if (columns.Length >= 11) { result = new LoggedEntry(); result.ApplicationName = columns[2]; result.DatabaseName = columns[4]; result.ProcessID = columns[1]; result.RemoteHostAndPort = columns[5]; result.SessionID = columns[6]; if (!String.IsNullOrEmpty(columns[7])) { result.SessionLineNumber = long.Parse(columns[7]); } result.Timestamp = DateTimeOffset.FromUnixTimeMilliseconds((long)(double.Parse(columns[0], System.Globalization.CultureInfo.InvariantCulture) * 1000)).LocalDateTime; result.TransactionID = columns[9]; result.UserName = columns[3]; result.VirtualTransactionIdentifier = columns[8]; string input = columns[10]; result.Detail = input; Match match = null; if ( ((match = statementRegex.Match(input)) != null && match.Success) || ((match = statementRegex2.Match(input)) != null && match.Success) ) { var statementSubString = match.Value.Substring(match.Value.IndexOf("duration:") + 9); result.Statement = statementSubString.Substring(statementSubString.IndexOf(":") + 1).Trim(); if (result.Statement.EndsWith(";")) { result.Statement = result.Statement.Substring(0, result.Statement.Length - 1); // for normalization statement ending and not ending with ; should be same } if ((match = durationRegex.Match(match.Value)) != null && match.Success) { var durationStr = match.Value.Replace("ms", "").Substring(9).Trim(); double duration = 0; if (double.TryParse(durationStr, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out duration)) { result.Duration = TimeSpan.FromMilliseconds(duration); } } } else if ((match = queryRegex.Match(input)) != null && match.Success) { result.QueryTrees.Add(match.Value); } else if ((match = planRegex.Match(input)) != null && match.Success) { result.PlanTrees.Add(match.Value); } } this.cache.Clear(); } return(result); }