コード例 #1
0
        private bool ProcessAppLogEntry(string line, AppLogEntryType type)
        {
            if (type == AppLogEntryType.NewSession)
            {
                throw new ArgumentException("Use ProcessNewIrmaSessionAndLogEntry method", nameof(type));
            }

            // deconstruct line: [<timestamp>]| Receiving ..: | JSON object
            var     lineParts = line.Split('|');
            var     timestamp = DateTime.Parse(lineParts[0].Trim('[').Trim(']'));
            dynamic json      = JsonConvert.DeserializeObject <dynamic>(lineParts[2].Trim());

            // check the sessionId
            int sessionId = json.sessionId;

            if (sessionId == 0 || sessionId != _currentIrmaSession.AppSessionId)
            {
                return(false);
            }

            // create the log entry
            var appLogEntry = new IrmaAppLogEntry();

            appLogEntry.Id            = Guid.NewGuid();
            appLogEntry.Timestamp     = timestamp;
            appLogEntry.Type          = type;
            appLogEntry.IrmaSessionId = _currentIrmaSession.Id;

            // add and save
            _context.Add(appLogEntry);
            _context.SaveChanges();

            return(true);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        private static double CalculateApplogTimestampDelta(List <IrmaAppLogEntry> appLogEntries, AppLogEntryType startType, AppLogEntryType endType)
        {
            if (!appLogEntries.Any())
            {
                // there is something missing, indicate by -1
                return(-1.0);
            }

            var endEntry   = appLogEntries.FirstOrDefault(a => a.Type == endType);
            var startEntry = appLogEntries.FirstOrDefault(a => a.Type == startType);

            if (endEntry == null || startEntry == null)
            {
                // there is something missing, indicate by -1
                return(-1.0);
            }


            var diff = endEntry.Timestamp - startEntry.Timestamp;

            if (diff.Milliseconds < 0)
            {
                throw new ArithmeticException("Difference should not be negative");
            }
            return(diff.TotalSeconds);
        }