private void Connection_Notification(object sender, NpgsqlNotificationEventArgs e) { try { if (e.Condition == "events" || e.Condition == "aggregate_roots") { TraceSource.TraceEvent(TraceEventType.Verbose, 5137, "Postgres notification: {0} with {1}", e.Condition, e.AdditionalInformation); var firstSeparator = e.AdditionalInformation.IndexOf(':'); var name = e.AdditionalInformation.Substring(0, firstSeparator); var secondSeparator = e.AdditionalInformation.Substring(firstSeparator + 1).IndexOf(':'); var op = e.AdditionalInformation.Substring(firstSeparator + 1, secondSeparator).Trim(); var array = e.AdditionalInformation.Substring(firstSeparator + secondSeparator + 2).Trim(); if (array.Length > 0) { var uris = StringConverter.ParseCollection(Reader.Reuse(array), 0, false).ToArray(); switch (op) { case "Update": Subject.OnNext(new NotifyInfo(name, NotifyInfo.OperationEnum.Update, NotifyInfo.SourceEnum.Database, uris)); break; case "Change": Subject.OnNext(new NotifyInfo(name, NotifyInfo.OperationEnum.Change, NotifyInfo.SourceEnum.Database, uris)); break; case "Delete": Subject.OnNext(new NotifyInfo(name, NotifyInfo.OperationEnum.Delete, NotifyInfo.SourceEnum.Database, uris)); break; default: Subject.OnNext(new NotifyInfo(name, NotifyInfo.OperationEnum.Insert, NotifyInfo.SourceEnum.Database, uris)); break; } } } else if (e.Condition == "migration") { TraceSource.TraceEvent(TraceEventType.Information, 5155, "Postgres migration detected: {0} ", e.AdditionalInformation); SystemState.Notify(new SystemEvent("migration", e.AdditionalInformation)); } } catch (Exception ex) { TraceSource.TraceEvent(TraceEventType.Error, 5138, "{0}{1} {2}", e.Condition, e.AdditionalInformation, ex); } }