Exemplo n.º 1
0
        internal async Task <bool> ProcessSubscriptions(FanInfo fanInfo)
        {
            var modified             = false;
            var newSubscriptions     = new HashSet <long>();
            var removedSubscriptions = new HashSet <long>();

            if (fanInfo.LastTransactionInfo.TransactionId <= _lastProcessedTransactionId)
            {
                return(false);
            }

            var fans = new HashSet <long>();

            foreach (var fanId in fanInfo.Fans)
            {
                fans.Add(fanId);
                if (!_subscriptions.ContainsKey(fanId))
                {
                    var info = new SubscriptionInfo(fanId, this)
                    {
                        Profile = (await ProfileManager.Current.GetProfileInfo(fanId, ProfileDownloadType.QueryStoredData, false)).Profile
                    };

                    _subscriptions.Add(fanId, info);
                    modified = true;
                    newSubscriptions.Add(fanId);
                }

                _lastProcessedTransactionId = fanInfo.LastTransactionInfo.TransactionId;
            }

            foreach (var subscription in _subscriptions)
            {
                if (!fans.Contains(subscription.Key))
                {
                    removedSubscriptions.Add(subscription.Key);
                }
            }

            foreach (var removed in removedSubscriptions)
            {
                _subscriptions.Remove(removed);
                modified = true;
            }

            foreach (var @new in newSubscriptions)
            {
                AddToBatch(@new);
            }

            return(modified);
        }
Exemplo n.º 2
0
        public void FacebookFanInfo_SetNextRunByNode()
        {
            FanInfo.SetNextRunIntervalByNode(FanInfo.ProcessorName, FanInfo.Context);

            Assert.AreEqual(FanInfo.Context.NextRun, DateTime.Today.AddDays(1));
        }