public static NServiceBus_Audit_Message To_NServiceBus_Audit_Message(this TransportMessage transportMessage) { var body = Encoding.UTF8.GetString(transportMessage.Body); var headers = transportMessage.Headers.ToDictionary(d => d.Key, r => r.Value); var audit = new NServiceBus_Audit_Message { Version = headers.Try_Get_And_Remove(Headers.NServiceBusVersion), WinIdName = headers.Try_Get_And_Remove(Headers.WindowsIdentityName), CorrId = headers.Try_Get_And_Remove(TransportHeaderKeys.IdForCorrelation), TimeSent = headers.Try_Get_And_Remove(NServiceBus.Unicast.Monitoring.Headers.TimeSent).To_DateTime(), ProcessingStarted = headers.Try_Get_And_Remove(NServiceBus.Unicast.Monitoring.Headers.ProcessingStarted).To_DateTime(), ProcessingEnded = headers.Try_Get_And_Remove(NServiceBus.Unicast.Monitoring.Headers.ProcessingEnded).To_DateTime(), OriginatingAddress = headers.Try_Get_And_Remove("NServiceBus.OriginatingAddress"), EnclosedMessageTypes = headers.Try_Get_And_Remove("NServiceBus.EnclosedMessageTypes") .Split(new[]{";"}, StringSplitOptions.RemoveEmptyEntries), XmlBody = body, Message_Id = transportMessage.Id, CorrelationId = transportMessage.CorrelationId, IdForCorrelation = transportMessage.IdForCorrelation, MessageIntent = transportMessage.MessageIntent + "", ReplyToAddress = transportMessage.ReplyToAddress.ToString(), }; audit.Headers = headers.Select(p => new Header { Name = p.Key, Value = p.Value }).ToList(); return audit; }
public void Append(NServiceBus_Audit_Message message) { Session.Store(message); Session.SaveChanges(); }