Ejemplo n.º 1
0
        /// <summary>
        /// Dels the HTML.
        /// </summary>
        /// <param name="Model">The model.</param>
        /// <returns></returns>
        public void DelHtml(int id)
        {
            try
            {
                ROYcms.Sys.BLL.ROYcms_news    BLL      = new ROYcms.Sys.BLL.ROYcms_news();
                ROYcms.Sys.BLL.ROYcms_class   ClassBLL = new ROYcms.Sys.BLL.ROYcms_class();
                ROYcms.Sys.Model.ROYcms_class Model    = ClassBLL.GetModel(ClassBLL.GetClassId(Convert.ToInt32(BLL.GetClassName(id))));
                ROYcms.Sys.Model.ROYcms_news  NewModel = BLL.GetModel(id);
                string Path = null;
                Model.FilePath = Model.FilePath.Replace("{cmspath}", "~");
                Path           = (Model.ShowRules.Contains("~/") ? Model.ShowRules : (Model.FilePath + Model.ShowRules)); //文件生成地址
                Path           = Path.Replace("{yyyy}", Convert.ToDateTime(NewModel.time).ToString("yyyy"));
                Path           = Path.Replace("{MM}", Convert.ToDateTime(NewModel.time).ToString("MM"));
                Path           = Path.Replace("{dd}", Convert.ToDateTime(NewModel.time).ToString("dd"));
                Path           = Path.Replace("{id}", id.ToString());

                using (StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath(Path), false, Encoding.GetEncoding(ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_language"))))
                {
                    // File.Delete(HttpContext.Current.Server.MapPath(Path));

                    sw.WriteLine("文件已经删除!<a href='/inde.aspx'>到首页</a>");
                    sw.Flush();
                }
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.Write(ex.Message);
            }
        }
Ejemplo n.º 2
0
        ///// <summary>
        ///// loop标签的匹配替换
        ///// </summary>
        ///// <param name="template">模板内容</param>
        public string LoopClass(string template)
        {
            string Attributes = "";
            string Text       = "";
            string AllText    = "";
            Regex  r          = new Regex(@"(\[SG:class\s+(?<attributes>[^\]]*?)\](?<text>[\s\S]*?)\[/SG:class\])", RegexOptions.Compiled | RegexOptions.IgnoreCase);

            foreach (Match m in r.Matches(template))
            {
                Attributes = m.Groups["attributes"].ToString(); //循环属性集
                Text       = m.Groups["text"].ToString();       //循环的内容不包含SG:Loop
                AllText    = m.Groups[0].Value.ToString();      //整个匹配的内容包含SG:Loop

                #region  取得相关属性
                string Count   = null;   //调用数量
                string classID = null;
                string Templet = null;   // 模板ID

                Templet = TagVal(Attributes, "Templet");
                Count   = TagVal(Attributes, "Count");

                classID = TagVal(Attributes, "classID");

                #endregion

                #region 对循环的内容进行替换
                string content = "";
                ROYcms.Sys.BLL.ROYcms_class bll = new ROYcms.Sys.BLL.ROYcms_class();
                DataSet dt = bll.GetClassList(0);
                if (classID != null)
                {
                    dt = bll.GetSubClassList(bll.GetClassId(Convert.ToInt32(classID)));
                }
                if (dt.Tables[0].Rows.Count > 0)
                {
                    int rowsCount = dt.Tables[0].Rows.Count;
                    if (Count != null && rowsCount > Convert.ToInt32(Count))
                    {
                        rowsCount = Convert.ToInt32(Count);
                    }
                    for (int n = 0; n < rowsCount; n++)
                    {
                        string str = Text;
                        str      = Replace(str, @"\[SG:ClassName\]", dt.Tables[0].Rows[n]["ClassName"].ToString());
                        str      = Replace(str, @"\[SG:Link\]", config.web_host + TemplateZone.Zpath(this.pageHost) + "list" + Templet + "-" + dt.Tables[0].Rows[n]["Id"].ToString() + config.web_forge);
                        str      = Replace(str, @"\[SG:_Link\]", "list-" + dt.Tables[0].Rows[n]["Id"].ToString() + config.web_forge);
                        content += str;
                    }
                }
                else
                {
                    content = "";
                }
                #endregion
                template = template.Replace(AllText, content);
            }
            return(template);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// WebRepeater拼接
        /// </summary>
        /// <param name="MYclass"></param>
        /// <returns></returns>
        public string ClassWheres(string MYclass)
        {
            string Strs = null;

            DataSet DS = ROYcms_classBll.GetSubClassList(ROYcms_classBll.GetClassId(Convert.ToInt32(MYclass)));

            DataTable dt = DS.Tables[0];

            //遍历行
            if (dt.Rows.Count < 1)
            {
                Strs = MYclass + ",";
            }
            else
            {
                foreach (DataRow dr in dt.Rows)
                {
                    Strs += dr["Id"].ToString() + ",";
                }
            }
            Strs = Strs.Substring(0, Strs.Length - 1);
            return(Strs);
        }
Ejemplo n.º 4
0
        public string ClassWheres()
        {
            string Strs = null;

            ROYcms.Sys.BLL.ROYcms_class Bll = new ROYcms.Sys.BLL.ROYcms_class();
            DataSet DS = Bll.GetSubClassList(Bll.GetClassId(Convert.ToInt32(this.Type)));

            DataTable dt = DS.Tables[0];

            //遍历行
            if (dt.Rows.Count < 1)
            {
                Strs = this.Type + ",";
            }
            else
            {
                foreach (DataRow dr in dt.Rows)
                {
                    Strs += dr["Id"].ToString() + ",";
                }
            }
            Strs = Strs.Substring(0, Strs.Length - 1);
            return(Strs);
        }
Ejemplo n.º 5
0
        protected override void OnDataBinding(EventArgs e)
        {
            ROYcms.Sys.BLL.ROYcms_class ___ROYcms_class = new ROYcms.Sys.BLL.ROYcms_class();
            if (ClassKind != null)
            {
                if (Div != 00)
                {
                    dataSource = (IList)(new DataView(((DataSet)(___ROYcms_class.GetClassList(Convert.ToInt32(ClassKind), Div))).Tables[0]));
                }
                else
                {
                    dataSource = (IList)(new DataView(((DataSet)(___ROYcms_class.GetClassList(Convert.ToInt32(ClassKind)))).Tables[0]));
                }
            }
            if (Class != null)
            {
                dataSource = (IList)(new DataView(((DataSet)(___ROYcms_class.GetSubClassList(___ROYcms_class.GetClassId(Convert.ToInt32(Class))))).Tables[0]));
            }
            if (Path != null)
            {
                dataSource = (IList)(new DataView(((DataSet)(___ROYcms_class.GetSubClassList(___ROYcms_class.GetClassId(Convert.ToInt32(___ROYcms_class.GetId("{cmspath}/" + Path + "/")))))).Tables[0]));
            }
            //if (base.DataSource != null)
            //{
            intItemCount    = dataSource.Count;
            base.DataSource = dataSource;

            base.OnDataBinding(e);
            //}
        }
Ejemplo n.º 6
0
        /// <summary>
        /// loop标签的匹配替换
        /// </summary>
        /// <param name="template">模板内容</param>
        public string LoopTag(string template)
        {
            string Attributes = "";
            string Text       = "";
            string AllText    = "";
            Regex  r          = new Regex(@"(\[SG:loop\s+(?<attributes>[^\]]*?)\](?<text>[\s\S]*?)\[/SG:loop\])", RegexOptions.Compiled | RegexOptions.IgnoreCase);

            foreach (Match m in r.Matches(template))
            {
                Attributes = m.Groups["attributes"].ToString(); //循环属性集
                Text       = m.Groups["text"].ToString();       //循环的内容不包含SG:Loop
                AllText    = m.Groups[0].Value.ToString();      //整个匹配的内容包含SG:Loop

                #region  取得相关属性
                string NewsCount = null;     //调用数量
                string TitleNum  = null;     //新闻标题的显示字符数量
                string ding      = null;
                string tuijian   = null;
                string NewsType  = null;     //调用新闻的类型
                //string Templet = null;       // 模板ID

                string SQL = null;

                NewsCount = TagVal(Attributes, "NewsCount");
                if (NewsCount == null)
                {
                    NewsCount = "15";
                }
                TitleNum = TagVal(Attributes, "TitleNum");
                if (TitleNum == null)
                {
                    TitleNum = "100";
                }
                ding = TagVal(Attributes, "ding");
                if (ding == null)
                {
                    ding = "false";
                }
                tuijian = TagVal(Attributes, "tuijian");
                if (tuijian == null)
                {
                    tuijian = "false";
                }
                NewsType = TagVal(Attributes, "NewsType");
                if (NewsType == null)
                {
                    NewsType = "0";
                }

                SQL = TagVal(Attributes, "SQL");

                #endregion

                #region 构造 查询SQL语句
                //SQL语句拼接
                string        strWher = "";
                StringBuilder strSql  = new StringBuilder();
                if (SQL == null)
                {
                    strWher = "classname='" + NewsType + "'";
                    strSql.Append("select top ");
                    strSql.Append(NewsCount);
                    strSql.Append(" * from [ROYcms_news] where ");
                    strSql.Append(strWher);
                    strSql.Append(" AND switchs='0'");
                    if (ding == "true")
                    {
                        strSql.Append(" AND ding='0'");
                    }
                    if (tuijian == "true")
                    {
                        strSql.Append(" AND tuijian='0'");
                    }
                    strSql.Append(" order by switchs,bh DESC");
                }
                else
                {
                    strSql.Append(SQL);
                }

                #endregion

                #region 对循环的内容进行替换
                ROYcms_class_Model = ROYcms_class_Bll.GetModel(ROYcms_class_Bll.GetClassId(Convert.ToInt32(NewsType)));
                string  content = "";
                DataSet dt      = Bll.GetDataSet(strSql.ToString());
                if (dt.Tables[0].Rows.Count > 0)
                {
                    int rowsCount = dt.Tables[0].Rows.Count;
                    for (int n = 0; n < rowsCount; n++)
                    {
                        string str        = Text;
                        string T_ShowPath = (ROYcms_class_Model.ShowRules == null ? "" : ROYcms_class_Model.ShowRules);
                        str = Replace(str, @"\[SG:Title\]", ROYcms.Common.input.GetSubString(dt.Tables[0].Rows[n]["title"].ToString(), Convert.ToInt32(TitleNum)));
                        str = Replace(str, @"\[SG:_Title\]", dt.Tables[0].Rows[n]["title"].ToString());
                        str = Replace(str, @"\[SG:Id\]", dt.Tables[0].Rows[n]["bh"].ToString());
                        str = Replace(str, @"\[SG:Url\]", dt.Tables[0].Rows[n]["url"].ToString());


                        T_ShowPath = T_ShowPath.Replace("{yyyy}", Convert.ToDateTime(dt.Tables[0].Rows[n]["time"]).ToString("yyyy"));
                        T_ShowPath = T_ShowPath.Replace("{MM}", Convert.ToDateTime(dt.Tables[0].Rows[n]["time"]).ToString("MM"));
                        T_ShowPath = T_ShowPath.Replace("{dd}", Convert.ToDateTime(dt.Tables[0].Rows[n]["time"]).ToString("dd"));
                        T_ShowPath = T_ShowPath.Replace("{id}", dt.Tables[0].Rows[n]["bh"].ToString());
                        str        = Replace(str, @"\[SG:Link\]", T_ShowPath);

                        str = Replace(str, @"\[SG:Pic\]", dt.Tables[0].Rows[n]["pic"].ToString());
                        str = Replace(str, @"\[SG:Zhaiyao\]", dt.Tables[0].Rows[n]["zhaiyao"].ToString());
                        str = Replace(str, @"\[SG:Keyword\]", dt.Tables[0].Rows[n]["keyword"].ToString());
                        str = Replace(str, @"\[SG:classname\]", new ROYcms.Sys.BLL.ROYcms_class().GetClassTitle(Convert.ToInt32(dt.Tables[0].Rows[n]["classname"].ToString())));

                        str = Replace(str, @"\[SG:Content\]", dt.Tables[0].Rows[n]["contents"].ToString());
                        str = Replace(str, @"\[SG:Infor\]", dt.Tables[0].Rows[n]["infor"].ToString());
                        str = Replace(str, @"\[SG:Author\]", dt.Tables[0].Rows[n]["author"].ToString());
                        str = Replace(str, @"\[SG:Tag\]", dt.Tables[0].Rows[n]["tag"].ToString());
                        str = Replace(str, @"\[SG:Dig\]", dt.Tables[0].Rows[n]["dig"].ToString());
                        str = Replace(str, @"\[SG:Hits\]", dt.Tables[0].Rows[n]["hits"].ToString());
                        str = Replace(str, @"\[SG:Time\]", dt.Tables[0].Rows[n]["time"].ToString());
                        str = Replace(str, @"\[SG:Year\]", Convert.ToDateTime(dt.Tables[0].Rows[n]["time"]).Date.Year.ToString());
                        str = Replace(str, @"\[SG:Month\]", Convert.ToDateTime(dt.Tables[0].Rows[n]["time"]).Date.Month.ToString());
                        str = Replace(str, @"\[SG:Day\]", Convert.ToDateTime(dt.Tables[0].Rows[n]["time"]).Date.Day.ToString());

                        content += str;
                    }
                }
                else
                {
                    content = "";
                }
                #endregion
                template = template.Replace(AllText, content);
            }
            return(template);
        }