/// <summary>
        /// Checks and sets a specific value to the DB and adds a Social Media Message
        /// </summary>
        /// <param name="tweet">tweetenvi tweet object</param>
        /// <param name="MediaType">MediaType</param>
        private void SetSocialMediaMessage(ITweet tweet, int MediaType = 0)
        {
            Location                     location;
            LocationController           locationController           = new LocationController();
            SocialMediaMessageController socialMediaMessageController = new SocialMediaMessageController();

            if (tweet.Coordinates != null)
            {
                location = new Location(tweet.Coordinates.Latitude, tweet.Coordinates.Longitude);
            }
            else
            {
                location = Offence.Location;
            }
            int messageID = socialMediaMessageController.SetSocialMediaMessage(new SocialMediaMessage(0, tweet.CreatedAt, tweet.Text, tweet.CreatedBy.Name, tweet.CreatedBy.ScreenName, location, tweet.Id, Offence, MediaType));

            SocialMediaImageController imageController = new SocialMediaImageController();

            foreach (var media in tweet.Media)
            {
                imageController.SetSocialMediaImage(new SocialMediaImage
                {
                    SocialMediaMessageID = messageID,
                    URL = media.MediaURLHttps
                });
            }
        }
Beispiel #2
0
        /// <summary>
        /// instantiates the window
        /// </summary>
        /// <param name="offence">data to be shown</param>
        public DelictDialog(Offence offence)
        {
            InitializeComponent();
            _controller        = new DelictDialogController();
            _messageController = new SocialMediaMessageController();

            wpfDelict.DataContext = offence;
            _controller.DisplayMessages(offence, wpfLVMessages);
            _controller.RetrieveWitnessMessages(offence);
            _controller.DisplayMessages(offence, WitnessMessages, 1);

            foreach (SocialMediaMessage message in wpfLVMessages.ItemsSource)
            {
                foreach (SocialMediaImage image in message.Media)
                {
                    _images.Add(image.URL, new Image {
                        Source = new BitmapImage(new Uri(image.URL))
                    });
                }
            }
        }
        /// <summary>
        /// Function checks if new social Media Messages have been posted and adds them to the DB
        /// </summary>
        public void UpdateSocialMediaMessages(int MediaType = 0)
        {
            try
            {
                Connect();
                var tweets = Search.SearchTweets(_searchParameters);
                SocialMediaMessageController mediaMessageController = new SocialMediaMessageController();

                foreach (var tweet in tweets)
                {
                    if (mediaMessageController.GetTweetSocialMediaMessage(tweet.Id) == null)
                    {
                        SetSocialMediaMessage(tweet, MediaType);
                    }
                }
            }

            catch (Exception)
            {
                // Twitter API Request has been failed; Bad request, network failure or unauthorized request
                Logger.Log.ErrorEventHandler(this);
            }
        }
Beispiel #4
0
 /// <summary>
 /// Window for display of socialMediaMessages in the radius of the given offence
 /// </summary>
 /// <param name="pin"></param>
 /// <param name="offenceListItems"></param>
 public DelictDialogController()
 {
     _controller = new SocialMediaMessageController();
 }