private T GetDetails <T>(NotificationTableValue ntv) where T : INotificationDetails, new() { if (ntv == null || ntv.Json.TryGet(nameof(AlertRaised.Details), out BlittableJsonReaderObject detailsJson) == false || detailsJson == null) { return(new T()); } return((T)EntityToBlittable.ConvertToEntity(typeof(T), null, detailsJson, DocumentConventions.Default)); }
private T GetDetails <T>(NotificationTableValue ntv) where T : INotificationDetails, new() { if (ntv == null || ntv.Json.TryGet(nameof(AlertRaised.Details), out BlittableJsonReaderObject detailsJson) == false || detailsJson == null) { return(new T()); } return(DocumentConventions.DefaultForServer.Serialization.DefaultConverter.FromBlittable <T>(detailsJson)); }
public IDisposable Read(string id, out NotificationTableValue value) { using (var scope = new DisposableScope()) { RavenTransaction tx; scope.EnsureDispose(_contextPool.AllocateOperationContext(out TransactionOperationContext context)); scope.EnsureDispose(tx = context.OpenReadTransaction()); value = Get(id, context, tx); return(scope.Delay()); } }
private static void ThrowCouldNotFindNotificationType(NotificationTableValue action) { string notificationJson; try { notificationJson = action.Json.ToString(); } catch (Exception e) { notificationJson = $"invalid json - {e.Message}"; } throw new InvalidOperationException( $"Could not find notification type. Notification: {notificationJson}, created at: {action.CreatedAt}, postponed until: {action.PostponedUntil}"); }