public static void LogSession(HttpContext context, NameValueCollection requestForm, bool before) { var logType = before ? LogType.OnHandlerSessionBefore : LogType.OnHandlerSessionAfter; var sessionValues = LoggingHelper.GetSessionValues(context); var newLogElement = new LogElementDTO( guid: Guid.NewGuid(), sessionGUID: LoggingHelper.GetSessionGUID(context, null, () => new Guid(), requestForm).Value, pageGUID: LoggingHelper.GetPageGUID(context, null, () => new Guid(), requestForm).Value, bundleGUID: null, progressGUID: null, unixTimestamp: TimeHelper.UnixTimestamp(), logType: logType, element: LoggingHelper.StripUrlForLRAP(context.Request.RawUrl), element2: null, value: sessionValues != null ? SerializationHelper.SerializeNameValueCollection(sessionValues, SerializationType.Json) : null, times: 1, unixTimestampEnd: null, instanceTime: DateTime.Now, stackTrace: null ); if (LoggingHelper.IsPlaying(context, requestForm)) { var serverGUID = LoggingHelper.GetServerGUID(context, () => { throw new Exception(); }, requestForm).Value; var sessionGUID = LoggingHelper.GetSessionGUID(context, null, null, requestForm); var pageGUID = LoggingHelper.GetPageGUID(context, null, null, requestForm); if (LoggingHelper.FetchAndExecuteLogElement(serverGUID, sessionGUID, pageGUID, logType, (logElement) => { TimeHelper.SetNow(context, logElement.InstanceTime); if (logElement.Value != null) { var loggedSessionValues = SerializationHelper.DeserializeNameValueCollection(logElement.Value, SerializationType.Json); LoggingHelper.SetSessionValues(context, loggedSessionValues); } else if (sessionValues != null) { throw new Exception("Session difference"); } PlayerCommunicationHelper.SetLogElementAsDone(serverGUID, sessionGUID, pageGUID, logElement.GUID, new JobStatus() { Success = true }); //, async: false); })) { return; } } LoggingHelper.LogElement(newLogElement); }