private static async Task <Subscriptions> MigrateSubscriptions(IAsyncDocumentSession session, SubscriptionClient localClient)
        {
            logger.Info("Migrating subscriptions to new format");

            var subscriptions = new Subscriptions();

            using (var stream = await session.Advanced.StreamAsync <Subscription>("Subscriptions")
                                .ConfigureAwait(false))
            {
                while (await stream.MoveNextAsync().ConfigureAwait(false))
                {
                    var existingSubscription = stream.Current.Document;
                    existingSubscription.Subscribers.Remove(localClient);
                    subscriptions.All.Add(existingSubscription.Id.Replace("Subscriptions/", String.Empty), existingSubscription);
                    await session.Advanced.DocumentStore.AsyncDatabaseCommands.DeleteAsync(stream.Current.Key, null)
                    .ConfigureAwait(false);
                }
            }

            await session.StoreAsync(subscriptions, Subscriptions.SingleDocumentId).ConfigureAwait(false);

            await session.SaveChangesAsync().ConfigureAwait(false);

            return(subscriptions);
        }
示例#2
0
 bool Equals(SubscriptionClient obj) => string.Equals(TransportAddress, obj.TransportAddress,
                                                      StringComparison.InvariantCultureIgnoreCase);