/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.ClassKind = Convert.ToInt32(Request.QueryString["ClassKind"] == null ? "10" : Request.QueryString["ClassKind"]);

                //默认模板地址
                txtTemplateIndex.Text = ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_root") + "default/index.html";
                txtTemplateList.Text  = ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_root") + "default/list.html";
                txtTemplateShow.Text  = ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_root") + "default/show.html";
                if (Request["ClassId"] != null)
                {
                    _model           = new ROYcms.Sys.BLL.ROYcms_class().GetModel(Request["ClassId"]);
                    txtFilePath.Text = (_model.FilePath == "" ? "{cmspath}/" : _model.FilePath) + Guid.NewGuid().ToString() + "/";
                    F_Label.Text     = _model.ClassName;
                }
                else
                {
                    txtFilePath.Text = "{cmspath}/" + Guid.NewGuid().ToString() + "/";
                }
                txtListeRules.Text  = "list_{class}" + ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("web_forge");
                txtShowRules.Text   = "show_{id}" + ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("web_forge");
                txtDefaultFile.Text = "index" + ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("web_forge");
            }
        }
Exemple #2
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);
            }
        }
Exemple #3
0
        /// <summary>
        /// 生成所有栏目 News all HTML.
        /// </summary>
        /// <returns></returns>
        public bool NewAllHtml(int?ClassKind)
        {
            ROYcms.Sys.BLL.ROYcms_class   BLL   = new ROYcms.Sys.BLL.ROYcms_class();
            ROYcms.Sys.Model.ROYcms_class Model = new ROYcms.Sys.Model.ROYcms_class();

            DataSet ds = new DataSet();

            ds = BLL.GetClassList(Convert.ToInt32(ClassKind));

            DataTable dt = ds.Tables[0];

            foreach (DataRow dr in dt.Rows)
            {
                Model = BLL.GetModel(dr["ClassId"].ToString());
                NewHtml(Model);
                err = true;
            }
            return(err);
        }
Exemple #4
0
        /// <summary>
        /// 新闻子页面生成方法  News the HTML.
        /// </summary>
        /// <param name="Model">The model.</param>
        /// <returns></returns>
        public bool NewHtml(ROYcms.Sys.Model.ROYcms_class Model)
        {
            // StreamWriter sw = null;//定义参数

            Model.FilePath = Model.FilePath.Replace("{cmspath}", "~");
            string Path         = "";
            string templatepath = Model.TemplateShow;//模版地址
            string SQL          = null;

            if (this.bh != null)
            {
                SQL = "SELECT * FROM  [ROYcms_news] "
                      + " where bh=" + this.bh + "";
            }
            else
            {
                SQL = "SELECT "
                      + (this.top == null ? "" : "TOP " + this.top) +
                      " * FROM  [ROYcms_news] "
                      + (this.star_id == null ? "" : " where bh>" + this.star_id) +
                      (this.end_id == null ? "" : (this._star_id == null ? " where" : " and ") + "  bh<" + this.end_id) +
                      " ORDER BY bh desc";
            }

            //写文件
            try
            {
                DataSet   ds = BLL.GetDataSet(SQL);
                DataTable dt = ds.Tables[0];
                //读取模版
                string Text = PublicTag(SystemCms.Read_File(HttpContext.Current.Server.MapPath(templatepath), ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_language")));
                //列表标签过滤
                Template.ROYcms_class_Model = Model;//全局赋值
                Text = Template.LoopTag(Text);

                foreach (DataRow dr in dt.Rows)
                {
                    Path = (Model.ShowRules.Contains("~/") ? Model.ShowRules : (Model.FilePath + Model.ShowRules));//文件生成地址
                    Path = Path.Replace("{yyyy}", Convert.ToDateTime(dr["time"]).ToString("yyyy"));
                    Path = Path.Replace("{MM}", Convert.ToDateTime(dr["time"]).ToString("MM"));
                    Path = Path.Replace("{dd}", Convert.ToDateTime(dr["time"]).ToString("dd"));
                    Path = Path.Replace("{id}", dr["bh"].ToString());

                    string tempath = Path.Substring(0, Path.LastIndexOf("/") + 1);

                    if (!Directory.Exists(HttpContext.Current.Server.MapPath(tempath)))
                    {
                        Directory.CreateDirectory(HttpContext.Current.Server.MapPath(tempath));
                    }
                    using (StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath(Path), false, Encoding.GetEncoding(ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_language"))))
                    {
                        try
                        {
                            //sw = new StreamWriter(HttpContext.Current.Server.MapPath(Path), false, Encoding.GetEncoding(config.templet_language));


                            string str = Text;
                            str = Template.Replace(str, @"\[SG:Title\]", dr["title"].ToString());
                            str = Template.Replace(str, @"\[SG:Id\]", dr["bh"].ToString());
                            str = Template.Replace(str, @"\[SG:Url\]", dr["url"].ToString());

                            str = Template.Replace(str, @"\[SG:Pic\]", dr["pic"].ToString());
                            str = Template.Replace(str, @"\[SG:Zhaiyao\]", dr["zhaiyao"].ToString());
                            str = Template.Replace(str, @"\[SG:Keyword\]", dr["keyword"].ToString());
                            str = Template.Replace(str, @"\[SG:classname\]", dr["classname"].ToString());

                            str = Template.Replace(str, @"\[SG:Content\]", dr["contents"].ToString());
                            str = Template.Replace(str, @"\[SG:Infor\]", dr["infor"].ToString());
                            str = Template.Replace(str, @"\[SG:Author\]", dr["author"].ToString());
                            str = Template.Replace(str, @"\[SG:Tag\]", dr["tag"].ToString());
                            str = Template.Replace(str, @"\[SG:Dig\]", dr["dig"].ToString());
                            str = Template.Replace(str, @"\[SG:Hits\]", dr["hits"].ToString());
                            str = Template.Replace(str, @"\[SG:Time\]", dr["time"].ToString());
                            str = Template.Replace(str, @"\[SG:Year\]", Convert.ToDateTime(dr["time"]).ToString("yyyy"));
                            str = Template.Replace(str, @"\[SG:Month\]", Convert.ToDateTime(dr["time"]).ToString("MM"));
                            str = Template.Replace(str, @"\[SG:Day\]", Convert.ToDateTime(dr["time"]).ToString("dd"));

                            // str = Template.Replace(str, @"\[SG:Day\]", Xml.GetValue(Convert.ToInt32(dr["bh"]), dr["type"].ToString(), "o"));


                            sw.WriteLine(str);
                            sw.Flush();
                            err = true;
                        }

                        catch (Exception ex)
                        {
                            HttpContext.Current.Response.Write(ex.Message);
                            HttpContext.Current.Response.End();
                            err = false;
                        }
                        finally
                        {
                            sw.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.Write(ex.Message);
                HttpContext.Current.Response.End();
                err = false;
            }

            return(err);
        }
Exemple #5
0
 /// <summary>
 /// 编辑一个菜单项
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool ClassUpdate(ROYcms.Sys.Model.ROYcms_class model)
 {
     return(dal.ClassUpdate(model));
 }
Exemple #6
0
 /// <summary>
 /// 添加一个菜单项
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool ClassAdd(ROYcms.Sys.Model.ROYcms_class model)
 {
     return(dal.ClassAdd(model));
 }
Exemple #7
0
        /// <summary>
        /// 文章列表 频道 生成方法  循环标签的匹配替换 News the HTML.
        /// </summary>
        /// <param name="Model">The model.ROYcms_class 表对象</param>
        /// <returns></returns>
        public bool NewHtml(ROYcms.Sys.Model.ROYcms_class Model)
        {
            //定义参数
            //StreamWriter sw = null;
            Model.FilePath = Model.FilePath.Replace("{cmspath}", "~");
            string Path         = "";
            string ShowPath     = "";
            string templatepath = null; //模版地址
            string HTML         = "";   //模版内容

            //最终列表栏目模式
            if (Model.ColumnsType == 0)
            {
                templatepath = Model.TemplateList;//模版地址

                // 生成默认页面开始
                string TemplateIndexHTML = PublicTag(SystemCms.Read_File(HttpContext.Current.Server.MapPath(templatepath), ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_language")));
                string TemplateIndexPath = (Model.FilePath + Model.DefaultFile);     //文件生成地址
                NewMain(TemplateIndexPath, TemplateIndexHTML);
                //生成默认页面结束

                int    onepage  = (this.onepage == null ? 10 : Convert.ToInt32(this.onepage));
                int    Count    = new ROYcms.Sys.BLL.ROYcms_news().GetCount((this.classname == null ? "" : " classname=" + this.classname));
                int    allpages = Count / onepage;
                string Text     = "";
                string AllText  = "";
                string content  = "";
                Regex  r        = new Regex(@"(\[SG:loop\s+(?<attributes>[^\]]*?)\](?<text>[\s\S]*?)\[/SG:loop\])", RegexOptions.Compiled | RegexOptions.IgnoreCase);

                for (int i = 0; i < (allpages < 1 ? 1 : allpages); i++)
                {
                    HTML     = PublicTag(SystemCms.Read_File(HttpContext.Current.Server.MapPath(templatepath), ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_language")));
                    Path     = (Model.ListeRules.Contains("~/") ? Model.ListeRules : (Model.FilePath + Model.ListeRules));//文件生成地址
                    Path     = Path.Replace("{page}", i.ToString());
                    ShowPath = Model.ShowRules;
                    string tempath = Path.Substring(0, Path.LastIndexOf("/") + 1);

                    if (!Directory.Exists(HttpContext.Current.Server.MapPath(tempath)))
                    {
                        Directory.CreateDirectory(HttpContext.Current.Server.MapPath(tempath));
                    }

                    int start    = i * onepage;
                    int nextpage = i + 1;
                    int perpage  = i - 1;
                    if (nextpage == allpages)
                    {
                        nextpage = i;
                    }
                    if (perpage == -1)
                    {
                        perpage = 0;
                    }
                    string SQL = "SELECT TOP "
                                 + onepage +
                                 " * FROM  [ROYcms_news] WHERE (bh NOT IN (SELECT TOP "
                                 + start +
                                 " bh FROM [ROYcms_news] "
                                 + (this.classname == null ? "" : " where classname=" + this.classname) +
                                 " ORDER BY bh desc ))"
                                 + (this.classname == null ? "" : " and classname=" + this.classname) +
                                 " ORDER BY bh desc ";

                    DataSet   ds = BLL.GetDataSet(SQL);
                    DataTable dt = ds.Tables[0];

                    using (StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath(Path), false, Encoding.GetEncoding(ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_language"))))
                    {
                        #region 对循环的内容进行替换
                        foreach (Match m in r.Matches(HTML))
                        {
                            Text    = m.Groups["text"].ToString();          //循环的内容不包含SG:Loop
                            AllText = m.Groups[0].Value.ToString();         //整个匹配的内容包含SG:Loop

                            foreach (DataRow dr in dt.Rows)
                            {
                                string str        = Text;
                                string T_ShowPath = ShowPath;
                                str = Template.Replace(str, @"\[SG:Id\]", dr["bh"].ToString());
                                str = Template.Replace(str, @"\[SG:Title\]", dr["title"].ToString());
                                str = Template.Replace(str, @"\[SG:zhaiyao\]", dr["zhaiyao"].ToString());
                                str = Template.Replace(str, @"\[SG:pic\]", dr["pic"].ToString());
                                str = Template.Replace(str, @"\[SG:classname\]", dr["classname"].ToString());
                                str = Template.Replace(str, @"\[SG:author\]", dr["author"].ToString());
                                str = Template.Replace(str, @"\[SG:time\]", dr["time"].ToString());
                                str = Template.Replace(str, @"\[SG:Year\]", Convert.ToDateTime(dr["time"]).ToString("yyyy"));
                                str = Template.Replace(str, @"\[SG:Month\]", Convert.ToDateTime(dr["time"]).ToString("MM"));
                                str = Template.Replace(str, @"\[SG:Day\]", Convert.ToDateTime(dr["time"]).ToString("dd"));

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

                                content += AllText.Replace(AllText, str);
                            }
                            HTML = HTML.Replace(AllText, content);

                            HTML    = HTML.Replace(@"[SG:PageUp]", Model.ListeRules.Replace("{page}", perpage.ToString()));
                            HTML    = HTML.Replace(@"[SG:PageDow]", Model.ListeRules.Replace("{page}", nextpage.ToString()));
                            content = "";
                        }

                        #endregion

                        //创建文件
                        try
                        {
                            sw.WriteLine(HTML);
                            sw.Flush();
                            err = true;
                        }
                        catch (Exception ex)
                        {
                            HttpContext.Current.Response.Write(ex.Message);
                            HttpContext.Current.Response.End();
                            err = false;
                        }
                        finally { sw.Close(); }
                    }
                }
            }
            //封面频道方式
            if (Model.ColumnsType == 1)
            {
                templatepath = Model.TemplateIndex;                  //模版地址
                HTML         = PublicTag(SystemCms.Read_File(HttpContext.Current.Server.MapPath(templatepath), ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_language")));
                Path         = (Model.FilePath + Model.DefaultFile); //文件生成地址

                NewMain(Path, HTML);
                err = true;
            }
            return(err);
        }
Exemple #8
0
        /// <summary>
        ///
        /// </summary>
        void DateBind()
        {
            model = BLL.GetModel(Request["ClassId"]);
            //模板地址
            txtClassName.Text = model.ClassName.Trim();
            if (model.WebsiteUrl != "")
            {
                txtWebsiteUrl.Text = model.WebsiteUrl.Trim();
            }
            if (model.FilePath != "")
            {
                txtFilePath.Text = model.FilePath.Trim();
            }
            else
            {
                txtFilePath.Text = "{cmspath}/" + Guid.NewGuid().ToString() + "/";
            }

            txtColumnsType.SelectedValue = model.ColumnsType.ToString();
            if (model.TemplateIndex != "")
            {
                txtTemplateIndex.Text = model.TemplateIndex.Trim();
            }
            else
            {
                txtTemplateIndex.Text = ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_root") + "default/index.aspx";
            }
            if (model.TemplateList != "")
            {
                txtTemplateList.Text = model.TemplateList.Trim();
            }
            else
            {
                txtTemplateList.Text = ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_root") + "default/list.aspx";
            }
            if (model.TemplateShow != "")
            {
                txtTemplateShow.Text = model.TemplateShow.Trim();
            }
            else
            {
                txtTemplateShow.Text = ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("templet_root") + "default/show.aspx";
            }
            if (model.ListeRules != "")
            {
                txtListeRules.Text = model.ListeRules.Trim();
            }
            else
            {
                txtListeRules.Text = "list_{class}" + ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("web_forge");
            }
            if (model.ShowRules != "")
            {
                txtShowRules.Text = model.ShowRules.Trim();
            }
            else
            {
                txtShowRules.Text = "show_{id}" + ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("web_forge");
            }
            if (model.DefaultFile != "")
            {
                txtDefaultFile.Text = model.DefaultFile.Trim();
            }
            else
            {
                txtDefaultFile.Text = "index" + ROYcms.Config.ROYcmsConfig.GetCmsConfigValue("web_forge");
            }

            txtkeyword.Text     = model.keyword;
            txtDescription.Text = model.Description;
            //Fck.Value = model.contents;
        }
Exemple #9
0
 /// <summary>
 ///
 /// </summary>
 protected void Page_Load(object sender, EventArgs e)
 {
     ViewState["Class"] = ROYcms.Common.Request.GetQueryInt("Id");
     Model = ClassBll._GetModel(ViewState["Class"].ToString());
 }
        /// <summary>
        /// 添加一个频道
        /// </summary>
        public int Insert()
        {
            Model.Id = ROYcms.Common.Request.GetFormInt("Id");
            if (Model.Id > 0) //   如果是编辑
            {
                Model = BLL._GetModel(Model.Id.ToString());
            }
            else
            {
                Model.ClassId = ROYcms.Common.StringPlus.GetRamCode();
                string ClassList = "";                                                                                                          //栏目包含列表
                string ClassPre  = ROYcms.Common.Request.GetFormString("ClassId") == "" ? "0" : ROYcms.Common.Request.GetFormString("ClassId"); //父亲级ID
                int    ClassTj   = 1;                                                                                                           //栏目深度
                if (ClassPre == "0")                                                                                                            //是顶层
                {
                    ClassList = Model.ClassId + ",";
                    ClassTj   = 1;
                }
                else
                {
                    DataSet ds = new ROYcms.Sys.BLL.ROYcms_class().GetClassListByClassId(ClassPre);

                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        DataRow dr = ds.Tables[0].Rows[0];
                        ClassList = dr["ClassList"].ToString().Trim() + Model.ClassId + ",";
                        ClassTj   = Convert.ToInt32(dr["ClassTj"]) + 1;
                    }
                }
                Model.ClassList = ClassList;
                Model.ClassPre  = ClassPre;
                Model.ClassTj   = ClassTj;
            }

            Model.ClassName = ROYcms.Common.Request.GetFormString("ClassName");
            Model.ClassKind = ROYcms.Common.Request.GetFormInt("ClassKind");

            Model.ClassOrder    = 0;
            Model.ListType      = 0;
            Model.GoType        = 0;
            Model.ContentType   = 0;
            Model.DefaultFile   = ROYcms.Common.Request.GetFormString("DefaultFile");
            Model.FilePath      = ROYcms.Common.Request.GetFormString("FilePath");
            Model.ColumnsType   = ROYcms.Common.Request.GetFormInt("ColumnsType");
            Model.WebsiteUrl    = ROYcms.Common.Request.GetFormString("WebsiteUrl");
            Model.TemplateIndex = ROYcms.Common.Request.GetFormString("TemplateIndex");
            Model.TemplateList  = ROYcms.Common.Request.GetFormString("TemplateList");
            Model.TemplateShow  = ROYcms.Common.Request.GetFormString("TemplateShow");
            Model.ListeRules    = ROYcms.Common.Request.GetFormString("ListeRules");
            Model.ShowRules     = ROYcms.Common.Request.GetFormString("ShowRules");
            Model.keyword       = ROYcms.Common.Request.GetFormString("keyword");
            Model.Description   = ROYcms.Common.Request.GetFormString("Description");
            Model.contents      = ROYcms.Common.Request.GetFormString("contents");
            if (Model.Id > 0)
            {
                if (!BLL.Exists(Model.FilePath, Model.DefaultFile)) //不存在
                {
                    return(BLL.ClassUpdate(Model) == true ? 1 : 0);
                }
                else
                {
                    if (BLL.GetId(Model.FilePath, Model.DefaultFile) == Model.Id)//当前的地址
                    {
                        return(BLL.ClassUpdate(Model) == true ? 1 : 0);
                    }
                    else
                    {
                        return(-1);
                    }
                }
            }
            else
            {
                if (!BLL.Exists(Model.FilePath, Model.DefaultFile))
                {
                    return(BLL.ClassAdd(Model) == true ? 1 : 0);
                }
                else
                {
                    return(-1);
                }
            }
        }