Exemple #1
0
        public ActionResult Add(NewsFeed newsFeed, IEnumerable <HttpPostedFileBase> imageBase)
        {
            newsFeed.Date      = DateTime.Now;
            newsFeed.Edited    = false;
            newsFeed.Moderator = User.Identity.GetUserName();
            var             factory         = DependencyResolver.Current.GetService <IControllerFactory>() ?? new DefaultControllerFactory();
            ImageController imageController = factory.CreateController(this.ControllerContext.RequestContext, "Image") as ImageController;

            RouteData route = new RouteData();

            route.Values.Add("action", "Test");

            ControllerContext imageContext = new ControllerContext(new HttpContextWrapper(System.Web.HttpContext.Current), route, imageController);

            //Speichere Image in Datenbank
            imageController.ControllerContext = imageContext;
            imageController.Create(imageBase);

            //Nehme das Image aus der Datenbank anhand des Namens und Rufe die View Create mit dem Image aus der Datenbank auf.
            var fileName = Path.GetFileName(imageBase.First().FileName);
            var dbImage  = _context.Image.SingleOrDefault(n => n.Name == fileName);

            newsFeed.TitelImage = dbImage;
            _context.NewsFeed.Add(newsFeed);
            _context.SaveChanges();

            return(RedirectToAction("Index", "NewsFeed"));
        }
Exemple #2
0
        public NewsFeed Get(GetParams @params)
        {
            var parameters = new VkParameters
            {
                { "filters", @params.Filters },
                { "return_banned", @params.ReturnBanned },
                { "start_time", @params.StartTime },
                { "end_time", @params.EndTime },
                { "max_photos", @params.MaxPhotos },
                { "source_ids", @params.SourceIds },
                { "start_from", @params.StartFrom },
                { "count", @params.Count },
                { "fields", @params.Fields }
            };
            var response = _vk.Call("newsfeed.get", parameters);
            var result   = new NewsFeed
            {
                Items     = response["items"].ToReadOnlyCollectionOf <NewsItem>(x => x),
                Profiles  = response["profiles"].ToReadOnlyCollectionOf <User>(x => x),
                Groups    = response["groups"].ToReadOnlyCollectionOf <Group>(x => x),
                NewOffset = response["new_offset"],
                NextFrom  = response["next_from"]
            };

            return(result);
        }
        public NewsFeed GetNewsFeed(string requestingUsername, string verificationToken)
        {
            NewsFeed    newsfeed = new NewsFeed();
            List <Post> posts    = new List <Post>();

            DBConnect  objDB      = new DBConnect();
            SqlCommand objCommand = new SqlCommand();

            objCommand.CommandType = CommandType.StoredProcedure;
            objCommand.CommandText = "TP_GetNewsFeedPosts";
            objCommand.Parameters.AddWithValue("@UserEmail", requestingUsername);
            objCommand.Parameters.AddWithValue("@VerificationToken", verificationToken);
            DataSet ds   = objDB.GetDataSetUsingCmdObj(objCommand);
            int     rows = ds.Tables[0].Rows.Count;

            for (int i = 0; i < rows; i++)
            {
                Post post = new Post();
                post.PostID       = Convert.ToInt32(ds.Tables[0].Rows[i]["PostID"].ToString());
                post.PosterEmail  = ds.Tables[0].Rows[i]["Email"].ToString();
                post.Message      = ds.Tables[0].Rows[i]["Message"].ToString();
                post.dateOfPost   = Convert.ToDateTime(ds.Tables[0].Rows[i]["Date"].ToString());
                post.PostLocation = ds.Tables[0].Rows[i]["PostLocation"].ToString();
                post.FirstName    = ds.Tables[0].Rows[i]["FirstName"].ToString();
                post.LastName     = ds.Tables[0].Rows[i]["LastName"].ToString();
                post.PhotoUrl     = ds.Tables[0].Rows[i]["ProfilePhotoUrl"].ToString();
                posts.Add(post);
            }

            newsfeed.Posts = posts;
            return(newsfeed);
        }
Exemple #4
0
    public static string GetTitle(this NewsFeed feed)
    {
        switch (feed.Type)
        {
        case NewsFeedType.NewProblem:
            return("New Problem Posted");

        case NewsFeedType.SolvedProblem:
            return("Problem Solved");

        case NewsFeedType.ShortestSolution:
            return("New Shortest solution");

        case NewsFeedType.CodeSnippet:
            return("New CodeSnippet Posted");

        case NewsFeedType.News:
            return("New News Posted");

        case NewsFeedType.ForumPost:
            return("New Forum Post");

        case NewsFeedType.SourcePost:
            return("New Source code Post");

        case NewsFeedType.ProblemPost:
            return("New Problem Post");

        case NewsFeedType.NewContest:
            return("New Contest Scheduled");
        }
        return(String.Empty);
    }
Exemple #5
0
        public List <NewsFeed> GetPersonalFeed(string loginID, string Password)
        {
            List <NewsFeed> newsFeedsList = new List <NewsFeed>();
            DataSet         personalFeed  = new DataSet();

            personalFeed = storedProcedure.GetNewsFeed(loginID);

            string oldkey = "-1";

            foreach (DataRow rows in personalFeed.Tables[0].Rows)
            {
                if (oldkey == "-1")
                {
                    NewsFeed newsFeed = new NewsFeed();
                    newsFeed.LoginID         = rows["LoginID"].ToString();
                    newsFeed.NewsFeedMessage = rows["NewsFeed"].ToString();
                    newsFeedsList.Add(newsFeed);
                }
                else if (oldkey != rows["NewsFeedID"].ToString())
                {
                    NewsFeed newsFeed = new NewsFeed();
                    newsFeed.LoginID         = rows["LoginID"].ToString();
                    newsFeed.NewsFeedMessage = rows["NewsFeed"].ToString();
                    newsFeedsList.Add(newsFeed);
                }
                oldkey = rows["NewsFeedID"].ToString();
            }

            return(newsFeedsList);
        }
Exemple #6
0
        public async Task <IActionResult> PutNewsFeed([FromRoute] int id, [FromBody] NewsFeed newsFeed)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != newsFeed.ChangeId)
            {
                return(BadRequest());
            }

            _context.Entry(newsFeed).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!NewsFeedExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #7
0
        public NewsFeed GetComments(GetCommentsParams @params)
        {
            var parameters = new VkParameters
            {
                { "count", @params.Count },
                { "filters", @params.Filters },
                { "reposts", @params.Reposts },
                { "start_time", @params.StartTime },
                { "end_time", @params.EndTime },
                { "last_comments_count", @params.LastCommentsCount },
                { "start_from", @params.StartFrom },
                { "fields", @params.Fields }
            };
            var response = _vk.Call("newsfeed.getComments", parameters);
            var result   = new NewsFeed
            {
                Items     = response["items"].ToReadOnlyCollectionOf <NewsItem>(x => x),
                Profiles  = response["profiles"].ToReadOnlyCollectionOf <User>(x => x),
                Groups    = response["groups"].ToReadOnlyCollectionOf <Group>(x => x),
                NewOffset = response["new_offset"],
                NextFrom  = response["next_from"]
            };

            return(result);
        }
		protected override void Run() {
			
			discoveredFeed = new NewsFeed();

			try {
				
				//feedInfo = feedHandler.GetFeedDetails(this.feedUrl, this.credentials);
				using (Stream mem = SyncWebRequest.GetResponseStream(this.feedUrl, this.credentials, RssBanditApplication.UserAgent, this.Proxy))
				{
					NewsFeed f = new NewsFeed();
					f.link = feedUrl;
					if (RssParser.CanProcessUrl(feedUrl)) {
						feedInfo = RssParser.GetItemsForFeed(f, mem, false); 
						if (feedInfo.ItemsList != null && feedInfo.ItemsList.Count > 0)
							f.containsNewMessages = true;
					}
				}

			} catch (ThreadAbortException) {
				// eat up
			} catch (Exception e) {	// fatal errors
				p_operationException = e;
			} finally {
				WorkDone.Set();
			}
		}
Exemple #9
0
        public void AddComment(int id)
        {
            string   currid = Request.Params["id"].ToString();
            user     us     = Session["User" + currid] as user;
            NewsFeed feed   = db.NewsFeeds.Find(id);
            comment  com    = new comment();

            com.newsfeed_id    = id;
            com.datetime       = DateTime.Now;
            com.comment1       = Request.Params["content"];
            com.commentator_id = us.id;
            db.comments.Add(com);

            if (feed.user_id != us.id)
            {
                notification notif = new notification();
                notif.datetime   = DateTime.Now;
                notif.sender_id  = us.id;
                notif.user_id    = feed.user_id;
                notif.on_feed_id = id;
                notif.state      = 1;
                notif.text_id    = 5;
                db.notifications.Add(notif);
            }
            db.SaveChanges();
        }
        public NewsFeed Deserialize(string _data, Func <VideoInfo, string> _loadVideoItem = null)
        {
            var jObject = JObject.Parse(_data);

            if (jObject[PResponse][PItems] is JArray jItems)
            {
                try
                {
                    var newsFeed = new NewsFeed();

                    foreach (JObject jItem in jItems)
                    {
                        var itemRawType = jItem[PItemType].Value <string>();

                        if (itemRawType == "post")
                        {
                            newsFeed.Add(ParsePostItem(jItem, _loadVideoItem));
                        }
                    }

                    return(newsFeed);
                }
                catch (Exception ex)
                {
                    throw new DeserializerException("Failed to deserialize newsfeed", ex);
                }
            }

            throw new DeserializerException($"Failed recognize jObject as vk response \n {_data}");
        }
        public async Task <IActionResult> Edit(int id, [Bind("Title,TitleEng,Description,DescriptionEng,ColumnCount,LinkTo,LinkToId,Id")] NewsFeed newsFeed)
        {
            if (id != newsFeed.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(newsFeed);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!NewsFeedExists(newsFeed.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            ViewData["LinkToSelectList"] = LinkTo.Anime.ToSelectList(newsFeed.LinkTo);
            return(View(newsFeed));
        }
Exemple #12
0
        public void ShareNewPost()
        {
            string   currid = Request.Params["id"].ToString();
            user     us     = Session["User" + currid] as user;
            string   descr  = Request.Params["text"].ToString();
            string   part   = Request.Params["src"].ToString();
            NewsFeed feed   = new NewsFeed();

            feed.user_id      = us.id;
            feed.feedState_id = 1;
            feed.dateTime     = DateTime.Now;
            if (descr != "" && descr != null)
            {
                feed.contetnfeed = descr;
            }
            if (part.EndsWith(".png") || part.EndsWith(".jpg") || part.EndsWith(".jpeg"))
            {
                feed.photos = part;
            }
            else if (part.EndsWith(".ogg") || part.EndsWith(".mp4") || part.EndsWith(".webm"))
            {
                feed.videos = part;
            }
            db.NewsFeeds.Add(feed);
            db.SaveChanges();
        }
Exemple #13
0
        private void GoHomeButton_Click(object sender, RoutedEventArgs e)
        {
            if (MainFrame.HasContent)
            {
                if (!(MainFrame.Content is NewsFeed))
                {
                    _newsFeed = new NewsFeed();

                    MainFrame.Navigate(_newsFeed);

                    var lastExit = AdministrationClass.LastModuleExit(AdministrationClass.Modules.NewsFeed);
                    _newsFeed.ShowNews(lastExit);

                    NotificationManager.ShowNotifications(AdministrationClass.CurrentWorkerId);
                }
            }

            if (MenuPopupBorder.Child != null)
            {
                MenuPopupBorder.Child = null;
                MainGrid.Children.Add(MenuGrid);
            }

            MenuListBox.SelectedItems.Clear();
        }
Exemple #14
0
        public async void ShareViedo(int id)
        {
            string   currid = Request.Params["id"].ToString();
            user     us     = Session["User" + currid] as user;
            NewsFeed feed   = await db.NewsFeeds.FindAsync(id);

            NewsFeed myfeed = new NewsFeed();

            myfeed.dateTime     = DateTime.Now;
            myfeed.user_id      = us.id;
            myfeed.feedState_id = 4;
            if (feed.on_feed_id == null)
            {
                myfeed.on_feed_id = feed.id;
            }
            else
            {
                myfeed.on_feed_id = feed.on_feed_id;
            }
            myfeed.videos      = feed.videos;
            myfeed.contetnfeed = feed.contetnfeed;
            db.NewsFeeds.Add(myfeed);
            if (feed.user_id != us.id)
            {
                notification not = new notification();
                not.sender_id  = us.id;
                not.datetime   = DateTime.Now;
                not.user_id    = feed.user_id;
                not.text_id    = 7;
                not.state      = 1;
                not.on_feed_id = feed.id;
                db.notifications.Add(not);
            }
            db.SaveChanges();
        }
Exemple #15
0
        public void  ChangeProfile(int id)
        {
            string   currid = Request.Params["id"].ToString();
            user     us     = Session["User" + currid] as user;
            NewsFeed feed   = db.NewsFeeds.Find(id);
            var      user   = new user {
                id = us.id, profile_photo = feed.photos
            };

            using (var db = new socialEntities())
            {
                db.users.Attach(user);
                db.Entry(user).Property(x => x.profile_photo).IsModified = true;
                try
                {
                    //add to feed
                    NewsFeed feeds = new NewsFeed();
                    feeds.dateTime     = DateTime.Now;
                    feeds.user_id      = us.id;
                    feeds.photos       = feed.photos;
                    feeds.feedState_id = 6;
                    db.NewsFeeds.Add(feeds);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    string st = e.Message;
                }
            }
        }
        public Task <List <Article> > ParseFeed(string rss)
        {
            return(Task.Factory.StartNew(() =>
            {
                //try
                //{
                XDocument xdoc = XDocument.Load(rss);
                var channel = xdoc.Descendants("channel").First();
                NewsFeed newsfeed = new NewsFeed
                {
                    Title = (string)channel.Element("title"),
                    Description = (string)channel.Element("description"),
                    Link = new Uri(rss),
                    //Icon = ImageSource.FromUri(new Uri($"https://www.google.com/s2/favicons?domain={rss}"))
                };

                return (from item in xdoc.Descendants("item")
                        select new Article
                {
                    Title = (string)item.Element("title"),
                    Description = (string)item.Element("description"),
                    Link = new Uri((string)item.Element("link")),
                    PublishDate = DateTime.Parse(((string)item.Element("pubDate")).Replace("PST", "+0800").Replace("PDT", "+0700")),
                    Author = (string)item.Element("author"),
                    Source = newsfeed
                }).ToList();
                //}
                //catch (XmlException)
                //{

                //    return null;
                //}
            }));
        }
Exemple #17
0
    public virtual NewsFeed GetNewsFeed()
    {
        NewsFeed newsFeed = base.GetNewsFeed();

        newsFeed.OwnerIsMyManager = promoManagerIds.Contains(x.UserID);
        return(newsFeed);
    }
        protected void btnPost_Click(object sender, EventArgs e)
        {
            Encrypt              encrypt    = new Encrypt();
            HttpCookie           userCookie = Request.Cookies["UserCookie"];
            JavaScriptSerializer js         = new JavaScriptSerializer();
            NewsFeed             newsFeed   = new NewsFeed(encrypt.Decrypt(userCookie.Values["Username"].ToString()), txtPostWall.Text);

            string jsonNews = js.Serialize(newsFeed);

            WebRequest request = WebRequest.Create("http://localhost:49241/api/NewsFeed");

            request.Method      = "POST";
            request.ContentType = "application/json";

            StreamWriter writer = new StreamWriter(request.GetRequestStream());

            writer.Write(jsonNews);
            writer.Flush();
            writer.Close();

            WebResponse  response      = request.GetResponse();
            Stream       theDataStream = response.GetResponseStream();
            StreamReader reader        = new StreamReader(theDataStream);



            string data = reader.ReadToEnd();

            reader.Close();
            response.Close();
            loadPosts();
        }
        // delete an entry by id
        public void Delete(Object id)
        {
            NewsFeed newsFeed = db.NewsFeeds.Find(Int32.Parse(id.ToString()));

            db.NewsFeeds.Remove(newsFeed);
            db.SaveChanges();
        }
Exemple #20
0
        public WelcomeViewModel(INavigationService navigationService)
        {
            if (!isInternetConnected)
            {
                throw new Exception("No network");
            }

            _navigationService = navigationService;



            var newsFeed = new NewsFeed();

            if (IsInDesignMode)
            {
                var publications = new List <Publication>();
                for (int i = 0; i < 40; i++)
                {
                    publications.Add(new Publication()
                    {
                        Title           = "No Data",
                        Description     = "No Data",
                        ApplicationUser = null
                    });
                }
                newsFeed.PublicationNewsFeed = publications;
                NewsFeed = new ObservableCollection <Publication>(publications);
            }
            else
            {
                InitializeAsync();
            }
        }
        public override void SetUp()
        {
            base.SetUp();

            this.newsFeeds = new NewsFeeds(this.Session);

            this.english = new Languages(this.Session).FindBy(M.Language.IsoCode, "en");
            this.german  = new Languages(this.Session).FindBy(M.Language.IsoCode, "de");
            this.dutch   = new Languages(this.Session).FindBy(M.Language.IsoCode, "nl");

            this.multiLanguages = new List <Language>()
            {
                this.english, this.german
            };

            this.newsTopic         = new TopicBuilder(this.Session).WithName("News").Build();
            this.worldTopic        = new TopicBuilder(this.Session).WithName("World").Build();
            this.noneExistingTopic = new TopicBuilder(this.Session).WithName("None").Build();

            this.topics = new List <Topic> {
                this.worldTopic, this.newsTopic
            };

            this.RemoveAllNewsFeeds();

            this.newsFeed = this.newsFeeds.SetupNewsFeed("http://feeds.bbci.co.uk/news/rss.xml", "BBC Top Stories", this.multiLanguages, this.topics);
            //_newsGermanFeed = newsFeeds.SetupNewsFeed("http://feeds.bbci.co.uk/world/rss.xml", "BBC Top Stories", multiLanguages, topics);
            //_newsEnglishFeed = newsFeeds.SetupNewsFeed("http://feeds.bbci.co.uk/news/rss.xml", "BBC Top Stories", multiLanguages, topics);
        }
Exemple #22
0
        public List <NewsFeed> FetchAllNewsFeed()
        {
            List <NewsFeed> feeds = new List <NewsFeed>();

            using (SqlConnection connection = new SqlConnection(this._connectionString))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand("FETCH_ALL_NEWS_FEED", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        try
                        {
                            while (reader.Read())
                            {
                                var feed = new NewsFeed();
                                feed.FeedID         = Convert.ToInt32(reader["FeedID"].ToString());
                                feed.Title          = reader["Title"].ToString();
                                feed.Content        = reader["Content"].ToString();
                                feed.PostDate       = reader["PostDate"].ToString();
                                feed.PostValidity   = (Convert.ToDateTime(reader["ExpirationDate"].ToString()) - DateTime.Now).Days;
                                feed.ExpirationDate = reader["ExpirationDate"].ToString();
                                feeds.Add(feed);
                            }
                            return(feeds);
                        }
                        catch (Exception ex)
                        {
                            return(null);
                        }
                    }
                }
            }
        }
Exemple #23
0
        public void GetItemsForFeedWithRssRdfv091()
        {
            using (var stream = Resources.Resource.GetResourceAsStream("TestFeeds.rss_rdf_0_91.xml"))
            {
                NewsFeed f = new NewsFeed();
                f.link = TEST_BASE_URL + "rss_rdf_0_91.xml";
                var feedInfo = RssParser.GetItemsForFeed(f, stream, false, true);
                Assert.IsNotNull(feedInfo);
                Assert.IsNotNull(feedInfo.ItemsList);
                Assert.AreEqual(40, feedInfo.ItemsList.Count);
                Assert.AreEqual(new DateTime(2013, 9, 12, 12, 0, 0, DateTimeKind.Utc), feedInfo.ItemsList[39].Date);

                string requestUrl = null;
                var    xElem      = RssHelper.GetOptionalElement(feedInfo.OptionalElements, "image");
                if (xElem != null)
                {
                    var urlNode = xElem.SelectSingleNode("url");
                    if (urlNode != null)
                    {
                        requestUrl = urlNode.InnerText;
                    }
                }

                Assert.AreEqual("http://www.golem.de/staticrl/images/golem-rss.png", requestUrl);
            }
        }
Exemple #24
0
        public async Task <IHttpActionResult> PutNewsFeed(int id, NewsFeed newsFeed)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != newsFeed.Id)
            {
                return(BadRequest());
            }

            db.Entry(newsFeed).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!NewsFeedExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
    public override NewsFeed GetNewsFeed()
    {
        NewsFeed newsFeed = base.GetNewsFeed();

        newsFeed.AlbumPhotoPath = AlbumPhoto.Where(...);
        return(newsFeed);
    }
        /// <summary>
        ///    Add news
        /// </summary>
        /// <param name="newsFeed">News feed</param>
        /// <returns>Added news</returns>
        public async Task <NewsFeed> AddNewsAsync(NewsFeed newsFeed)
        {
            var newFeed = _hrEntities.NewsFeeds.Add(newsFeed);
            await _hrEntities.SaveChangesAsync().ConfigureAwait(false);

            return(newFeed);
        }
Exemple #27
0
        public ActionResult DeleteConfirmed(int id)
        {
            NewsFeed newsFeed = db.NewsFeed.Find(id);

            db.NewsFeed.Remove(newsFeed);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #28
0
 public void NullFiltersGetEverything()
 {
     Assert.IsTrue(NewsFeed.IncludeInFilter(new NewNewsItemEventArgs {
         Person = new PersonSetting {
             RawName = "sam"
         }
     }, null, null));
 }
 public static void AddNewsFeed(NewsFeed newsFeed)
 {
     using (var context = new NewsFeedDBEntities())
     {
         context.NewsFeed.Add(newsFeed);
         context.SaveChanges();
     }
 }
Exemple #30
0
 public async Task <int> CreateNewsFeed(NewsFeed feed)
 {
     using (var connection = new SqlConnection(_connectionString))
     {
         const string sql = "INSERT INTO rad.NewsFeed ( DateCreated, Content ) VALUES ( GETDATE(), @Content ) SELECT CAST(SCOPE_IDENTITY() AS INT)";
         return(await connection.ExecuteScalarAsync <int>(sql, feed).ConfigureAwait(false));
     }
 }