Exemple #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         //读取
         MainConfigInfo mainconfiginfo = MainConfigs.Load();
         tbxWebSiteName.Text        = mainconfiginfo.Websitename;
         tbxSEOTitle.Text           = mainconfiginfo.Seotitle;
         ckbxUrlRewrite.Checked     = mainconfiginfo.Urlrewrite == 1 ? true : false;
         tbxUrlRewriteExtName.Text  = mainconfiginfo.Urlrewriteextname;
         tbxGlobalCacheTimeOut.Text = mainconfiginfo.Globalcachetimeout.ToString();
         tbxAnalyticsCode.Text      = mainconfiginfo.Analyticscode.Trim();
     }
     else
     {
         string websitename = tbxWebSiteName.Text.Trim();
         string seotitle    = tbxSEOTitle.Text.Trim();
         if (websitename != string.Empty && seotitle != string.Empty)
         {
             MainConfigInfo info = MainConfigs.Load();
             info.Closed             = 0;
             info.Closedreason       = "";
             info.ApplictionSecKey   = "";
             info.Cookiedomain       = "";
             info.Urlrewrite         = Convert.ToInt32(ckbxUrlRewrite.Checked);
             info.Urlrewriteextname  = tbxUrlRewriteExtName.Text.Trim();
             info.Globalcachetimeout = Convert.ToInt32(tbxGlobalCacheTimeOut.Text.Trim());
             info.Websitename        = websitename;
             info.Seotitle           = seotitle;
             info.Analyticscode      = tbxAnalyticsCode.Text.Trim();
             MainConfigs.Save(info);
             MainConfigs.ResetConfig();
         }
     }
 }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string action = Natsuhime.Web.YRequest.GetString("action");

            if (action == "browser")
            {
                cbxlTemplateFileList.DataTextField  = "filename";
                cbxlTemplateFileList.DataValueField = "fullfilename";
                cbxlTemplateFileList.DataSource     = LoadTemplateFileList();
                cbxlTemplateFileList.DataBind();
            }
            else if (action == "create")
            {
                string folder = Natsuhime.Web.YRequest.GetString("folder");
                if (folder.Length > 0)
                {
                    CreateTemplate(folder);
                    //读取
                    MainConfigInfo info = MainConfigs.Load();
                    info.Templatefolder = folder;
                    MainConfigs.Save(info);
                    MainConfigs.ResetConfig();

                    ShowMsg("模板管理", "设置默认模板成功.", "", "frame.aspx?action=template", true);
                }
            }
            else
            {
                rptFolderList.DataSource = LoadTemplateFolder();
                rptFolderList.DataBind();
            }
        }
Exemple #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string action = Natsuhime.Web.YRequest.GetString("action");

            if (action == "browser")
            {
                cbxlTemplateFileList.DataTextField  = "filename";
                cbxlTemplateFileList.DataValueField = "fullfilename";
                cbxlTemplateFileList.DataSource     = LoadTemplateFileList();
                cbxlTemplateFileList.DataBind();
            }
            else if (action == "create")
            {
                List <KeyValuePair <string, string> > templateFileList = new List <KeyValuePair <string, string> >();
                string rootTemplatePath = Server.MapPath(string.Format(@"~\templates\{0}", MainConfigs.Load().Templatefolder));

                string folder = Natsuhime.Web.YRequest.GetString("folder");
                if (folder.Length > 0)
                {
                    string[] baseRefTemplateList = Directory.GetFiles(rootTemplatePath, "_*.htm");
                    foreach (string file in baseRefTemplateList)
                    {
                        templateFileList.Add(new KeyValuePair <string, string>(file, ""));
                    }

                    string   folderTemplatePath = Path.Combine(rootTemplatePath, folder);
                    string[] mainTemplateList   = Directory.GetFiles(folderTemplatePath, "*.htm");
                    foreach (string file in mainTemplateList)
                    {
                        templateFileList.Add(new KeyValuePair <string, string>(file, Server.MapPath("~/" + folder)));
                    }
                }
                else
                {
                    string[] allTemplateList = Directory.GetFiles(rootTemplatePath, "*.htm", SearchOption.AllDirectories);
                    foreach (string file in allTemplateList)
                    {
                        string currentFolder = Path.GetDirectoryName(file);
                        string outputPath    = Server.MapPath("~\\" + currentFolder.Replace(rootTemplatePath, ""));
                        templateFileList.Add(new KeyValuePair <string, string>(file, outputPath));
                    }
                }
                CreateTemplate(templateFileList);
                ShowMsg("模板管理", "生成模板成功.", "", "frame.aspx?action=template", true);
            }
            else if (action == "settemplate")
            {
                string folder = Natsuhime.Web.YRequest.GetString("folder");

                MainConfigInfo info = MainConfigs.Load();
                info.Templatefolder = folder;
                MainConfigs.Save(info);
                MainConfigs.ResetConfig();
                ShowMsg("模板管理", "设置默认模板成功.", "", "frame.aspx?action=template", true);
            }
            else
            {
                rptTemplateList.DataSource = LoadTemplateFolder();
                rptFolderList.DataSource   = LoadSubFolder();
                rptTemplateList.DataBind();
                rptFolderList.DataBind();
            }
        }
Exemple #4
0
        private DataTable LoadSubFolder()
        {
            string[] folders = Directory.GetDirectories(Server.MapPath("~/templates/" + MainConfigs.Load().Templatefolder));

            DataTable folderlist = new DataTable("folderlist");

            folderlist.Columns.Add("folder", Type.GetType("System.String"));

            foreach (string folder in folders)
            {
                DataRow dr = folderlist.NewRow();
                dr["folder"] = folder.Substring(folder.LastIndexOf(Path.DirectorySeparatorChar) + 1);
                folderlist.Rows.Add(dr);
            }
            return(folderlist);
        }
Exemple #5
0
        private DataTable LoadTemplateFileList()
        {
            #region 装入模板文件
            DataTable templatefilelist = new DataTable("templatefilelist");

            templatefilelist.Columns.Add("fullfilename", Type.GetType("System.String"));
            templatefilelist.Columns.Add("filename", Type.GetType("System.String"));
            templatefilelist.Columns.Add("id", Type.GetType("System.Int32"));
            templatefilelist.Columns.Add("extension", Type.GetType("System.String"));
            templatefilelist.Columns.Add("parentid", Type.GetType("System.String"));
            templatefilelist.Columns.Add("filepath", Type.GetType("System.String"));
            templatefilelist.Columns.Add("filedescription", Type.GetType("System.String"));

            DirectoryInfo dirinfo = new DirectoryInfo(Server.MapPath("~/templates/" + MainConfigs.Load().Templatefolder));
            int           i       = 1;
            string        extname;
            foreach (FileSystemInfo file in dirinfo.GetFileSystemInfos())
            {
                if (file != null)
                {
                    extname = file.Extension.ToLower();
                    if (extname == ".htm" || extname == ".config")
                    {
                        DataRow dr = templatefilelist.NewRow();

                        dr["id"]       = i;
                        dr["filename"] = file.Name.Substring(0, file.Name.LastIndexOf("."));
                        if (extname == ".htm")
                        {
                            dr["fullfilename"] = "\\" + dr["filename"] + ".htm";
                        }
                        else
                        {
                            dr["fullfilename"] = "\\" + dr["filename"] + ".config";
                        }
                        dr["extension"]       = file.Extension.ToLower();
                        dr["parentid"]        = "0";
                        dr["filepath"]        = "";
                        dr["filedescription"] = "";
                        templatefilelist.Rows.Add(dr);
                        i++;
                    }
                }
            }

            foreach (DataRow dr in templatefilelist.Rows)
            {
                foreach (DataRow childdr in templatefilelist.Select("filename like '" + dr["filename"].ToString() + "_%%'"))
                {
                    if (dr["filename"].ToString() != childdr["filename"].ToString())
                    {
                        childdr["parentid"] = dr["id"].ToString();
                    }
                }
            }

            return(templatefilelist);

            #endregion
        }