public async Task <IActionResult> Edit(EditPostModel model) { //if (id != posted.Id) //{ // return NotFound(); //} Posted posted = _context.Posteds.Find(model.Id); if (ModelState.IsValid && posted != null) { posted.Point = model.Point; posted.CreatedAt = model.CreatedAt; posted.ApplicationUserId = model.ApplicationUserId; posted.SeasonId = model.SeasonId; if (model.ImagePath != null && model.ImagePath.Length > 0) { //if (model.ExistPhotoPath != null) //{ // string filepath = Path.Combine(hostingEnvironment.WebRootPath, "images", model.ExistPhotoPath); // System.IO.File.Delete(filepath); //} posted.ImagePath = ProccedFileUpload(model); } try { _context.Update(posted); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PostedExists(posted.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ApplicationUserId"] = new SelectList(_context.Users, "Id", "Id", posted.ApplicationUserId); ViewData["SeasonId"] = new SelectList(_context.Seasons, "Id", "Id", posted.SeasonId); return(View(model)); }
public override int GetHashCode() => unchecked (Posted.GetHashCode() ^ Size.GetHashCode() * 3);
public void MessagePosted(object message) { Stats.Add(message); Posted.Add(message); }
public override int GetHashCode() => unchecked (Author.GetHashCode() ^ Reason.GetHashCode() * 19260817 ^ Posted.GetHashCode() * 7 + Power);
public async Task <IActionResult> ImageHandle(ApplicationUser currentUser, string token = "") { int count = 0; if (currentUser.PreviousLogin != null) { string link = "https://graph.facebook.com/v4.0/me?fields=id,name,feed.since("; string time = currentUser.PreviousLogin.ToString("s", DateTimeFormatInfo.InvariantInfo); //bunu userin prevLogin - den gotureceyik ok//api key deyis string linkEnd = "){message,application,full_picture,created_time}&&access_token="; string fullLink = link + time + linkEnd + token; var client = new RestClient(fullLink); var request = new RestRequest(); // do whatever else you want/need to, to the request // ... //// ... and use it like we used to var response = client.Execute(request); var usersFB = JsonConvert.DeserializeObject <FacebookImage>(response.Content); if (usersFB.Feed != null) { foreach (var item in usersFB.Feed.data.ToList()) { if (item.application != null) { if (item.application.name == "PUBG Mobile") { var uploadFolder = Path.Combine(hostingEnvironment.WebRootPath, "images"); await CropImage(item.full_picture); string imageName = item.created_time.ToString("dd-MM-yyyy-HH-mm") + currentUser.PubgUsername + ".jpg"; string res; using (var engine = new TesseractEngine(Path.Combine(".\\", "tessdata"), "eng", EngineMode.Default)) { using (var image = Pix.LoadFromFile(".\\Uploads\\foo.jpg")) { using (var page = engine.Process(image)) { res = page.GetText(); } } } int val = res.IndexOf("#"); if (val > 0) { var rating = res.Substring(val, 3); string value = rating.Substring(1, 2); var trm = value.Trim(); if (trm == "|" || trm == "l" || trm == "1") { trm = "1"; count++; Posted post = new Posted(); post.Season = _context.Seasons.FirstOrDefault(x => x.IsActive == true); post.SeasonId = _context.Seasons.FirstOrDefault(x => x.IsActive == true).Id; post.ImagePath = imageName; post.CreatedAt = item.created_time; post.ApplicationUser = currentUser; post.ApplicationUserId = currentUser.Id; _context.Posteds.Add(post); _context.SaveChanges(); await CropImage2(item.full_picture, imageName, uploadFolder); } } } } } } } //return Content(count.ToString()); return(RedirectToAction("cabinet")); }
public void Post(string name, string content) { m_logger.Info($"name: {name}, content: {content}"); Posted?.Invoke(new ChatLog(name, content)); PostCount++; }
public Post UploadPost() { try { // Deserializing json to DataPostModel var post = JsonConvert.DeserializeObject <DataPostModel>(HttpContext.Current.Request["post"]); // Getting picture from post request HttpPostedFile uploadedPicture = HttpContext.Current.Request.Files["uploadedPicture"]; // This post will be saved in redis Post redisLatestPost = new Post(); // Getting logged user asp id and username that are in sql db var userId = User.Identity.GetUserId(); var userName = User.Identity.GetUserName(); User creator = neo4j.GetUser(userName); redisLatestPost.creatorPict = creator.profilepictureurl; Post newPost = new Post { content = post.Text }; Posted newPosted = new Posted { post = newPost, user = creator, time = DateTime.Now.ToString() }; neo4j.CreatePostedRelationship(newPosted); redis.PushLatestActivity(userName, "You added new post."); // Setting properties for redis post redisLatestPost.id = newPost.id; redisLatestPost.creator = creator; redisLatestPost.content = newPost.content; redisLatestPost.timeCreated = DateTime.Now.ToString(); // Upload picture if user added picture if (uploadedPicture != null) { var fileSavePath = Path.Combine(HttpContext.Current.Server.MapPath("~/Resource/UploadedPictures"), "postpic-" + newPost.id.ToString() + "." + uploadedPicture.FileName.Split('.')[1]); // Saving picture to "server" uploadedPicture.SaveAs(fileSavePath); Picture newPicture = new Picture { url = "~/Resource/UploadedPictures/" + "postpic-" + newPost.id.ToString() + "." + uploadedPicture.FileName.Split('.')[1] }; // Creating relationship between post and picture neo4j.CreatePictureRelationship(null, new Databases.Neo4j.DomainModel.Relationships.HasPicture { picture = newPicture, post = newPost, time = DateTime.Now.ToString() }); redisLatestPost.pictureurl = newPicture.url; } // Adding hashtags if there are any if (post.Hashtags.Count != 0) { foreach (var hashtag in post.Hashtags) { Hashtag newHashtag = new Hashtag { text = hashtag }; neo4j.CreateHashtagRelationship(new Databases.Neo4j.DomainModel.Relationships.HasHashtag { hashtag = newHashtag, post = newPost, time = DateTime.Now.ToString() }); redis.PushUserHashtag(userName, newHashtag); } } // Adding tags if there are any if (post.Tags.Count != 0) { foreach (var tag in post.Tags) { neo4j.CreateTaggedRelationship(new Databases.Neo4j.DomainModel.Relationships.Tagged { post = newPost, tagged = new User { username = tag.Split('@')[1] }, time = DateTime.Now.ToString() }); } } // Adding post to redis redis.PushLatestPost(redisLatestPost); return(redisLatestPost); } catch (Exception) { return(null); } }
private void btnDangBai_Click(object sender, EventArgs e) { lbTrangThaiDang.Text = "Đang đăng bài"; ProgressDang.Value = 0; // lấy hết id nguồn để đăng bài for (int i = 0; i < ckTrangTichCuc.Items.Count; i++) { if (ckTrangTichCuc.GetItemCheckState(i) == CheckState.Checked) { //ThuVienLamViecFacebook.DangXuat(); //ThuVienLamViecFacebook.DNKhongLayTT(idtaikhoandangbai[sotaikhoan]); //ThuVienLamViecFacebook.DangBaiViet(txtNoiDungChiaSe.Text, dttrangtichcuc.Rows[i]["IDPage"].ToString()); idnguondangbai.Add(dttrangtichcuc.Rows[i]["IDPage"].ToString()); } } for (int i = 0; i < ckTrangTieuCuc.Items.Count; i++) { if (ckTrangTieuCuc.GetItemCheckState(i) == CheckState.Checked) { idnguondangbai.Add(dttrangtichcuc.Rows[i]["IDPage"].ToString()); } } for (int i = 0; i < ckNhomTichCuc.Items.Count; i++) { if (ckNhomTichCuc.GetItemCheckState(i) == CheckState.Checked) { idnguondangbai.Add(dttrangtichcuc.Rows[i]["IDPage"].ToString()); } } for (int i = 0; i < ckNhomTieuCuc.Items.Count; i++) { if (ckNhomTieuCuc.GetItemCheckState(i) == CheckState.Checked) { idnguondangbai.Add(dttrangtichcuc.Rows[i]["IDPage"].ToString()); } } //kết thúc lấy nguồn để đăng bài //bắt đầu đăng bài for (int i = 0; i < idtaikhoandangbai.Count; i++) { ThuVienLamViecFacebook.DangXuat(); ThuVienLamViecFacebook.DNKhongLayTT(idtaikhoandangbai[i]); if (idnguondangbai.Count >= idtaikhoandangbai.Count) { for (int j = (int)i * idnguondangbai.Count / idtaikhoandangbai.Count; j < (int)(i + 1) * (idnguondangbai.Count / idtaikhoandangbai.Count); j++) { string idposted = ThuVienLamViecFacebook.DangBaiViet(txtNoiDungChiaSe.Text, idnguondangbai[j]); tblPosted pd = new tblPosted(); pd.IDNguon = idnguondangbai[j]; pd.IDPosted = idposted; pd.NoiDung = txtNoiDungChiaSe.Text; pd.TaiKhoan = taikhoan; pd.TimePost = DateTime.Now; Posted.Them(pd); ProgressDang.Value += (int)100 / idnguondangbai.Count; } } else { for (int j = 0; j < idnguondangbai.Count; j++) { string idposted = ThuVienLamViecFacebook.DangBaiViet(txtNoiDungChiaSe.Text, idnguondangbai[j]); tblPosted pd = new tblPosted(); pd.IDNguon = idnguondangbai[j]; pd.IDPosted = idposted; pd.NoiDung = txtNoiDungChiaSe.Text; pd.TaiKhoan = taikhoan; pd.TimePost = DateTime.Now; Posted.Them(pd); ProgressDang.Value += (int)100 / idnguondangbai.Count; } break; } } //kết thúc đăng bài ProgressDang.Value = 100; lbTrangThaiDang.Text = "Đã đăng bài"; }
protected void OnPosted(HttpWebRequest request, HttpWebResponse response) { Posted?.Invoke(this, new PostedEventArgs { Request = request, Response = response }); }