public static blog_varticle VArticle()
        {
            blog_varticle varticle = new blog_varticle();
            varticle.articleid = 0;
            varticle.typeid = 0;
            varticle.cateid = 0;
            varticle.catename = "";
            varticle.catepath = "";
            varticle.title = "";
            varticle.summary = "";
            varticle.content = "";
            varticle.tags = "";
            varticle.layer = 0;
            varticle.orderid = 1;
            varticle.parentid = 0;
            varticle.replypermit = 1;
            varticle.seodescription = "";
            varticle.seokeywords = "";
            varticle.seometas = "";
            varticle.seotitle = "";
            varticle.rename = "";
            varticle.status = 1;
            varticle.userid = 0;
            varticle.username = "";
            varticle.iscommend = 2;
            varticle.istop = 2;
            varticle.articletypeid = 0;
            varticle.viewcount = 0;
            varticle.ip = Utils.GetIP();
            varticle.createdate = DateTime.Now;
            varticle.lastreplydate = DateTime.Now;

            return varticle;
        }
 /// <summary>
 /// 添加文章
 /// </summary>
 public int AddArticle(blog_varticle varticle)
 {
     using (YQBlogEntities entity = new YQBlogEntities())
     {
         blog_varticle obj = varticle;
         entity.blog_varticle.AddObject(obj);
         entity.SaveChanges();
         return obj.id;
     }
 }
示例#3
0
 public ActionResult AjaxArticleInfo(int id)
 {
     Hashtable hash = new Hashtable();
     try
     {
         blog_varticle varticle = new blog_varticle();
         varticle = myService.GetVArticleByID(id);
         varticle.viewcount++;
         myService.UpdateArticle(varticle);
         hash["error"] = 0;
         hash["viewcount"] = varticle.viewcount;
         hash["digg_favor"] = varticle.favor;
         hash["digg_against"] = varticle.against;
         hash["digg_isvote"] = IsVote(id);
         hash["digg_tip"] = IsVote(id) ? res.Vote_Tip1 : res.Vote_Tip2;
         hash["commentcount"] = varticle.subcount;
         hash["prenextlink"] = GetNextPreArticleLink(id);
         hash["isLogIn"] = Request.IsAuthenticated;
         hash["isValidationCode"] = configinfo.IfValidateCode==1;
         hash["mustLogIn"] = configinfo.UserPermission == 1;
         hash["typeid"] = varticle.typeid;
         if (Request.IsAuthenticated)
         {
             hash["user"] = User.Identity.Name;
         }
         else
         {
             hash["user"] = "";
         }
         return Json(hash, "text/html;charset=UTF-8");
     }
     catch
     {
         hash["error"] = 1;
         return Json(hash, "text/html;charset=UTF-8");
     }
 }
 /// <summary>
 /// 文章对象转换为相册对象
 /// </summary>
 public AlbumModel GetAlbum(blog_varticle varticle)
 {
     AlbumModel album = new AlbumModel();
     AlbumImageModel cover = new AlbumImageModel();
     if (varticle != null)
     {
         album.Id = varticle.id;
         album.ImageList = GetAlbumImageList(varticle.content, out cover);
         album.Cover = cover;
         album.Title = varticle.title;
         album.ReName = varticle.rename;
         album.Description = Utils.RemoveHtml(varticle.summary);
         album.ImgCount = album.ImageList.Count();
         album.CommentCount = varticle.subcount;
         album.ViewCount = varticle.viewcount;
         album.AlbumPath = GetCategoryPathUrl2(varticle.catepath);
         album.AlbumCategory = GetCategoryByID(varticle.cateid).CateName;
         album.Createdate = varticle.createdate;
         album.Favor = varticle.favor;
         album.Against = varticle.against;
         album.Url = varticle.url;
     }
     return album;
 }
示例#5
0
 /// <summary>
 /// 用于向 blog_varticle EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToblog_varticle(blog_varticle blog_varticle)
 {
     base.AddObject("blog_varticle", blog_varticle);
 }
示例#6
0
 /// <summary>
 /// 创建新的 blog_varticle 对象。
 /// </summary>
 /// <param name="id">id 属性的初始值。</param>
 /// <param name="typeid">typeid 属性的初始值。</param>
 /// <param name="cateid">cateid 属性的初始值。</param>
 /// <param name="catepath">catepath 属性的初始值。</param>
 /// <param name="articleid">articleid 属性的初始值。</param>
 /// <param name="parentid">parentid 属性的初始值。</param>
 /// <param name="layer">layer 属性的初始值。</param>
 /// <param name="subcount">subcount 属性的初始值。</param>
 /// <param name="catename">catename 属性的初始值。</param>
 /// <param name="userid">userid 属性的初始值。</param>
 /// <param name="username">username 属性的初始值。</param>
 /// <param name="title">title 属性的初始值。</param>
 /// <param name="summary">summary 属性的初始值。</param>
 /// <param name="content">content 属性的初始值。</param>
 /// <param name="viewcount">viewcount 属性的初始值。</param>
 /// <param name="orderid">orderid 属性的初始值。</param>
 /// <param name="replypermit">replypermit 属性的初始值。</param>
 /// <param name="status">status 属性的初始值。</param>
 /// <param name="ip">ip 属性的初始值。</param>
 /// <param name="favor">favor 属性的初始值。</param>
 /// <param name="against">against 属性的初始值。</param>
 /// <param name="iscommend">iscommend 属性的初始值。</param>
 /// <param name="istop">istop 属性的初始值。</param>
 /// <param name="createdate">createdate 属性的初始值。</param>
 /// <param name="lastreplydate">lastreplydate 属性的初始值。</param>
 /// <param name="lastreplyuser">lastreplyuser 属性的初始值。</param>
 /// <param name="seotitle">seotitle 属性的初始值。</param>
 /// <param name="seodescription">seodescription 属性的初始值。</param>
 /// <param name="seokeywords">seokeywords 属性的初始值。</param>
 /// <param name="seometas">seometas 属性的初始值。</param>
 /// <param name="rename">rename 属性的初始值。</param>
 /// <param name="tags">tags 属性的初始值。</param>
 public static blog_varticle Createblog_varticle(global::System.Int32 id, global::System.Int32 typeid, global::System.Int32 cateid, global::System.String catepath, global::System.Int32 articleid, global::System.Int32 parentid, global::System.Int32 layer, global::System.Int32 subcount, global::System.String catename, global::System.Int32 userid, global::System.String username, global::System.String title, global::System.String summary, global::System.String content, global::System.Int32 viewcount, global::System.Int32 orderid, global::System.Byte replypermit, global::System.Byte status, global::System.String ip, global::System.Int32 favor, global::System.Int32 against, global::System.Byte iscommend, global::System.Byte istop, global::System.DateTime createdate, global::System.DateTime lastreplydate, global::System.String lastreplyuser, global::System.String seotitle, global::System.String seodescription, global::System.String seokeywords, global::System.String seometas, global::System.String rename, global::System.String tags)
 {
     blog_varticle blog_varticle = new blog_varticle();
     blog_varticle.id = id;
     blog_varticle.typeid = typeid;
     blog_varticle.cateid = cateid;
     blog_varticle.catepath = catepath;
     blog_varticle.articleid = articleid;
     blog_varticle.parentid = parentid;
     blog_varticle.layer = layer;
     blog_varticle.subcount = subcount;
     blog_varticle.catename = catename;
     blog_varticle.userid = userid;
     blog_varticle.username = username;
     blog_varticle.title = title;
     blog_varticle.summary = summary;
     blog_varticle.content = content;
     blog_varticle.viewcount = viewcount;
     blog_varticle.orderid = orderid;
     blog_varticle.replypermit = replypermit;
     blog_varticle.status = status;
     blog_varticle.ip = ip;
     blog_varticle.favor = favor;
     blog_varticle.against = against;
     blog_varticle.iscommend = iscommend;
     blog_varticle.istop = istop;
     blog_varticle.createdate = createdate;
     blog_varticle.lastreplydate = lastreplydate;
     blog_varticle.lastreplyuser = lastreplyuser;
     blog_varticle.seotitle = seotitle;
     blog_varticle.seodescription = seodescription;
     blog_varticle.seokeywords = seokeywords;
     blog_varticle.seometas = seometas;
     blog_varticle.rename = rename;
     blog_varticle.tags = tags;
     return blog_varticle;
 }
示例#7
0
 /// <summary>
 /// 网站文章url,根据相关设置及当前环境数据确定正确的文章url
 /// </summary>
 public static string YQUrl(this HtmlHelper helper, blog_varticle varticle)
 {
     return WebUtils.GetYQUrl(varticle);
 }
示例#8
0
 /// <summary>
 /// 网站文章url,根据相关设置及当前环境数据确定正确的文章url
 /// </summary>
 public static string GetYQUrl(blog_varticle varticle)
 {
     int pageId = varticle.parentid > 0 ? varticle.parentid : varticle.id;
     string url = "";
     if (configinfo.IfWebStatic == 1 && GetCurrentTheme()== MyString(configinfo.Theme))
     {
         url = "/" + WebUtils.GetStaticFolder(varticle.createdate, res.Lang).Trim('/') + "/";
         if (varticle.rename.Length > 0)
         { url += varticle.rename + ".html"; }
         else
         { url += pageId.ToString() + ".html"; }
     }
     else
     {
         url = GetYQUrl(varticle.url, 1);
     }
     return url;
 }
示例#9
0
 /// <summary>
 /// 文章链接url
 /// </summary>
 public static string GetArticleUrl(blog_varticle varticle)
 {
     return !string.IsNullOrWhiteSpace(varticle.rename) ? "/article/" + varticle.rename : "/archive/" + varticle.id.ToString();
 }
 /// <summary>
 /// 更新文章(VArticle整体更新)
 /// </summary>
 public void UpdateVArticle(blog_varticle varticle)
 {
     using (YQBlogEntities entity = new YQBlogEntities())
     {
         var obj = entity.blog_varticle.FirstOrDefault(m => m.id == varticle.id);
         if (obj != null)
         {
             obj.title = varticle.title;
             obj.cateid = varticle.cateid;
             obj.catename = varticle.catename;
             obj.catepath = varticle.catepath;
             obj.summary = varticle.summary;
             obj.content = varticle.content;
             obj.tags = varticle.tags;
             obj.seodescription = varticle.seodescription;
             obj.seokeywords = varticle.seokeywords;
             obj.seometas = varticle.seometas;
             obj.seotitle = varticle.seotitle;
             obj.rename = varticle.rename;
             obj.status = varticle.status;
             obj.replypermit = varticle.replypermit;
             obj.iscommend = varticle.iscommend;
             obj.istop = varticle.istop;
             entity.SaveChanges();
         }
     }
 }
        /// <summary>
        /// 更新文章(Article表更新)
        /// </summary>
        public void UpdateArticle(blog_varticle varitcle)
        {
            using (YQBlogEntities entity = new YQBlogEntities())
            {
                var query = entity.blog_article.FirstOrDefault(m => m.id == varitcle.id);
                if (query != null)
                {
                    query.typeid = varitcle.typeid;
                    query.cateid = varitcle.cateid;
                    query.catepath = varitcle.catepath;
                    query.articleid = varitcle.articleid;
                    query.parentid = varitcle.parentid;
                    query.layer = varitcle.layer;
                    query.subcount = varitcle.subcount;
                    query.catename = varitcle.catename;
                    query.userid = varitcle.userid;
                    query.username = varitcle.username;
                    query.title = varitcle.title;
                    query.summary = varitcle.summary;
                    query.content = varitcle.content;
                    query.viewcount = varitcle.viewcount;
                    query.orderid = varitcle.orderid;
                    query.replypermit = varitcle.replypermit;
                    query.status = varitcle.status;
                    query.ip = varitcle.ip;
                    query.favor = varitcle.favor;
                    query.against = varitcle.against;
                    query.createdate = varitcle.createdate;

                    entity.SaveChanges();
                }
            }
        }
示例#12
0
        /// <summary>
        /// 发送email
        /// </summary>
        private void SendEmails(string txt, string title, string content, int id, int parentid, int authorid, string author)
        {
            try
            {
                if (configinfo.IfSendReplyEmail == 2)
                    return;
                string etitle = title;
                string econtent = content;
                List<string> lst = WebUtils.GetUsersFromTxt(txt);

                if (lst.Count > 0 && parentid > 0)
                {
                    string authorinfo = author;
                    if (authorid == 1)
                    {
                        authorinfo = "<a href=\"" + configinfo.Weburl + "/u/" + HttpUtility.UrlEncode(author, System.Text.Encoding.UTF8) + "\" target=\"_blank\">" + author + "</a>";
                    }
                    blog_varticle varticle = new blog_varticle();
                    varticle = myService.GetVArticleByID(parentid);
                    etitle = etitle + " Re:" + varticle.title;
                    econtent = "#Re:" + varticle.title + "<br><br>" + txt + "<br><hr>By " + authorinfo + "<br>URL:" + configinfo.Weburl + varticle.url + "#" + id.ToString();
                }

                foreach (string user in lst)
                {
                    string email = GetUserEmail(user);
                    if (email != "")
                    {
                        WebUtils.SendSysMail(email, etitle, econtent.Replace("\r\n", "<br>"));
                    }
                }
            }
            catch
            { }
        }
示例#13
0
        public ActionResult Category(int id, int? p, int? commend, int? f)
        {
            try
            {
                CategoryModel category = myService.GetCategoryByID(id);
                ViewBag.Title = category.CateName;
                ViewBag.WebPath = myService.GetCategoryPathUrl(category.Path);
                string currenturl = WebUtils.GetCateUrl(category);
                ViewBag.CurrentUrl = currenturl;
                Pager pager = new Pager();
                pager.PageNo = p ?? 1;

                switch(category.Type)
                {
                    //单页
                    case "2":
                        blog_varticle varticle = new blog_varticle();
                        var re = myService.GetArticles(0,id,0);
                        if (re.Count() > 0)
                        {
                            varticle = re.ToList()[0];
                            varticle.viewcount++;
                            myService.UpdateArticle(varticle);
                            ViewBag.VoteTip = IsVote(varticle.id) ? res.Vote_Tip1 : res.Vote_Tip2;
                            ViewBag.PreNextLink = GetNextPreArticleLink(varticle.id);
                            ViewBag.ArticleId = varticle.id;
                            return View(WebUtils.GetViewName(category.CustomView, "Article"), varticle);
                        }
                        else
                            return View("Error");
                    //相册
                    case "4":
                        return View(WebUtils.GetViewName(category.CustomView, "Albums"), myService.GetAlbums(id));
                    //留言板
                    case "6":
                        if ((f ?? 0) > 0)
                        {
                            int floorpage = myService.GetArticlePageNo(configinfo.NotePagerCount, id, f ?? 0, 2);
                            string paras = "";
                            paras += floorpage > 1 ? "&p=" + floorpage.ToString() : "";
                            paras = paras != "" ? "?" + paras.Trim('&') : "";
                            paras += "#f_" + f.ToString();
                            return Redirect(currenturl + paras);
                        }
                        NoteModel note = new NoteModel();
                        note.CateId = id;
                        note.UserName = User.Identity.Name;
                        pager.PageSize = configinfo.NotePagerCount;
                        pager = myService.GetArticlePaging(pager, 0, id);
                        ViewBag.PageNo = p ?? 1;
                        ViewBag.PageCount = pager.PageCount;
                        ViewBag.CateId = id;
                        ViewData["NoteList"] = pager.Entity;
                        return View(WebUtils.GetViewName(category.CustomView, "Note"), note);
                    //文章列表
                    default:
                        int iscommend = commend ?? 0;
                        ViewBag.Commend = iscommend;
                        pager.PageSize = configinfo.CatePagerCount;
                        bool HasSub = true;//是否还有子分类
                        if (Utils.StrToInt(category.SubCount) > 0)
                        {
                            ViewData["CateLinks"] = myService.GetSonCategoryList(Utils.StrToInt(category.CateId));
                            pager = myService.GetArticlePaging(pager, 0, myService.GetCategoryIds(id), iscommend);
                        }
                        else
                        {
                            if (category.ParentId != "0")
                                ViewData["CateLinks"] = myService.GetSonCategoryList(Utils.StrToInt(category.ParentId));
                            else
                                ViewData["CateLinks"] = new List<CategoryModel>();
                            pager = myService.GetArticlePaging(pager, 0, id, iscommend);
                            HasSub = false;
                        }
                        ViewBag.HasSub = HasSub;
                        ViewBag.PageNo = p ?? 1;
                        ViewBag.PageCount = pager.PageCount;
                        ViewBag.CateId = id;
                        string jsonSummaryImg = "";
                        pager.Entity = GetNewArticleQuery(pager.Entity as IQueryable<blog_varticle>, out jsonSummaryImg);
                        ViewBag.SummaryImgs = jsonSummaryImg;
                        return View(WebUtils.GetViewName(category.CustomView, "Category"),pager.Entity);
                }
            }
            catch
            { return View("Error"); }
        }
示例#14
0
 /// <summary>
 /// 文章页
 /// </summary>
 public ActionResult ArticleByKey(string key)
 {
     try
     {
         int articleid = Utils.StrToInt(key);
         if (articleid > 0)
             return Article(articleid);
         blog_varticle varticle = new blog_varticle();
         varticle = myService.GetArticleByReName(key);
         if (varticle != null)
         {
             return Article(varticle.id);
         }
         else
         {
             return View("Error");
         }
     }
     catch
     { return View("Error"); }
 }
示例#15
0
 /// <summary>
 /// 文章页
 /// </summary>
 public ActionResult Article(int id)
 {
     try
     {
         blog_varticle varticle = new blog_varticle();
         varticle = myService.GetVArticleByID(id);
         ViewBag.Title = WebUtils.MyString(varticle.seotitle,varticle.title);
         string metaDescription = string.IsNullOrWhiteSpace(varticle.seodescription) ? "" : "<meta content=\"" + varticle.seodescription + "\" name=\"Description\" />\r\n";
         string metaKeywords = string.IsNullOrWhiteSpace(varticle.seokeywords) ? "" : "<meta content=\"" + varticle.seokeywords + "\" name=\"keywords\" />\r\n";
         string metaInfo = WebUtils.MyString(varticle.seometas) + "\r\n";
         ViewBag.Seo = metaDescription + metaKeywords + metaInfo;
         ViewBag.ArticleId = varticle.id;
         ViewBag.WebPath = myService.GetCategoryPathUrl(varticle.catepath);
         return View("Article", varticle);
     }
     catch
     { return View("Error"); }
 }
示例#16
0
 public ActionResult AjaxVote(int articleid,int vote)
 {
     try
     {
         if (IsVote(articleid))
             return VoteJsonRe(1, res.Vote_Tip1, 0);
         if (Request.Cookies["article.vote"] == null)
         {
             HttpCookie voteCookie = new HttpCookie("article.vote");
             voteCookie["articleid"] = articleid.ToString()+",";
             voteCookie.Expires = DateTime.Now.AddDays(7d);
             Response.Cookies.Add(voteCookie);
         }
         else
         {
             string cookieString = Request.Cookies["article.vote"]["articleid"];
             string[] cookies = cookieString.Split(new char[] { ',' });
             if (!cookies.Contains(articleid.ToString()))
             {
                 HttpCookie voteCookie = new HttpCookie("article.vote");
                 voteCookie["articleid"] = cookieString + articleid.ToString() + ",";
                 voteCookie.Expires = DateTime.Now.AddDays(7d);
                 Response.Cookies.Add(voteCookie);
             }
         }
         int re = 0;
         blog_varticle varticle = new blog_varticle();
         varticle = myService.GetVArticleByID(articleid);
         if (vote == 1)
         {
             varticle.favor++;
             re = varticle.favor;
         }
         else
         {
             varticle.against++;
             re = varticle.against;
         }
         myService.UpdateArticle(varticle);
         return VoteJsonRe(0, res.Vote_Tip3, re);
     }
     catch
     {
         return VoteJsonRe(1, res.Ajax_Error, 0);
     }
 }