Exemple #1
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);
            }
        }
        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);
        }
        void ReceiveStatuses(RestRequest request, RestResponse response, object userState)
        {
            Action<TwitterObjectCollection, RestResponse> action = userState as Action<TwitterObjectCollection, RestResponse>;

            var collection = new TwitterObjectCollection(response.Content);

            if (action != null)
                action(collection, response);
        }