Ejemplo n.º 1
0
        private void SavePic(MySelfie.Scraper.InstagramObject.Datum data, string originalURL, string fileName)
        {
            var azureURL = this.StorePicture(originalURL, fileName);
            var urls = data.images.standard_resolution.url;
            var hashTags = "";

            try
            {
                hashTags = String.Join("|", data.tags.Select(x => x.To<string>()));
            }
            catch
            {

            }

            using (var db = new MySelfieEntities())
            {
                var entity = new Photo();

                entity.Username = data.user.username;
                entity.Text = data.caption.text;
                //entity.SocialCreatedAt = new DateTime(long.Parse(data.created_time));
                entity.SocialCreatedAt = DateTime.UtcNow;
                entity.SocialID = long.Parse(data.caption.id);
                entity.SocialIDstring = data.id;

                entity.HashTags = hashTags;
                entity.Urls = urls;

                entity.Filename = azureURL;
                entity.OriginalURL = originalURL;

                entity.Source = "Instagram";
                entity.HasPhoto = true;
                entity.CreatedAt = DateTime.UtcNow;
                entity.Approved = false;
                entity.Status = "new";
                entity.WallId = this._wallId;

                db.Photos.Add(entity);

                try
                {
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    Logger.Log("SaveTweetPic error: " + ex.ToString());
                }
            }
        }
Ejemplo n.º 2
0
        private void SaveTweetPic(ITweet tweet, string originalURL, string fileName)
        {
            var azureURL = this.StorePicture(originalURL, fileName);
            var urls = String.Join("|", tweet.Urls.Select(x => x.ExpandedURL));
            var hashTags = String.Join("|", tweet.Hashtags.Select(x => x.Text));

            using (var db = new MySelfieEntities())
            {
                var entity = new Photo();

                entity.Username = tweet.Creator.ScreenName;
                entity.Text = tweet.Text;
                entity.SocialCreatedAt = tweet.CreatedAt;
                entity.SocialID = tweet.Id;
                entity.SocialIDstring = tweet.IdStr;

                entity.HashTags = hashTags;
                entity.Urls = urls;

                entity.Filename = azureURL;
                entity.OriginalURL = originalURL;

                entity.Source = "Twitter";
                entity.HasPhoto = true;
                entity.CreatedAt = DateTime.UtcNow;
                entity.Approved = false;
                entity.Status = "new";
                entity.WallId = this._wallId;

                db.Photos.Add(entity);

                try
                {
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    Logger.Log("SaveTweetPic error: " + ex.ToString());
                }
            }
        }