public Task <EventSubscription> GetFirstOpenSubscription(string eventName, string eventKey, DateTime asOf)
        {
            var data = _subscriptionContainer.Value.GetItemLinqQueryable <PersistedSubscription>(true)
                       .FirstOrDefault(x => x.ExternalToken == null && x.EventName == eventName && x.EventKey == eventKey && x.SubscribeAsOf <= asOf);

            return(Task.FromResult(PersistedSubscription.ToInstance(data)));
        }
        public async Task <string> CreateEventSubscription(EventSubscription subscription)
        {
            subscription.Id = Guid.NewGuid().ToString();
            var result = await _subscriptionContainer.Value.CreateItemAsync(PersistedSubscription.FromInstance(subscription));

            return(result.Resource.id);
        }
        public Task <IEnumerable <EventSubscription> > GetSubscriptions(string eventName, string eventKey, DateTime asOf)
        {
            var data = _subscriptionContainer.Value.GetItemLinqQueryable <PersistedSubscription>(true)
                       .Where(x => x.EventName == eventName && x.EventKey == eventKey && x.SubscribeAsOf <= asOf)
                       .ToList()
                       .Select(x => PersistedSubscription.ToInstance(x));

            return(Task.FromResult(data.AsEnumerable()));
        }
Exemple #4
0
        internal static PersistedSubscription ToPersistable(this EventSubscription instance)
        {
            PersistedSubscription result = new PersistedSubscription();

            result.SubscriptionId = new Guid(instance.Id);
            result.EventKey       = instance.EventKey;
            result.EventName      = instance.EventName;
            result.StepId         = instance.StepId;
            result.WorkflowId     = instance.WorkflowId;

            return(result);
        }
Exemple #5
0
        internal static EventSubscription ToEventSubscription(this PersistedSubscription instance)
        {
            EventSubscription result = new EventSubscription();

            result.Id         = instance.SubscriptionId.ToString();
            result.EventKey   = instance.EventKey;
            result.EventName  = instance.EventName;
            result.StepId     = instance.StepId;
            result.WorkflowId = instance.WorkflowId;

            return(result);
        }
        internal static EventSubscription ToEventSubscription(this PersistedSubscription instance)
        {
            EventSubscription result = new EventSubscription();

            result.Id            = instance.SubscriptionId.ToString();
            result.EventKey      = instance.EventKey;
            result.EventName     = instance.EventName;
            result.StepId        = instance.StepId;
            result.WorkflowId    = instance.WorkflowId;
            result.SubscribeAsOf = DateTime.SpecifyKind(instance.SubscribeAsOf, DateTimeKind.Utc);

            return(result);
        }
        internal static PersistedSubscription ToPersistable(this EventSubscription instance)
        {
            PersistedSubscription result = new PersistedSubscription();

            result.SubscriptionId = new Guid(instance.Id);
            result.EventKey       = instance.EventKey;
            result.EventName      = instance.EventName;
            result.StepId         = instance.StepId;
            result.WorkflowId     = instance.WorkflowId;
            result.SubscribeAsOf  = DateTime.SpecifyKind(instance.SubscribeAsOf, DateTimeKind.Utc);

            return(result);
        }
Exemple #8
0
        internal static EventSubscription ToEventSubscription(this PersistedSubscription instance)
        {
            EventSubscription result = new EventSubscription();

            result.Id               = instance.SubscriptionId.ToString();
            result.EventKey         = instance.EventKey;
            result.EventName        = instance.EventName;
            result.StepId           = instance.StepId;
            result.WorkflowId       = instance.WorkflowId;
            result.SubscribeAsOf    = DateTime.SpecifyKind(instance.SubscribeAsOf, DateTimeKind.Utc);
            result.SubscriptionData = JsonConvert.DeserializeObject(instance.SubscriptionData, SerializerSettings);

            return(result);
        }
Exemple #9
0
        internal static PersistedSubscription ToPersistable(this EventSubscription instance)
        {
            PersistedSubscription result = new PersistedSubscription();

            result.Id                  = new Guid(instance.Id);
            result.EventKey            = instance.EventKey;
            result.EventName           = instance.EventName;
            result.StepId              = instance.StepId;
            result.ExecutionPointerId  = instance.ExecutionPointerId;
            result.WorkflowId          = instance.WorkflowId;
            result.SubscribeAsOf       = DateTime.SpecifyKind(instance.SubscribeAsOf, DateTimeKind.Utc);
            result.SubscriptionData    = JsonConvert.SerializeObject(instance.SubscriptionData, SerializerSettings);
            result.ExternalToken       = instance.ExternalToken;
            result.ExternalTokenExpiry = instance.ExternalTokenExpiry;
            result.ExternalWorkerId    = instance.ExternalWorkerId;

            return(result);
        }
Exemple #10
0
        public async Task <IEnumerable <EventSubscription> > GetSubscriptions(string eventName, string eventKey, DateTime asOf, CancellationToken cancellationToken)
        {
            var subscriptions = new List <EventSubscription>();

            using (FeedIterator <PersistedSubscription> feedIterator = _subscriptionContainer.Value.GetItemLinqQueryable <PersistedSubscription>()
                                                                       .Where(x => x.EventName == eventName && x.EventKey == eventKey && x.SubscribeAsOf <= asOf)
                                                                       .ToFeedIterator())
            {
                while (feedIterator.HasMoreResults)
                {
                    foreach (var item in await feedIterator.ReadNextAsync(cancellationToken))
                    {
                        subscriptions.Add(PersistedSubscription.ToInstance(item));
                    }
                }
            }

            return(subscriptions);
        }
Exemple #11
0
        public async Task <EventSubscription> GetFirstOpenSubscription(string eventName, string eventKey, DateTime asOf, CancellationToken cancellationToken)
        {
            EventSubscription eventSubscription = null;

            using (FeedIterator <PersistedSubscription> feedIterator = _subscriptionContainer.Value.GetItemLinqQueryable <PersistedSubscription>()
                                                                       .Where(x => x.ExternalToken == null && x.EventName == eventName && x.EventKey == eventKey && x.SubscribeAsOf <= asOf)
                                                                       .ToFeedIterator())
            {
                while (feedIterator.HasMoreResults && eventSubscription == null)
                {
                    foreach (var item in await feedIterator.ReadNextAsync(cancellationToken))
                    {
                        eventSubscription = PersistedSubscription.ToInstance(item);
                    }
                }
            }

            return(eventSubscription);
        }
Exemple #12
0
        internal static EventSubscription ToEventSubscription(this PersistedSubscription instance)
        {
            EventSubscription result = new EventSubscription();

            result.Id                 = instance.SubscriptionId.ToString();
            result.EventKey           = instance.EventKey;
            result.EventName          = instance.EventName;
            result.StepId             = instance.StepId;
            result.ExecutionPointerId = instance.ExecutionPointerId;
            result.WorkflowId         = instance.WorkflowId;
            result.SubscribeAsOf      = DateTime.SpecifyKind(instance.SubscribeAsOf, DateTimeKind.Utc);
            // Oz, Added a check to stop null exception.
            if (instance.SubscriptionData != null)
            {
                result.SubscriptionData = JsonConvert.DeserializeObject(instance.SubscriptionData, SerializerSettings);
            }
            result.ExternalToken       = instance.ExternalToken;
            result.ExternalTokenExpiry = instance.ExternalTokenExpiry;
            result.ExternalWorkerId    = instance.ExternalWorkerId;

            return(result);
        }
        public async Task <EventSubscription> GetSubscription(string eventSubscriptionId)
        {
            var resp = await _subscriptionContainer.Value.ReadItemAsync <PersistedSubscription>(eventSubscriptionId, new PartitionKey(eventSubscriptionId));

            return(PersistedSubscription.ToInstance(resp.Resource));
        }