コード例 #1
0
        //文章内容
        public ActionResult Content(string keyword1 = "", string keyword2 = "", int articleId = 1)
        {
            string menuKey = "";

            if (keyword2 == "")
            {
                menuKey = keyword1;
            }
            else
            {
                menuKey = keyword1 + "/" + keyword2;
            }
            MyResult   result = new MyResult();
            ArticleDAL dal    = new ArticleDAL();

            result = dal.getArticleContent(menuKey, articleId);
            ArticleContent model = new ArticleContent();

            //Article article = new Article();
            //ArticleTag articleTag = new ArticleTag();
            //PrevNext prevNext = new PrevNext();
            model.article    = ConvertHelper.FillModel <Article>(((DataTable)result.obj).Rows[0]);
            model.articleTag = ConvertHelper.FillModelList <ArticleTag>(((DataTable)result.obj2));
            model.prevNext   = ConvertHelper.FillModelList <PrevNext>(((DataTable)result.obj3));
            ViewBag.menuKey  = menuKey;
            return(View(model));
        }
コード例 #2
0
        // GET: Article
        public ActionResult Index()
        {
            var articles = new ArticleDAL().ListAll();

            ViewBag.articleCategory = new ArticleCategoryDAL().ListAll();
            return(View(articles));
        }
コード例 #3
0
ファイル: ArticleBLL.cs プロジェクト: cnsmallant/WebCrawler
        public int Insert(Article art)
        {
            ArticleDAL dalArticle = new ArticleDAL();
            int        insertId   = dalArticle.Insert(art);

            return(insertId);
        }
コード例 #4
0
        public static List <ArticleViewModel> GetArticalList()
        {
            List <ArticleViewModel> AList = new List <ArticleViewModel>();

            ArticleDAL.GetArticlesList().ForEach(a => AList.Add(new ArticleViewModel(a)));
            return(AList);
        }
コード例 #5
0
        public ActionResult ArticleByCate(int id)
        {
            var articles = new ArticleDAL().ListByArticleCategory(id);

            ViewBag.articleCategory = new ArticleCategoryDAL().ListAll();
            return(View(articles));
        }
コード例 #6
0
 public List <Article> GetAll(Paginate arPage)
 {
     arDal = new ArticleDAL();
     arDal.GetAll(arPage);
     arDal.ReturnUnitToPool();
     return(arDal.list_ArticleInfo);
 }
コード例 #7
0
        public ActionResult List(string id, int page, string title = null)  //list这个类型是不存在的,是为了满足路由器而写的,查询全部和按标题查询就用list /list/1 或/list?title=
        {
            string where = null;
            SqlParameter[] param     = null;
            string         hrefParam = null;

            if (title != null)
            {
                where     = "title like @title";
                param     = new SqlParameter[] { new SqlParameter("@title", "%" + title + "%") };
                hrefParam = "?title=" + title;
            }
            else if (id != "list")
            {
                where = "tid=@tid";
                param = new SqlParameter[] { new SqlParameter("@tid", id) };
            }
            ViewBag.topPage    = page == 1 ? "javascript:void(0)" : "/" + id + "/" + (page - 1) + hrefParam;
            ViewBag.bottomPage = "/" + id + "/" + (page + 1) + hrefParam;
            //标题关键词描述
            string typeName = Convert.ToString(DbHelper.ExecuteScalar("select Title from Types where TID=@TID", new SqlParameter[] { new SqlParameter("@TID", id) }));

            typeName      = typeName.Length == 0 ? "全部" : typeName;
            ViewBag.Title = typeName + "_易风网";
            ViewBag.Key   = typeName + ",易风";
            //ViewBag.Desc = "";

            List <Article> model = new ArticleDAL().SelPageID(page, 30, where, "ID DESC", param);

            return(View(model));
        }
コード例 #8
0
        public ActionResult Details(int id)
        {
            var articles = new ArticleDAL().ViewDetail(id);

            ViewBag.Comment = new CommentDAL().ListByArticleID(articles.ArticleID);
            return(View(articles));
        }
コード例 #9
0
        public ResultModel <object> DeleteArticle(Article article, UserInfoForCookie user)
        {
            ResultModel <object> msg = new ResultModel <object>();

            if (article == null)
            {
                msg.Code    = 2001;
                msg.Message = "参数错误";
                return(msg);
            }
            if (string.IsNullOrEmpty(article.ArticleNo))
            {
                msg.Code    = 2001;
                msg.Message = "参数错误";
                return(msg);
            }
            int result = 0;

            result = new ArticleDAL().DeleteArticle(article, user);
            if (result > 0)
            {
                msg.Message = "操作成功";
            }
            else
            {
                msg.Code    = 2001;
                msg.Message = "操作失败";
            }
            return(msg);
        }
コード例 #10
0
        public ActionResult Xq(int id)    //若要静态化,保存路径就是 /html/id前三位/id后几位.html
        {
            ArticleDAL dal   = new ArticleDAL();
            Article    model = dal.SelModel(id);

            return(View(model));
        }
コード例 #11
0
 public void GetDetail(Container_Article_Detail conta_Atc_Dta, int id)
 {
     arDal = new ArticleDAL();
     conta_Atc_Dta.curArticle   = arDal.GetDetail(id);
     conta_Atc_Dta.list_Article = arDal.GetAllAriticleTitle();
     arDal.ReturnUnitToPool();
 }
コード例 #12
0
        //文章列表
        public ActionResult List(string keyword1 = "", string keyword2 = "", int page = 1)
        {
            string menuKey = "";

            if (keyword2 == "")
            {
                menuKey = keyword1;
            }
            else
            {
                menuKey = keyword1 + "/" + keyword2;
            }
            MyResult   result = new MyResult();
            int        count  = Convert.ToInt32(ConfigurationManager.AppSettings["articleListCount"]);
            ArticleDAL dal    = new ArticleDAL();

            result = dal.getArticleList(menuKey, count, page);
            ArticleList <Article> model = new ArticleList <Article>();

            model.head = ConvertHelper.FillModel <Head>(((DataTable)result.obj).Rows[0]);
            Paging <Article> paging = new Paging <Article>();

            paging.list       = ConvertHelper.FillModelList <Article>((DataTable)result.obj2);
            paging.totalPages = Convert.ToInt32(result.obj3);
            model.paging      = paging;
            ViewBag.page      = page;
            ViewBag.menuKey   = menuKey;
            return(View(model));
        }
コード例 #13
0
        public ActionResult Create([Bind(Include = "ArticleID,ArticleCategoryID,Title,MetaTitle,ArticleContent,Image,Tag,ViewCount,Votes,TotalRating,Approved,ApprovedUser,ApprovedDate,CreateDate,CreateUser,ModifiedDate,ModifiedUser,MetalKeywords,MetalDescriptions,IsActive")] Article article)
        {
            var UserSession = (UserLogin)Session[TechDeviShopVs002.Common.CommonConstants.USER_SESSION];

            if (ModelState.IsValid)
            {
                var _dal = new ArticleDAL();

                article.CreateUser = UserSession.UserID;
                if (article.Approved == true)
                {
                    article.ApprovedUser = UserSession.UserID;
                    article.ApprovedDate = DateTime.Now;
                }
                int id = _dal.Insert(article);
                if (id > 0)
                {
                    return(RedirectToAction("Index", "Articles"));
                }
                else
                {
                    ModelState.AddModelError("", "Thêm bài viết ko thành công");
                }
            }

            ViewBag.ArticleCategoryID = new SelectList(db.ArticleCategories, "ArticleCategoryID", "ArticleCategoryName", article.ArticleCategoryID);
            return(View(article));
        }
コード例 #14
0
        private void  除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确定要删除这篇文章吗?", "确认", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                var id = (this.dataGridView1.SelectedRows[0].DataBoundItem as Article).Id;

                ArticleDAL.Delete(id);
            }
        }
コード例 #15
0
        public ActionResult _PartialRight()
        {
            ArticleDAL         artDal = new ArticleDAL();
            _PartialRightModel model  = new _PartialRightModel();

            model.ermen    = artDal.SelPageID(10, 5, "ImgUrl is not null", "ID DESC");
            model.jingxuan = artDal.SelPageID(10, 6, "ImgUrl is not null", "ID DESC");
            return(PartialView(model));
        }
コード例 #16
0
        public HomeViewModel()
        {
            ArticlesTopRandom = new List <ArticleViewModel>();
            ArticleDAL articleDAL = new ArticleDAL();

            foreach (Article article in articleDAL.Random(3, 7))
            {
                ArticlesTopRandom.Add(new ArticleViewModel(article));
            }
        }
コード例 #17
0
        private void 修改ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var id = (this.dataGridView1.SelectedRows[0].DataBoundItem as Article).Id;

            var article = ArticleDAL.Get(id);

            new FrmEditor(article).ShowDialog();

            this.FrmArticles_Load(null, null);
        }
コード例 #18
0
        private void 保存ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                string txt = this.webBrowser1.Document.InvokeScript("getContentTxt").ToString();
                if (txt.Trim().Length == 0)
                {
                    MessageBox.Show("请填写文章内容");
                    return;
                }

                if (string.IsNullOrWhiteSpace(this.txtTitle.Text))
                {
                    MessageBox.Show("请填写标题");
                    return;
                }

                if (this.cboCategory.SelectedIndex < 0)
                {
                    MessageBox.Show("请选择分类");
                    return;
                }

                string content = this.webBrowser1.Document.InvokeScript("getContent").ToString();

                this.m_article.Content    = content;
                this.m_article.Title      = this.txtTitle.Text.Trim();
                this.m_article.CategoryId = (long)(this.cboCategory.SelectedValue);
                if (txt.Length > 200)
                {
                    this.m_article.Summary = txt.Substring(0, 200);
                }
                else
                {
                    this.m_article.Summary = txt;
                }

                if (this.m_article.Id == 0)
                {
                    ArticleDAL.Insert(this.m_article);
                }
                else
                {
                    ArticleDAL.Update(this.m_article);
                }

                this.chkHasChange.Checked = this.m_article.HasChange;

                MessageBox.Show("保存成功");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "保存失败");
            }
        }
コード例 #19
0
        public ActionResult ModifierEtape2(Article article, string prix, HttpPostedFileBase file)
        {
            if (AdminArticle)
            {
                double prixOk = Math.Abs(Math.Round(float.Parse(prix, CultureInfo.InvariantCulture.NumberFormat), 2));
                article.PrixTTC    = prixOk;
                article.Nom        = article.Nom.NomAdmis();
                article.Grammage   = Math.Abs(article.Grammage);
                article.Litrage    = Math.Abs(article.Litrage);
                article.Allergenes = article.Allergenes ?? "";

                ArticleDAL articleDAL = new ArticleDAL();
                if (articleDAL.NomExiste(article.Nom, article.Id))
                {
                    TempData["message"]          = new Message("Ce nom d'article existe déjà.\nMerci de choisir un autre nom ou bien de renommer d'abord l'article en doublon.", TypeMessage.Erreur);
                    TempData["articleAModifier"] = articleDAL.Details(article.Id);
                }
                else
                {
                    try
                    {
                        if (file != null)
                        {
                            string dossierImage  = ConfigurationManager.AppSettings["PathImagesArticles"];
                            string fileName      = Guid.NewGuid().ToString("n") + Path.GetExtension(file.FileName);
                            string chemin        = Path.Combine(Server.MapPath(dossierImage), fileName);
                            Image  image         = Image.FromStream(file.InputStream);
                            int    tailleImage   = int.Parse(ConfigurationManager.AppSettings["ImagesArticlesSize"]);
                            var    nouvelleImage = new Bitmap(image, tailleImage, tailleImage);
                            nouvelleImage.Save(chemin);
                            nouvelleImage.Dispose();
                            image.Dispose();
                            article.Image = fileName;
                        }
                        else
                        {
                            Article ancienArticle = articleDAL.Details(article.Id);
                            article.Image = ancienArticle.Image;
                        }
                        articleDAL.Modifier(article);
                        TempData["message"] = new Message("Votre article a bien été modifié", TypeMessage.Ok);
                    }
                    catch (Exception ex)
                    {
                        TempData["message"] = new Message(ex.Message, TypeMessage.Erreur);
                    }
                }
                return(RedirectToAction("Modifier", "Article", new { area = "Administrer" }));
            }
            else
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
            }
        }
コード例 #20
0
        public ArticleBLL ArticleFindByName(int ArticleName)
        {
            ArticleBLL proposedReturnValue = null;
            ArticleDAL item = _context.ArticleFindByName(ArticleName);

            if (item != null)
            {
                proposedReturnValue = new ArticleBLL(item);
            }
            return(proposedReturnValue);
        }
コード例 #21
0
        //首页
        public ActionResult Index(int page = 1)
        {
            ArticleDAL       dal   = new ArticleDAL();
            DataSet          ds    = dal.getLatelyArticleList(page);
            Paging <Article> model = new Paging <Article>();

            model.list       = ConvertHelper.FillModelList <Article>(ds.Tables[0]);
            model.totalPages = Convert.ToInt32(ds.Tables[1].Rows[0][0]);
            ViewBag.page     = page;
            return(View(model));
        }
コード例 #22
0
        public ActionResult DeleteConfirmed(int id)
        {
            //new ArticleDAL().Delete(id);

            var article = new ArticleDAL().ViewDetail(id);

            article.IsActive = false;
            var _dal    = new ArticleDAL();
            var _result = _dal.Update(article);

            return(RedirectToAction("Index"));
        }
コード例 #23
0
ファイル: ArticleBLL.cs プロジェクト: cnsmallant/WebCrawler
        public int InsertByLinkId(Article art, int linkId)
        {
            ArticleDAL dalArticle = new ArticleDAL();
            int        insertId   = dalArticle.Insert(art);

            if (insertId > 0)
            {
                LinkDAL dalLink = new LinkDAL();
                dalLink.UpdateIsDownloadById(linkId, true);
            }
            return(insertId);
        }
コード例 #24
0
 public ArticleViewModel(ArticleDAL A)
 {
     _Id            = A.Articles.Id;
     _Titles        = A.Articles.Titles;
     _Description   = A.Articles.Description;
     _Contents      = A.Articles.Contents;
     _Status        = A.Articles.Status;
     _Category_Id   = A.Articles.Category_Id;
     _Entity_Order  = A.Articles.Entity_Order;
     _IsPublish     = A.Articles.IsPublish;
     _ArticalDate   = A.Articles.ArticalDate;
     _Artical_Image = A.Articles.Artical_Image;
 }
コード例 #25
0
        public ActionResult HtmlEditorPartial(string Id)
        {
            int Article_Id           = Int32.Parse(Id);
            ArticleViewModel article = new ArticleViewModel();

            if (Article_Id > 0)
            {
                ArticleDAL articleDal = new ArticleDAL(Article_Id);
                article = new ArticleViewModel(articleDal);
            }

            return(PartialView("_HtmlEditor", article));
        }
コード例 #26
0
 public ActionResult Modifier(int id)
 {
     if (AdminArticle)
     {
         ArticleDAL articleDAL = new ArticleDAL();
         TempData["articleAModifier"] = articleDAL.Details(id);
         return(View(articleDAL.Tous()));
     }
     else
     {
         return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
     }
 }
コード例 #27
0
        //标签列表
        public ActionResult HotTagList()
        {
            ArticleDAL    dal  = new ArticleDAL();
            DataTable     dt   = dal.getHotTagList();
            StringBuilder strB = new StringBuilder();

            foreach (DataRow row in dt.Rows)
            {
                strB.Append("<li><a href=\"javascript:void(0);\" title=\"" + row["tagName"].ToString() + "\">" + row["tagName"].ToString() + "</a></li>");
            }
            ViewBag.strHotTag = strB.ToString();
            return(PartialView());
        }
コード例 #28
0
        private void FrmArticles_Load(object sender, EventArgs e)
        {
            var categories = CategoryDAL.GetCategories();

            this.colCategoy.DisplayMember = "Name";
            this.colCategoy.ValueMember   = "Id";
            this.colCategoy.DataSource    = categories;


            var data = ArticleDAL.GetAllNoContent();

            this.dataGridView1.DataSource = data;
        }
コード例 #29
0
        public void Update()
        {
            ArticleDAL Ar = new ArticleDAL(_Id);

            if (!string.IsNullOrEmpty(_Titles))
            {
                Ar.Articles.Titles = _Titles;
            }

            if (!string.IsNullOrEmpty(_Description))
            {
                Ar.Articles.Description = _Description;
            }

            if (!string.IsNullOrEmpty(_Contents))
            {
                Ar.Articles.Contents = _Contents;
            }

            if (!string.IsNullOrEmpty(_Status))
            {
                Ar.Articles.Status = _Status;
            }

            if (_Category_Id != null)
            {
                Ar.Articles.Category_Id = _Category_Id;
            }

            if (_Entity_Order != null)
            {
                Ar.Articles.Entity_Order = _Entity_Order;
            }

            if (_IsPublish != null)
            {
                Ar.Articles.IsPublish = _IsPublish;
            }

            if (_ArticalDate != null)
            {
                Ar.Articles.ArticalDate = _ArticalDate;
            }

            if (!string.IsNullOrEmpty(_Artical_Image))
            {
                Ar.Articles.Artical_Image = _Artical_Image;
            }

            Ar.Update();
        }
コード例 #30
0
        // GET: Admin/Articles/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var article = new ArticleDAL().ViewDetail(id);

            if (article == null)
            {
                return(HttpNotFound());
            }
            return(View(article));
        }