public static async Task <NotificationLog> CreateNotificationLog(NotificationLogInfo notificationLogInfo, long notificationCount, IEnumerable <Notification> notificationList) { NotificationLogId first = null, next = null, previous = null; var isArchived = false; if (notificationLogInfo.TotalLogged > 0) { first = notificationLogInfo.NotificationLogId.First(EVENTS_PER_LOG, notificationLogInfo.TotalLogged); next = notificationLogInfo.NotificationLogId.Next(EVENTS_PER_LOG, notificationLogInfo.TotalLogged); previous = notificationLogInfo.NotificationLogId.Previous(EVENTS_PER_LOG, notificationLogInfo.TotalLogged); var currentLog = EventStore.CalculateCurrentNotificationLogId(notificationCount); isArchived = notificationLogInfo.NotificationLogId.High < currentLog.NotificationLogId.Low || ( notificationLogInfo.TotalLogged >= EVENTS_PER_LOG && notificationLogInfo.TotalLogged == notificationLogInfo.NotificationLogId.High && notificationLogInfo.NotificationLogId.High == currentLog.NotificationLogId.High ); } return(new NotificationLog( new NotificationLogId(notificationLogInfo.NotificationLogId), first, next, previous, notificationList, isArchived, (int)notificationCount )); }
public async Task <NotificationLog> GetLog(NotificationLogId logId, CancellationToken cancellationToken = default) { var connection = await this.GetCreateConnection(); var totalCount = await connection.Table <Notification>().CountAsync(); return(await this.GetLogCore(logId, totalCount, connection)); }
public async Task <NotificationLog> GetNotificationLog(string notificationLogId, CancellationToken cancellationToken = default) { if (!NotificationLogId.TryParse(notificationLogId, out NotificationLogId logId)) { throw new FormatException($"Specified {nameof(notificationLogId)} value of '{notificationLogId}' was not in the expected format."); } return(await this.eventStore.GetLog(logId, cancellationToken)); }
private async Task <NotificationLog> GetLogCore(NotificationLogId logId, int totalCount, SQLiteAsyncConnection connection, CancellationToken cancellationToken = default) { AssertionConcern.AssertMinimumMaximumValid(logId.Low, logId.High, nameof(logId.Low), nameof(logId.High)); AssertionConcern.AssertMinimum(logId.Low, totalCount > 0 ? 1 : 0, nameof(logId.Low)); var query = connection.Table <Notification>().Where(e => e.SequenceId >= logId.Low && e.SequenceId <= logId.High); var results = await query.ToListAsync(); // TODO: await this.CloseConnection(connection); return(await EventStore.CreateNotificationLog(logId, totalCount, results)); }
// TODO: private async Task CloseConnection(SQLiteAsyncConnection connection) //{ // await connection.CloseAsync(); // connection = null; // GC.Collect(); // GC.WaitForPendingFinalizers(); //} public static async Task <NotificationLog> CreateNotificationLog(NotificationLogId notificationLogId, long notificationCount, IEnumerable <Notification> notificationList) { AssertionConcern.AssertArgumentValid( l => (l % EVENTS_PER_LOG) == 0, notificationLogId.High, $"LogId 'High' value must be divisible by '{EVENTS_PER_LOG}'", nameof(notificationLogId) ); AssertionConcern.AssertArgumentValid( l => (notificationCount == 0 && l == 0) || ((l - 1 == 0) || ((l - 1) % EVENTS_PER_LOG) == 0), notificationLogId.Low, $"LogId 'Low' value must be equal to 1 or, 1 plus a number divisible by '{EVENTS_PER_LOG}'", nameof(notificationLogId) ); return(await EventStore.CreateNotificationLog(new NotificationLogInfo(notificationLogId, notificationCount), notificationCount, notificationList)); }
public NotificationLogInfo(NotificationLogId notificationLogId, long totalLogged) { this.notificationLogId = notificationLogId; this.totalLogged = totalLogged; }
public NotificationLogInfo(NotificationLogId notificationLogId, long totalLogged) { NotificationLogId = notificationLogId; TotalLogged = totalLogged; }
public NotificationLogInfo(NotificationLogId notificationLogId, long totalLogged) { this._notificationLogId = notificationLogId; this._totalLogged = totalLogged; }