public ActionResult search() { int pageIndex = WebHelper.GetQueryInt("pn", 1); int pageSize = ConstConfig.PageSize; //查询条件 string word = WebHelper.GetQueryString("wd"); ArticleBll bll = new ArticleBll(); #region 查询结果 List <bs_Article> newslist = bll.GetArticleListByKeyWords(word, pageIndex, pageSize); int listcnt = bll.GetArticleRecordCount(word); ViewData["keywords"] = word; //当前页 ViewData["pn"] = pageIndex; //总数据数 ViewData["listcnt"] = listcnt; //分页页数 ViewData["pagecnt"] = Math.Ceiling((float)listcnt / pageSize); #endregion #region 最新资讯 //前10条 List <bs_Article> newlist = bll.GetArticleListByKeyWords("", 1, 10); ViewData["newlist"] = newlist; #endregion return(View(newslist)); }
public Server(ArticleBll articleBll, IMapper mapper, WriterBll writerBll1) { _articleBll = articleBll; _writerBll = writerBll1; _mapper = mapper; _connectedClients = new List <NetworkStream>(); }
public void Page_Load(object sender, EventArgs args) { //me = UserBll.GetSessionUser(); var t_site_id = Request["site"].TryToShort(); if (t_site_id > 0) { site = SiteBll.GetById(t_site_id); SiteBll.SetSessionSite(site); } site = SiteBll.GetSessionSite(); //cases = CaseBll.GetCasesForFront(6, 0).Table.Populate<Case>() ; cases = CaseBll.GetCasesForFrontOnlyDesigner(6, 0, 0, 0).Populate <Case>(); articles1 = ArticleBll.GetArticleForFront("热点新闻").Table.Populate <Article>(); articles2 = ArticleBll.GetArticleForFront("居家布置").Table.Populate <Article>(); articles3 = ArticleBll.GetArticleForFront("装修常识").Table.Populate <Article>(); articles4 = ArticleBll.GetArticleForFront("装修手册").Table.Populate <Article>(); materials = MaterialsBll.GetMaterialsForFront().Table.Populate <Material>(); tdks = SeoBll.GetTDKbyPage("index.aspx", "").Table.Populate <SeoBll.Seo>(); contractors = ContractorBll.GetAllContractors(0, 50).Table.Populate <Contractor>(); suppliers = SupplierBll.GetAll(0, 50).Table.Populate <Supplier>(); dists = DistrictBll.GetAll(); contractorsList4global = ContractorBll.GetAllContractors(0, 500).Table.Populate <Contractor>(); }
public ActionResult AddArticle(Article ar) { ar = (Article)ModelHelper.ModelSupplement(ar); ViewBag.ArticleCategory = GetAllCategoryForDLL(ar.category_id).AsEnumerable(); foreach (string upload in Request.Files.AllKeys) { HttpPostedFileBase excelFile = Request.Files["article_cover_image"]; if (excelFile.ContentLength > 0) { DateTime now = DateTime.Now; string newDirPath = string.Format(@"{0}\{1}\{2}\", Server.MapPath("../"), "Upload", now.ToString(@"yyyy\\mm\\dd")); string newUrlPath = string.Format("/{0}/{1}/", "Upload", now.ToString("yyyy/mm/dd")); string newPath = Path.Combine(Server.MapPath(@"..\"), "Upload", ""); string fileName = now.ToFileTime().ToString() + excelFile.FileName.Substring(excelFile.FileName.LastIndexOf('.')); ar.article_cover_image = newUrlPath + fileName; if (!Directory.Exists(newDirPath)) { Directory.CreateDirectory(newDirPath); } excelFile.SaveAs(newDirPath + fileName); } } ar.article_kuser = Session["user_id"].ToString(); ar.article_muser = Session["user_id"].ToString(); if (ModelState.IsValid) { ArticleBll articleBll = new ArticleBll(); articleBll.AddArticle(ar); } return(Redirect("index")); }
public ActionResult FooterGuanyuwomen() { ArticleBll acBll = new ArticleBll(); var articleList = acBll.GetArticleByCategory("footerguanyuwomen", 7); return(View(articleList)); }
public int Like(string id) { tb_Article articleModel = new tb_Article(); articleModel = ArticleBll.getModel(p => p.Id == id); articleModel.LikeNum++; return(ArticleBll.Edit(articleModel)?1:0); }
public IActionResult Index(string KeyWord) { if (String.IsNullOrEmpty(KeyWord)) { return(View(null)); } return(View(ArticleBll.SearchArticles(KeyWord))); }
public ActionResult FriendLink() { ArticleBll acBll = new ArticleBll(); var articleList = acBll.GetArticleByCategory("FriendLink", 100); return(View(articleList)); }
public IActionResult Delete(int?Reference) { if (Reference == null) { return(NotFound()); } ArticleBll.Delete(Reference.Value); return(RedirectToAction("Index")); }
// GET: Article public ActionResult Index() { ViewBag.ArticleCategory = GetAllCategoryForDLL().AsEnumerable(); ArticleBll articleBll = new ArticleBll(); ArticleListModel articleListModel = new ArticleListModel(); Article a = new Article(); articleListModel.articleList = articleBll.GetAllArticle(a); return(View(articleListModel)); }
/// <summary> /// 详情页 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Detailed(string id) { tb_Article articleModel = new tb_Article(); articleModel = ArticleBll.getModel(p => p.Id == id); articleModel.ReadNum++; ArticleBll.Edit(articleModel); view_Article article = new view_Article(); article = vArticleBll.getModel(p => p.Id == id); return(View(article)); }
//删除还原 protected void Unnamed3_Click(object sender, EventArgs e) { LinkButton lb = (LinkButton)sender; string delid = lb.CommandArgument; int id = BasePage.GetRequestId(delid); bool b = new ArticleBll().Update1(datatable, "IsDel", "0", id.ToString()); if (b) { BasePage.JscriptPrint(Page, "还原成功!", "Article.aspx?ac=del&Tid=" + tid + "&mid=" + mid + "&language=" + Language); } }
public HttpContextBase Refrubish(int id) { if (id == null || id == 0) { return(null);; } ArticleBll articleBll = new ArticleBll(); Article article = new Article(); article.article_id = id; article.article_muser = Session["callid"].ToString(); article.article_mdate = DateTime.Now; articleBll.RefrubishArticle(article); return(null); }
public ActionResult UserEdit(int id) { if (id == null || id == 0) { return(View("Index")); } ArticleBll articleBll = new ArticleBll(); Article article = new Article(); article.article_id = id; article = articleBll.GetArticle(article); article.article_id = id; ViewBag.ArticleCategory = GetAllCategoryForDLL(article.category_id).AsEnumerable(); return(View(article)); }
public IActionResult Edit(int?Reference) { if (Reference == null) { return(NotFound()); } var Article = ArticleBll.SelectArticle(Reference.Value); if (Article == null) { return(NotFound()); } return(View(Article)); }
public HttpContextBase AddTick(int id) { ArticleBll acBll = new ArticleBll(); ArticleTicks at = new ArticleTicks(); at.article_id = id; at.at_brower = Request.Browser.Browser; at.at_device = Request.UserHostName; at.at_ipfrom = Request.UserHostAddress; at.at_kdate = DateTime.Now; at.at_kuser = ""; //acBll.AddTick(); acBll.AddTick(at); return(null); }
// GET: Home public async Task <ActionResult> Index() { if (Request.Url.Host.Contains("tuhu.cn")) { return(RedirectPermanent(DomainConfig.WwwSite)); } else { var pager = new PagerModel { PageSize = 20 }; var list = await ArticleBll.SearchArticle(pager); return(PartialView("/Views/Article/List.cshtml", list)); } }
//审核通过 protected void Button2_Click1(object sender, EventArgs e) { string allid = Request.Form["checkbox"]; if (!String.IsNullOrEmpty(allid)) { bool b = new ArticleBll().Update1(datatable, "Verific", "0", allid); if (b) { BasePage.JscriptPrint(Page, "批量操作成功!", "products.aspx?mid=" + mid + "&ac=sh"); } } else { BasePage.Alertback(Page, "请先选择要操作的选项ID"); return; } }
static void Main() { const string api = "https://interface.meiriyiwen.com/article/random"; for (var i = 0; i < 10; i++) { var json = HttpHelper.HttpGet(api); var obj = JObject.Parse(json); try { var author = obj["data"]["author"].ToString(); var title = obj["data"]["title"].ToString(); var digest = obj["data"]["digest"].ToString(); var content = obj["data"]["content"].ToString(); var words = obj["data"]["wc"].ToString(); var articles = new Articles { Id = Guid.NewGuid().ToString(), Author = author, Title = title, Digest = digest, Content = content, Words = words, CreateTime = DateTime.Now }; var bll = new ArticleBll(); if (bll.IsExistArticle(author, title)) { Console.WriteLine("exist"); } else { var v = bll.InsertArticle(articles); Console.WriteLine(v >= 1 ? "ojbk" : "error"); } } catch (Exception e) { Console.WriteLine(e); } } }
public int Save(tb_Article article) { try { if (article != null) { article.Id = Guid.NewGuid().ToString(); article.Date = DateTime.Now; if (ArticleBll.Save(article)) { return(1); } } return(0); } catch (Exception e) { throw e; } }
public IActionResult Store([Bind] Article P) { ArticleBll.Insert(P); return(RedirectToAction("Index")); }
public IActionResult Update([Bind] Article P) { ArticleBll.Update(P); return(RedirectToAction("Index")); }
public IActionResult Index() { return(View(ArticleBll.SeletAllArticles())); }
protected void Page_Load(object sender, EventArgs e) { mid = BasePage.GetRequestId(Request.QueryString["mid"]); if (mid == 0) { mid = 1; } id = BasePage.GetRequestId(Request.QueryString["id"]); if (!String.IsNullOrEmpty(Request.QueryString["language"])) { Language = BasePage.GetRequestId(Request.QueryString["language"]).ToString(); } string checklogin = new AdminBll().CheckLogin("m" + mid); if (checklogin != "true") { BasePage.Alertback(checklogin); Response.End(); } //根据模型找出数据表名 ModelModel mo = new ModelBll().GetModel(mid); datatable = mo.ModelTable; if (!Page.IsPostBack) { ItemName = mo.ItemName; if (!String.IsNullOrEmpty(mo.ModeContent)) { //0模型内容可选字段`1模型栏目可选字段`2内容字段名称`3模型列表可选字段`4提示语 string[] aa = mo.ModeContent.Split('`'); string[] a = aa[4].Split('|'); txtTips0.Text = a[0]; txtTips1.Text = a[1]; txtTips2.Text = a[2]; txtTips3.Text = a[3]; iw = a[4]; ih = a[5]; txtTips6.Text = a[6]; txtTips7.Text = a[7]; txtTips8.Text = a[8]; txtTips9.Text = a[9]; txtTips10.Text = a[10]; txtTips11.Text = a[11]; titletips = aa[2]; ModeContent = aa[0]; } //绑定栏目下拉 txtLiteral9.Text = new ClassBll().GetClassSelect(0, "请选择所属类别", mid, "txtTid", "ClassType=0 and Languagen=" + BasePage.GetRequestId(Language) + "", "", "required input-control select-control"); //绑定自定义字段 GetModelField(id); //txtAddDate.Text = Convert.ToDateTime(DateTime.Now).ToString("yyyy-MM-dd HH:mm:ss"); txtAddDate.Text = BasePage.formatDateTime(DateTime.Now.ToString()); Drlanguage.SelectedValue = Language.ToString(); hiddenbackurl.Value = "Article.aspx?mid=" + mid; //修改时绑定数据 if (id != 0) { ArticleModel am = new ArticleBll().GetModel(datatable, id); //根据语言和当前栏目重新绑定栏目 // ClassTreeBind(0, "请选择所属类别", mid, this.txtTid, "ClassType=0 and Languagen=" + am.Languagen); txtLiteral9.Text = new ClassBll().GetClassSelect(0, "请选择所属类别", mid, "txtTid", "ClassType=0 and Languagen=" + am.Languagen + "", am.Tid.ToString(), "required input-control select-control"); txtTitle.Text = am.Title; if (am.IsRecommend == 1) { txtRecommend.Checked = true; } if (am.IsPopular == 1) { txtPopular.Checked = true; } if (am.IsNew == 1) { txtNew.Checked = true; } txtFullTitle.Text = am.FullTitle; txtPx.Text = am.Px.ToString(); txtAuthor.Text = am.Author; txtOrigin.Text = am.Origin; txtHist.Text = am.Hits.ToString(); //txtAddDate.Text = Convert.ToDateTime(am.AddDate).ToString("yyyy-MM-dd HH:mm:ss").ToString(); txtAddDate.Text = BasePage.formatDateTime(am.AddDate.ToString()); txtPicUrl.Text = am.PicUrl; txtKeyWord.Text = am.SeoKeyword; txtIntro.Text = am.Intro; txtcontents.Text = am.Contents; txtcontents2.Text = am.Contents2; txtcontents3.Text = am.Contents3; txtseotitle.Text = am.SeoTitle; txtDescription.Text = am.SeoDescription; filesurl.Text = am.FilesUrl; Button1.Text = "确认修改"; Drlanguage.SelectedValue = am.Languagen.ToString(); Drlanguage.Enabled = false; colortxt.Value = am.TitltColor; rallowcomment.SelectedValue = am.AllowComment.ToString(); if (!String.IsNullOrEmpty(am.TitltColor)) { txtTitle.Style.Add("color", am.TitltColor); } // hiddenbackurl.Value = System.Web.HttpContext.Current.Request.RawUrl; if (Request.UrlReferrer != null) { ViewState["UrlReferrer"] = Request.UrlReferrer.ToString(); hiddenbackurl.Value = ViewState["UrlReferrer"].ToString(); } } ((Literal)Master.FindControl("breadcrumbs")).Text = "<a href=\"Article.aspx?mid=" + mid + "\" class=\"home\">" + ItemName + "管理</a> > 添加" + ItemName; } }
//批量处理 protected void Button3_Click(object sender, EventArgs e) { string radiobutton = Request.Form["radiobutton"]; string allid = articleid.Text; if (Request.UrlReferrer != null) { ViewState["UrlReferrer"] = Request.UrlReferrer.ToString(); } if (String.IsNullOrEmpty(radiobutton) || String.IsNullOrEmpty(allid)) { BasePage.Alertback("请选择要操作的选项!"); Response.End(); } if (radiobutton == "1")//移动栏目 { if (String.IsNullOrEmpty(ddlclassforall.SelectedValue)) { BasePage.Alertback("请选择要移动到的栏目"); Response.End(); } else { bool b = new ArticleBll().Update1(datatable, "Tid", ddlclassforall.SelectedValue, allid); BasePage.AlertAndRedirect("转移成功", ViewState["UrlReferrer"].ToString()); } } else if (radiobutton == "2") { //属性 string ddlsx1 = ddlsx.SelectedValue; bool b = false; if (ddlsx1 == "0") { //设为热门 b = new ArticleBll().Update1(datatable, "IsPopular", "1", allid); } else if (ddlsx1 == "1") { //取消热门 b = new ArticleBll().Update1(datatable, "IsPopular", "0", allid); } else if (ddlsx1 == "2") { //设为推荐 b = new ArticleBll().Update1(datatable, "IsRecommend", "1", allid); } else if (ddlsx1 == "3") { //取消推荐 b = new ArticleBll().Update1(datatable, "IsRecommend", "0", allid); } else if (ddlsx1 == "4") { //设为最新 b = new ArticleBll().Update1(datatable, "IsNew", "1", allid); } else if (ddlsx1 == "5") { //取消最新 b = new ArticleBll().Update1(datatable, "IsNew", "0", allid); } if (b) { BasePage.AlertAndRedirect("设置成功", ViewState["UrlReferrer"].ToString()); } } else if (radiobutton == "3") { //放入回收站 bool b = new ArticleBll().Update1(datatable, "IsDel", "1", allid); BasePage.AlertAndRedirect("放入回收站成功", ViewState["UrlReferrer"].ToString()); } else if (radiobutton == "8") { //彻底删除 bool b = new CommonBll().DeleteList(datatable, allid); BasePage.AlertAndRedirect("彻底删除成功", ViewState["UrlReferrer"].ToString()); } else if (radiobutton == "4")//改变作者 { if (!String.IsNullOrEmpty(txtAuthor.Text)) { bool b = new ArticleBll().Update1(datatable, "Author", txtAuthor.Text.Trim(), allid); BasePage.AlertAndRedirect("新作者改变成功", ViewState["UrlReferrer"].ToString()); } else { BasePage.Alertback("请输入新作者名!"); Response.End(); } } else if (radiobutton == "5") { //来源 if (!String.IsNullOrEmpty(txtOrigin.Text)) { bool b = new ArticleBll().Update1(datatable, "Origin", txtOrigin.Text.Trim(), allid); BasePage.AlertAndRedirect("新来源改变成功", ViewState["UrlReferrer"].ToString()); } else { BasePage.Alertback("请输入新来源!"); Response.End(); } } else if (radiobutton == "6") { //浏览次数 if (!String.IsNullOrEmpty(txthits.Text)) { bool b = new ArticleBll().Update1(datatable, "Hits", txthits.Text.Trim(), allid); BasePage.AlertAndRedirect("浏览次数修改成功", ViewState["UrlReferrer"].ToString()); } else { BasePage.Alertback("请输入浏览次数!"); Response.End(); } } else if (radiobutton == "7") { //修改时间 if (!String.IsNullOrEmpty(txteditdata.Text)) { bool b = new ArticleBll().Update1(datatable, "EditDate", txteditdata.Text.Trim(), allid); BasePage.AlertAndRedirect("修改时间批量操作成功", ViewState["UrlReferrer"].ToString()); } else { BasePage.Alertback("请输入修改时间!"); Response.End(); } } }
/// <summary> /// 文章详情 /// </summary> /// <param name="articleId"></param> /// <returns></returns> public static async Task <Component.Discovery.BusinessData.Article> GetArticleDetailById(int articleId) => await GetFromCacheAsync($"DetailById/{articleId}", () => ArticleBll.GetArticleDetailById(articleId), CacheTimeEnum.Short);
//add or edit protected void Button1_Click(object sender, EventArgs e) { ArticleModel ma = new ArticleModel(); ma.Title = txtTitle.Text.Trim(); int ctid = BasePage.GetRequestId(Request.Form["txtTid"]); ma.Tid = ctid; ma.FullTitle = txtFullTitle.Text; ma.Px = BasePage.GetRequestId(txtPx.Text); ma.Author = txtAuthor.Text; ma.Origin = txtOrigin.Text; ma.Hits = BasePage.GetRequestId(txtHist.Text); if (!String.IsNullOrEmpty(txtAddDate.Text)) { ma.AddDate = DateTime.Parse(txtAddDate.Text); } else { ma.AddDate = DateTime.Now; } ma.EditDate = DateTime.Now; ma.PicUrl = txtPicUrl.Text; ma.SeoKeyword = txtKeyWord.Text; ma.Intro = txtIntro.Text; string contents1 = txtcontents.Text; if (txtspanfont.Checked)//过滤span font { contents1 = Regex.Replace(contents1, "(<span[^>]+>)|(</span>)", ""); contents1 = Regex.Replace(contents1, "(<font[^>]+>)|(</font>)", "");//font } if (txthtml.Checked) { contents1 = BasePage.HtmlFilter(contents1); } ma.Contents = contents1; ma.Contents2 = txtcontents2.Text; ma.Contents3 = txtcontents3.Text; ma.Owner = Cookies.GetCookie("User_Name"); ma.SeoDescription = txtDescription.Text; if (!String.IsNullOrEmpty(txtseotitle.Text)) { ma.SeoTitle = txtseotitle.Text; } else { ma.SeoTitle = txtTitle.Text; } ma.Languagen = int.Parse(Drlanguage.SelectedValue); ma.IsPopular = txtPopular.Checked ? 1 : 0; ma.IsRecommend = txtRecommend.Checked ? 1 : 0; ma.IsNew = txtNew.Checked ? 1 : 0; ma.FilesUrl = filesurl.Text; ma.TitltColor = colortxt.Value; ma.AllowComment = int.Parse(rallowcomment.SelectedValue); if (BasePage.ArrayExist(Cookies.GetCookie("ModelPower"), "ms" + mid)) { ma.Verific = 1; } else { ma.Verific = 0; } ma.id = id; //扩展字段 string _sql = ""; int modeexists = new CommonBll().GetRecordCount("GL_ModelField", "FieldOnOff=0 and Modeid=" + mid); if (modeexists > 0) { string[] _atype = Request.Params.GetValues("hideFieldType"); //类型 string[] _atitle = Request.Params.GetValues("hideFieldTitle"); // string[] _bcontents = Request.Params.GetValues("txtFieldContent"); if (_atype != null && _atitle != null && _bcontents != null) { for (int i = 0; i < _atitle.Length; i++) { string vv = "'" + _bcontents[i] + "'"; if (_atype[i].ToString() == "1") { //数值 vv = _bcontents[i]; } if (String.IsNullOrEmpty(_sql)) { _sql += _atitle[i] + "=" + vv; } else { _sql += "," + _atitle[i] + "=" + vv; } } } } if (id == 0) { ma.IsDel = 0; int i = new ArticleBll().Add(datatable, ma); if (i > 0) { //更新自定义 if (modeexists > 0) { bool bb = new ArticleBll().Updatezd(datatable, _sql, i); } BasePage.JscriptPrint(Page, "添加成功!", "Article.aspx?mid=" + mid + "&tid=" + ctid + "&language=" + Language);//添加成功返回当前栏目 } } else { bool b = new ArticleBll().Update(datatable, ma); if (b) { ////更新自定义 if (modeexists > 0) { bool bb = new ArticleBll().Updatezd(datatable, _sql, id); } BasePage.JscriptPrint(Page, "修改成功!", hiddenbackurl.Value.ToString()); } } }