private bool TestDbSource() { if (string.IsNullOrEmpty(this.TxtDataSource.Text)) { this.TxtTestStat.Text = "请输入正确的代码!"; return(false); } string text = this.TxtDataSource.Text; string selectedValue = this.RbtDataType.SelectedValue; if (string.Compare(selectedValue, "mdb_read", StringComparison.Ordinal) == 0) { text = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" + GetDbPath(this.TxtDataSource.Text); selectedValue = "ole_read"; } if (string.Compare(selectedValue, "xsl_read", StringComparison.Ordinal) == 0) { text = "Provider=Microsoft.JET.OLEDB.4.0;Extended Properties=Excel 8.0;Data Source=" + GetDbPath(this.TxtDataSource.Text); selectedValue = "ole_read"; } if (LabelManage.TestOutSideDatabase(selectedValue, text)) { this.TxtTestStat.Text = "连接成功!"; return(true); } this.TxtTestStat.Text = "连接失败!"; return(false); }
protected void GdvLabelList_RowCommand(object sender, CommandEventArgs e) { bool flag = false; switch (e.CommandName) { case "Deleted": if (LabelManage.Delete(e.CommandArgument.ToString())) { AdminPage.WriteSuccessMsg("删除成功", "LabelManage.aspx"); return; } AdminPage.WriteErrMsg("删除失败", "LabelManage.aspx"); return; case "Copy": if (LabelManage.Copy(e.CommandArgument.ToString())) { AdminPage.WriteSuccessMsg("复制成功", "LabelManage.aspx"); return; } AdminPage.WriteErrMsg("复制失败", "LabelManage.aspx"); return; } flag = false; }
private void InitListLabelType() { this.RbtLabelType.DataSource = LabelManage.GetLabelTypeList(); this.RbtLabelType.DataTextField = "Name"; this.RbtLabelType.DataValueField = "Name"; this.RbtLabelType.DataBind(); }
protected void Page_PreRender(object sender, EventArgs e) { this.labelname = BasePage.RequestString("name"); if (!string.IsNullOrEmpty(this.labelname)) { string path = WebConfigurationManager.AppSettings["EasyOne:LabelXsltPath"]; this.xmlfilepath = HttpContext.Current.Server.MapPath(path) + @"\" + this.labelname + ".config"; this.Dbtype = XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelDataType"); string presstr = XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelDataSource"); string str3 = XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelSqlString"); string istr = string.Empty; XmlDocument document = new XmlDocument(); document.Load(this.xmlfilepath); XmlNodeList attriblist = document.SelectNodes("root/attributes"); presstr = this.ParaProc(attriblist, presstr); str3 = this.ParaProc(attriblist, str3).Replace("@pagesize", "10").Replace("@startrow", "0"); if ((string.Compare(this.Dbtype, "xml_read", StringComparison.OrdinalIgnoreCase) != 0) && string.IsNullOrEmpty(str3)) { base.Response.Write("查询语句为空!"); } else { istr = LabelManage.GetDBQuery(this.Dbtype, presstr, str3, attriblist); this.XmlProc(this.Dbtype, presstr, istr); } } else { base.Response.Write("标签名称为空!"); } }
protected void Page_Load(object sender, EventArgs e) { string str = BasePage.RequestStringToLower("action"); this.TxtTemplate.Attributes.Add("onmouseup", "dragend(this)"); this.TxtTemplate.Attributes.Add("onClick", "savePos(this)"); this.TxtTemplate.Attributes.Add("onmousemove", "DragPos(this)"); this.RegTxtFileName.ValidationExpression = "^[^\\\\\\./:\\*\\?\\\"<>\\|]{1}[^\\\\/:\\*\\.\\?\\\"<>\\|]{0,254}\\.[^\\\\/:\\*\\.\\?\\\"<>\\|]{1,8}$"; this.RegTxtFileName.ErrorMessage = "文件名格式不正确"; if (!base.IsPostBack) { ListItem item = new ListItem(); item.Text = "全部分类"; this.DropLabelList.DataSource = LabelManage.GetLabelTypeList(); this.DropLabelList.DataTextField = "Name"; this.DropLabelList.DataValueField = "Name"; this.DropLabelList.DataBind(); this.DropLabelList.Items.Insert(0, item); this.DropPagerList.DataSource = PagerManage.GetPagerTypeList(); this.DropPagerList.DataTextField = "Name"; this.DropPagerList.DataValueField = "Name"; this.DropPagerList.DataBind(); this.DropPagerList.Items.Insert(0, item); this.BuildLabelList(string.Empty); this.BuildPagerList(string.Empty); } if ((str == "modify") && !base.IsPostBack) { this.BindDataToControls(); } }
protected void BtnNext_Click(object sender, EventArgs e) { if ((this.RbtDataType.SelectedIndex <= 2) || this.TestDbSource()) { string iname = this.TxtLabelName.Text.Trim(); string path = WebConfigurationManager.AppSettings["EasyOne:LabelXsltPath"]; string xmlfilepath = string.Empty; if (!string.IsNullOrEmpty(this.m_LabelName)) { xmlfilepath = HttpContext.Current.Server.MapPath(path) + @"\" + this.ViewState["oldlabelname"].ToString() + ".config"; } else { xmlfilepath = HttpContext.Current.Server.MapPath(path) + @"\" + iname + ".config"; } if (this.SaveToXmlFile(xmlfilepath)) { if (string.IsNullOrEmpty(this.m_LabelName)) { if (!LabelManage.Exists(iname)) { BasePage.ResponseRedirect("LabelProperty.aspx?action=add&name=" + base.Server.UrlEncode(iname)); } else { this.NReq.Text = "该标签已存在!"; this.NReq.IsValid = false; } } else if (string.Compare(this.ViewState["oldlabelname"].ToString(), iname, StringComparison.OrdinalIgnoreCase) != 0) { if (File.Exists(base.Server.MapPath(this.m_LabelLibPath) + @"\" + iname + ".config")) { this.NReq.Text = "您不能改成已存在的标签名!"; this.NReq.IsValid = false; } else { File.Delete(HttpContext.Current.Server.MapPath(this.m_LabelLibPath) + @"\" + this.ViewState["oldlabelname"].ToString() + ".config"); File.Copy(xmlfilepath, HttpContext.Current.Server.MapPath(this.m_LabelLibPath) + @"\" + iname + ".config"); if (File.Exists(base.Server.MapPath(path) + @"\" + iname + ".config")) { File.Delete(HttpContext.Current.Server.MapPath(path) + @"\" + iname + ".config"); } File.Move(xmlfilepath, HttpContext.Current.Server.MapPath(path) + @"\" + iname + ".config"); BasePage.ResponseRedirect("LabelProperty.aspx?action=modify&name=" + base.Server.UrlEncode(iname)); } } else { BasePage.ResponseRedirect("LabelProperty.aspx?action=modify&name=" + base.Server.UrlEncode(iname)); } } else { AdminPage.WriteErrMsg("保存失败!", "LabelManage.aspx"); } } }
protected void EBtnUpload_Click(object sender, EventArgs e) { if (this.Page.IsValid && this.FileUpload1.HasFile) { string fileName = this.FileUpload1.FileName; if (Path.GetExtension(fileName) == ".config") { if (!LabelManage.Exists(Path.GetFileNameWithoutExtension(fileName))) { string path = WebConfigurationManager.AppSettings["EasyOne:LabelXsltPath"]; path = HttpContext.Current.Server.MapPath(path) + @"\" + fileName; this.FileUpload1.SaveAs(path); bool flag = false; XmlDocument document = new XmlDocument(); try { document.Load(path); if (((document.SelectSingleNode("root") != null) && (document.SelectSingleNode("root/LabelType") != null)) && (document.SelectSingleNode("root/LabelTemplate") != null)) { flag = true; } } catch (XmlException) { flag = false; } if (flag) { string str3 = "~/" + SiteConfig.SiteOption.LabelDir; string destFileName = HttpContext.Current.Server.MapPath(str3) + @"\" + fileName; try { File.Copy(path, destFileName, false); } catch (IOException) { File.Delete(path); AdminPage.WriteErrMsg("上传错误!请检查标签文件格式是否正确"); } AdminPage.WriteSuccessMsg("上传成功", "javascript:opener.location.reload();window.close();"); } else { AdminPage.WriteErrMsg("文件不是规范的标签文件"); File.Delete(path); } } else { AdminPage.WriteErrMsg("标签已存在,请改名后上传"); } } else { AdminPage.WriteErrMsg("请上传.config文件"); } } }
protected void BuildLabelList(string typename) { this.LblLabelList.Text = string.Empty; foreach (LabelManageInfo info in LabelManage.GetLabelList(typename)) { string text = this.LblLabelList.Text; this.LblLabelList.Text = text + "<div onclick=\"cit()\" outype=\"1\" class=\"spanfixdiv\" alt=\"" + info.Intro + "\">" + info.Name + "</div>"; } }
protected void BtnSearch_Click(object sender, EventArgs e) { this.LblLabelList.Text = string.Empty; foreach (LabelManageInfo info in LabelManage.GetLabelList(1, 0, this.LabelSearch.Text, string.Empty)) { string text = this.LblLabelList.Text; this.LblLabelList.Text = text + "<div onclick=\"cit()\" outype=\"1\" class=\"spanfixdiv\" alt=\"" + info.Intro + "\">" + info.Name + "</div>"; } }
protected void BtnAddProperty_Click(object sender, EventArgs e) { if (LabelManage.AttributeExists(this.xmlfilepath, this.TxtAttributeName.Text) && LabelManage.AddAttribute(this.xmlfilepath, this.TxtAttributeName.Text, this.TxtDefaultValue.Text, this.TxtIntro.Text)) { this.TxtAttributeName.Text = string.Empty; this.TxtDefaultValue.Text = string.Empty; this.TxtIntro.Text = string.Empty; this.GdvPropertys.DataBind(); } }
protected void BtnFinal_Click(object sender, EventArgs e) { bool flag = true; if (!string.IsNullOrEmpty(this.ReplaceSource.Text)) { if (string.Compare(this.RbtSearType.SelectedValue, "type", StringComparison.OrdinalIgnoreCase) == 0) { if (!string.IsNullOrEmpty(this.RbtLabelType.SelectedValue)) { foreach (LabelManageInfo info in LabelManage.GetLabelList(this.RbtLabelType.SelectedValue)) { if (!this.ReplaceProc(info.Name)) { flag = false; break; } } } } else if (string.Compare(this.RbtSearType.SelectedValue, "keyword", StringComparison.OrdinalIgnoreCase) == 0) { if (!string.IsNullOrEmpty(this.KeyWord.Text)) { foreach (LabelManageInfo info2 in LabelManage.GetLabelList(1, 1, this.KeyWord.Text, "")) { if (!this.ReplaceProc(info2.Name)) { flag = false; break; } } } } else { foreach (LabelManageInfo info3 in LabelManage.GetLabelList(string.Empty)) { if (!this.ReplaceProc(info3.Name)) { flag = false; break; } } } if (flag) { BasePage.ResponseRedirect("LabelManage.aspx"); } else { base.Response.Write("处理错误"); } } }
private void InitDropLabelType() { this.DropLabelType.DataSource = LabelManage.GetLabelTypeList(); this.DropLabelType.DataTextField = "Name"; this.DropLabelType.DataValueField = "Name"; this.DropLabelType.DataBind(); ListItem item = new ListItem(); item.Text = "全部分类"; item.Value = "全部分类"; this.DropLabelType.Items.Insert(0, item); }
protected void BtnDel_Click(object sender, EventArgs e) { if (this.GdvLabelList.SelectList.Length <= 0) { AdminPage.WriteErrMsg("<li>对不起,您还没选择要删除的标签!</li>"); } else if (LabelManage.Delete(this.GdvLabelList.SelectList.ToString())) { this.GdvLabelList.DataBind(); } else { AdminPage.WriteErrMsg("删除失败!"); } }
protected void DBTableDownList2_SelectedIndexChanged(object sender, EventArgs e) { if (this.DbTableDownList2.SelectedIndex <= 0) { this.Span1.Visible = false; } else { DataTable table = new DataTable(); string dbtype = this.Dbtype; if (dbtype != null) { if (!(dbtype == "sql_sysquery")) { if (dbtype == "sql_outquery") { table = LabelManage.GetSchemaTable(this.DbTableDownList2.SelectedValue, XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelDataSource"), DataSourceType.Sql); } else if (dbtype == "ole_read") { table = LabelManage.GetSchemaTable(this.DbTableDownList2.SelectedValue, XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelDataSource"), DataSourceType.Ole); } else if (dbtype == "odbc_read") { table = LabelManage.GetSchemaTable(this.DbTableDownList2.SelectedValue, XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelDataSource"), DataSourceType.Odbc); } else if (dbtype == "orc_read") { table = LabelManage.GetSchemaTable(this.DbTableDownList2.SelectedValue, XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelDataSource"), DataSourceType.Oracle); } } else { table = LabelManage.GetSchemaTable(this.DbTableDownList2.SelectedValue, string.Empty, DataSourceType.None); } } this.DbFieldDownList2.DataSource = table; this.DbFieldList2.DataSource = table; this.DbFieldDownList2.DataTextField = "ColumnName"; this.DbFieldDownList2.DataValueField = "ColumnName"; this.DbFieldDownList2.DataBind(); this.DbFieldList2.DataTextField = "ColumnName"; this.DbFieldList2.DataValueField = "ColumnName"; this.DbFieldList2.DataBind(); this.Span1.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { this.action = BasePage.RequestString("action"); this.labelname = BasePage.RequestString("name"); this.m_LabelLibPath = "~/" + SiteConfig.SiteOption.LabelDir; if (string.IsNullOrEmpty(this.labelname)) { BasePage.ResponseRedirect("Label.aspx"); } else { string path = WebConfigurationManager.AppSettings["EasyOne:LabelXsltPath"]; this.xmlfilepath = HttpContext.Current.Server.MapPath(path) + @"\" + this.labelname + ".config"; if (!base.IsPostBack) { if (LabelManage.GetAttributeList(this.xmlfilepath).Count == 0) { this.attlist.Text = "您尚未建立属性!<a href=\"LabelProperty.aspx?action=" + this.action + "&name=" + this.labelname + "\">建立属性</a>"; } else { foreach (LabelAttributeInfo info in LabelManage.GetAttributeList(this.xmlfilepath)) { string text = this.attlist.Text; this.attlist.Text = text + "<div onclick=\"cit()\" outype=\"2\" class=\"spanfixdiv\" alt=\"" + info.Intro + "
默认值:" + info.DefaultValue + "\">" + info.AttributeName + "</div>"; } } if (!string.IsNullOrEmpty(XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelTemplate"))) { this.TxtTemplate.Text = XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelTemplate"); } ListItem item = new ListItem(); item.Text = "全部分类"; this.DropLabelList.DataSource = LabelManage.GetLabelTypeList(); this.DropLabelList.DataTextField = "Name"; this.DropLabelList.DataValueField = "Name"; this.DropLabelList.DataBind(); this.DropLabelList.Items.Insert(0, item); this.BuildLabelList(string.Empty); this.TxtTemplateTest.Text = "{PE.Label id=\"" + this.labelname + "\" /}"; } this.TxtTemplate.Attributes.Add("onmouseup", "dragend(this)"); this.TxtTemplate.Attributes.Add("onClick", "savePos(this)"); this.TxtTemplate.Attributes.Add("onmousemove", "DragPos(this)"); } this.SmpNavigator.AdditionalNode = this.labelname; }
protected void BtnDW_Click(object sender, EventArgs e) { string str2 = HttpContext.Current.Server.MapPath("~/" + SiteConfig.SiteOption.LabelDir); if (!FileSystemObject.IsExist(str2 + @"\Dreamweaver", FsoMethod.Folder)) { FileSystemObject.Create(str2 + @"\Dreamweaver", FsoMethod.Folder); if (!FileSystemObject.IsExist(str2 + @"\Dreamweaver\_folderinfo.txt", FsoMethod.File)) { FileSystemObject.Create(str2 + @"\Dreamweaver\_folderinfo.txt", FsoMethod.File); FileSystemObject.WriteFile(str2 + @"\Dreamweaver\_folderinfo.txt", "PE2007标签"); } } foreach (LabelManageInfo info in LabelManage.GetLabelList(string.Empty)) { StringBuilder builder = new StringBuilder(); IList <LabelAttributeInfo> attributeList = LabelManage.GetAttributeList(str2 + @"\" + info.Name + ".config"); if (!FileSystemObject.IsExist(str2 + @"\Dreamweaver\" + info.Name + ".csn", FsoMethod.File)) { FileSystemObject.Create(str2 + @"\Dreamweaver\" + info.Name + ".csn", FsoMethod.File); } builder.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); builder.Append("<snippet name = \"" + info.Name + "\" description = \"" + info.Intro + "\" preview=\"code\" type=\"block\">\n"); builder.Append("<insertText location=\"beforeSelection\">\n"); builder.Append("<![CDATA[{PE.Label "); builder.Append("id=\"" + info.Name + "\""); foreach (LabelAttributeInfo info2 in attributeList) { builder.Append(" " + info2.AttributeName + "=\"" + info2.DefaultValue + "\""); } builder.Append(" /}]]>\n"); builder.Append("</insertText>\n"); builder.Append("<insertText location=\"afterSelection\"><![CDATA[]]>\n"); builder.Append("</insertText>\n"); builder.Append("</snippet>\n"); FileSystemObject.WriteFile(str2 + @"\Dreamweaver\" + info.Name + ".csn", builder.ToString()); } PackFiles(str2 + @"\Dreamweaver.zip", str2 + @"\Dreamweaver"); if (!ResponseFile(this.Page.Request, this.Page.Response, "PE2007_DwPlus.zip", str2 + @"\Dreamweaver.zip", 0xfa000L)) { base.Response.Write("下载文件出错!"); } }
protected void GdvPropertys_RowCommand(object sender, CommandEventArgs e) { string str; bool flag = false; if (((str = e.CommandName) != null) && (str == "Delete")) { flag = LabelManage.DeleteAttribute(this.xmlfilepath, e.CommandArgument.ToString()); this.OdsPropertys.DeleteParameters[0].DefaultValue = this.xmlfilepath; } else { flag = false; } if (flag) { this.GdvPropertys.DataBind(); } }
protected void ShowLabelAdd() { string str = BasePage.RequestString("n"); if (!string.IsNullOrEmpty(str)) { this.LabelName.Text = str; LabelManageInfo labelByName = LabelManage.GetLabelByName(str); if (!labelByName.IsNull) { StringBuilder builder = new StringBuilder(); builder.Append("<table width='100%'>"); XmlDocument document = new XmlDocument(); document.LoadXml(labelByName.Define.ToString()); foreach (XmlNode node in document.SelectNodes("root/attributes")) { string innerText = node.SelectSingleNode("default").InnerText; string[] sArray = innerText.Split(new string[] { "|||" }, StringSplitOptions.None); builder.Append(this.CtrlProc(node.SelectSingleNode("name").InnerText, innerText, innerText, node.SelectSingleNode("intro").InnerText, sArray)); } string input = (document.SelectSingleNode("root/UsePage") == null) ? "" : document.SelectSingleNode("root/UsePage").InnerText.Trim(); if (DataConverter.CBoolean(input)) { builder.Append("<tr><td align=\"right\">是否分页:</td><td align=\"left\"><input id=\"page\" type=\"checkbox\"/></td></tr>"); builder.Append("<tr><td align=\"right\">分页显示数:</td><td align=\"left\"><input type=\"text\" id=\"pagesize\" value=\"10\"/></td></tr>"); builder.Append("<tr><td align=\"right\">是否主分页:</td><td align=\"left\"><input id=\"urlpage\" type=\"checkbox\" value=\"true\"/></td></tr>"); } builder.Append("<tr><td align=\"right\">缓存时间:</td><td align=\"left\"><input type=\"text\" id=\"cachetime\" value=\"0\" /></td></tr>"); builder.Append("<tr><td align=\"right\">不解析内部标签:</td><td align=\"left\"><input id=\"nolabelproc\" type=\"checkbox\"/></td></tr>"); builder.Append("<tr><td align=\"right\">容器类型:</td><td align=\"left\"><input type=\"text\" id=\"spantype\" /></td></tr>"); builder.Append("<tr><td align=\"right\">容器风格:</td><td align=\"left\"><input type=\"text\" id=\"cssname\" /></td></tr>"); builder.Append("</table>"); this.labelbody.Text = builder.ToString(); input = (document.SelectSingleNode("root/LabelIntro") == null) ? "" : document.SelectSingleNode("root/LabelIntro").InnerText.Trim(); if (!string.IsNullOrEmpty(input)) { this.labelintro.Text = input; } } } }
protected static DataTable GetDataBaseSchema(string dtype, string xpath, string tablename) { switch (dtype) { case "sql_sysquery": return(LabelManage.GetSchemaTable(tablename, string.Empty, DataSourceType.None)); case "sql_outquery": return(LabelManage.GetSchemaTable(tablename, XmlManage.ReadFileNode(xpath, "root/LabelDataSource"), DataSourceType.Sql)); case "ole_read": return(LabelManage.GetSchemaTable(tablename, XmlManage.ReadFileNode(xpath, "root/LabelDataSource"), DataSourceType.Ole)); case "odbc_read": return(LabelManage.GetSchemaTable(tablename, XmlManage.ReadFileNode(xpath, "root/LabelDataSource"), DataSourceType.Odbc)); case "orc_read": return(LabelManage.GetSchemaTable(tablename, XmlManage.ReadFileNode(xpath, "root/LabelDataSource"), DataSourceType.Oracle)); } return(null); }
protected void Page_Load(object sender, EventArgs e) { this.action = BasePage.RequestString("action"); this.m_LabelName = BasePage.RequestString("name"); this.m_LabelLibPath = "~/" + SiteConfig.SiteOption.LabelDir; if (string.IsNullOrEmpty(this.m_LabelName)) { BasePage.ResponseRedirect("Label.aspx"); } else { string path = WebConfigurationManager.AppSettings["EasyOne:LabelXsltPath"]; this.xmlfilepath = HttpContext.Current.Server.MapPath(path) + @"\" + this.m_LabelName + ".config"; this.Dbtype = XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelDataType"); string presstr = XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelDataSource"); string str3 = XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelSqlString"); string istr = string.Empty; XmlDocument document = new XmlDocument(); document.Load(this.xmlfilepath); XmlNodeList attriblist = document.SelectNodes("root/attributes"); presstr = this.ParaProc(attriblist, presstr); str3 = this.ParaProc(attriblist, str3).Replace("@pagesize", "10").Replace("@startrow", "0"); if (((string.Compare(this.Dbtype, "static", StringComparison.Ordinal) == 0) && (string.Compare(this.Dbtype, "xml_read", StringComparison.Ordinal) == 0)) && string.IsNullOrEmpty(str3)) { this.ShowXml.Text = "查询语句为空!"; return; } if (((string.Compare(this.Dbtype, "static", StringComparison.Ordinal) != 0) && (string.Compare(this.Dbtype, "sql_sysquery", StringComparison.Ordinal) != 0)) && ((string.Compare(this.Dbtype, "sql_sysstoredquery", StringComparison.Ordinal) != 0) && string.IsNullOrEmpty(presstr))) { this.ShowXml.Text = "数据源地址为空!"; return; } istr = LabelManage.GetDBQuery(this.Dbtype, presstr, str3, attriblist); XmlDocument document2 = (XmlDocument)this.XmlProc(this.Dbtype, presstr, istr); if (!string.IsNullOrEmpty(document2.OuterXml)) { this.rootnode = document2.DocumentElement; this.ShowXml.Text = this.GetXmlScheam(2).ToString(); } else { document2.LoadXml("<root></root>"); this.rootnode = document2.DocumentElement; this.ShowXml.Text = this.GetXmlScheam(2).ToString(); } if (LabelManage.GetAttributeList(this.xmlfilepath).Count == 0) { this.attlist.Text = "您尚未添加参数!<a href=\"LabelProperty.aspx?action=" + this.action + "&name=" + this.m_LabelName + "\">添加参数</a>"; } else { foreach (LabelAttributeInfo info in LabelManage.GetAttributeList(this.xmlfilepath)) { string text = this.attlist.Text; this.attlist.Text = text + "<div onclick=\"cit()\" outype=\"3\" class=\"spanfixdiv\" alt=\"" + info.Intro + "
默认值:" + info.DefaultValue + "\">" + info.AttributeName + "</div>"; } } this.TxtTemplate.Attributes.Add("onmouseup", "dragend(this)"); this.TxtTemplate.Attributes.Add("onClick", "savePos(this)"); this.TxtTemplate.Attributes.Add("onmousemove", "DragPos(this)"); if (!base.IsPostBack) { string filename = HttpContext.Current.Server.MapPath("~/") + @"\Temp\DefaultLabelTemplate.xsl"; if (string.Compare(this.action, "modify", StringComparison.OrdinalIgnoreCase) == 0) { this.TxtTemplate.Text = XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelTemplate").Replace("><", ">\n<"); } else { XmlDocument document3 = new XmlDocument(); document3.Load(filename); this.TxtTemplate.Text = document3.OuterXml.Replace("><", ">\n<"); } this.TxtTemplateTest.Text = "{PE.Label id=\"" + this.m_LabelName + "\" /}"; } } this.SmpNavigator.AdditionalNode = this.m_LabelName; }
protected void InitPage() { this.m_action = BasePage.RequestString("Action", "Add"); this.ValeTxtFileName.ValidationExpression = "^[^\\/ :*?\"<>|.]+\\.html$"; string str = BasePage.RequestString("Dir").Replace("..", string.Empty); this.currentPath = base.Request.PhysicalApplicationPath + SiteConfig.SiteOption.TemplateDir + str; this.currentPath = this.currentPath.Replace("/", @"\"); if (!this.Page.IsPostBack) { string str2 = "TemplateManage.aspx"; if (!string.IsNullOrEmpty(str)) { if (str.IndexOf('.') > 0) { str2 = str2 + "?Dir=" + base.Server.UrlEncode(str.Substring(0, str.LastIndexOf('/'))); } else { str2 = str2 + "?Dir=" + base.Server.UrlEncode(str); } } this.ViewState["UrlReferrer"] = str2; if (this.m_action == "Modify") { this.LblFileName.Text = str; this.TxtFileName.Visible = false; this.ValrTxtFileName.Visible = false; this.ValeTxtFileName.Enabled = false; try { this.TxtTemplate.Text = FileSystemObject.ReadFile(this.currentPath); } catch (FileNotFoundException) { AdminPage.WriteErrMsg("文件未找到", this.ViewState["UrlReferrer"].ToString()); } catch (UnauthorizedAccessException) { AdminPage.WriteErrMsg("<li>读取文件失败!检查您的服务器是否给模板文件夹写入权限。</li>", this.ViewState["UrlReferrer"].ToString()); } } if (this.m_action == "Add") { this.LblFileName.Text = str + "/"; } ListItem item = new ListItem(); item.Text = "全部分类"; this.DropLabelList.DataSource = LabelManage.GetLabelTypeList(); this.DropLabelList.DataTextField = "Name"; this.DropLabelList.DataValueField = "Name"; this.DropLabelList.DataBind(); this.DropLabelList.Items.Insert(0, item); this.DropPagerList.DataSource = PagerManage.GetPagerTypeList(); this.DropPagerList.DataTextField = "Name"; this.DropPagerList.DataValueField = "Name"; this.DropPagerList.DataBind(); this.DropPagerList.Items.Insert(0, item); this.BuildLabelList(string.Empty); this.BuildPagerList(string.Empty); } }
protected bool ReplaceProc(string labelName) { LabelManageInfo ainfo = new LabelManageInfo(); ainfo = LabelManage.GetLabelByName(labelName); if (string.Compare(this.RadioButtonList2.SelectedValue, "labelname", StringComparison.OrdinalIgnoreCase) == 0) { string str = ainfo.Name.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text); if (this.ChkAdd.Checked) { ainfo.Name = str; return(LabelManage.Add(ainfo)); } return(LabelManage.Update(ainfo, str)); } if (string.Compare(this.RadioButtonList2.SelectedValue, "labeltype", StringComparison.OrdinalIgnoreCase) == 0) { XmlDocument document = new XmlDocument(); document.LoadXml(ainfo.Define.ToString()); if (document.SelectSingleNode("root/LabelType") != null) { document.SelectSingleNode("root/LabelType").InnerText = document.SelectSingleNode("root/LabelType").InnerText.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text); } ainfo.Define = new StringBuilder(document.InnerXml); if (this.ChkAdd.Checked) { return(LabelManage.Add(ainfo)); } return(LabelManage.Update(ainfo)); } if (string.Compare(this.RadioButtonList2.SelectedValue, "labelintro", StringComparison.OrdinalIgnoreCase) == 0) { XmlDocument document2 = new XmlDocument(); document2.LoadXml(ainfo.Define.ToString()); if (document2.SelectSingleNode("root/LabelIntro") != null) { document2.SelectSingleNode("root/LabelIntro").InnerText = document2.SelectSingleNode("root/LabelIntro").InnerText.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text); } ainfo.Define = new StringBuilder(document2.InnerXml); if (this.ChkAdd.Checked) { return(LabelManage.Add(ainfo)); } return(LabelManage.Update(ainfo)); } if (string.Compare(this.RadioButtonList2.SelectedValue, "sql", StringComparison.OrdinalIgnoreCase) == 0) { XmlDocument document3 = new XmlDocument(); document3.LoadXml(ainfo.Define.ToString()); if (document3.SelectSingleNode("root/LabelSqlString") != null) { document3.SelectSingleNode("root/LabelSqlString").InnerText = document3.SelectSingleNode("root/LabelSqlString").InnerText.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text); } ainfo.Define = new StringBuilder(document3.InnerXml); if (this.ChkAdd.Checked) { return(LabelManage.Add(ainfo)); } return(LabelManage.Update(ainfo)); } if (string.Compare(this.RadioButtonList2.SelectedValue, "template", StringComparison.OrdinalIgnoreCase) == 0) { XmlDocument document4 = new XmlDocument(); document4.LoadXml(ainfo.Define.ToString()); if (document4.SelectSingleNode("root/LabelTemplate") != null) { document4.SelectSingleNode("root/LabelTemplate").InnerText = document4.SelectSingleNode("root/LabelTemplate").InnerText.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text); } ainfo.Define = new StringBuilder(document4.InnerXml); if (this.ChkAdd.Checked) { return(LabelManage.Add(ainfo)); } return(LabelManage.Update(ainfo)); } string newLableName = ainfo.Name.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text); XmlDocument document5 = new XmlDocument(); document5.LoadXml(ainfo.Define.ToString()); if (document5.SelectSingleNode("root/LabelType") != null) { document5.SelectSingleNode("root/LabelType").InnerText = document5.SelectSingleNode("root/LabelType").InnerText.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text); } if (document5.SelectSingleNode("root/LabelIntro") != null) { document5.SelectSingleNode("root/LabelIntro").InnerText = document5.SelectSingleNode("root/LabelIntro").InnerText.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text); } if (document5.SelectSingleNode("root/LabelSqlString") != null) { document5.SelectSingleNode("root/LabelSqlString").InnerText = document5.SelectSingleNode("root/LabelSqlString").InnerText.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text); } if (document5.SelectSingleNode("root/LabelTemplate") != null) { document5.SelectSingleNode("root/LabelTemplate").InnerText = document5.SelectSingleNode("root/LabelTemplate").InnerText.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text); } ainfo.Define = new StringBuilder(document5.InnerXml); if (this.ChkAdd.Checked) { ainfo.Name = newLableName; return(LabelManage.Add(ainfo)); } return(LabelManage.Update(ainfo, newLableName)); }
protected void ShowLabelModify() { string labelName = string.Empty; string str2 = BasePage.RequestString("n"); if (!string.IsNullOrEmpty(str2)) { str2 = str2.Replace("{", "<").Replace("}", ">"); XmlDocument document = new XmlDocument(); document.LoadXml(str2); XmlElement documentElement = document.DocumentElement; if (documentElement.HasAttribute("id")) { labelName = documentElement.GetAttribute("id"); this.LabelName.Text = labelName; LabelManageInfo labelByName = LabelManage.GetLabelByName(labelName); if (!labelByName.IsNull) { StringBuilder builder = new StringBuilder(); builder.Append("<table width='100%'>"); XmlDocument document2 = new XmlDocument(); document2.LoadXml(labelByName.Define.ToString()); foreach (XmlNode node in document2.SelectNodes("root/attributes")) { string innerText = node.SelectSingleNode("name").InnerText; string avalue = string.Empty; if (documentElement.HasAttribute(innerText)) { avalue = documentElement.GetAttribute(innerText); } else { avalue = node.SelectSingleNode("default").InnerText; } string[] sArray = node.SelectSingleNode("default").InnerText.Split(new string[] { "|||" }, StringSplitOptions.None); builder.Append(this.CtrlProc(node.SelectSingleNode("name").InnerText, avalue, node.SelectSingleNode("default").InnerText, node.SelectSingleNode("intro").InnerText, sArray)); } string input = (document2.SelectSingleNode("root/UsePage") == null) ? "" : document2.SelectSingleNode("root/UsePage").InnerText.Trim(); string attribute = string.Empty; if (DataConverter.CBoolean(input)) { if (documentElement.HasAttribute("page") && DataConverter.CBoolean(documentElement.GetAttribute("page"))) { attribute = " checked"; } builder.Append("<tr><td align=\"right\">是否分页:</td><td align=\"left\"><input id=\"page\" type=\"checkbox\"" + attribute + "/></td></tr>"); attribute = "10"; if (documentElement.HasAttribute("pagesize") && !string.IsNullOrEmpty(documentElement.GetAttribute("pagesize"))) { attribute = documentElement.GetAttribute("pagesize"); } builder.Append("<tr><td align=\"right\">分页显示数:</td><td align=\"left\"><input type=\"text\" id=\"pagesize\" value=\"" + attribute + "\"/></td></tr>"); attribute = string.Empty; if (documentElement.HasAttribute("urlpage") && DataConverter.CBoolean(documentElement.GetAttribute("urlpage"))) { attribute = " checked"; } builder.Append("<tr><td align=\"right\">是否主分页:</td><td align=\"left\"><input id=\"urlpage\" type=\"checkbox\"" + attribute + "/></td></tr>"); } builder.Append("<tr><td align=\"right\">缓存时间:</td><td align=\"left\"><input type=\"text\" id=\"cachetime\""); if (documentElement.HasAttribute("cachetime")) { builder.Append("value=\"" + documentElement.GetAttribute("cachetime") + "\""); } builder.Append("/></td></tr>"); if (documentElement.HasAttribute("noprocinlabel") && DataConverter.CBoolean(documentElement.GetAttribute("noprocinlabel"))) { attribute = " checked"; } builder.Append("<tr><td align=\"right\">不解析内部标签:</td><td align=\"left\"><input id=\"nolabelproc\" type=\"checkbox\"" + attribute + "/></td></tr>"); builder.Append("<tr><td align=\"right\">容器类型:</td><td align=\"left\"><input type=\"text\" id=\"spantype\""); if (documentElement.HasAttribute("span")) { builder.Append("value=\"" + documentElement.GetAttribute("span") + "\""); } builder.Append("/></td></tr>"); builder.Append("<tr><td align=\"right\">容器风格:</td><td align=\"left\"><input type=\"text\" id=\"cssname\""); if (documentElement.HasAttribute("class")) { builder.Append("value=\"" + documentElement.GetAttribute("class") + "\""); } builder.Append("/></td></tr>"); builder.Append("</table>"); this.labelbody.Text = builder.ToString(); input = (document2.SelectSingleNode("root/LabelIntro") == null) ? "" : document2.SelectSingleNode("root/LabelIntro").InnerText.Trim(); if (!string.IsNullOrEmpty(input)) { this.labelintro.Text = input; } } } } }
protected void Page_Load(object sender, EventArgs e) { this.action = BasePage.RequestString("action"); this.m_LabelName = BasePage.RequestString("name"); this.m_LabelLibPath = "~/" + SiteConfig.SiteOption.LabelDir; if (string.IsNullOrEmpty(this.m_LabelName)) { BasePage.ResponseRedirect("Label.aspx"); } string path = WebConfigurationManager.AppSettings["EasyOne:LabelXsltPath"]; this.xmlfilepath = HttpContext.Current.Server.MapPath(path) + @"\" + this.m_LabelName + ".config"; if (string.Compare(this.action, "modify", StringComparison.OrdinalIgnoreCase) == 0) { this.BtnSave.Visible = true; } this.Dbtype = XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelDataType"); if (!base.IsPostBack) { string str2; DataRow[] rowArray; this.TxtSqlstr.Text = XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelSqlString"); DataTable table = new DataTable(); if ((string.Compare("sql_sysquery", this.Dbtype, StringComparison.OrdinalIgnoreCase) == 0) || (string.Compare("sql_outquery", this.Dbtype, StringComparison.OrdinalIgnoreCase) == 0)) { if (DataConverter.CBoolean(XmlManage.ReadFileNode(this.xmlfilepath, "root/UsePage"))) { this.ChkPage.Checked = true; this.CountShow.Visible = true; this.TxtSqlCount.Text = XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelSqlCount"); } if (string.Compare("sql_sysquery", this.Dbtype, StringComparison.OrdinalIgnoreCase) == 0) { rowArray = LabelManage.GetSystemSchemaDataBases().Select("", " TABLE_NAME "); table = LabelManage.GetSystemSchemaDataBases().Clone(); table.Rows.Clear(); foreach (DataRow row in rowArray) { table.ImportRow(row); } } else { str2 = XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelDataSource"); rowArray = LabelManage.GetSchemaDataBase(str2, DataSourceType.Sql).Select("", " TABLE_NAME "); table = LabelManage.GetSchemaDataBase(str2, DataSourceType.Sql).Clone(); table.Rows.Clear(); foreach (DataRow row2 in rowArray) { table.ImportRow(row2); } } } else if (string.Compare(this.Dbtype, "ole_read", StringComparison.OrdinalIgnoreCase) == 0) { if (DataConverter.CBoolean(XmlManage.ReadFileNode(this.xmlfilepath, "root/UsePage"))) { this.ChkPage.Checked = true; this.CountShow.Visible = true; this.PageShow.Visible = true; this.TxtSqlCount.Text = XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelSqlCount"); this.TxtSqlPage.Text = XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelSqlPage"); } str2 = XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelDataSource"); rowArray = LabelManage.GetSchemaDataBase(str2, DataSourceType.Ole).Select("", " TABLE_NAME "); table = LabelManage.GetSchemaDataBase(str2, DataSourceType.Ole).Clone(); table.Rows.Clear(); foreach (DataRow row3 in rowArray) { table.ImportRow(row3); } } else if (string.Compare(this.Dbtype, "odbc_read", StringComparison.OrdinalIgnoreCase) == 0) { if (DataConverter.CBoolean(XmlManage.ReadFileNode(this.xmlfilepath, "root/UsePage"))) { this.ChkPage.Checked = true; this.CountShow.Visible = true; this.PageShow.Visible = true; this.TxtSqlCount.Text = XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelSqlCount"); this.TxtSqlPage.Text = XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelSqlPage"); } str2 = XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelDataSource"); rowArray = LabelManage.GetSchemaDataBase(str2, DataSourceType.Odbc).Select("", " TABLE_NAME "); table = LabelManage.GetSchemaDataBase(str2, DataSourceType.Odbc).Clone(); table.Rows.Clear(); foreach (DataRow row4 in rowArray) { table.ImportRow(row4); } } else if (string.Compare(this.Dbtype, "orc_read", StringComparison.OrdinalIgnoreCase) == 0) { if (DataConverter.CBoolean(XmlManage.ReadFileNode(this.xmlfilepath, "root/UsePage"))) { this.ChkPage.Checked = true; this.CountShow.Visible = true; this.TxtSqlCount.Text = XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelSqlCount"); } str2 = XmlManage.ReadFileNode(this.xmlfilepath, "root/LabelDataSource"); rowArray = LabelManage.GetSchemaDataBase(str2, DataSourceType.Oracle).Select("", " TABLE_NAME "); table = LabelManage.GetSchemaDataBase(str2, DataSourceType.Oracle).Clone(); table.Rows.Clear(); foreach (DataRow row5 in rowArray) { table.ImportRow(row5); } } this.DbTableDownList.DataSource = table; this.DbTableDownList.DataTextField = "TABLE_NAME"; this.DbTableDownList.DataValueField = "TABLE_NAME"; this.DbTableDownList.DataBind(); ListItem item = new ListItem(); item.Text = "请选择一个表"; this.DbTableDownList.Items.Insert(0, item); this.DbTableDownList2.DataSource = table; this.DbTableDownList2.DataTextField = "TABLE_NAME"; this.DbTableDownList2.DataValueField = "TABLE_NAME"; this.DbTableDownList2.DataBind(); item.Text = "请选择一个表"; this.DbTableDownList2.Items.Insert(0, item); if (LabelManage.GetAttributeList(this.xmlfilepath).Count == 0) { this.attlist.Text = "您尚未添加参数!<a href=\"LabelProperty.aspx?action=" + this.action + "&name=" + this.m_LabelName + "\">添加参数</a>"; } else { foreach (LabelAttributeInfo info in LabelManage.GetAttributeList(this.xmlfilepath)) { this.attlist.Text = this.attlist.Text + "<div onmousedown=\"dragstart();\" class=\"spanfixdiv\">" + info.AttributeName + "</div>"; } } } base.Form.Attributes.Add("onmouseup", "dragclear()"); base.Form.Attributes.Add("onmousemove", "dragmove()"); this.TxtSqlstr.Attributes.Add("onmouseup", "dragend(1);"); this.TxtSqlstr.Attributes.Add("onmousemove", "movePoint();;"); this.TxtSqlPage.Attributes.Add("onmouseup", "dragend(1);"); this.TxtSqlPage.Attributes.Add("onmousemove", "movePoint();;"); this.TxtSqlCount.Attributes.Add("onmouseup", "dragend(1);"); this.TxtSqlCount.Attributes.Add("onmousemove", "movePoint();;"); this.SmpNavigator.AdditionalNode = this.m_LabelName; }