private bool ProcessServerLogEntry(string line, ServerLogEntryType type) { var timestamp = DateTime.Parse(line.Between("[", "] TRACE")); if (type == ServerLogEntryType.ServerLogGETIrmaWithToken) { // validate if token is the same var sessionToken = line.Between("url=/irma/", "/"); if (sessionToken != _currentIrmaSession.SessionToken) { return(false); } } if (type == ServerLogEntryType.ServerLogPOSTCommitments) { // validate if token is the same var sessionToken = line.Between("url=/irma/", "/commitments"); if (sessionToken != _currentIrmaSession.SessionToken) { return(false); } } // create the server log entry var serverLogEntry = new IrmaServerLogEntry { Id = Guid.NewGuid(), Timestamp = timestamp, Type = type, IrmaSessionId = _currentIrmaSession.Id }; // add and save _context.Add(serverLogEntry); _context.SaveChanges(); return(true); }
private static double CalculateServerToAppLogsTimestampDelta(List <IrmaAppLogEntry> appLogEntries, List <IrmaServerLogEntry> serverLogEntries, ServerLogEntryType startType, AppLogEntryType endType) { if (!serverLogEntries.Any() || !appLogEntries.Any()) { // there is something missing, indicate by -1 return(-1.0); } var endEntry = appLogEntries.FirstOrDefault(a => a.Type == endType); var startEntry = serverLogEntries.FirstOrDefault(a => a.Type == startType); var diff = endEntry.Timestamp - startEntry.Timestamp; if (endEntry == null || startEntry == null) { // there is something missing, indicate by -1 return(-1.0); } return(diff.TotalSeconds); }