public static void LogSession(HttpContext context, Page page, NameValueCollection requestForm, bool before) { var logType = before ? LogType.OnPageSessionBefore : LogType.OnPageSessionAfter; NameValueCollection sessionValues = LoggingHelper.GetSessionValues(page); var postBackControlClientId = GetPostBackControlClientId(context, page, requestForm); var newLogElement = new LogElementDTO( guid: Guid.NewGuid(), sessionGUID: LoggingHelper.GetSessionGUID(context, page, () => new Guid(), requestForm).Value, pageGUID: LoggingHelper.GetPageGUID(context, page, () => new Guid(), requestForm).Value, bundleGUID: null, progressGUID: null, unixTimestamp: TimeHelper.UnixTimestamp(), logType: logType, element: LoggingHelper.StripUrlForLRAP(context.Request.RawUrl), element2: postBackControlClientId, 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, page, null, requestForm); var pageGUID = LoggingHelper.GetPageGUID(context, page, null, requestForm); if (LoggingHelper.FetchAndExecuteLogElement(serverGUID, sessionGUID, pageGUID, logType, (logElement) => { TimeHelper.SetNow(context, logElement.InstanceTime); if (logElement.Value != null) { NameValueCollection loggedSessionValues = SerializationHelper.DeserializeNameValueCollection(logElement.Value, SerializationType.Json); //Kan jo ikke bare overskrive... uden at spørge brugeren om det er det der ønskes, det kan ihf ikke være default behavior //LoggingHelper.SetSessionValues(page, 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); }
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); }