private void setInfo() { if (id > 0) { using (BLLNewsDetail bll = new BLLNewsDetail()) { NewsDetail cpinfor = bll.GetSingle(id); if (cpinfor != null) { ddlNewsType.SelectedValue = cpinfor.NewsTypeID.ToString(); txtNewsTitle.Text = cpinfor.NewsTitle; txtContent.Value = cpinfor.NewsContent; txtRemarks.Text = cpinfor.Remarks; txtAutoSort.Text = cpinfor.AutoSort.ToString(); if (cpinfor.IsEnglish == 1) { rbtnIsChinese.Checked = true; } else if (cpinfor.IsEnglish == 2) { rbtnIsEnglish.Checked = true; } } } } }
public async Task <ActionResult <NewsDetail> > PostNewsDetail(NewsDetail newsDetail) { _context.NewsDetails.Add(newsDetail); await _context.SaveChangesAsync(); return(CreatedAtAction("GetNewsDetail", new { id = newsDetail.NewsId }, newsDetail)); }
public async Task <IActionResult> Edit(int id, [Bind("NewsDetailID,Content,Nameposted,CreateDate,NewsID")] NewsDetail newsDetail) { if (id != newsDetail.NewsDetailID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(newsDetail); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NewsDetailExists(newsDetail.NewsDetailID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["NewsID"] = new SelectList(_context.News, "NewsID", "NewsID", newsDetail.NewsID); return(View(newsDetail)); }
public static NewsDetail AddNews(AddNewsRequestModel request) { NewsDetail resp = new NewsDetail(); try { var client = new HttpClient(); client.BaseAddress = baseUri; client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var content = new StringContent(JsonConvert.SerializeObject(request)); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var response = client.PostAsync("api/news/addNews", content).Result; if (response.IsSuccessStatusCode) { var value = response.Content.ReadAsStringAsync(); resp = JsonConvert.DeserializeObject <NewsDetail>(value.Result); } return(resp); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> PutNewsDetail(int id, NewsDetail newsDetail) { if (id != newsDetail.NewsId) { return(BadRequest()); } _context.Entry(newsDetail).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NewsDetailExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
/// <summary> /// 获取新闻评论。 /// </summary> /// <param name="newsDetail">新闻内容。</param> /// <param name="pageIndex">第几页,从 1 开始。</param> /// <param name="pageSize">每页条数。</param> /// <returns>新闻评论。</returns> /// <exception cref="ArgumentNullException">新闻内容为 null。</exception> public static async Task <IEnumerable <NewsComment> > CommentAsync(this NewsDetail newsDetail, int pageIndex, int pageSize) { if (newsDetail == null) { throw new ArgumentNullException(nameof(newsDetail)); } return(await NewsService.CommentAsync(newsDetail.Id, pageIndex, pageSize)); }
public IRequisiteCmd GetMethod() { string bodyJson = body != null?body.ToString() : null; IRequisiteCmd requisiteCmd = null; switch (operationTable) { case OperateTable.PagePost: var page = new Page(); try { page = JsonHelper.JsonDeserilize <Page>(bodyJson); } catch (Exception e) { } PagePost pagePost = new PagePost(page, Db); requisiteCmd = pagePost as IRequisiteCmd; break; case OperateTable.NewsItemPost: var newsItem = new NewsItem(); try { newsItem = JsonHelper.JsonDeserilize <NewsItem>(bodyJson); } catch (Exception e) { } NewsItemPost newsItemPost = new NewsItemPost(newsItem, Db); requisiteCmd = newsItemPost as IRequisiteCmd; break; case OperateTable.NewsDetailPost: var newsDetail = new NewsDetail(); try { newsDetail = JsonHelper.JsonDeserilize <NewsDetail>(bodyJson); } catch (Exception e) { } NewsDetailPost newsDetailPost = new NewsDetailPost(newsDetail, Db); requisiteCmd = newsDetailPost as IRequisiteCmd; break; case OperateTable.MediaPost: var media = new Media(); try { media = JsonHelper.JsonDeserilize <Media>(bodyJson); } catch (Exception e) { } MediaPost mediaPost = new MediaPost(media, Db); requisiteCmd = mediaPost as IRequisiteCmd; break; default: break; } return(requisiteCmd); }
public NewsDetailPage(NewsDetail newsDetail) { InitializeComponent(); name.Text = newsDetail.data[0].Name; //content.Text = newsDetail.data[0].Content; content.Source = new HtmlWebViewSource { Html = @newsDetail.data[0].Content }; image.Source = newsDetail.data[0].Image; date.Text = newsDetail.data[0].Date; }
public ActionResult NewsDetails() { if (Sitecore.Context.Item == null) { return(null); } var dataSourceId = Sitecore.Context.Item.ID.ToString(); Assert.IsNotNullOrEmpty(dataSourceId, "dataSourceId is null or empty"); var item = Sitecore.Context.Database.GetItem(dataSourceId); if (item == null) { return(null); } NewsDetail newsDetail = new NewsDetail(); // Artists List - TreeList Field MultilistField newsArtistsListField = item.Fields[Templates.News.Fields.NewsArtists]; Item[] newsArtistsItems = newsArtistsListField.GetItems(); List <Artist> newsArtistsList = new List <Artist>(); if (newsArtistsItems != null && newsArtistsItems.Count() > 0) { foreach (Item i in newsArtistsItems) { Artist artist = new Artist(); Item artistItem = Sitecore.Context.Database.GetItem(i.ID); artist.ArtistName = artistItem.Fields[Templates.Artist.Fields.ArtistName.ToString()].Value; artist.ArtistTitle = artistItem.Fields[Templates.Artist.Fields.ArtistTitle.ToString()].Value; artist.ArtistDescription = artistItem.Fields[Templates.Artist.Fields.ArtistDescription.ToString()].Value; LinkField artistTwitterLink = artistItem.Fields[Templates.Artist.Fields.ArtistTwitterUrl]; artist.ArtistTwitterUrl = artistTwitterLink.Url; LinkField artistLinkedInLink = artistItem.Fields[Templates.Artist.Fields.ArtistLinkedInUrl]; artist.ArtistLinkedInUrl = artistLinkedInLink.Url; LinkField artistWebsiteLink = artistItem.Fields[Templates.Artist.Fields.ArtistWebsiteUrl]; artist.ArtistWebsiteUrl = artistWebsiteLink.Url; ImageField artistImage = artistItem.Fields[Templates.Artist.Fields.ArtistImage]; artist.ArtistImageUrl = Sitecore.Resources.Media.MediaManager.GetMediaUrl(artistImage.MediaItem); artist.ArtistImageAlt = artistImage.Alt; newsArtistsList.Add(artist); } } newsDetail.NewsArtistList = newsArtistsList; return(View(newsDetail)); }
public async Task <IActionResult> Create([Bind("NewsDetailID,Content,Nameposted,CreateDate,NewsID")] NewsDetail newsDetail) { if (ModelState.IsValid) { _context.Add(newsDetail); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["NewsID"] = new SelectList(_context.News, "NewsID", "NewsID", newsDetail.NewsID); return(View(newsDetail)); }
private void EvetClicked(object s, SelectedItemChangedEventArgs e) { var obj = (News.Data)e.SelectedItem; string param = obj.NewsId.ToString(); NewsDetail newsdetail = repo.getNewsDetail(param).Result; NewsDetailPage myHomePage = new NewsDetailPage(newsdetail); NavigationPage.SetHasNavigationBar(myHomePage, false); Navigation.PushModalAsync(myHomePage); }
internal static NewsDetail Deserialize(XDocument document) { var root = document?.Root; if (root == null) { return(null); } var ns = root.GetDefaultNamespace(); var title = root.Element(ns + "Title"); var sourceName = root.Element(ns + "SourceName"); var submitDate = root.Element(ns + "SubmitDate"); var content = root.Element(ns + "Content"); var imageUrl = root.Element(ns + "ImageUrl"); var prevNews = root.Element(ns + "PrevNews"); var nextNews = root.Element(ns + "NextNews"); var commentCount = root.Element(ns + "CommentCount"); if (title == null || sourceName == null || submitDate == null || content == null || imageUrl == null || prevNews == null || nextNews == null || commentCount == null) { return(null); } var newsDetail = new NewsDetail { Title = WebUtility.HtmlDecode(title.Value).Trim(), SourceName = sourceName.Value, SubmitDate = DateTime.Parse(submitDate.Value, CultureInfo.InvariantCulture), Content = content.Value, ImageUrl = new ReadOnlyCollection <Uri>(new List <Uri>(from temp in imageUrl.Value.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries) select new Uri(temp, UriKind.Absolute))), CommentCount = int.Parse(commentCount.Value, CultureInfo.InvariantCulture) }; if (prevNews.IsEmpty == false) { newsDetail.PrevNews = int.Parse(prevNews.Value, CultureInfo.InvariantCulture); } if (nextNews.IsEmpty == false) { newsDetail.NextNews = int.Parse(nextNews.Value, CultureInfo.InvariantCulture); } return(newsDetail); }
protected void btnSubmit_Click(object sender, EventArgs e) { using (BLLNewsDetail bll = new BLLNewsDetail()) { NewsDetail obj = new NewsDetail(); if (id > 0) { obj = bll.GetSingle(id); } obj.NewsTypeID = Convert.ToInt32(ddlNewsType.SelectedValue); obj.NewsTitle = txtNewsTitle.Text.ToString(); obj.NewsContent = txtContent.Value; obj.Remarks = txtRemarks.Text.ToString(); obj.AddTime = Convert.ToDateTime(System.DateTime.Now.ToShortDateString()); if (txtAutoSort.Text.ToString() == "") { obj.AutoSort = 0; } else { obj.AutoSort = Convert.ToInt32(txtAutoSort.Text.Trim().ToString()); } if (rbtnIsChinese.Checked == true) { obj.IsEnglish = 1; } else if (rbtnIsEnglish.Checked == true) { obj.IsEnglish = 2; } else { ShowMsg("请选择语言类别!"); return; } bll.Save(obj); if (bll.IsFail) { ExceptionManager.ShowErrorMsg(this, bll.DevNetException); } else { JSMsg.ShowWinRedirect(this, "保存成功", "cpNewsList.aspx"); } } }
private void Bind() { string[] fileds = new string[] { "id", "IsEnglish" }; object[] values = new object[] { id, 1 }; using (BLLNewsDetail BLL = new BLLNewsDetail()) { NewsDetail obj = new NewsDetail(); obj = BLL.GetSingle(fileds, values); if (obj != null) { lblTitle.Text = obj.NewsTitle; lblcontent.Text = obj.NewsContent; lblTime.Text = string.Format("{0:D}", obj.AddTime); } } }
/// <summary> /// 获得信息详细 /// </summary> /// <returns></returns> public string getNewsDetailInfo() { JObject msg = new JObject(); string appid = this.Request.Form["aid"]; string id = this.Request.Form["id"]; if (!Lw_Utils.WeChartCertify(appid)) { msg.Add("msg", "APPIDERROR"); } else { WebReference.WebService1 client = Lw_Utils.getServiceMethod(); JArray NewsDetail; NewsDetail = (JArray)JsonConvert.DeserializeObject(client.GetNewsDetail(id)); if (NewsDetail.LongCount() == 0) { msg.Add("data", new JArray()); msg.Add("msg", "NOTFOUNT"); } else { foreach (JToken jt in NewsDetail) { JObject item = (JObject)jt; string hasfile = (string)item["FileLoad"]; if (hasfile == "1") { JArray FileList = (JArray)JsonConvert.DeserializeObject(client.GetFiles((string)item["id"])); item.Add("FileList", FileList); } else { item.Add("FileList", new JArray()); } JArray ja = new JArray(); ja.Add(item); msg.Add("data", NewsDetail); msg.Add("msg", "OK"); } } } return(msg.ToString()); }
public async Task <NewsDetail> getNewsDetail(string newsId) { object param = new { newsId }; var jsonObj = JsonConvert.SerializeObject(param); using (HttpClient client = new HttpClient()) { StringContent content = new StringContent(jsonObj.ToString(), Encoding.UTF8, "application/json"); var request = new HttpRequestMessage() { RequestUri = new Uri("https://crmpuntos.oliviadirect.co/services/content/detail-news.php"), Method = HttpMethod.Post, Content = content }; //you can add headers //request.Headers.Add("key", "value"); var response = await client.SendAsync(request).ConfigureAwait(false); string dataResult = response.Content.ReadAsStringAsync().Result; NewsDetail result = JsonConvert.DeserializeObject <NewsDetail>(dataResult); return(result); } }
public NewsDetailPresenter(NewsDetail page) { view = page; }
public void Add(NewsDetail data) { _context.Add(data); }
public HttpResponseMessage GetNewsDetails(NewsDetail arg) { BaseJson <GetZX_NewsDetails> resultMsg = new BaseJson <GetZX_NewsDetails> { Status = (int)JsonObjectStatus.Error, Message = "服务器未知错误。", Data = null }; Logger(typeof(ZxNewsController), arg.TryToJson(), "新闻详情-GetNewsDetails", () => { if (!string.IsNullOrEmpty(arg.NewsId)) { #region 用 //NewsEntity data = newsBll.GetEntity(arg.NewsId); ////获取数据 //GetZX_NewsDetails res = new GetZX_NewsDetails(); //if (data != null) //{ // res = new GetZX_NewsDetails // { // NewsId = data.NewsId, // PK = data.PK, // FullHead = data.FullHead, // CreateDate = data.CreateDate.TryToDateTimeToString("yyyy-MM-dd"), // CreateUserName = data.CreateUserName, // NewsContent = data.NewsContent, // PeriodsNumber = data.PeriodsNumber, // IsRecommend = data.IsRecommend ?? false, // IsHot = data.IsHot ?? false, // PV = data.PV ?? 0, // TitleElement = data.TitleElement, // DescriptionElement = data.DescriptionElement, // KeywordElement = data.KeywordElement, // }; // #region 新增上一期、下一期预告 // List<OnThene> preAndNext = GetNewsListByPk(res.PK ?? 1); // res.PreAndNextNewsList = preAndNext; // #endregion //} #endregion DataTable data = commonBll.ExcuteSqlDataTable(string.Format(GetNewsDetailSql, arg.NewsId), DatabaseLinksEnum.Base); if (data != null && data.Rows.Count > 0) { NewsEntity entity = data.DataTableToObject <NewsEntity>(); GetZX_NewsDetails res = new GetZX_NewsDetails { NewsId = entity.NewsId, PK = entity.PK, FullHead = entity.FullHead, CreateDate = entity.CreateDate.TryToDateTimeToString("yyyy-MM-dd"), CreateUserName = entity.CreateUserName, NewsContent = entity.NewsContent, PeriodsNumber = entity.PeriodsNumber, IsRecommend = entity.IsRecommend ?? false, IsHot = entity.IsHot ?? false, PV = entity.PV ?? 0, TitleElement = entity.TitleElement, DescriptionElement = entity.DescriptionElement, KeywordElement = entity.KeywordElement, }; #region 新增上一期、下一期预告 List <PreAndNextNews> preAndNext = GetNewsListByPk(res.PK ?? 1); res.PreAndNextNewsList = preAndNext; #endregion resultMsg = new BaseJson <GetZX_NewsDetails> { Status = (int)JsonObjectStatus.Success, Data = res, Message = JsonObjectStatus.Success.GetEnumText(), BackUrl = null }; } } else { resultMsg = new BaseJson <GetZX_NewsDetails> { Status = (int)JsonObjectStatus.Fail, Data = null, Message = JsonObjectStatus.Fail.GetEnumText() + ",请求参数有误。", BackUrl = null }; } }, e => { resultMsg = new BaseJson <GetZX_NewsDetails> { Status = (int)JsonObjectStatus.Exception, Data = null, Message = JsonObjectStatus.Exception.GetEnumText() + ",异常信息:" + e.Message, BackUrl = null }; }); return(resultMsg.TryToJson().ToHttpResponseMessage()); }
public void UpdateNews(NewsDetail news) { NewsData.SubmitChanges(); }
public void Update(NewsDetail data) { _context.Update(data); }
/// <summary> /// 发送新闻评论。 /// </summary> /// <param name="newsDetail">新闻内容。</param> /// <param name="cookie">Cookie。</param> /// <param name="comment">评论内容,不少于 3 个字符。</param> /// <returns>一段 Html,指示是否操作成功。</returns> public static async Task <string> SendCommentAsync(this NewsDetail newsDetail, Cookie cookie, string comment) { return(await UserService.SendNewsCommentAsync(cookie, newsDetail.Id, comment, 0)); }
/// <summary> /// Handles the <see cref="E:NewsEvent" /> event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="NewsSummaryEventArgs" /> instance containing the event data.</param> protected virtual void OnNewsDetail(object sender, NewsDetailEventArgs e) { NewsDetail?.Invoke(sender, e); }
/// <summary> /// 下载文章详情 /// </summary> private void DownloadDocument(string uri) { WebClient proxy = Tool.SendWebClient(uri, new Dictionary <string, string>( )); proxy.DownloadStringCompleted += (s, e) => { if (e.Error != null) { System.Diagnostics.Debug.WriteLine("获取 {0} 网络错误: {0}", this.DetailType.ToString( ), e.Error.Message); return; } }; switch (this.DetailType) { case DetailType.News: proxy.DownloadStringCompleted += (s, e) => { NewsDetail n = Tool.GetNewsDetail(e.Result); if (n != null) { this.newsDetail = n; this.browser.NavigateToString(Tool.ProcessHTMLString(Tool.HtmlProcess_News(n))); this.CheckApplicationBarByDetailType( ); this.lblCommentCount.Text = string.Format("评论({0})", this.newsDetail.commentCount); } }; break; case DetailType.Post: proxy.DownloadStringCompleted += (s, e) => { PostDetail p = Tool.GetPostDetail(e.Result); if (p != null) { this.postDetail = p; this.browser.NavigateToString(Tool.ProcessHTMLString(Tool.HtmlProcess_Post(p))); this.CheckApplicationBarByDetailType( ); this.lblCommentCount.Text = string.Format("评论({0})", this.postDetail.answerCount); } }; break; case DetailType.Blog: proxy.DownloadStringCompleted += (s, e) => { BlogDetail b = Tool.GetBlogDetail(e.Result); if (b != null) { this.blogDetail = b; this.browser.NavigateToString(Tool.ProcessHTMLString(Tool.HtmlProcess_Blog(b))); this.CheckApplicationBarByDetailType( ); this.lblCommentCount.Text = string.Format("评论({0})", this.blogDetail.commentCount); //这里特别注意 要获取一下owneruid this.commentListControl.owneruid = this.blogDetail.authorID.ToString( ); } }; break; case DetailType.Software: proxy.DownloadStringCompleted += (s, e) => { SoftwareDetail soft = Tool.GetSoftwareDetail(e.Result); if (soft != null) { this.softwareDetail = soft; this.browser.NavigateToString(Tool.ProcessHTMLString(Tool.HtmlProcess_Software(soft))); this.CheckApplicationBarByDetailType( ); } }; break; case DetailType.Tweet: proxy.DownloadStringCompleted += (s, e) => { TweetDetail t = Tool.GetTweetDetail(e.Result); if (t != null) { this.tweetDetail = t; this.browser.NavigateToString(Tool.ProcessHTMLString(Tool.HtmlProcess_Tweet(t))); this.CheckApplicationBarByDetailType( ); this.lblCommentCount.Text = string.Format("评论({0})", this.tweetDetail.commentCount); } }; break; } GC.Collect( ); }