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
        public static DateSync ConvertToDateSync(DateTime date)
        {
            var result = new DateSync();

            result.Day    = date.Day;
            result.Month  = date.Month;
            result.Year   = date.Year;
            result.Hour   = date.Hour;
            result.Minute = date.Minute;
            return(result);
        }
Esempio n. 3
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);
            }
        }
Esempio n. 4
0
 public static DateTime ConvertToDateTime(DateSync date)
 {
     return(new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, 0));
 }