Ejemplo n.º 1
0
        private async Task HandleInstrumentSettingsChanged(StringBuilder state, string name, AuditMessage auditMessage)
        {
            var assetDisplayId = GetAssetDisplayId(auditMessage);

            if (!string.IsNullOrWhiteSpace(assetDisplayId))
            {
                state.AppendLine($"Asset DisplayId: {assetDisplayId}");
            }

            var assetPairName = GetAssetPairName(auditMessage);

            if (!string.IsNullOrWhiteSpace(assetPairName))
            {
                state.AppendLine($"AssetPair Name: {assetPairName}");
            }

            if (auditMessage.SettingsChangeType == SettingsChangeType.Modified)
            {
                foreach (var key in auditMessage.PreviousValues.Keys)
                {
                    if (auditMessage.CurrentValues[key] != auditMessage.PreviousValues[key])
                    {
                        state.AppendLine(
                            $"{name}-{key} {auditMessage.CurrentValues[key]} ({auditMessage.PreviousValues[key]})");
                    }
                }
            }
            else if (auditMessage.SettingsChangeType == SettingsChangeType.Created ||
                     auditMessage.SettingsChangeType == SettingsChangeType.Deleted)
            {
                state.AppendLine($"{name}");
            }
            else
            {
                await _log.WriteWarningAsync(nameof(NettingEngineAuditProvider), nameof(GetAuditMessage),
                                             $"auditMessage: {auditMessage.ToJson()}",
                                             "Unrecognized SettingsChangeType in audit message.");
            }
        }
Ejemplo n.º 2
0
        private async Task <string> GetAuditMessage(AuditMessage auditMessage)
        {
            var state = new StringBuilder();

            state.AppendLine($"======= {DateTime.UtcNow:yyyy/MM/dd HH:mm:ss} =======\r\n");
            state.AppendLine("Netting Engine audit event:\r\n");

            state.AppendLine($"User: {auditMessage.ClientId}");
            state.Append($"{auditMessage.EventType}");
            if (auditMessage.SettingsChangeType != SettingsChangeType.None)
            {
                state.Append($" ({auditMessage.SettingsChangeType})");
            }
            state.AppendLine(":");
            state.AppendLine();

            switch (auditMessage.EventType)
            {
            case AuditEventType.InstrumentStarted:
            case AuditEventType.InstrumentStopped:
                state.AppendLine($"{GetInstrument(auditMessage)}");
                break;

            case AuditEventType.InstrumentSettingsChanged:
                await HandleInstrumentSettingsChanged(state, GetInstrument(auditMessage), auditMessage);

                break;

            case AuditEventType.HedgeSettingsChanged:
                await HandleInstrumentSettingsChanged(state, GetAsset(auditMessage), auditMessage);

                break;

            default:
                await _log.WriteWarningAsync(nameof(NettingEngineAuditProvider), nameof(GetAuditMessage), $"auditMessage: {auditMessage.ToJson()}",
                                             "Unrecognized AuditEventType in audit message.");

                break;
            }

            return(state.ToString());
        }
Ejemplo n.º 3
0
 private async Task ProcessMessageAsync(AuditMessage auditMessage)
 {
     try
     {
         await _handler.Publish(auditMessage);
     }
     catch (Exception ex)
     {
         await _log.WriteErrorAsync(nameof(NettingEngineAuditSubscriber), nameof(ProcessMessageAsync), $"auditMessage {auditMessage.ToJson()}", ex);
     }
 }