public static string AddRssContentsUrl(string keywords, long userId, Helper.AppSettings _appSettings)
        {
            MongoRepository _rssNewsContents = new MongoRepository("RssNewsContents", _appSettings);

            List <string> list = new List <string>();

            list = findUrl(keywords).ToList();

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

            foreach (var urlValue in list)
            {
                if (urlValue != null)
                {
                    string rt   = ParseFeedUrl(urlValue.ToString(), keywords, userId.ToString(), _appSettings);
                    var    ret  = _rssNewsContents.Find <Domain.Socioboard.Models.Mongo.RssNewsContents>(t => t.RssFeedUrl.Equals(urlValue) && t.ProfileId.Contains(userId.ToString()));
                    var    task = Task.Run(async() =>
                    {
                        return(await ret);
                    });
                    int count = task.Result.Count;
                    if (count < 1)
                    {
                        _rssnews.Id = ObjectId.GenerateNewId();
                        //_rssnews.strId = ObjectId.GenerateNewId();
                        _rssnews.ProfileId  = userId.ToString();
                        _rssnews.RssFeedUrl = urlValue.ToString();
                        _rssnews.LastUpdate = Domain.Socioboard.Helpers.SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow);
                        _rssNewsContents.Add(_rssnews);
                    }
                    else
                    {
                        return("please fill correct url");
                    }
                }
            }
            return("ok");
        }
Exemplo n.º 2
0
        public static string AddRssContentsUrl(string keywords, long 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.ToString(), _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.ToString()));
                    var task = Task.Run(async() =>
                    {
                        return(await ret);
                    });
                    int count = task.Result.Count;
                    if (count < 1)
                    {
                        _rssnews.Id         = ObjectId.GenerateNewId();
                        _rssnews.ProfileId  = userId.ToString();
                        _rssnews.RssFeedUrl = urlValue.ToString();
                        _rssnews.LastUpdate = Domain.Socioboard.Helpers.SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow);
                        _rssNewsContents.Add(_rssnews);
                    }
                    else
                    {
                        return("Data already added");
                    }
                }
            }
            return("added successfully");
        }
Exemplo n.º 3
0
 public static void updateRssContentFeeds(Domain.Socioboard.Models.Mongo.RssNewsContents _rssNews, string keywords)
 {
     ParseContentFeedUrl(_rssNews.RssFeedUrl, _rssNews.ProfileId, keywords);
 }