コード例 #1
0
        public static string AddRssContentsUrl(string keywords, string userId, Helper.AppSettings _appSettings, Model.DatabaseRepository dbr)
        {
            MongoRepository _rssNewsContents = new MongoRepository("RssNewsContents", _appSettings);
            //Domain.Socioboard.Models.RssFeedUrl _RssFeedUrl = dbr.FindSingle<Domain.Socioboard.Models.RssFeedUrl>(t => t.rssurl.Contains(url));
            List <string> list = new List <string>();

            list = findUrl(keywords).ToList();

            Domain.Socioboard.Models.Mongo.RssNewsContents _rssnews = new Domain.Socioboard.Models.Mongo.RssNewsContents();

            Domain.Socioboard.Models.RssFeedUrl _RssContentFeeds = new Domain.Socioboard.Models.RssFeedUrl();


            foreach (var urlValue in list)
            {
                if (urlValue != null)
                {
                    string rt = ParseFeedUrl(urlValue.ToString(), keywords, userId, _appSettings);

                    _RssContentFeeds = dbr.FindSingle <Domain.Socioboard.Models.RssFeedUrl>(t => t.rssurl.Contains(urlValue) && t.Keywords != null);

                    if (_RssContentFeeds != null)
                    {
                        //return _RssFeedUrl.ToString();
                    }
                    else
                    {
                        _RssContentFeeds            = new Domain.Socioboard.Models.RssFeedUrl();
                        _RssContentFeeds.rssurl     = urlValue;
                        _RssContentFeeds.LastUpdate = DateTime.UtcNow;
                        _RssContentFeeds.Keywords   = keywords;
                        try
                        {
                            dbr.Add <Domain.Socioboard.Models.RssFeedUrl>(_RssContentFeeds);
                        }
                        catch (Exception error)
                        {
                        }

                        //_RssContentFeedUrl = dbr.FindSingle<Domain.Socioboard.Models.RssFeedUrl>(t => t.rssurl.Contains(urlValue) && t.Keywords == null);
                        //return urlValue;
                    }
                    var ret  = _rssNewsContents.Find <Domain.Socioboard.Models.Mongo.RssNewsContents>(t => t.RssFeedUrl.Equals(urlValue) && t.ProfileId.Contains(userId));
                    var task = Task.Run(async() =>
                    {
                        return(await ret);
                    });
                    int count = task.Result.Count;
                    if (count < 1)
                    {
                        _rssnews.Id         = ObjectId.GenerateNewId();
                        _rssnews.ProfileId  = userId;
                        _rssnews.RssFeedUrl = urlValue.ToString();
                        _rssnews.LastUpdate = Domain.Socioboard.Helpers.SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow);
                        _rssNewsContents.Add(_rssnews);
                    }
                    else
                    {
                        return("Data already added");
                    }
                }
            }
            return("added successfully");
        }
コード例 #2
0
 public static void updateRssContentFeeds(Domain.Socioboard.Models.Mongo.RssNewsContents _rssNews, string keywords)
 {
     ParseContentFeedUrl(_rssNews.RssFeedUrl, _rssNews.ProfileId, keywords);
     addContentfeedsdata(keywords);
     addGplusContentfeedsdata(keywords, _rssNews.ProfileId);
 }