Пример #1
0
 /// <summary>
 /// 链接到内容页
 /// </summary>
 /// <param name="_contentid">内容ID</param>
 /// <param name="_initialize">是否初始化</param>
 /// <returns></returns>
 public string Go2View(string _contentid)
 {
     SiteGroupCms.Dal.ArticleDal        articledal = new ArticleDal();
     SiteGroupCms.Entity.Article        article    = articledal.GetEntity(_contentid);
     SiteGroupCms.Entity.Normal_Channel _Channel   = new SiteGroupCms.Dal.Normal_ChannelDAL().GetEntity(article.Catalogid.ToString());
     return(ModuleCommand.GetContentLink(_contentid));
 }
Пример #2
0
        /// <summary>
        /// 得到内容页地址
        /// </summary>
        /// <param name="_contentid"></param>
        /// <param name="_truefile"></param>
        /// <returns></returns>
        public string GetContentLink(string _contentid)
        {
            SiteGroupCms.Dal.Normal_ChannelDAL _ChannelDal = new Normal_ChannelDAL();
            SiteGroupCms.Dal.ArticleDal        articledal  = new ArticleDal();
            SiteGroupCms.Entity.Article        article     = articledal.GetEntity(_contentid);
            if (article.Yyarticleid.ToString() != "" && article.Yyarticleid != 0)//如果引用文章
            {
                _contentid = article.Yyarticleid.ToString();
            }
            article = articledal.GetEntity(_contentid);           //重新取引用的文章

            if (article.Linkurl != "" && article.Linkurl != null) //如果是连接文章
            // return article.Linkurl; //这个直接得到连接地址
            {
                return("/ajaxhandler/Gethits.aspx?articleid=" + article.Id); //得到可以统计点击次数的连接地址
            }
            SiteGroupCms.Entity.Normal_Channel _Channel = _ChannelDal.GetEntity(article.Catalogid.ToString());
            site = (SiteGroupCms.Entity.Site)HttpContext.Current.Session["site"];
            string qianstr   = "/sites/" + site.Location + "/pub";
            string centerstr = "";

            //检查对应的文件夹是否存在,若不存在则创建,若存在则以id为标题生成
            while (_Channel.Father != 0)//不为跟节点就继续往上走
            {
                centerstr = "/" + _Channel.Dirname + centerstr;
                _Channel  = _ChannelDal.GetEntity(_Channel.Father.ToString());
            }
            centerstr = "/" + _Channel.Dirname + centerstr + "/";
            string title = article.Addtime.Year.ToString() + article.Addtime.Month.ToString() + article.Addtime.Day.ToString() + _contentid;

            return(qianstr + centerstr + title + ".html");
        }
Пример #3
0
        /// <summary>
        /// 删除内容页
        /// </summary>
        /// <param name="_ChannelId"></param>
        /// <param name="_ContentId"></param>
        public void DeleteContent(string _ContentId)
        {
            SiteGroupCms.Dal.ArticleDal        articledal = new ArticleDal();
            SiteGroupCms.Entity.Article        article    = articledal.GetEntity(_ContentId);
            SiteGroupCms.Entity.Normal_Channel _Channel   = new SiteGroupCms.Dal.Normal_ChannelDAL().GetEntity(article.Catalogid.ToString());

            using (DbOperHandler _doh = new Common().Doh())
            {
                _doh.Reset();
                _doh.ConditionExpress = "[Id]=" + _ContentId;
                object[] _value     = _doh.GetFields("yy_articleinfo", "AddDate,FirstPage");
                string   _date      = _value[0].ToString();
                string   _firstpage = _value[1].ToString();
                if (_firstpage.Length > 0)
                {
                    string _folderName = String.Format("/detail_{0}_{1}/{2}",
                                                       DateTime.Parse(_date).ToString("yyyy"),
                                                       DateTime.Parse(_date).ToString("MM"),
                                                       DateTime.Parse(_date).ToString("dd")
                                                       );
                    if (System.IO.Directory.Exists(HttpContext.Current.Server.MapPath(site.Location + _Channel.Dirname + _folderName)))
                    {
                        string htmFile = HttpContext.Current.Server.MapPath(Go2View(_ContentId));
                        if (System.IO.File.Exists(htmFile))
                        {
                            System.IO.File.Delete(htmFile);
                        }
                        string[] htmFiles = System.IO.Directory.GetFiles(HttpContext.Current.Server.MapPath(site.Location + _Channel.Dirname + _folderName), _ContentId + "_*" + "htm");
                        foreach (string fileName in htmFiles)
                        {
                            if (System.IO.File.Exists(fileName))
                            {
                                System.IO.File.Delete(fileName);
                            }
                        }
                    }
                    _doh.Reset();
                    _doh.SqlCmd = "UPDATE [jcms_module_" + _Channel.Type + "] SET [FirstPage]='' WHERE [ChannelId]=" + article.Catalogid + " AND [Id]=" + _ContentId;
                    _doh.ExecuteSqlNonQuery();
                }
            }
        }
Пример #4
0
 public List <SiteGroupCms.Entity.Module_Article> DT2List(DataTable _dt)
 {
     if (_dt == null)
     {
         return(null);
     }
     //对其中一些数据进行替换 如点击量 作者  图片 附件等
     for (int i = 0; i < _dt.Rows.Count; i++)
     {
         if (_dt.Rows[i]["yyarticleid"].ToString() != "" && _dt.Rows[i]["yyarticleid"].ToString() != "0")//是引用
         {
             DataRow dttemp = new ArticleDal().getDT("id=" + _dt.Rows[i]["yyarticleid"].ToString()).Rows[0];
             for (int j = 0; j < _dt.Columns.Count; j++)
             {
                 _dt.Rows[i][j] = dttemp[j];
             }
         }
     }
     return(this.DT2List <SiteGroupCms.Entity.Module_Article>(_dt, true, true));
 }
Пример #5
0
 public virtual string GetContent(string _ContentId)
 {
     using (DbOperHandler _doh = new Common().Doh())
     {
         _doh.Reset();
         _doh.SqlCmd = "SELECT * FROM [yy_articleinfo] WHERE  [Id]=" + _ContentId;
         DataTable dtSearch = _doh.GetDataTable();
         if (dtSearch.Rows.Count == 0)
         {
             dtSearch.Clear();
             dtSearch.Dispose();
             return("内容错误");
         }
         SiteGroupCms.Dal.ArticleDal articledal = new ArticleDal();
         SiteGroupCms.Entity.Article article    = articledal.GetEntity(_ContentId);
         SiteGroupCms.Entity.Site    site       = (SiteGroupCms.Entity.Site)HttpContext.Current.Session["site"];
         TemplateEngineDAL           te         = new TemplateEngineDAL(article.Catalogid.ToString());
         string PageStr = string.Empty;
         _doh.Reset();
         _doh.SqlCmd = "SELECT * FROM [yy_articleinfo] WHERE  [Id]=" + _ContentId;
         DataTable dtContent = _doh.GetDataTable();
         string    ChannelId = dtContent.Rows[0]["catalogid"].ToString();
         te.PageNav         = Go2Site() + " &raquo;" + Go2Channel(ChannelId, 0);
         te.PageTitle       = site.WebTitle + "--" + dtContent.Rows[0]["title"].ToString();
         te.PageKeywords    = dtContent.Rows[0]["keywords"].ToString();
         te.PageDescription = dtContent.Rows[0]["abstract"].ToString();
         p__GetChannel_Article(te, dtContent, ref PageStr); //提取出模板的内容
         te.ReplacePublicTag(ref PageStr);                  //包含include解析 siteconfig解析 已经注释掉了  replaceTag_ChannelLoop解析
         //te.ReplaceChannelTag(ref PageStr, ChannelId);
         // PageStr = PageStr.Replace("{$channelid}",ChannelId);
         te.replaceTag_ChannelLoop(ref PageStr, ChannelId);      //替换频道循环标签
         te.ReplaceContentTag(ref PageStr, _ContentId);          //解释单片文档的所有标签
         te.ReplaceContentLoopTag(ref PageStr);                  //
         te.ReplaceChannelTag(ref PageStr, ChannelId);           //替换
         te.ExcuteLastHTML(ref PageStr);                         //替换注释标签
         PageStr = SiteGroupCms.Utils.Strings.UBB2HTML(PageStr); //替换ubb标签
         return(PageStr.Replace("{$Content}", dtContent.Rows[0]["content"].ToString()));
         // .Replace("{$_getPageBar()}", getPageBar(1, "html", 7, ContentList.Count - 1, 1, _CurrentPage, Go2View(true, _ChannelId, _ContentId, false), Go2View(true, _ChannelId, _ContentId, false), Go2View((true), _ChannelId, _ContentId, false), 0));
     }
 }
Пример #6
0
        public virtual void CreateContent(string _ContentId)
        {
            using (DbOperHandler _doh = new Common().Doh())
            {
                _doh.Reset();
                _doh.SqlCmd = "SELECT [Content],[linkurl],[yyarticleid] FROM [yy_articleinfo] WHERE  [Id]=" + _ContentId;
                DataTable dtContent      = _doh.GetDataTable();
                string    ArticleContent = dtContent.Rows[0]["Content"].ToString();
                string    linkurl        = dtContent.Rows[0]["linkurl"].ToString();
                string    yyarticleid    = dtContent.Rows[0]["yyarticleid"].ToString();
                dtContent.Clear();
                dtContent.Dispose();
                if (yyarticleid == "0" || yyarticleid == "") //如果不是引用文章
                {
                    if (linkurl == "")                       //且不是连接文章
                    {
                        SiteGroupCms.Utils.DirFile.SaveFile(GetContent(_ContentId), Go2View(_ContentId));
                    }
                }

//同时上传到服务器上 出现问题时 不进行处理 程序照常进行
//上传服务器暂时不使用上传ftp功能

                /*
                 *         try
                 *      {
                 *          FtpDal ftpdal = new FtpDal();
                 *          ftpdal.UploadFile(Go2View(_ContentId, true));
                 *      }
                 *      catch (Exception e )
                 *      {
                 *          throw;
                 *      }*/
//更新数据库的内容为已经发布
                SiteGroupCms.Dal.ArticleDal articledal = new ArticleDal();
                articledal.publish(_ContentId, 1);
            }
        }
Пример #7
0
        /// <summary>
        /// 取得栏目需要生成的静态文章的数目
        /// </summary>
        /// <param name="catalogid"></param>
        /// <returns></returns>
        public int getpublishcontnum(string catalogid)
        {
            DataTable dt = new ArticleDal().getDT("catalogid=" + catalogid + " and ispassed=1");

            return(dt.Rows.Count);
        }
Пример #8
0
        /// <summary>
        /// 得到列表JSON数据
        /// </summary>
        /// <param name="_thispage">当前页码</param>
        /// <param name="_pagesize">每页记录条数</param>
        /// <param name="_wherestr">搜索条件</param>
        /// <param name="_jsonstr">返回值</param>
        public void GetListJSON(int _thispage, int _pagesize, string _wherestr, ref string _jsonstr, string orderstr)
        {
            SiteGroupCms.Entity.Admin _admin = new SiteGroupCms.Entity.Admin();
            AdminDal   _adminobj             = new AdminDal();
            CatalogDal catadalobj            = new CatalogDal();

            using (DbOperHandler _doh = new Common().Doh())
            {
                _doh.Reset();
                _doh.ConditionExpress = _wherestr;
                string sqlStr    = "";
                int    _countnum = _doh.Count("yy_articleinfo");
                sqlStr = SiteGroupCms.Utils.SqlHelp.GetSql("*", "yy_articleinfo", _pagesize, _thispage, orderstr, _wherestr);
                _doh.Reset();
                _doh.SqlCmd = sqlStr;
                DataTable  dt   = _doh.GetDataTable();
                DataTable  dt2  = new DataTable();
                DataColumn col  = new DataColumn("id", System.Type.GetType("System.String"));
                DataColumn col2 = new DataColumn("title", System.Type.GetType("System.String"));
                DataColumn col3 = new DataColumn("author", System.Type.GetType("System.String"));
                DataColumn col4 = new DataColumn("addtime", System.Type.GetType("System.String"));
                DataColumn col5 = new DataColumn("catalogid", System.Type.GetType("System.String"));
                DataColumn col6 = new DataColumn("state", System.Type.GetType("System.String"));
                DataColumn col7 = new DataColumn("clickcount", System.Type.GetType("System.String"));
                DataColumn col8 = new DataColumn("articletype", System.Type.GetType("System.String"));
                dt2.Columns.Add(col);
                dt2.Columns.Add(col2);
                dt2.Columns.Add(col3);
                dt2.Columns.Add(col4);
                dt2.Columns.Add(col5);
                dt2.Columns.Add(col6);
                dt2.Columns.Add(col7);
                dt2.Columns.Add(col8);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow dr = dt2.NewRow();
                    dr["id"] = dt.Rows[i]["id"];
                    if (dt.Rows[i]["yyarticleid"].ToString() == "" || dt.Rows[i]["yyarticleid"].ToString() == "0")
                    {
                        if (dt.Rows[i]["linkurl"] != null && dt.Rows[i]["linkurl"].ToString() != "")//为连接文章
                        {
                            dr["articletype"] = "链接";
                        }
                        else
                        {
                            dr["articletype"] = "普通";
                        }

                        dr["title"] = dt.Rows[i]["title"];
                        if (dt.Rows[i]["author"].ToString() == "")
                        {
                            dr["author"] = "匿名";
                        }
                        else
                        {
                            dr["author"] = dt.Rows[i]["author"].ToString();
                        }

                        dr["addtime"] = String.Format("{0:d}", SiteGroupCms.Utils.Validator.StrToDate(dt.Rows[i]["addtime"].ToString(), DateTime.Now));

                        if (dt.Rows[i]["catalogid"].ToString() != "")
                        {
                            if (catadalobj.GetEntity(dt.Rows[i]["catalogid"].ToString()) != null)
                            {
                                dr["catalogid"] = catadalobj.GetEntity(dt.Rows[i]["catalogid"].ToString()).Title;
                            }
                            else
                            {
                                dr["catalogid"] = "栏目不存在了";
                            }
                        }
                        else
                        {
                            dr["catalogid"] = "无栏目";
                        }

                        dr["state"] = "";
                        if (dt.Rows[i]["ispassed"].ToString() == "0")
                        {
                            dr["state"] += "<span style='color:red;'>未审核</span>&nbsp;";
                        }
                        else
                        {
                            dr["state"] += "已审核&nbsp;";
                        }
                        if (dt.Rows[i]["isrecommend"].ToString() != "0")
                        {
                            dr["state"] += "推荐&nbsp;";
                        }
                        if (dt.Rows[i]["isppt"].ToString() != "0")
                        {
                            dr["state"] += "幻灯片&nbsp;";
                        }
                        if (dt.Rows[i]["isroll"].ToString() != "0")
                        {
                            dr["state"] += "滚动&nbsp;";
                        }
                        if (dt.Rows[i]["ispublish"].ToString() != "0")
                        {
                            dr["state"] += "已发布&nbsp;";
                        }
                        else
                        {
                            dr["state"] += "<span style='color:red;'>未发布</span>&nbsp;";
                        }
                        if (dt.Rows[i]["isshare"].ToString() != "0")
                        {
                            dr["state"] += "共享&nbsp;";
                        }
                        dr["clickcount"] = dt.Rows[i]["clickcount"].ToString();
                    }
                    else //如果是引用 则查找源文章
                    {
                        dr["articletype"] = "引用";
                        SiteGroupCms.Entity.Article yuanarticle = new ArticleDal().GetEntity(dt.Rows[i]["yyarticleid"].ToString());
                        if (yuanarticle.Title == null)//源文章不存在了
                        {
                            dr["title"] = "源文章不存在了";
                        }
                        else
                        {
                            dr["title"] = yuanarticle.Title;
                        }

                        if (dt.Rows[i]["author"].ToString() == "")
                        {
                            dr["author"] = "匿名";
                        }
                        else
                        {
                            dr["author"] = dt.Rows[i]["author"].ToString();
                        }

                        dr["addtime"] = String.Format("{0:g}", yuanarticle.Addtime);

                        if (yuanarticle.Catalogid.ToString() != "")
                        {
                            if (catadalobj.GetEntity(yuanarticle.Catalogid.ToString()) != null)
                            {
                                dr["catalogid"] = catadalobj.GetEntity(yuanarticle.Catalogid.ToString()).Title;
                            }
                            else
                            {
                                dr["catalogid"] = "栏目不存在了";
                            }
                        }
                        else
                        {
                            dr["catalogid"] = "无栏目";
                        }

                        dr["state"] = "";
                        if (yuanarticle.Ispass.ToString() == "0")
                        {
                            dr["state"] += "未审核&nbsp;";
                        }
                        else
                        {
                            dr["state"] += "已审核&nbsp;";
                        }
                        if (yuanarticle.Isrecommend.ToString() != "0")
                        {
                            dr["state"] += "推荐&nbsp;";
                        }
                        if (yuanarticle.Isppt.ToString() != "0")
                        {
                            dr["state"] += "幻灯片&nbsp;";
                        }
                        if (yuanarticle.Isroll.ToString() != "0")
                        {
                            dr["state"] += "滚动&nbsp;";
                        }
                        if (yuanarticle.Ispublish.ToString() != "0")
                        {
                            dr["state"] += "已发布&nbsp;";
                        }
                        else
                        {
                            dr["state"] += "未发布&nbsp;";
                        }
                        if (yuanarticle.Isshare.ToString() != "0")
                        {
                            dr["state"] += "共享&nbsp;";
                        }
                        dr["clickcount"] = yuanarticle.Clickcount.ToString();
                    }


                    dt2.Rows.Add(dr);
                }
                _jsonstr = SiteGroupCms.Utils.dtHelp.DT2JSON(dt2, _countnum);
                dt.Clear();
                dt.Dispose();
            }
        }