private void CreateCollectionExecutionWithError(string requestId, string errorMessage) { using (var session = Repository.GetSession()) { var executionLogBuilder = new Probe.Common.BasicClasses.ExecutionLogBuilder(); executionLogBuilder.AnErrorOccurred(String.Format("An error occurred while collect execution (see server log for more details): '{0}'", errorMessage)); executionLogBuilder.EndCollect(); var logEntries = executionLogBuilder.BuildExecutionLogs(); var collectFactory = new Entities.CollectFactory(session); var executionWithError = collectFactory.CreateAProbeExecutionWithError("", logEntries); var collectRequest = Repository.GetCollectRequest(session, requestId); var collectExecution = collectFactory.CreateCollectExecution(session, collectRequest); collectExecution.ProbeExecutions.Add(executionWithError); collectRequest.SetResultError(); collectRequest.Close(); session.SaveChanges(); } }