public static DateTime Now(HttpContext context = null) { context = context ?? HttpContext.Current; if (!LoggingHelper.IsPlaying(context, null)) { return(DateTime.Now); } DateTime?nowTimestamp = null; DateTime?nowSetTimestamp = null; if (context.Session != null) { nowTimestamp = TimeHelper.UnixTimeStampToDateTime(Double.Parse(context.Session[Consts.NowTimestampTag] as string, CultureInfo.InvariantCulture)); nowSetTimestamp = TimeHelper.UnixTimeStampToDateTime(Double.Parse(context.Session[Consts.NowSetTimestampTag] as string, CultureInfo.InvariantCulture)); } else if (context.Request?.Headers != null) { nowTimestamp = TimeHelper.UnixTimeStampToDateTime(Double.Parse(context.Request.Headers[Consts.NowTimestampTag] as string, CultureInfo.InvariantCulture)); nowSetTimestamp = TimeHelper.UnixTimeStampToDateTime(Double.Parse(context.Request.Headers[Consts.NowSetTimestampTag] as string, CultureInfo.InvariantCulture)); } if (nowSetTimestamp == null || nowTimestamp == null) { throw new Exception("Failed to fetch LRAP-Now"); } return(nowTimestamp.Value + (DateTime.Now - nowSetTimestamp.Value)); }
private string BuildFilePath(LogElementDTO logElement, string filePath) { var timestamp = TimeHelper.UnixTimeStampToDateTime(logElement.UnixTimestamp); var fileName = $"{timestamp.ToString("yyyyMMddHHmmssffffff")}_{logElement.SessionGUID}__{logElement.PageGUID}_{logElement.LogType}_{prepareElementForIO(logElement.Element)}"; var filePathAndName = filePath.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar + fileName; var fileExtension = ".json"; var finalPath = filePathAndName + fileExtension; if (finalPath.Length > maxFilePathLength) { filePathAndName = filePathAndName.Substring(0, maxFilePathLength - fileExtension.Length); finalPath = filePathAndName + fileExtension; } return(finalPath); }