Example #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);
            }
        }
Example #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);
        }
        //forecast, just do delta from yesterday to today
        private void doForecast()
        {
            //TweetType
            int[] deltas = new int[numEmotions];
            int maxDelta=0;
            int tmpDelta = 0;
            int maxIndex=0;

            for(int i=0;i<numEmotions;i++){
                tmpDelta = tweetTypePercentage[i, numDays - 1] - tweetTypePercentage[i, numDays - 2];
                 if (tmpDelta > maxDelta)
                 {
                     maxDelta = tmpDelta;
                     maxIndex = i;
                 }
            }
            //set forecast type
            forecast = (TweetType)(maxIndex);

            //set image
            string imageForecastString = "Images/" + forecast.ToString().ToLower() + "Face.png";
            Uri uri = new Uri(imageForecastString, UriKind.Relative);
            StreamResourceInfo resourceInfo = Application.GetResourceStream(uri);
            BitmapImage bmp = new BitmapImage();
            bmp.SetSource(resourceInfo.Stream);

            imageForecast.Source = bmp;
        }