예제 #1
0
        public void BindTempList()
        {
            string pathdir = (AppDomain.CurrentDomain.BaseDirectory + ZoomLa.Components.SiteConfig.SiteOption.TemplateDir.Replace("/", @"\")).Replace(@"\\", @"\");

            if (!File.Exists(pathdir))
            {
                return;
            }
            DataTable tables = FileSystemObject.GetDirectoryAllInfos(pathdir + "/" + Resources.L.内容页 + "/", FsoMethod.File);

            tables.Columns.Add("TemplatePic");//添加模板图片url
            tables.Columns.Add("TemplateID");
            tables.Columns.Add("TemplateUrl");
            for (int i = 0; i < tables.Rows.Count; i++)
            {
                tables.Rows[i]["rname"] = tables.Rows[i]["rname"].ToString().Replace(pathdir, "").Replace(@"\", "/").Substring(1);
                string filename = "内容页_" + Path.GetFileNameWithoutExtension(tables.Rows[i]["name"].ToString()) + ".jpg";
                tables.Rows[i]["TemplatePic"] = ZoomLa.Components.SiteConfig.SiteOption.TemplateDir + "/thumbnail/" + filename;
                tables.Rows[i]["TemplateID"]  = tables.Rows[i]["rname"];
                tables.Rows[i]["TemplateUrl"] = tables.Rows[i]["rname"];
                if (!File.Exists(function.VToP(pathdir + "/thumbnail/" + filename)))
                {
                    tables.Rows.Remove(tables.Rows[i]);
                    i--;
                }
            }
            tables.DefaultView.RowFilter = "type=1 OR name LIKE '%.html'";
            TlpView_Tlp.DataSource       = tables;
            TlpView_Tlp.DataBind();
        }
예제 #2
0
        private DataTable GetTemplateDT()
        {
            string pathdir = function.VToP(SiteConfig.SiteOption.TemplateDir + "/");

            if (!Directory.Exists(pathdir))
            {
                return(null);
            }
            DataTable tables = FileSystemObject.GetDirectoryAllInfos(pathdir + @"\内容页\", FsoMethod.File);

            tables.Columns.Add("TemplatePic");//添加模板图片url
            tables.Columns.Add("TemplateID");
            tables.Columns.Add("TemplateUrl");
            for (int i = 0; i < tables.Rows.Count; i++)
            {
                tables.Rows[i]["rname"] = Path.GetFileName(DataConverter.CStr(tables.Rows[i]["rname"]));
                string imgname = "内容页_" + Path.GetFileNameWithoutExtension(tables.Rows[i]["name"].ToString()) + ".jpg";
                tables.Rows[i]["TemplatePic"] = SiteConfig.SiteOption.TemplateDir + "/thumbnail/" + imgname;
                tables.Rows[i]["TemplateID"]  = tables.Rows[i]["rname"];
                tables.Rows[i]["TemplateUrl"] = tables.Rows[i]["rname"];
                //if (!File.Exists(function.VToP(pathdir + "/thumbnail/" + imgname)))
                //{
                //    tables.Rows.Remove(tables.Rows[i]);
                //    i--;
                //}
            }
            tables.DefaultView.RowFilter = "type=1 OR name LIKE '%.html'";
            return(tables.DefaultView.ToTable());
        }
예제 #3
0
파일: C_TlpDP.cs 프로젝트: baixue001/IPS
        public DataTable GetDTForTemplate()
        {
            DataTable tables = FileSystemObject.GetDirectoryAllInfos(function.VToP(SiteConfig.SiteOption.TemplateDir), FsoMethod.All);

            tables.DefaultView.RowFilter = "type=1 OR name LIKE '%.html'";
            DataTable newtables = FileSystemObject.FiterHasFile(tables.DefaultView.ToTable());

            //追加根目录文件
            foreach (DataRow dr in tables.Rows)
            {
                //如果是html文件,如放置在根目录
                if (dr["type"].Equals("2") && Path.GetExtension(dr["name"].ToString()).Equals(".html"))
                {
                    DataRow[] temprows = newtables.Select("name='" + dr["name"] + "'");
                    if (temprows.Length == 0)
                    {
                        DataRow child = newtables.NewRow();
                        child["type"]  = 3;
                        child["path"]  = dr["path"];
                        child["rname"] = dr["rname"].ToString();
                        child["name"]  = dr["name"];
                        child["pid"]   = 0;
                        newtables.Rows.Add(child);
                    }
                }
            }
            string templateDir = SiteConfig.SiteOption.TemplateDir;

            //忽略部分目录,并替换路径
            for (int i = 0; i < newtables.Rows.Count; i++)
            {
                DataRow dr = newtables.Rows[i];
                if (dr["rname"].ToString().Contains(@"\views"))
                {
                    dr["rname"] = "ignore";
                }
                else
                {
                    dr["rname"] = function.PToV(dr["rname"].ToString()).Replace(templateDir, "").TrimStart('/');
                }
            }

            newtables.DefaultView.RowFilter = "rname not in ('ignore')";
            newtables = newtables.DefaultView.ToTable();
            //加一条空模板数据
            DataRow empdr = newtables.NewRow();

            empdr["type"]  = 4;
            empdr["path"]  = "";
            empdr["rname"] = "";
            empdr["name"]  = "不指定模板!";
            empdr["pid"]   = 0;
            newtables.Rows.InsertAt(empdr, 0);
            return(newtables);
        }
예제 #4
0
    //--------------Tools
    public void BindDP(string vpath)
    {
        string    ppath = Server.MapPath(vpath);
        DataTable dt    = FileSystemObject.GetDirectoryAllInfos(ppath, FsoMethod.File);

        dt.DefaultView.RowFilter = "rname Like '%.html'";
        dt = dt.DefaultView.ToTable(false, "rname");
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            dt.Rows[i]["rname"] = dt.Rows[i]["rname"].ToString().Replace(ppath, "").Replace(@"\", "/");
        }
        IndexTemplate_DP.DataSource = dt;
        IndexTemplate_DP.DataBind();
        ShopTemplate_DP.DataSource = dt;
        ShopTemplate_DP.DataBind();
        IndexTemplate_DP.Items.Insert(0, new ListItem("未指定", ""));
        ShopTemplate_DP.Items.Insert(0, new ListItem("未指定", ""));
    }