/// <summary> /// Loads the execution data. /// </summary> /// <param name="execution">The execution.</param> /// <returns></returns> public static byte[] LoadExecutionData(Execution execution) { if (execution == null) { throw new ArgumentNullException("execution"); } if (!execution.Application.HasValue) { throw new InvalidOperationException("Application must be set"); } if (string.IsNullOrEmpty(execution.Id)) { throw new InvalidOperationException("Id must be set"); } int executionId = int.Parse(execution.Id); using (var data = new Emdat.InVision.Sql.ReportingDataContext(execution.Application.Value, "Emdat.InVision.ReportContent")) { var result = data.GetExecutionData(executionId).FirstOrDefault(); if (result == null || result.Data == null) { throw new KeyNotFoundException(string.Format("Could not find data for report: {0}", executionId)); } return(result.Data); } }
/// <summary> /// Loads the execution data into the specified stream. /// </summary> /// <param name="execution">The execution.</param> /// <param name="stream">The stream.</param> public static void LoadExecutionData(Execution execution, Stream stream) { if (execution == null) { throw new ArgumentNullException("execution"); } if (stream == null) { throw new ArgumentNullException("stream"); } if (!stream.CanWrite) { throw new InvalidOperationException("Stream is not writable"); } if (!execution.Application.HasValue) { throw new InvalidOperationException("Application must be set"); } if (string.IsNullOrEmpty(execution.Id)) { throw new InvalidOperationException("Id must be set"); } int executionId = int.Parse(execution.Id); using (var data = new Emdat.InVision.Sql.ReportingDataContext(execution.Application.Value, "Emdat.InVision.ReportContent")) { var result = data.GetExecutionData(executionId, stream); if (result == null) { throw new KeyNotFoundException(string.Format("Could not find data for report: {0}", executionId)); } } }