// Création des news et ajout dans le dictionary public News(user u) { this.u = u; NewsInfo criseAuCaire = new NewsInfo(this, "Une crise éclate au caire.", "Manifestations contre le gouvernement en place en Irak, le pays est paralisé", "désactivé",10,30,10,1, "Pétrole", 0.95,"Geopoliticien", "WW3"); NewsInfo Gisement = new NewsInfo(this, "Découverte d'une gisement", "Découverte d'un immense gisement de pétrole au coeur de la Gironde", "désactivé",10,30,10,1,"Pétrole", 1.05, "Ingénieur", "none"); NewsInfo CriseTextile = new NewsInfo( this, "Crise du textile", "L'industrie du textile en plus crise", "désactivé", 10, 30, 10, 1, "Vêtement", 0.95, "Geopoliticien", "none" ); NewsInfo DéfiléMode = new NewsInfo(this, "Défilé de mode", "Incroyable succès du dernier défilé de mode parisien","désactivé",10,30,10,1,"Vêtement",1.05,"Coiffeuse","none"); NewsInfo CriseTelephone = new NewsInfo( this, "Crise du téléphone", "15000 Iphone cassé chaque jour dans le monde , déja qu'ils ont pas de batterie...", "désactivé", 10, 30, 10, 1, "Mecano", 0.95, "Mecano", "none" ); NewsInfo ExpansionConsole = new NewsInfo( this, "Expansion des jeux", "Le jeux vidéo fait un grand retour sur vos consoles cette année", "désactivé", 10, 30, 10, 1, "Electronique", 1.05, "Coiffeuse", "none" ); NewsInfo CrashTest = new NewsInfo( this, "CrashTest", "D'après une récette enquète , les crash test des grandes compagnies de voitures seraient truqués","désactivé", 10, 30, 10, 1, "Voiture", 0.95, "Coiffeuse", "none" ); NewsInfo AlcolVolant = new NewsInfo( this, "Alcol au volant", "Loi Bourbon , l'alcolémie au volant est maintenant autorisé", "désactivé", 10, 30, 10, 1, "Voiture", 0.95, "Coiffeuse", "none" ); NewsInfo FonciaVoleur = new NewsInfo( this, "FOncia vole ", "Une association indépendante a porté plainte contre Foncia contre escroquerie","désactivé", 10, 30, 10, 1, "Commerial", 0.95, "Coiffeuse", "none" ); NewsInfo BaisseDesprix = new NewsInfo( this, "Baisse des prix", "Baisse général du prix de l'immobilier dans toute la françe", "désactivé", 10, 30, 10, 1, "Immobilier", 1.05, "Commercial", "none" ); NewsInfo Hack = new NewsInfo( this, "hack", "Hacking de tous les comptes tweeter", "désactivé", 10, 30, 10, 1, "Informatique", 0.95, "Mecano", "none" ); NewsInfo LA5G = new NewsInfo (this , "5g", "La 5g est désormais disponible partout en françe","désactivé", 10,30,10,1,"Informatique", 1.05,"Mecano","none"); N.Add( "criseAuCaire", criseAuCaire ); N.Add("Gisement", Gisement); N.Add("CriseTextile",CriseTextile); N.Add( "DéfiléMode", DéfiléMode ); N.Add( "CriseTelephone", CriseTelephone ); N.Add( "ExpansionConsole", ExpansionConsole ); N.Add( "CrashTest", CrashTest ); N.Add("AlcolVolant",AlcolVolant); N.Add( "FonciaVoleur", FonciaVoleur ); N.Add( "BaisseDesprix", BaisseDesprix ); N.Add( "Hack", Hack ); N.Add( "LA5G", LA5G ); }
protected void Page_Load(object sender, EventArgs e) { NewsInfo news = new NewsInfo(); NewsInfoImpl pl = new NewsInfoImpl(); news = pl.GetNewsInfoById(Convert.ToInt32(Request.Params["id"])); id = news.id.ToString(); title = news.title; datetime = news.addtime.ToShortDateString(); scource = news.source == "" ? "不详" : news.source; content = news.newscontent; catname = news.categoryName; catid = news.catid.ToString(); author = news.author == "" ? "工大在线运营团队" : news.author; introduction = Common.CutString((news.introduce == "" ? Common.DelHTML(news.newscontent) : news.introduce), 200); keywords = news.keyword; Page.Title = title; //找出校区 if (ConfigurationManager.AppSettings["daxuecheng"].ToString().IndexOf(catid) != -1) campus = "daxuecheng"; else if (ConfigurationManager.AppSettings["longdong"].ToString().IndexOf(catid) != -1) campus = "longdong"; else campus = "dongfenglu"; //增加点击量 pl.UpdateNewsInfoHit(news.id); //评论部分 //CommentImpl cpl = new CommentImpl(); //commentpl.DataSource = cpl.GetCommentbyNewsId(news.id); //commentpl.DataBind(); }
/// <summary> /// /// </summary> /// <param name="newsid"></param> /// <returns></returns> public static NewsInfo GetModel(int newsid) { try { SqlParameter[] parameters = { new SqlParameter("@newsid", SqlDbType.Int, 4) }; parameters[0].Value = newsid; NewsInfo model = new NewsInfo(); DataSet ds = DataBase.ExecuteDataset(CommandType.StoredProcedure, "proc_news_GetModel", parameters); if (ds.Tables[0].Rows.Count > 0) { return(GetModelFromDR(ds.Tables[0].Rows[0])); } else { return(null); } } catch (Exception ex) { ExceptionHandler.HandleException(ex); return(null); } }
public ActionResult EditNews(NewsModel model, int newsId = -1) { NewsInfo newsInfo = AdminNews.AdminGetNewsById(newsId); if (newsInfo == null) { return(PromptView("新闻不存在")); } int newsId2 = AdminNews.AdminGetNewsIdByTitle(model.Title); if (newsId2 > 0 && newsId2 != newsId) { ModelState.AddModelError("Title", "名称已经存在"); } if (ModelState.IsValid) { newsInfo.NewsTypeId = model.NewsTypeId; newsInfo.IsShow = model.IsShow; newsInfo.IsTop = model.IsTop; newsInfo.IsHome = model.IsHome; newsInfo.DisplayOrder = model.DisplayOrder; newsInfo.Title = model.Title; newsInfo.Url = model.Url == null ? "" : model.Url; newsInfo.Body = model.Body ?? ""; AdminNews.UpdateNews(newsInfo); AddMallAdminLog("修改新闻", "修改新闻,新闻ID为:" + newsId); return(PromptView("新闻修改成功")); } Load(); return(View(model)); }
public NewsInfo GetInfo(int id) { NewsInfo news = null; var param = new[] { new SqlParameter("@pk_ID", SqlDbType.Int) { Value = id } }; var r = DataHelper.ExecuteReader(Config.ConnectionString, "usp_News_GETDetail", param); while (r.Read()) { news = new NewsInfo { pk_Id = UntilityFunction.IntegerForNull(r["pk_ID"]), s_Title = UntilityFunction.StringForNull(r["s_Title"]), s_Description = UntilityFunction.StringForNull(r["s_Description"]), s_Image = UntilityFunction.StringForNull(r["s_Image"]), s_Content = UntilityFunction.StringForNull(r["s_Content"]), d_DateCreated = Convert.ToDateTime(r["d_DateCreated"]), fk_UserId = UntilityFunction.IntegerForNull(r["fk_User"]), s_FullName = UntilityFunction.StringForNull(r["s_FullName"]), fk_CategoryId = UntilityFunction.IntegerForNull(r["fk_CategoryID"]), fk_CategoryName = UntilityFunction.StringForNull(r["s_CategoryName"]), SortField = UntilityFunction.IntegerForNull(r["SortField"]), Active = (r["Active"].ToString() == "Y") }; } r.Close(); r.Dispose(); return(news); }
static void CreateTestData_NewsInfo() { Repository <NewsInfo> repository = new Repository <NewsInfo>(); for (int i = 0; i < 100; i++) { NewsInfo imgPlayInfo = new NewsInfo() { CategoryId = 0, Title = "文章标题_" + i, ImgUrl = "/images/bg-img/defaultNewCover.png", Author = "山治", Summary = "这是是简介,这是是简介,这是是简介,这是是简介,这是是简介,这是是简介", Content = "<p>不信自己百度<p>", Source = "本网自产", ReleaseTime = DateTime.Now, ViewCount = 0, IsDisable = EYesOrNo.No, Sort = i, CreateAdminId = 1, UpdateAdminId = 1, UpdateTime = DateTime.Now }; repository.Insert(imgPlayInfo); } }
/// <summary> /// 获取分页数据 /// </summary> /// <param name="start"></param> /// <param name="end"></param> /// <returns></returns> public List <NewsInfo> GetPageList(int start, int end) { string sql = "select * from (select row_number() over(order by id) as num,* from NewsInfo) as t where t.num>=@start and t.num<=@end"; //先把所有的产品筛选出来,然后对这些产品进行编号。然后在where子句中进行过滤。 SqlParameter[] pars = { new SqlParameter("@start", SqlDbType.Int), new SqlParameter("@end", SqlDbType.Int) }; pars[0].Value = start; pars[1].Value = end; DataTable da = SqlHelper.GetTable(sql, CommandType.Text, pars); List <NewsInfo> list = null; if (da.Rows.Count > 0) { list = new List <NewsInfo>(); NewsInfo newInfo = null; foreach (DataRow row in da.Rows) //datatable数据装到list集合返回 遍历所有行 { newInfo = new NewsInfo(); LoadEntity(row, newInfo); list.Add(newInfo); } } return(list); }
public ActionResult GetNewsInfoModel() { int id = int.Parse(Request["id"]); NewsInfo newInfo = NewsInfoService.GetModel(id); //获取详细信息. return(Json(newInfo, JsonRequestBehavior.AllowGet)); //get方法请求的话会抛出异常 }
protected void Page_Load(object sender, EventArgs e) { int id = Convert.ToInt32(Request["id"]); newsInfo = DataProvider.Instance.GetNewsById(id); strSeoInfo = ""; strPublishTime = newsInfo.AddTime.ToString("yyyy-MM-dd"); }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { if (ViewState["strAction"].ToString() == "add" || FileUploadHTML.HasFile) { string fileName = CommonFunction.Get_DynamicString() + FileUploadHTML.FileName; string filePath = Server.MapPath("~/workexpress/" + fileName); if (!CommonFunction.Is_FileUploadSuccessfully(FileUploadHTML, Literal1, filePath, new string[] { ".html", "htm", "shtml" })) { return; } ViewState["HTML"] = fileName; } NewsInfo news = new NewsInfo(); news.N_Title = txtTitle.Text; news.N_From = txtFrom.Text; news.N_Content = ""; news.N_ImgPath = ViewState["HTML"].ToString(); news.N_ImgView = ""; news.N_HotIco = ""; news.N_PicIco = ""; news.N_Time = txtTime.Text; news.N_TID = Convert.ToInt32(((DataTable)ViewState["dtType"]).Rows[0]["T_ID"]); if (ViewState["strAction"].ToString() == "update") { news.N_ID = Convert.ToInt32(ViewState["nid"]); NewsInfoService.Update_NewsInfoWithTime(news); } else if (ViewState["strAction"].ToString() == "add") { NewsInfoService.Insert_NewsInfoWithTime(news); } CommonFunction.AlertAndRedirect(Literal1, "操作成功", "WorkExpressMgr.aspx?tid=" + Convert.ToInt32(((DataTable)ViewState["dtType"]).Rows[0]["T_ID"])); }
public static string BuildContentItem(NewsInfo oItem) { //#if !DEBUG // var oData = CacheController.GetNews(oItem.pk_Id); // if (oData != null) return oData.ToString(); //#endif StringBuilder sb = new StringBuilder(); sb = new StringBuilder(); sb.AppendFormat("<h3 class=\"colorxah\" style=\"padding:5px 0 0 7px;\">{0}</h3>", oItem.fk_CategoryName); sb.Append("<hr />"); sb.AppendFormat("<p style=\"font-weight: bold;font-size:14pt;line-height: 20px; padding-left:5px; padding-bottom: 10px; padding-Right: 10px; text-align:justify \" >{0}</p>", oItem.s_Title); if (oItem.s_Image.Trim() != "") { //sb.AppendFormat("<script>DrawImgSize('{0}');</script>",UntilityFunction.GetPathImg(oItem.s_Image)); //sb.AppendFormat("<img style=\"width:400px; display:block; margin:10px auto;\" src=\"{0}\" />", UntilityFunction.GetPathImg(oItem.s_Image)); sb.AppendFormat("<div style=\"float:left\"><img alt=\"{1}\" style=\"display:block;width:105px; padding:0px 10px 0px 10px;\" src=\"{0}\" /></div>", UntilityFunction.GetPathImgThumb(oItem.s_Image), oItem.s_Title); } sb.AppendFormat("<p style=\"font-weight:bold; line-height: 15px; padding-left: 10px; padding-Right: 10px; text-align:justify\">{0}</p>", oItem.s_Description); sb.AppendFormat("<div style=\"clear:both\"></div>"); sb.AppendFormat("<div style=\"padding: 10px; width: 680px;\"><div id=\"DivContent\">{0}</div></div>", oItem.s_Content); string s = sb.ToString(); //#if !DEBUG // CacheController.GetNews(oItem.pk_Id,s); //#endif return(s); }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { NewsInfo news = new NewsInfo(); news.N_Title = txtTitle.Text.Trim(); news.N_From = "河南省高速公路路警联合指挥中心"; news.N_Content = txtContent.Text; news.N_ImgPath = ""; news.N_ImgView = ""; news.N_HotIco = ""; news.N_PicIco = ""; news.N_Time = txtTime.Text; news.N_TID = Convert.ToInt32(((DataTable)ViewState["dtType"]).Rows[0]["T_ID"]); if (ViewState["strAction"].ToString() == "update") { news.N_ID = Convert.ToInt32(ViewState["nid"]); NewsInfoService.Update_NewsInfoWithTime(news); } else if (ViewState["strAction"].ToString() == "add") { NewsInfoService.Insert_NewsInfoWithTime(news); } if (Convert.ToInt32(((DataTable)ViewState["dtType"]).Rows[0]["T_ID"]) == 80) { CommonFunction.AlertAndRedirect(Literal1, "操作成功", "CurrentRoadContion.aspx?tid=" + Convert.ToInt32(((DataTable)ViewState["dtType"]).Rows[0]["T_ID"])); } else if (Convert.ToInt32(((DataTable)ViewState["dtType"]).Rows[0]["T_ID"]) == 81) { CommonFunction.AlertAndRedirect(Literal1, "操作成功", "HistoryRoadCondition.aspx?tid=" + Convert.ToInt32(((DataTable)ViewState["dtType"]).Rows[0]["T_ID"])); } }
public void UpdateNewsInfo(NewsInfo entity) { DataCommand dc = DataCommandManager.GetDataCommand("News_UpdateNews"); dc.SetParameterValue <NewsInfo>(entity); dc.ExecuteNonQuery(); }
protected void Bind() { if (Request.QueryString["id"] != null) { if (Tools.TryParseMethod(id.ToString()) > 0) { NewsInfo info = nBLL.getAllById(id); FriendLinkInfo finfo = fBLL.getDataByLid(lid); lbCategory.Text = finfo.f_title; lbTitle.Text = info.n_title; litContent.Text = info.n_detail; img1.ImageUrl = Tools.GetAppSettings("NewsImageTruePath") + info.n_image; lbHits.Text = info.n_hits.ToString(); lbBuilddate.Text = info.n_ts.ToString("yyyy/MM/dd HH:mm"); lbEditDate.Text = info.n_editDate.ToString("yyyy/MM/dd HH:mm"); lbStartdate.Text = info.n_startDate.ToString("yyyy/MM/dd"); lbEnddate.Text = info.n_endDate.ToString("yyyy/MM/dd"); if (info.n_show) { lbShow.Text = "顯示"; } else { lbShow.Text = "不顯示"; } rpImage.DataSource = niBLL.GetAllImgWithNews(id); rpImage.DataBind(); } } }
public ActionResult CreateNews(FormCollection fc) { int userId = -1; if (Session["UserID"] != null) { userId = int.Parse(Convert.ToString(Session["UserID"])); } NewsModel news = new NewsModel(); BLLNews bll = new BLLNews(); NewsInfo newsObject = new NewsInfo() { Title = fc["Title"].ToString(), Content = fc["Message"].ToString(), CreateDate = DateTime.Now, IsDelete = false, IsPublic = Convert.ToBoolean(fc["IsPublic"]), IsTop = false, ViewTimes = 0, IsCommented = false, UserId = userId }; //保存到数据库 bll.Insert(newsObject); //返回到列表 return(RedirectToAction("Index")); }
public virtual int?CreateNewsInfo(NewsInfo entity) { ValidateEntity(entity); //处理飘红 if (entity.IsRed.HasValue && entity.IsRed.Value) { entity.Title.Content = GetRedTitle(entity.Title.Content); } using (TransactionScope scope = new TransactionScope()) { //1.插入新闻公告 entity = newsDA.CreateNewsInfo(entity); //2.插入新闻地区关系 if (entity.AreaShow != null && entity.AreaShow.Count() > 0) { foreach (var area in entity.AreaShow) { ObjectFactory <IAreaRelationDA> .Instance.Create(area, entity.SysNo.Value, AreaRelationType.News); } } scope.Complete(); return(entity.SysNo); } return(null); }
public IHttpActionResult PutNews(int id, NewsInfo nw) { ctx.Entry(nw).State = EntityState.Modified; ctx.SaveChanges(); return(Ok(nw)); }
protected void btnPublish_Click(object sender, EventArgs e) { string newstitle = string.Format("{0}月{1}日提现已出款请商户查收", DateTime.Now.Month, DateTime.Now.Day); var itemInfo = new NewsInfo { newstype = NewsType.佣金公告, newstitle = newstitle, addTime = DateTime.Now, newscontent = newstitle, IsRed = 0, IsTop = 0, IsPop = 0, Isbold = 0, Color = "", release = true }; if (NewsFactory.Add(itemInfo) > 0) { AlertAndRedirect("发送成功!", "NewsList.aspx"); } else { AlertAndRedirect("发送失败!", "NewsList.aspx"); } }
private int iType = 5;//cong ty protected void Page_Load(object sender, EventArgs e) { int id = ConvertUtility.ToInt32(Request.QueryString["ID"]); NewsInfo oItem = ServiceFactory.GetInstanceNews().GetInfo(id); if (oItem != null) { sTitle = oItem.s_Title; sDescription = oItem.s_Description; sContent = oItem.s_Content; var oList = ServiceFactory.GetInstanceNews().SelectTopNews(iType, 10); if (oList != null) { sOther = App_Code.Controls.News.News.BuildContentOtherItem(oList, id, "cong-ty/default.aspx"); } } else { var oList = ServiceFactory.GetInstanceNews().SelectTopNews(iType, 10); if (oList != null) { if (oList.Count > 0) { sTitle = oList[0].s_Title; sDescription = oList[0].s_Description; sContent = oList[0].s_Content; MetaTag("description", oList[0].s_Description); sOther = App_Code.Controls.News.News.BuildContentOtherItem(oList, oList[0].pk_Id, "cong-ty"); } } } }
public ResponseMessageWrap <int> Update([FromBody] NewsInfo newsInfo) { return(new ResponseMessageWrap <int> { Body = NewsInfoService.Update(newsInfo) }); }
public ResponseMessageWrap <int> Insert([FromBody] NewsInfo newsInfo) { return(new ResponseMessageWrap <int> { Body = NewsInfoService.Insert(newsInfo) }); }
private bool AddNews() { if (string.IsNullOrEmpty(txtTenTin.Text) || string.IsNullOrEmpty(Content.Text)) { ltrThongbao.Text = "Bắt buộc nhập tên tin và nội dung tin"; return(false); } var info = new NewsInfo(); info.Title = txtTenTin.Text; info.CateName = drpNhomTin.SelectedItem.Text; info.CateId = int.Parse(drpNhomTin.SelectedValue); info.Content = Content.Text; info.MetaDescription = txtMotaSeo.Text; info.Description = txtdesc.Text; var nextId = LicSystem.Core.UntilityFunction.nextId("News"); info.Link = Rewrite.GenDetail(info.CateName, info.CateId, nextId, info.Title, Rewrite.News); info.AltImage = Server.HtmlEncode(info.Title); info.MetaKeyword = txtkeyword.Text; info.MetaHeading = txtkeyword.Text; info.CreateDate = DateTime.Now; info.Action = chkAction.Checked; info.TitleRewrite = ""; info.LanguageId = "VN"; info.Image = upHinhanh.HasFile ? UploadImage(info.Id) : ""; NewsImpl.Instance.Add(info); return(true); }
protected bool GetData() { if (!InfoType.ToText().IsIn("1;2")) { return(false); } if (InfoType == 1) { NewsBLL bll = new NewsBLL(); NewsInfo model = bll.GetNewsInfo(NewsId.ToInt(0)); if (model == null) { return(false); } strTitle = model.Title; Content = model.Content; AddDate = (model.AddDate ?? DateTime.Today).ToString("yyyy-MM-dd"); } else if (InfoType == 2) { VideoBLL bll = new VideoBLL(); VideoInfo model = bll.GetVideoInfo(SafeConvert.ToGuid(NewsId).Value); if (model == null) { return(false); } strTitle = model.Title; AddDate = (model.AddDate ?? DateTime.Today).ToString("yyyy-MM-dd"); VideoPath = model.videopath; } return(true); }
private void Add() { NewsInfo model = new NewsInfo(); model.ID = int.Parse(Request.Form["ID"]); model.CategoryID = int.Parse(Request.Form["CategoryID"]); model.Title = Request.Form["Title"]; if (Request.Form["Release_time"].Trim() == "") { model.Release_time = DateTime.Now; } else { model.Release_time = Convert.ToDateTime(Request.Form["Release_time"]); } model.Release_people = Request.Form["Release_people"]; model.Click = int.Parse(Request.Form["Click"]); model.IsHost = Convert.ToBoolean(Request.Form["IsHost"]); model.State = Convert.ToBoolean(Request.Form["State"]); //大文本处理 int id = dao.Add(model); ///////////////////// NewsDao.AddGive(id); Log.WritePage(id > 0 ? "SUCCESS" : "Error"); }
public ActionResult ModifyNewsConfirm() { NewsInfo news = new NewsInfo(); news.news_id = int.Parse(Request.Form["id"]); news.news_title = Request.Form["title"]; news.news_author = Request.Form["author"]; news.news_source = Request.Form["from"]; news.news_abstract = Request.Form["abstract"]; news.new_release_time = DateTime.Now; String text = Request.Form["text"]; text = text.Replace("#lt;", "<"); text = text.Replace("#gt;", ">"); news.news_content = text; int categoryId = int.Parse(Request.Form["classify"]); news.newsCategory_id = categoryId; if (ModelState.IsValid) { newsContext.Entry(news).State = EntityState.Modified; newsContext.SaveChanges(); } return(Content("修改成功")); }
private void edit() { NewsInfo model = new NewsInfo(); model.ID = int.Parse(Request.Form["ID"]); model.CategoryID = int.Parse(Request.Form["CategoryID"]); model.Title = Request.Form["Title"]; if (Request.Form["Release_time"].Trim() == "") { model.Release_time = DateTime.Now; } else { model.Release_time = Convert.ToDateTime(Request.Form["Release_time"]); } model.Release_people = Request.Form["Release_people"]; model.Click = int.Parse(Request.Form["Click"]); model.IsHost = Convert.ToBoolean(Request.Form["IsHost"]); model.State = Convert.ToBoolean(Request.Form["State"]); //上传图片处理 //string imgUrl = ImageHelper.UploadImg("fuligoods"); //if (imgUrl != "") model.imgUrl = imgUrl; bool result = dao.Update(model); Log.WritePage(result ? "SUCCESS" : "Error"); }
private void BindObject(int objID) { NewsInfo obj = NewsManager.Select(objID); if (obj != null) { this.txtTitle.Text = obj.Title; this.txtSubTitle.Text = obj.SubTitle; this.txtSumary.Text = obj.Summary; this.txtDetailText.Value = obj.Detail; this.txtSource.Text = obj.Source; this.txtAuthor.Text = obj.Author; this.chkShowSubTitle.Checked = obj.ShowSubTitle; this.ddlCategory.SelectedIndex = -1; ListItem item1 = this.ddlCategory.Items.FindByValue(obj.CategoryID.ToString()); if (item1 != null) { item1.Selected = true; } this.img1.ImageUrl = "/Upload/" + obj.ImagePath; this.imageName = obj.ImagePath; this.lblImg1.Text = this.imageName; this.Label1.Text = obj.IconPath; this.lblCreatedBy.Text = obj.CreatedBy; this.lblCreatedDate.Text = obj.CreatedOn.ToString("dd/MM/yyyy"); this.lblModifiedBy.Text = obj.ModifiedBy; this.lblModifiedDate.Text = obj.ModifiedOn.ToString("dd/MM/yyyy"); this.lblApprovedBy.Text = obj.ApprovedBy; this.lblApprovedDate.Text = obj.ApprovedOn.ToString("dd/MM/yyyy"); } }
public ActionResult AddNews(NewsModel model) { if (AdminNews.AdminGetNewsIdByTitle(model.Title) > 0) { ModelState.AddModelError("Title", "标题已经存在"); } if (ModelState.IsValid) { NewsInfo newsInfo = new NewsInfo() { NewsTypeId = model.NewsTypeId, IsShow = model.IsShow, IsTop = model.IsTop, IsHome = model.IsHome, DisplayOrder = model.DisplayOrder, AddTime = DateTime.Now, Title = model.Title, Url = model.Url == null ? "" : model.Url, Body = model.Body ?? "" }; AdminNews.CreateNews(newsInfo); AddMallAdminLog("添加新闻", "添加新闻,新闻为:" + model.Title); return(PromptView("新闻添加成功")); } Load(); return(View(model)); }
public ActionResult Edit(NewsModel news) { try { int userId = -1; if (Session["UserId"] != null) { userId = int.Parse(Session["UserID"].ToString()); } BLLNews bll = new BLLNews(); NewsInfo newsObjest = new NewsInfo() { NewId = news.NewId, Title = news.Title, Content = SecurityUtility.RemoveIllegalCharacters(news.Message), CreateDate = DateTime.Now, IsDelete = false, IsTop = false, IsPublic = true, ViewTimes = 0, UserId = userId, ImageUrl = "" }; //编辑信息 之后提交更新 bll.Update(newsObjest); return(RedirectToAction("Index", "News")); } catch (Exception) { return(View()); } }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { string strContent = Request.Form["t_contents"].ToString(); NewsInfo news = new NewsInfo(); news.N_Title = txtTitle.Text; news.N_From = txtFrom.Text; news.N_Content = PubClass.Tool.CheckStr(strContent); news.N_ImgPath = ""; news.N_ImgView = ""; news.N_HotIco = ""; news.N_PicIco = ""; news.N_Time = txtTime.Text; news.N_TID = Convert.ToInt32(((DataTable)ViewState["dtType"]).Rows[0]["T_ID"]); if (ViewState["strAction"].ToString() == "update") { news.N_ID = Convert.ToInt32(ViewState["nid"]); NewsInfoService.Update_NewsInfoWithTime(news); } else if (ViewState["strAction"].ToString() == "add") { NewsInfoService.Insert_NewsInfoWithTime(news); } CommonFunction.AlertAndRedirect(Literal1, "操作成功", "CommonNewsMgr.aspx?tid=" + Convert.ToInt32(((DataTable)ViewState["dtType"]).Rows[0]["T_ID"])); }
protected ActionResult GenerateNewsActionResult(IList <NewsArticle> articles, bool actionSuccess) { var actionResult = new ActionResult() { NewsList = new List <NewsInfo>(), ActionSuccess = actionSuccess }; var newsArticles = articles as List <NewsArticle>; foreach (var article in newsArticles) { var newsInfo = new NewsInfo() { Title = article.Name, Subtitle = article.DatePublished, Description = article.Description, ImageUrl = article?.Image?.Thumbnail?.ContentUrl, Url = article.WebSearchUrl }; actionResult.NewsList.Add(newsInfo); } return(actionResult); }
public List <NewsInfo> GetPageList(int pageIndex, int pageSize) { string sql = "SELECT * FROM TB_NEWS WHERE IsDeleted=0 ORDER BY Id DESC OFFSET (@pageIndex-1)*@pageSize ROWS FETCH NEXT @pageSize ROWS ONLY;"; List <SqlParameter> sqlParameters = new List <SqlParameter>(); sqlParameters.Add(new SqlParameter() { ParameterName = "pageIndex", SqlDbType = System.Data.SqlDbType.Int, Value = pageIndex }); sqlParameters.Add(new SqlParameter() { ParameterName = "pageSize", SqlDbType = System.Data.SqlDbType.Int, Value = pageSize }); var dt = sqlHelper.GetTable(sql, System.Data.CommandType.Text, sqlParameters.ToArray()); List <NewsInfo> list = new List <NewsInfo>(); foreach (DataRow item in dt.Rows) { NewsInfo news = new NewsInfo(); news.Title = item["Title"]?.ToString(); news.Id = Convert.ToInt32(item["Id"]); news.ScanCount = item["ScanCount"] == DBNull.Value ? 0 : (int)item["ScanCount"]; news.Content = item["Content"]?.ToString(); news.IsDeleted = item["IsDeleted"] == null ? false : Convert.ToBoolean(item["IsDeleted"]); list.Add(news); } return(list); }
public ActionResult PublishNews() { NewsInfo news = new NewsInfo(); news.news_title = Request.Form["title"]; news.news_author = Request.Form["author"]; news.news_source = Request.Form["from"]; news.news_abstract = Request.Form["abstract"]; news.new_release_time = DateTime.Now; String text = Request.Form["text"]; text = text.Replace("#lt;", "<"); text = text.Replace("#gt;", ">"); news.news_content = text; int categoryId = int.Parse(Request.Form["classify"]); news.newsCategory_id = categoryId; news.newsCategory = newsContext.newsCategoryLists.Find(categoryId); if (ModelState.IsValid) { newsContext.newsInfoLists.Add(news); newsContext.SaveChanges(); } return(Content("发布成功:")); }
/// <summary> /// 新闻资讯信息集合 /// </summary> /// <returns></returns> public string GetNewsList() { if (Signature != GetParam("sig").ToString()) { ErrorCode = (int)ErrorType.API_EC_SIGNATURE; return ""; } //如果是桌面程序则需要验证用户身份 if (this.App.ApplicationType == (int)ApplicationType.DESKTOP) { if (Uid < 1) { ErrorCode = (int)ErrorType.API_EC_SESSIONKEY; return ""; } } if (CallId <= LastCallId) { ErrorCode = (int)ErrorType.API_EC_CALLID; return ""; } List<SAS.Entity.NewsContent> newslist = new List<SAS.Entity.NewsContent>(); newslist = SAS.Logic.News.GetShangJiNews(); NewsGetListResponse ngr = new NewsGetListResponse(); List<NewsInfo> nlist = new List<NewsInfo>(); foreach (SAS.Entity.NewsContent newsc in newslist) { NewsInfo ninfo = new NewsInfo(); ninfo.Nid = newsc.ID; ninfo.NewsID = newsc.NewsID; ninfo.NewsTitle = newsc.NewsTitle; ninfo.NewsPic = newsc.NewsSPic; ninfo.NewsUrl = newsc.NewsUrl; nlist.Add(ninfo); } ngr.Anums = nlist.Count; ngr.NewsList = nlist.ToArray(); if (Format == FormatType.JSON) { return JavaScriptConvert.SerializeObject(ngr); } return SerializationHelper.Serialize(ngr); }
// GET: News public ActionResult Index() { NewsInfo info = new NewsInfo(); using (var db0 = getDB0()) { info.News = db0.News.Where(x => x.i_Hide == false & x.i_Lang == System.Globalization.CultureInfo.CurrentCulture.Name).OrderByDescending(x => x.news_date).ToList(); foreach (var item in info.News) { item.imgsrc = GetImg(item.news_id, "Photo1", "News", "News");//顯示列表圖 } info.title = info.News.Select(x => x.news_title).Take(3).ToList(); } return View("list", info); }
// GET: News public ActionResult Index(int? category) { NewsInfo info = new NewsInfo(); using (var db0 = getDB0()) { #region get content info.items = db0.News.Where(x => !x.i_Hide & x.i_Lang == System.Globalization.CultureInfo.CurrentCulture.Name).OrderByDescending(x => new { x.sort, x.day }) .Select(x => new m_News() { news_id = x.news_id, news_title = x.news_title, news_info = x.news_info, day = x.day, news_category = x.news_category }).ToList(); if (category != null) { info.items = info.items.Where(x => x.news_category == category).ToList(); } #endregion #region get category info.category = db0.All_Category_L2.Where(x => !x.i_Hide & x.all_category_l1_id == (int)AllCategoryType.News & x.i_Lang == System.Globalization.CultureInfo.CurrentCulture.Name) .OrderByDescending(x => x.sort) .Select(x => new L2() { l2_id = x.all_category_l2_id, l2_name = x.l2_name }).ToList(); #endregion var category_obj = info.category.Where(x => x.l2_id == category).FirstOrDefault(); if (category_obj == null & category != null) { return Redirect("~/News"); } else if (category_obj != null) { ViewBag.l2_name = category_obj.l2_name; } else { ViewBag.l2_name = "ALL"; } ViewBag.category = category; } return View("list", info); }
protected void Page_Load(object sender, EventArgs e) { NewsInfo news = new NewsInfo(); NewsInfoImpl pl = new NewsInfoImpl(); news = pl.GetNewsInfoById(Convert.ToInt32(Request.Params["id"])); id = news.id.ToString(); title = news.title; datetime = news.addtime.ToShortDateString(); scource = news.source == "" ? "不详" : news.source; content = news.newscontent; catname = news.categoryName; catid = news.catid.ToString(); author = news.author == "" ? "工大在线运营团队" : news.author; introduction = Common.CutString((news.introduce == "" ? Common.DelHTML(news.newscontent) : news.introduce), 200); keywords = news.keyword; Page.Title = title; //找出校区 if (ConfigurationManager.AppSettings["daxuecheng"].ToString().IndexOf(catid) != -1) campus = "daxuecheng"; else if (ConfigurationManager.AppSettings["longdong"].ToString().IndexOf(catid) != -1) campus = "longdong"; else campus = "dongfenglu"; xuexi.catid = Convert.ToInt32(ConfigurationManager.AppSettings[campus].ToString().Split(',')[0]); shenghuo.catid = Convert.ToInt32(ConfigurationManager.AppSettings[campus].ToString().Split(',')[1]); xiaoyuan.catid = Convert.ToInt32(ConfigurationManager.AppSettings[campus].ToString().Split(',')[3]); //增加点击量 pl.UpdateNewsInfoHit(news.id); //相关新闻 string str = "select DISTINCT top 5 n.id,n.title,n.addtime from((dc_keyword k join dc_getnewsid g on k.id=g.keyword_id) join dc_newsinfo n on g.title_id=n.id) where n.catid in (" + ConfigurationManager.AppSettings[campus].ToString() + ") and g.title_id!= " + news.id.ToString() + " and k.keyword in ( '" + keywords.Replace(",", ",").Replace(@",", @"','") + " ')"; RepeaterRelate.DataSource = SqlHelper.ExecuteReader(SqlHelper.ConnString, CommandType.Text, str, null); RepeaterRelate.DataBind(); //评论部分 //CommentImpl cpl = new CommentImpl(); //commentpl.DataSource = cpl.GetCommentbyNewsId(news.id); //commentpl.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { Page.Title = Page.Title +" - "+ ConfigurationManager.AppSettings["WebTitle"].ToString(); string catid, id; if (Request.Params["campus"] != null) { campus = Request.Params["campus"].ToString(); } else if (Request.Params["catid"] != null) { catid = Request["catid"].ToString(); if (ConfigurationManager.AppSettings["daxuecheng"].ToString().IndexOf(catid)!=-1) campus = "daxuecheng"; else if (ConfigurationManager.AppSettings["longdong"].ToString().IndexOf(catid)!=-1) campus = "longdong"; else campus = "dongfenglu"; } else if (Request.Params["id"] != null) { NewsInfo news = new NewsInfo(); NewsInfoImpl pl = new NewsInfoImpl(); news = pl.GetNewsInfoById(Convert.ToInt32(Request.Params["id"])); catid = news.catid.ToString(); if (ConfigurationManager.AppSettings["daxuecheng"].ToString().IndexOf(catid) != -1) campus = "daxuecheng"; else if (ConfigurationManager.AppSettings["longdong"].ToString().IndexOf(catid) != -1) campus = "longdong"; else campus = "dongfenglu"; } else { campus="daxuecheng"; } columns = ConfigurationManager.AppSettings[campus].ToString().Split(','); }
private void ShoutNews_Callback( NewsInfo info ) { TownCrierEntry tce = info.Entry; int index = info.Index++; if ( index < 0 || index >= tce.Lines.Length ) { if ( m_NewsTimer != null ) m_NewsTimer.Stop(); m_NewsTimer = null; } else PublicOverheadMessage( MessageType.Regular, 0x3B2, false, tce.Lines[index] ); }