Esempio n. 1
0
        public void OnLoad()
        {
            lastCheckTime = DateSync.GetLastCheckDate();

            var mentionOptions = new ListTweetsMentioningMeOptions
            {
                Count = 20,
            };

            var dmOption = new ListDirectMessagesReceivedOptions
            {
                Count = 20,
            };

            foreach (var account in Config.Accounts)
            {
                if (account.Preferences.MentionsPreferences != Library.Notifications.NotificationType.None)
                {
                    IsLoading = true;
                    Interlocked.Increment(ref requestsPending);
                    ServiceDispatcher.GetService(account).ListTweetsMentioningMe(mentionOptions, (t, r) => FilterAndAddStatuses(t.Cast <ITweetable>(), r)); // Ugh.
                }
                if (account.Preferences.MessagesPreferences != Library.Notifications.NotificationType.None)
                {
                    IsLoading = true;
                    Interlocked.Increment(ref requestsPending);
                    ServiceDispatcher.GetService(account).ListDirectMessagesReceived(dmOption, (t, r) => FilterAndAddStatuses(t.Cast <ITweetable>(), r));
                }
            }
#if WP8
            this.LoadFinished += (s, e) => SpeakNotifications();
#endif
        }
Esempio n. 2
0
        private void ReceiveTweetObjects(TweetType type, UserToken user, TwitterObjectCollection statuses, RestResponse response)
        {
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();
            WriteMemUsage("Received " + type.ToString());
            if (statuses == null || response.StatusCode != System.Net.HttpStatusCode.OK)
            {
                WriteMemUsage(type.ToString() + ": exit with error " + response.StatusDescription);
                return;
            }

            var CheckDate = DateSync.GetLastCheckDate();
            var ToastDate = DateSync.GetLastToastNotificationDate();

            if (CheckDate > ToastDate)
            {
                ToastDate = CheckDate;
            }

            var newStatuses      = statuses.Where(item => TwitterObjectIsOlderThan(item, CheckDate));
            var newToastStatuses = statuses.Where(item => TwitterObjectIsOlderThan(item, ToastDate));

            var tileStatuses  = newStatuses.Select(item => TwitterObjectToNotification(type, user.ScreenName, item));
            var toastStatuses = newToastStatuses.Select(item => TwitterObjectToNotification(type, user.ScreenName, item));

            var notPrefs = PreferencesForType(type, user);

            if (notPrefs == NotificationType.Tile || notPrefs == NotificationType.TileAndToast)
            {
                lock (notsSync)
                    tileNotifications.AddRange(tileStatuses);
            }

            if (notPrefs == NotificationType.Toast || notPrefs == NotificationType.TileAndToast)
            {
                lock (notsSync)
                    toastNotifications.AddRange(toastStatuses);
            }
        }