Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Details")] FeedItemModel feedItemModel)
        {
            if (id != feedItemModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(feedItemModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FeedItemModelExists(feedItemModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(feedItemModel));
        }
Beispiel #2
0
        public FeedItemModel ParseFeedUrl(string rssUrl, bool isValid)
        {
            WebClient     wclient       = new WebClient();
            string        rssData       = wclient.DownloadString(rssUrl);
            XDocument     xml           = XDocument.Parse(rssData);
            FeedItemModel feedItemModel = new FeedItemModel();

            var feed = _feedRepo.GetSingleResult(x => x.Url == rssUrl);

            if (feed == null)
            {
                var feedModel = new FeedModel
                {
                    Name = rssUrl,
                    Url  = rssUrl
                };
                this.Save(feedModel);
                feedItemModel.Url_Id = feed.Id;
            }
            else
            {
                feedItemModel.Url_Id = feed.Id;
            }

            feedItemModel.FeedXML = xml.ToString();
            return(feedItemModel);
        }
Beispiel #3
0
        public ActionResult MarketplaceFeed()
        {
            var result = _services.Cache.Get("Dashboard.MarketplaceFeed", () => {
                try
                {
                    string url        = "http://community.smartstore.com/index.php?/rss/downloads/";
                    var request       = (HttpWebRequest)WebRequest.Create(url);
                    request.Timeout   = 3000;
                    request.UserAgent = "SmartStore.NET {0}".FormatInvariant(SmartStoreVersion.CurrentFullVersion);

                    using (WebResponse response = request.GetResponse())
                    {
                        using (var reader = XmlReader.Create(response.GetResponseStream()))
                        {
                            var feed  = SyndicationFeed.Load(reader);
                            var model = new List <FeedItemModel>();
                            foreach (var item in feed.Items)
                            {
                                if (!item.Id.EndsWith("error=1", StringComparison.OrdinalIgnoreCase))
                                {
                                    var modelItem         = new FeedItemModel();
                                    modelItem.Title       = item.Title.Text;
                                    modelItem.Summary     = item.Summary.Text.RemoveHtml().Truncate(150, "...");
                                    modelItem.PublishDate = item.PublishDate.LocalDateTime.RelativeFormat();

                                    var link = item.Links.FirstOrDefault();
                                    if (link != null)
                                    {
                                        modelItem.Link = link.Uri.ToString();
                                    }

                                    model.Add(modelItem);
                                }
                            }

                            return(model);
                        }
                    }
                }
                catch (Exception ex)
                {
                    return(new List <FeedItemModel> {
                        new FeedItemModel {
                            IsError = true, Summary = ex.Message
                        }
                    });
                }
            }, 720 /* 12 h */);

            if (result.Any() && result.First().IsError)
            {
                ModelState.AddModelError("", result.First().Summary);
            }

            return(PartialView(result));
        }
        private void OnBlogSelectAsync(FeedItemModel item)
        {
            var psi = new ProcessStartInfo
            {
                FileName        = item.Link,
                UseShellExecute = true
            };

            Process.Start(psi);
        }
        private void OnRemoveFromPublish(FeedItemModel blogPost)
        {
            using var dbContext = new DailyDevDbContext();
            var existingEntry = dbContext.TempLinks.Where(x => x.FeedPostId == blogPost.Id).FirstOrDefault();

            if (existingEntry != null)
            {
                dbContext.TempLinks.Remove(existingEntry);
                dbContext.SaveChanges();
            }
        }
Beispiel #6
0
        public async Task <IActionResult> Create([Bind("Id,Title,Details")] FeedItemModel feedItemModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(feedItemModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(feedItemModel));
        }
        private void OnAddToPublish(FeedItemModel blogPost)
        {
            using var dbContext = new DailyDevDbContext();
            var hasEixtingEntry = dbContext.TempLinks.Any(x => x.FeedPostId == blogPost.Id);

            if (!hasEixtingEntry)
            {
                dbContext.TempLinks.Add(new TempLink {
                    FeedPostId = blogPost.Id, Author = blogPost.Author, Title = blogPost.Title, Url = blogPost.Link
                });
                dbContext.SaveChanges();
            }
        }
Beispiel #8
0
        public void Save(FeedItemModel model)
        {
            var feed = _newsItemRepo.GetSingleResult(x => x.Url_Id == model.Url_Id);

            if (feed == null)
            {
                _newsItemRepo.Save(this._modelMapper.ModelMapper.Map <FeedItem>(model));
            }
            else
            {
                feed.FeedXML = model.FeedXML;
                _newsItemRepo.Update(feed);
            }
        }
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var result = await Services.Cache.GetAsync("admin:marketplacefeed", async() =>
            {
                try
                {
                    string url        = "http://community.smartstore.com/index.php?/rss/downloads/";
                    var request       = (HttpWebRequest)WebRequest.Create(url);
                    request.Timeout   = 3000;
                    request.UserAgent = $"Smartstore {SmartstoreVersion.CurrentFullVersion}";

                    using WebResponse response = await request.GetResponseAsync();
                    using var reader           = XmlReader.Create(response.GetResponseStream());
                    var feed  = SyndicationFeed.Load(reader);
                    var model = new List <FeedItemModel>();
                    foreach (var item in feed.Items)
                    {
                        if (!item.Id.EndsWith("error=1", StringComparison.OrdinalIgnoreCase))
                        {
                            var modelItem = new FeedItemModel
                            {
                                Title       = item.Title.Text,
                                Summary     = item.Summary.Text.RemoveHtml().Truncate(150, "..."),
                                PublishDate = item.PublishDate.LocalDateTime.Humanize()
                            };

                            var link = item.Links.FirstOrDefault();
                            if (link != null)
                            {
                                modelItem.Link = link.Uri.ToString();
                            }

                            model.Add(modelItem);
                        }
                    }

                    return(model);
                }
                catch (Exception ex)
                {
                    return(new List <FeedItemModel> {
                        new FeedItemModel {
                            IsError = true, Summary = ex.Message
                        }
                    });
                }
            });
        //private void AddNewComments(FeedItemModel listItem, string comment)
        //{
        //    var row = Items.IndexOf(listItem);
        //    if (listItem.FilteredEngagementList == null)
        //    {
        //        listItem.FilteredEngagementList = new List<FeedEngagementModel>();
        //    }
        //    //Must add correct comment to local storage and current collection
        //    var autor = SL.Profile.UserName; //listItem.Header.Actor + " " + listItem.Header.ActionText == string.Empty ? "author" : listItem.Header.Actor + " " + listItem.Header.ActionText;
        //    listItem.FilteredEngagementList.Add(new FeedEngagementModel { EngagementType = "COMMENT", FeedTextQuoteID = 5, ID = 5, Notes = comment, UserName = autor });

        //    if (!listItem.LayoutSections.Contains(Enums.FeedContentType.Engagement))
        //    {
        //        var list = listItem.LayoutSections.ToList();
        //        list.Add(FeedContentType.Engagement);
        //        listItem.LayoutSections = list.ToArray();
        //    }
        //}

        public void UpdateComments(FeedItemModel item, string comment = "")
        {
            //{
            //    var listItem = ItemsSource?.Where(x => x.ID == item.ID).FirstOrDefault();
            //    if (listItem != null)
            //    {
            //        if (!string.IsNullOrEmpty(comment))
            //        {
            //            AddNewComments(listItem, comment);
            //        }
            //        listItem.TextQuote.IsModified = true;
            //        //FeedTableView.ShowLoader();
            //        //UpdateCommentView(item);
            //        //FeedTableView.HideLoader();
            //    }
            //}
        }
        private void LoadAction()
        {
            FeedItems?.Clear();
            SelectedFeedItem = null;

            using (XmlReader reader = XmlReader.Create(FeedURL))
            {
                SyndicationFeed feed = SyndicationFeed.Load(reader);

                //Next step, getting Images from Comic feeds/etc.
                foreach (SyndicationItem item in feed.Items)
                {
                    FeedItems.Add(FeedItemModel.FromSyndicationItem(item));
                }
            }

            OnPropertyChanged(nameof(FeedItems));
        }
        public void UpdateLike(FeedItemModel feedItem)
        {
            if (feedItem.Likes > 1)
            {
                _likeTextView.Text = string.Format("{0} likes", feedItem.Likes);
            }
            else
            {
                _likeTextView.Text = string.Format("{0} like", feedItem.Likes);
            }

            if (feedItem.DidLike == true)
            {
                _likesIcon.ImagePath = "res:ic_heart_icon_on";
                _likesIcon.Reload();
                return;
            }
            _likesIcon.ImagePath = "res:ic_heart_icon_off";
            _likesIcon.Reload();
        }
Beispiel #13
0
        //public async override Task Refresh()
        //{
        //    if (Platform.IsInternetConnectionAvailable() == false)
        //    {
        //        return;
        //    }
        //    await base.Refresh();
        //    await RefreshFeed();
        //    await RefreshProfile();
        //}


        public void OnFeedItemSelected(FeedItemModel model)
        {
            //HideAreaCollection();

            if (_didFeedActionInvoked)
            {
                return;
            }

            if (!_didFeedActionInvoked)
            {
                _didFeedActionInvoked = true;
                if ((model?.BaseContent as FeedContentImageModel)?.TapAction != null)
                {
                    ActionHandlerService service = new ActionHandlerService();
                    service.HandleActionAsync((model.BaseContent as FeedContentImageModel).TapAction, model.ActionType);
                    _didFeedActionInvoked = false;
                    return;
                }

                if (model?.BaseContent?.TapAction != null)
                {
                    ActionHandlerService service = new ActionHandlerService();
                    service.HandleActionAsync(model.BaseContent.TapAction, model.ActionType);
                    _didFeedActionInvoked = false;
                    return;
                }

                if (model?.ActionDictionary != null && model.ActionDictionary.Keys.Contains("View It"))
                {
                    var    viewItAction = model.ActionDictionary["View It"];
                    string url          = viewItAction.ActionParamDict["FeedURL"];
                    RefreshFeedByUrl(url);
                    _didFeedActionInvoked = false;
                }
                _didFeedActionInvoked = false;
            }
        }
Beispiel #14
0
 public void PostComment(FeedItemModel item)
 {
     ViewModel.CommentFeedCommand.Execute(item);
 }
 public void UpdateFeedItem(FeedItemModel feedItemModel)
 {
     ShowComments(feedItemModel.FilteredEngagementList);
 }
Beispiel #16
0
 public void PostLike(FeedItemModel item)
 {
     ViewModel.LikeFeedCommand.Execute(item);
 }
Beispiel #17
0
        public void PostComment(int position)
        {
            FeedItemModel item = (FeedItemModel)GetItem(position);

            Delegate.PostComment(item);
        }
Beispiel #18
0
 public virtual void UpdateCellData(FeedItemModel item)
 {
 }
Beispiel #19
0
        public int GetItemPosition(FeedItemModel feedItemModel)
        {
            var position = base.GetViewPosition(feedItemModel);

            return(position);
        }
Beispiel #20
0
 public void LoadProfileDetails(FeedItemModel feedItem, MvxCachedImageView image)
 {
     AnimatedUserImage     = image;
     AnimatedUserImagePath = AnimatedUserImage.ImagePath;
     ViewModel.LoadFeedByUrlCommand.Execute(feedItem);
 }
Beispiel #21
0
 public void PostReportIt(FeedItemModel feedItem)
 {
     ViewModel.PostReportItCommand.Execute(feedItem);
 }
Beispiel #22
0
        public void LoadProfileDetails(int position, MvxCachedImageView image)
        {
            FeedItemModel item = (FeedItemModel)GetItem(position);

            Delegate.LoadProfileDetails(item, image);
        }
Beispiel #23
0
 public void InviteToJoinClick(FeedItemModel feedItem)
 {
     ViewModel.InviteToJoinCommand.Execute(feedItem);
 }
Beispiel #24
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            int lastItemPosition = ItemCount - 1;

            if (position == lastItemPosition)
            {
                Delegate.LoadNextPage();
            }

            FeedCellHolder feedCellHolder = holder as FeedCellHolder;
            FeedItemModel  item           = (FeedItemModel)GetItem(position);

            if (feedCellHolder != null)
            {
                feedCellHolder.UpdateLayoutSections(item.LayoutSections, item.BaseContent, item.ChallengeTypeDisplayName);

                feedCellHolder.OnShowAllCommentsButtonClicked = new Action(() =>
                {
                    feedCellHolder.ShowCommentsWithEmoji(item.FilteredEngagementList.Where(x => x.EngagementType == "COMMENT").ToList());
                });
                GoogleMap           map        = feedCellHolder.CurrentMap;
                FeedContentMapModel mapContent = item.BaseContent as FeedContentMapModel;
                if ((mapContent != null) && (map != null))
                {
                    //GoogleMapHelper.UpdateMapZoom(map, mapContent.Lat, mapContent.Long, 5);

                    //map.MoveCamera(CameraUpdateFactory.NewLatLng(new Android.Gms.Maps.Model.LatLng(mapContent.Lat, mapContent.Long)));
                    //CameraUpdate zoom = CameraUpdateFactory.ZoomTo(15);
                    //map.AnimateCamera(zoom);
                }
                //ChallengeName, OfferName  ChallengeTypeDisplayName
                if (item.AggregateProfileImageUrls != null)
                {
                    var textEnd = item.ChallengeTypeDisplayName == null || item.ChallengeTypeDisplayName == string.Empty ? "reward" : "challenge";
                    var aggText = item.AggregateProfileImageUrls.Count.ToString() + (item.AggregateProfileImageUrls.Count > 1 ? " people" : " person") + " completed this " + textEnd;
                    feedCellHolder.SetAggregateViewText(aggText);
                }
                if (item.Header != null)
                {
                    string emojiString;
                    try
                    {
                        if (!string.IsNullOrEmpty(item.Header.Actor))
                        {
                            var      convertStr = string.Join("-", System.Text.RegularExpressions.Regex.Matches(item.Header.Actor, @"..").Cast <System.Text.RegularExpressions.Match>().ToList());
                            string[] tempArr    = convertStr.Split('-');
                            byte[]   decBytes   = new byte[tempArr.Length];
                            for (int i = 0; i < tempArr.Length; i++)
                            {
                                decBytes[i] = System.Convert.ToByte(tempArr[i], 16);
                            }
                            string strWithEmoji = Encoding.BigEndianUnicode.GetString(decBytes, 0, decBytes.Length);
                            emojiString = strWithEmoji;
                        }
                        else
                        {
                            emojiString = item.Header.Actor;
                        }
                    }
                    catch (FormatException)
                    {
                        emojiString = item.Header.Actor;
                    }

                    var titleText = string.IsNullOrEmpty(item.Header.Actor) ? item.Header.ActionText : emojiString + " " + item.Header.ActionText;
                    feedCellHolder.SetTitleViewText(titleText);
                }
                if (item.HasComments)
                {
                    //var engagementList = item.FilteredEngagementList.Where(x => x.EngagementType == "COMMENT").ToList();
                    //feedCellHolder.ShowComments(engagementList.GetRange(0, 3));
                }
            }
            base.OnBindViewHolder(holder, position);
        }
        public static List <FeedItemModel> GetFeedItems(string feedUrl)
        {
            var xmlDoc    = new XmlDocument();
            var feedItems = new List <FeedItemModel>();

            try
            {
                WebRequest req = HttpWebRequest.Create(feedUrl);
                using (Stream stream = req.GetResponse().GetResponseStream())
                {
                    using (StreamReader oReader = new StreamReader(stream, Encoding.GetEncoding("UTF-8")))
                    {
                        xmlDoc.Load(oReader);
                    }
                }
                var nTable    = xmlDoc.NameTable;
                var nsManager = new XmlNamespaceManager(nTable);
                nsManager.AddNamespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
                nsManager.AddNamespace("item", "http://purl.org/rss/1.0/");
                nsManager.AddNamespace("dc", "http://purl.org/dc/elements/1.1/");

                var xmlItems = xmlDoc.DocumentElement.SelectNodes("//rdf:RDF/item:item", nsManager);


                foreach (XmlNode currentItem in xmlItems)
                {
                    var title = currentItem.SelectSingleNode("item:title", nsManager).InnerText;
                    var link  = currentItem.SelectSingleNode("item:link", nsManager).InnerText;
                    var desc  = string.Empty;

                    try
                    {
                        desc = currentItem.SelectSingleNode("item:description", nsManager).InnerText;
                    }
                    catch (Exception ex)
                    {
                    }

                    Uri uri     = new Uri(link);
                    var id      = Path.GetFileName(uri.AbsolutePath).Replace(".html", "");
                    var siteurl = string.Format("{0}://{1}/", uri.Scheme, uri.DnsSafeHost);

                    var issued = DateTime.MinValue;
                    foreach (XmlNode n in currentItem.ChildNodes)
                    {
                        if (n.Name == "dcterms:issued")
                        {
                            DateTime.TryParse(n.InnerText, out issued);
                            break;
                        }
                    }

                    //var id = uri.
                    var itm = new FeedItemModel(id, uri.DnsSafeHost, title, link, desc, siteurl, issued);
                    if ((DateTime.Now - itm.Issued).TotalHours < 500)
                    {
                        feedItems.Add(itm);
                    }
                }
            }
            catch (Exception ex)
            {
                //
            }
            return(feedItems);
        }