/// <summary> /// 验证目录是否存在 /// </summary> private void ExistLabelDir(M_Label label) { if (!FileSystemObject.IsExist(dir + label.LabelCate, FsoMethod.Folder)) { FileSystemObject.CreateFileFolder(dir + label.LabelCate); } }
protected void repFileReName_ItemCommand(object sender, RepeaterCommandEventArgs e) { if (e.CommandName == "Del") { string LabelName = e.CommandArgument.ToString(); bll.DelLabelXML(LabelName); Response.Redirect("LabelManage.aspx"); } if (e.CommandName == "Copy") { string LabelName = e.CommandArgument.ToString(); M_Label newlbl = bll.GetLabelXML(LabelName); newlbl.LableName = newlbl.LableName + DataSecurity.RandomNum(4); newlbl.LabelID = 0; bll.AddLabelXML(newlbl); Response.Redirect("LabelManage.aspx"); } if (e.CommandName == "Download") { string LabelName = e.CommandArgument.ToString(); M_Label newlbl = bll.GetLabelXML(LabelName); XmlDocument doc = new XmlDocument(); XmlNode nodelist = doc.SelectSingleNode("//NewDataSet/Table[LabelID='" + newlbl.LabelID.ToString() + "']"); string fileName = newlbl.LableName + ".lable";//客户端保存的文件名 string path = newlbl.LabelCate + "/" + newlbl.LableName + ".label"; SafeSC.DownFile(bll.dir + path, HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); } }
private static SqlParameter[] GetParameters(M_Label Info) { SqlParameter[] parameter = new SqlParameter[] { new SqlParameter("@LabelID", SqlDbType.Int), new SqlParameter("@LabelName", SqlDbType.NVarChar, 50), new SqlParameter("@LabelType", SqlDbType.Int), new SqlParameter("@LabelCate", SqlDbType.NVarChar, 50), new SqlParameter("@LabelDesc", SqlDbType.NVarChar, 255), new SqlParameter("@LabelParam", SqlDbType.NText), new SqlParameter("@LabelTable", SqlDbType.NText), new SqlParameter("@LabelField", SqlDbType.NText), new SqlParameter("@LabelWhere", SqlDbType.NText), new SqlParameter("@LabelOrder", SqlDbType.NText), new SqlParameter("@LabelContent", SqlDbType.NText), new SqlParameter("@LabelCount", SqlDbType.NVarChar, 50) }; parameter[0].Value = Info.LabelID; parameter[1].Value = Info.LableName; parameter[2].Value = Info.LableType; parameter[3].Value = Info.LabelCate; parameter[4].Value = Info.Desc; parameter[5].Value = Info.Param; parameter[6].Value = Info.LabelTable; parameter[7].Value = Info.LabelField; parameter[8].Value = Info.LabelWhere; parameter[9].Value = Info.LabelOrder; parameter[10].Value = Info.Content; parameter[11].Value = Info.LabelCount; return(parameter); }
protected void BtnSave_Click(object sender, EventArgs e) { if (this.Page.IsValid) { M_Label LabelInfo = new M_Label(); LabelInfo.LabelID = DataConverter.CLng(this.HdnlabelID.Value); LabelInfo.LableName = this.TxtLabelName.Text; LabelInfo.LableType = DataConverter.CLng(this.DDLType.SelectedValue); LabelInfo.LabelCate = this.DDLType.SelectedIndex == 0 ? "列表分页导航" : "内容分页导航"; LabelInfo.Desc = this.TxtLabelIntro.Text; LabelInfo.Param = ""; LabelInfo.LabelTable = ""; LabelInfo.LabelField = ""; LabelInfo.LabelWhere = ""; LabelInfo.LabelOrder = ""; LabelInfo.Content = this.TxtLabelTemplate.Text; LabelInfo.LabelCount = "0"; if (LabelInfo.LabelID > 0) { this.bll.UpdateLabelXML(LabelInfo); } else { LabelInfo.LabelNodeID = 0; this.bll.AddLabelXML(LabelInfo); } function.WriteSuccessMsg("添加成功!", "LabelManage.aspx"); //Response.Redirect("LabelManage.aspx"); } }
void ID_Label.UpdateLabel(M_Label label) { string strSql = "PR_Label_Update"; SqlParameter[] cmdParams = GetParameters(label); SqlHelper.ExecuteProc(strSql, cmdParams); }
//标签列表管理 public string Label_API(string action, string name) { switch (action) { case "copy": { M_Label newlbl = labelBll.GetLabelXML(name); newlbl.LabelName = newlbl.LabelName + function.GetRandomString(4, 2); newlbl.LabelID = 0; labelBll.AddLabelXML(newlbl); } break; case "del": { labelBll.DelLabelXML(name); } break; case "down": //下载 { } break; } return(Success.ToString()); }
protected void repFileReName_ItemCommand(object sender, RepeaterCommandEventArgs e) { if (e.CommandName == "Edit") { string Id = e.CommandArgument.ToString(); M_Label labelInfo = this.bll.GetLabel(DataConverter.CLng(Id)); if (labelInfo.LableType == 1) { Response.Redirect("LabelHtml.aspx?LabelID=" + Id); } if (labelInfo.LableType > 1) { Response.Redirect("LabelSql.aspx?LabelID=" + Id); } } if (e.CommandName == "Del") { string Id = e.CommandArgument.ToString(); this.bll.DelLabel(DataConverter.CLng(Id)); Response.Redirect("LabelManage.aspx"); } if (e.CommandName == "Copy") { string Id = e.CommandArgument.ToString(); M_Label newlbl = this.bll.GetLabel(DataConverter.CLng(Id)); newlbl.LableName = newlbl.LableName + DataSecurity.RandomNum(4); this.bll.AddLabel(newlbl); Response.Redirect("LabelManage.aspx"); } }
public IActionResult LabelCallTab() { M_Label labelMod = new M_Label(); if (!string.IsNullOrEmpty(LabelName)) { labelMod = labelBll.GetLabelXML(LabelName); } return(View(labelMod)); // B_ARoleAuth.AuthCheckEx(ZLEnum.Auth.system, "label"); //CustomLabel_DP.DataSource = labelBll.GetLabelCateListXML(); //CustomLabel_DP.DataTextField = "name"; //CustomLabel_DP.DataValueField = "name"; //CustomLabel_DP.DataBind(); //CustomLabel_DP.Items.Insert(0, new ListItem("选择标签类型", "")); //Field_DP.DataSource = labelBll.GetSourceLabelXML();//LabelType //Field_DP.DataTextField = "LabelName"; //Field_DP.DataValueField = "LabelID"; //Field_DP.DataBind(); //Field_DP.Items.Insert(0, new ListItem("选择数据源标签", "")); //if (!string.IsNullOrEmpty(LabelName)) //{ // DealInvoke(); //} //return View(); }
private void LabelInvoke() { //1,获取主表与次表的表名,然后替换为 A. B. //{table1}.dbo.ZL_CommonModel left join {table1}.dbo.ZL_C_Article on {table1}.dbo.ZL_CommonModel.ArticleID={table1}.dbo.ZL_C_Article.aabbb M_Label labelMod = labelBll.GetLabelXML(LabelID); if (string.IsNullOrEmpty(labelMod.ProceParam)) { return; } M_SubLabel subMod = JsonConvert.DeserializeObject <M_SubLabel>(labelMod.ProceParam); Alias_T.Text = labelMod.LableName; T1_T.Text = subMod.PureT1; T2_T.Text = subMod.PureT2; labelMod.LabelField = PureStr(labelMod.LabelField, subMod); labelMod.LabelWhere = PureStr(labelMod.LabelWhere, subMod); labelMod.LabelOrder = PureStr(labelMod.LabelOrder, subMod); if (!string.IsNullOrEmpty(subMod.OnField2)) { //标签添加时,左边必定是主表,右边必定是次表 ONStr_T.Text = "A." + subMod.OnField1 + "=B." + subMod.OnField2; } Fields_T.Text = labelMod.LabelField; WhereStr_T.Text = labelMod.LabelWhere; OrderStr_T.Text = labelMod.LabelOrder; ReMark_T.Text = "调用标签" + labelMod.LableName; MyPK_T.Text = "A." + SqlHelper.ExecuteTable("SELECT TOP 1 * FROM " + subMod.PureT1 + " WHERE 1=2").Columns[0].ColumnName; //--------------- if (labelMod.ParamList.Count > 0) { Params_Hid.Value = JsonConvert.SerializeObject(labelMod.ParamList); } }
protected void BtnSave_Click(object sender, EventArgs e) { if (this.IsValid) { M_Label label = new M_Label(); label.LableName = this.TxtLabelName.Text; label.LableType = 1; label.LabelCate = this.TxtLabelType.Text; label.Desc = this.TxtLabelIntro.Text; label.Content = this.textContent.Text; label.Param = ""; label.LabelTable = ""; label.LabelField = ""; label.LabelWhere = ""; label.LabelOrder = ""; label.LabelCount = ""; label.LabelID = DataConverter.CLng(this.HdnLabelID.Value); if (label.LabelID == 0) { this.bll.AddLabel(label); } else { this.bll.UpdateLabel(label); } Response.Redirect("LabelManage.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(LabelName)) { M_Label labelinfo = labelBll.GetLabelXML(LabelName); param = labelinfo.Param; } if (!IsPostBack) { CustomLabel_DP.DataSource = labelBll.GetLabelCateListXML(); CustomLabel_DP.DataTextField = "name"; CustomLabel_DP.DataValueField = "name"; CustomLabel_DP.DataBind(); CustomLabel_DP.Items.Insert(0, new ListItem("选择标签类型", "")); Field_DP.DataSource = labelBll.GetSourceLabelXML();//LabelType Field_DP.DataTextField = "LabelName"; Field_DP.DataValueField = "LabelID"; Field_DP.DataBind(); Field_DP.Items.Insert(0, new ListItem("选择数据源标签", "")); lblSys.Text = bfun.GetSysLabel(); lblFun.Text = bfun.GetFunLabel(); DealInvoke(); Call.SetBreadCrumb(Master, "<li><a href='" + customPath2 + "Config/SiteInfo.aspx'>系统设置</a></li><li><a href='LabelManage.aspx'>标签管理</a></li><li class='active'>标签调用</li>"); } }
/// <summary> /// 更新xml标签 /// </summary> public void UpdateLabelXML(M_Label label) { if (string.IsNullOrEmpty(label.LableName)) { label.LableName = "随机命名" + DateTime.Now.ToString("yyyyMMdd") + "_" + function.GetRandomString(6); } ExistLabelDir(label); XmlDocument doc = new XmlDocument(); doc.Load(dirfilename); XmlNode nodelist = doc.SelectSingleNode("//NewDataSet/Table[LabelName='" + label.LableName + "']"); if (nodelist == null) { throw (new Exception("[" + label.LableName + "]不存在")); } string oldPath = (nodelist["LabelCate"].InnerText + "\\" + nodelist["LabelName"].InnerText).Replace(" ", "").ToLower(); string newPath = (label.LabelCate + "\\" + label.LableName).ToLower(); //-------------------- DataTable labelDT = GetInfoFromModel(label); DataSet newset = new DataSet("NewDataSet"); newset.Tables.Add(labelDT); string filename = dir + label.LabelCate + @"\" + label.LableName + ".label"; DataSet ds = FileSystemObject.ReadXML(dirfilename, "NewDataSet"); if (ds.Tables.Count <= 0) { ds.Tables.Add(new DataTable("Table")); } DataTable dsDT = ds.Tables[0]; if (dsDT.Columns.Count > 0) { dsDT.DefaultView.RowFilter = "LabelName='" + label.LableName + "'"; } dsDT = dsDT.DefaultView.ToTable(); newset.WriteXml(filename); //newset.Tables.Add(filename); if (!newPath.Equals(oldPath))//修改了名称或类别 { FileSystemObject.Delete(dir + oldPath + ".label", FsoMethod.File); string oldfolder = dir + nodelist["LabelCate"].InnerText; DataTable filelist = FileSystemObject.GetFileList(oldfolder); if (filelist == null || filelist.Rows.Count < 1) { FileSystemObject.Delete(oldfolder, FsoMethod.Folder); } } nodelist["LabelName"].InnerText = label.LableName; nodelist["LabelCate"].InnerText = label.LabelCate; nodelist["LabelType"].InnerText = label.LableType.ToString(); doc.Save(dirfilename); }
protected string getExternalConnStr(M_Label label) { try { string id = label.DataSourceType; dsTable = ViewState["dsTable"] == null?dsBll.Sel() : ViewState["dsTable"] as DataTable; return(dsTable.Select("ID='" + id + "'")[0][dsTable.Columns.IndexOf("ConnectionString")] as string); } catch { return(ConfigurationManager.ConnectionStrings["Connection String"].ConnectionString); } }
protected void Button1_Click(object sender, EventArgs e) { string filename = base.Request.PhysicalApplicationPath + @"\" + "App_Data" + @"\" + "LabelExport.xml"; if (!FileSystemObject.IsExist(filename, FsoMethod.File)) { function.WriteErrMsg("数据文件:../App_Data/LabelExport.xml 不存在"); } try { DataSet ds = new DataSet(); M_Label info = new M_Label(); ds.ReadXml(filename); DataTable dt = ds.Tables["Table"]; int count = dt.Rows.Count; int i = 1; foreach (DataRow dr in dt.Rows) { info.LabelID = 0; info.LableName = dr["LabelName"].ToString(); info.LabelCate = dr["LabelCate"].ToString(); info.Desc = dr["LabelDesc"].ToString(); info.LableType = DataConverter.CLng(dr["LabelType"]); info.Param = dr["LabelParam"].ToString(); info.LabelTable = dr["LabelTable"].ToString(); info.LabelField = dr["LabelField"].ToString(); info.LabelWhere = dr["LabelWhere"].ToString(); info.LabelOrder = dr["LabelOrder"].ToString(); info.LabelCount = dr["LabelCount"].ToString(); info.Content = dr["LabelContent"].ToString(); string str2 = ((i * 100) / count).ToString("F1"); str2 = str2 + "%"; if (this.bll.IsExist(info.LableName)) { info.LableName = info.LableName + DataSecurity.RandomNum(4); } this.bll.AddLabel(info); this.tp.Style["Width"] = str2; this.tn.Text = str2; this.tc.Text = i.ToString(); i++; } this.tp.Style["Width"] = "100%"; this.tn.Text = "100%"; this.tc.Text = count.ToString(); this.finallytd.Text = "导入完毕"; } catch { function.WriteErrMsg("导入标签出现异常!"); } }
private void CreateDataLabel(M_ModelInfo info) { //创建数据源标签 M_Label lab = new M_Label(); lab.LableName = info.ModelName + "数据源标签"; lab.LabelCate = "数据源标签"; lab.LableType = 3; lab.LabelTable = "ZL_CommonModel left join " + info.TableName + " on ZL_CommonModel.ItemID=" + info.TableName + ".ID"; lab.LabelField = "ZL_CommonModel.*," + info.TableName + ".*"; lab.LabelWhere = "ZL_CommonModel.GeneralID=@InfoID"; lab.Param = "InfoID,0,2,内容ID"; lab.LabelOrder = ""; lab.LabelCount = ""; lab.Content = ""; lab.Desc = info.ModelName + "数据源标签"; lab.LabelNodeID = 0; B_Label blab = new B_Label(); //blab.AddLabel(lab); blab.AddLabelXML(lab); //创建空白内容页模板并绑定到模型 string fname = "默认" + info.ModelName + "内容页.html"; info.ContentModule = "内容页/" + fname; string vpath = SiteConfig.SiteOption.TemplateDir + "/内容页/" + fname; string strcontent = @"{ZL.Source id=""[ZL_Modelname/]"" /} <!DOCTYPEHTML> <html> <head> <meta http-equiv=""Content-Type"" content=""text/html;charset=utf-8""/> <title>{SField sid=""[ZL_Modelname/]"" FD=""Title"" page=""0""/}</title> {ZL:Boot()/} <meta name=""Keywords"" content=""{SField sid=""[ZL_Modelname/]"" FD=""Tagkey"" page=""0"" /}""> <style> .container-fulid{ height:50vh;padding-top:10%;background:#ccc;text-align:center;} span{font-size:10em;} </style> </head> <body> <div class=""container-fulid""> <div class=""row""> <span class=""fa fa-info-circle""></span><h1>模板内容放这里!</h1><a href=""/hlep.html"" target=""_blank"">快速帮助></a> </div> </div> </body> </html>"; strcontent = strcontent.Replace("[ZL_Modelname/]", info.ModelName + "数据源标签"); SafeSC.WriteFile(vpath, strcontent); }
protected void EBtnSubmit_Click(object sender, EventArgs e)//保存 { if (this.Page.IsValid) { M_ModelInfo info = new M_ModelInfo(); info.ModelID = DataConverter.CLng(this.HdnModelId.Value); info.ModelName = this.TxtModelName.Text; if (info.ModelID > 0) { info.TableName = this.TxtTableName.Text; } else { info.TableName = this.LblTablePrefix.Text + this.TxtTableName.Text; } info.ItemName = this.TxtItemName.Text; info.ItemUnit = this.TxtItemUnit.Text; info.ItemIcon = this.TxtItemIcon.Text; info.Description = this.TxtDescription.Text; info.ModelType = 4; if (info.ModelID == 0) { //创建数据源标签 M_Label lab = new M_Label(); lab.LableName = info.ModelName + "数据源标签"; lab.LabelCate = "数据源标签"; lab.LableType = 3; lab.LabelTable = "ZL_CommonModel left join " + info.TableName + " on ZL_CommonModel.ItemID=" + info.TableName + ".ID"; lab.LabelField = "ZL_CommonModel.*," + info.TableName + ".*"; lab.LabelWhere = "ZL_CommonModel.GeneralID=@InfoID"; lab.Param = "InfoID,0,2,内容ID"; lab.LabelOrder = ""; lab.LabelCount = ""; lab.Content = ""; lab.Desc = info.ModelName + "数据源标签"; lab.LabelNodeID = 0; B_Label blab = new B_Label(); blab.AddLabelXML(lab); //创建空白内容页模板并绑定到模型 string strPath = "默认" + info.ModelName + "内容页.html"; SafeSC.WriteFile(SiteConfig.SiteOption.TemplateDir + "/内容页/" + strPath, info.ModelName + "内容页"); this.bll.AddModel(info); Response.Redirect("../Content/ModelManage.aspx?ModelType=4"); } else { this.bll.UpdateModel(info); Response.Redirect("../Content/ModelManage.aspx?ModelType=4"); } } }
protected void Page_Load(object sender, EventArgs e) { if (!this.Page.IsPostBack) { B_Admin badmin = new B_Admin(); badmin.CheckMulitLogin(); if (!badmin.ChkPermissions("LabelEdit")) { function.WriteErrMsg("没有权限进行此项操作"); } this.DDLCate.DataSource = this.bll.GetCateList(); this.DDLCate.DataTextField = "LabelCate"; this.DDLCate.DataValueField = "LabelCate"; this.DDLCate.DataBind(); this.DDLCate.Items.Insert(0, new ListItem("选择标签分类", "")); this.DropLabelType.DataSource = this.bll.GetCateList(); this.DropLabelType.DataTextField = "LabelCate"; this.DropLabelType.DataValueField = "LabelCate"; this.DropLabelType.DataBind(); this.DropLabelType.Items.Insert(0, new ListItem("选择标签分类", "")); if (!string.IsNullOrEmpty(this.Request.QueryString["LabelID"])) { this.HdnLabelID.Value = this.Request.QueryString["LabelID"]; int LabelID = DataConverter.CLng(this.Request.QueryString["LabelID"]); M_Label label = this.bll.GetLabel(LabelID); if (label.LableType >= 2) { Response.Redirect("LabelSql.aspx?LabelID=" + LabelID.ToString()); } this.TxtLabelName.Text = label.LableName; this.TxtLabelName.Enabled = false; this.TxtLabelType.Text = label.LabelCate; this.DropLabelType.SelectedValue = label.LabelCate; this.TxtLabelIntro.Text = label.Desc; this.textContent.Text = label.Content; } else { this.HdnLabelID.Value = "0"; } this.LblSysLabel.Text = this.bfun.GetSysLabel(); this.LblFunLabel.Text = this.bfun.GetFunLabel(); } this.textContent.Attributes.Add("onmouseup", "dragend(this)"); this.textContent.Attributes.Add("onClick", "savePos(this)"); this.textContent.Attributes.Add("onmousemove", "DragPos(this)"); }
protected void Page_Load(object sender, EventArgs e) { ZoomLa.Common.function.AccessRulo(); B_Admin badmin = new B_Admin(); if (!this.Page.IsPostBack) { if (!B_ARoleAuth.Check(ZoomLa.Model.ZLEnum.Auth.label, "LabelEdit")) { function.WriteErrMsg("没有权限进行此项操作"); } if (string.IsNullOrEmpty(this.Request.QueryString["LabelName"])) { this.m_LabelName = ""; } else { this.m_LabelName = this.Request.QueryString["LabelName"]; } if (this.m_LabelName != "") { M_Label labelInfo = this.bll.GetLabelXML(this.m_LabelName); this.HdnlabelID.Value = labelInfo.LabelID.ToString(); this.TxtLabelName.Text = labelInfo.LableName; //this.LblType.Text = labelInfo.LabelCate; if (labelInfo.LabelCate == "内容分页导航") { this.DDLType.SelectedValue = "6"; } else { this.DDLType.SelectedValue = "5"; } this.TxtLabelIntro.Text = labelInfo.Desc; this.TxtLabelTemplate.Text = labelInfo.Content; } else { this.HdnlabelID.Value = "0"; } } this.TxtLabelTemplate.Attributes.Add("onmouseup", "dragend(this)"); this.TxtLabelTemplate.Attributes.Add("onClick", "savePos(this)"); this.TxtLabelTemplate.Attributes.Add("onmousemove", "DragPos(this)"); Call.SetBreadCrumb(Master, "<li>系统设置</li><li><a href='LabelManage.aspx'>标签管理</a></li><li>动态标签设置</li>"); }
protected void ChangeSourceField(object sender, EventArgs e) { int LabelID = DataConverter.CLng(this.DDLField.SelectedValue); if (LabelID == 0) { this.LblSourceField.Text = ""; } else { M_Label labelinfo = this.bll.GetLabel(LabelID); string lbl = SetLabelColumn(labelinfo.LabelField, labelinfo.LabelTable, labelinfo.LableName); this.LblSourceField.Text = lbl; } }
public string GetLabelLink(string id) { string re = ""; M_Label labelInfo = this.bll.GetLabel(DataConverter.CLng(id)); if (labelInfo.LableType == 1) { re = "<a href=\"LabelHtml.aspx?LabelID=" + id + "\" title=\"" + labelInfo.Desc + "\">" + labelInfo.LableName + "</a>"; } if (labelInfo.LableType > 1) { re = "<a href=\"LabelSql.aspx?LabelID=" + id + "\" title=\"" + labelInfo.Desc + "\">" + labelInfo.LableName + "</a>"; } return(re); }
private void ShowLabelAdd() { string str = base.Request.QueryString["n"]; if (!string.IsNullOrEmpty(str)) { this.LabelName.Text = str; M_Label lblinfo = this.bll.GetLabel(str); if (lblinfo.LableType == 3) { this.m_Labeltype = 1; } else { this.m_Labeltype = 2; } if (!lblinfo.IsNull) { StringBuilder builder = new StringBuilder(); builder.Append("<table width='100%' cellpadding=\"2\" cellspacing=\"1\" class=\"border\">"); int ptype = 0; string aname = ""; string avalue = ""; string aintro = ""; string[] pa = lblinfo.Param.Split(new char[] { '|' }); for (int i = 0; i < pa.Length; i++) { ptype = DataConverter.CLng(pa[i].Split(new char[] { ',' })[2]); if (ptype != 2) { aname = pa[i].Split(new char[] { ',' })[0]; avalue = pa[i].Split(new char[] { ',' })[1]; aintro = pa[i].Split(new char[] { ',' })[3]; builder.Append("<tr class=\"tdbg\"><td class=\"tdbgleft\" align=\"right\"><SPAN sid=\"" + aname + "\" stype=\"0\" title=\"" + aname + "\">" + aintro + "</SPAN>:</td><td align=\"left\">"); builder.Append("<input type=\"text\" id=\"" + aname + "\" value=\"" + avalue + "\"/></td></tr>"); } } builder.Append("</table>"); this.labelbody.Text = builder.ToString(); this.labelintro.Text = lblinfo.Desc; } } }
private static M_Label GetInfoFromReader(SqlDataReader rdr) { M_Label label = new M_Label(); label.LabelID = DataConverter.CLng(rdr["LabelID"]); label.LableName = rdr["LabelName"].ToString(); label.LableType = DataConverter.CLng(rdr["LabelType"]); label.LabelCate = rdr["LabelCate"].ToString(); label.Desc = rdr["LabelDesc"].ToString(); label.Param = rdr["LabelParam"].ToString(); label.LabelTable = rdr["LabelTable"].ToString(); label.LabelField = rdr["LabelField"].ToString(); label.LabelWhere = rdr["LabelWhere"].ToString(); label.LabelOrder = rdr["LabelOrder"].ToString(); label.Content = rdr["LabelContent"].ToString(); label.LabelCount = rdr["LabelCount"].ToString(); return(label); }
//根据筛选到的节点,返回标签 private M_Label GetLabelByNode(XmlNode node) { if (node == null) { return(NullMod); } else { string labelPath = dir + node["LabelCate"].InnerText + @"\" + node["LabelName"].InnerText + ".label"; if (!File.Exists(labelPath)) { return(NullMod); } DataSet tempset = new DataSet(); tempset.ReadXml(labelPath); DataTable dt = tempset.Tables[0]; return(M_Label.GetInfoFromDataTable(node, dt)); } }
/// <summary> /// 将模型转化为DataTable,用于存入文件 /// </summary> /// <param name="Rowsinfo">DataTable</param> public DataTable GetInfoFromModel(M_Label labelMod) { DataTable dirtable = GetDirectoryXML(); if (labelMod.LabelID < 1) { //其是字符串类型,需转为int dirtable.Columns.Add("LabelIDs", typeof(int)); for (int i = 0; i < dirtable.Rows.Count; i++) { dirtable.Rows[i]["LabelIDs"] = dirtable.Rows[i]["LabelID"]; } dirtable.Columns.Remove("LabelID"); dirtable.Columns["LabelIDs"].ColumnName = "LabelID"; dirtable.Columns["LabelID"].SetOrdinal(0); labelMod.LabelID = (DataConverter.CLng(dirtable.Compute("max(LabelID)", "")) + 1); } return(GetLabelStruct(labelMod)); }
/// <summary> /// 添加标签 /// </summary> public bool AddLabelXML(M_Label label) { if (string.IsNullOrEmpty(label.LableName)) { label.LableName = "随机" + DateTime.Now.ToString("yyyyMMdd") + "_" + function.GetRandomString(6); } if (string.IsNullOrEmpty(label.LabelCate)) { label.LabelCate = "未分类"; } DataTable labelDT = GetInfoFromModel(label); DataTable directoryDT = GetDirectoryXML(); string filename = dir + label.LabelCate + @"\" + label.LableName + ".label"; ExistLabelDir(label); if (directoryDT.Columns.Count > 0) { directoryDT.DefaultView.RowFilter = "LabelName='" + label.LableName + "'"; } directoryDT = directoryDT.DefaultView.ToTable(); if (directoryDT.Rows.Count > 0) { function.WriteErrMsg("已存在该标签[" + label.LableName + "],请使用其他表签名!"); } directoryDT.Dispose(); DataSet settale = new DataSet("NewDataSet"); settale.Tables.Add(labelDT); settale.WriteXml(filename); //更新directorylabel(这里应切换成BLL返回table,避免[NewDataSet]中无任何标签引起报错) DataSet dirDS = FileSystemObject.ReadXML(dirfilename, "NewDataSet"); DataRow rows = dirDS.Tables[0].NewRow(); rows["LabelID"] = labelDT.Rows[0]["LabelID"]; rows["LabelName"] = label.LableName; rows["LabelType"] = label.LableType; rows["LabelCate"] = label.LabelCate; dirDS.Tables[0].Rows.Add(rows); dirDS.WriteXml(dirfilename); return(true); }
protected void repFileReName_ItemCommand(object sender, RepeaterCommandEventArgs e) { if (e.CommandName == "Del") { string LabelName = e.CommandArgument.ToString(); bll.DelLabelXML(LabelName); Response.Redirect("LabelManage.aspx"); } if (e.CommandName == "Copy") { string LabelName = e.CommandArgument.ToString(); M_Label newlbl = bll.GetLabelXML(LabelName); newlbl.LableName = newlbl.LableName + DataSecurity.RandomNum(4); newlbl.LabelID = 0; bll.AddLabelXML(newlbl); Response.Redirect("LabelManage.aspx"); } if (e.CommandName == "Download") { string LabelName = e.CommandArgument.ToString(); M_Label newlbl = bll.GetLabelXML(LabelName); SafeSC.DownFile(B_Label.GetLabelVPath(newlbl), newlbl.LableName + ".lable"); } }
/// <summary> /// 保存标签 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void BtnSave_Click(object sender, EventArgs e) { if (this.Page.IsValid) { M_Label LabelInfo = new M_Label(); LabelInfo.LabelID = DataConverter.CLng(this.HdnlabelID.Value); LabelInfo.LableName = this.TxtLabelName.Text; LabelInfo.LableType = DataConverter.CLng(this.RBLType.SelectedValue); LabelInfo.LabelCate = this.TxtLabelType.Text; LabelInfo.Desc = this.TxtLabelIntro.Text; LabelInfo.Param = this.HdnParam.Value; LabelInfo.LabelTable = this.TxtSqlTable.Text; LabelInfo.LabelField = this.TxtSqlField.Text; LabelInfo.LabelWhere = this.TxtSqlWhere.Text; LabelInfo.LabelOrder = this.TxtOrder.Text; LabelInfo.Content = this.textContent.Text; if (string.IsNullOrEmpty(this.TextBox1.Text)) { LabelInfo.LabelCount = "0"; } else { LabelInfo.LabelCount = this.TextBox1.Text; } if (LabelInfo.LabelID > 0) { this.bll.UpdateLabel(LabelInfo); } else { this.bll.AddLabel(LabelInfo); } Response.Redirect("LabelManage.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (string.IsNullOrEmpty(LName)) { function.WriteErrMsg("未指定标签名"); } M_Label labelMod = this.bll.GetLabelXML(LName); if (labelMod.IsNull) { function.WriteErrMsg("[" + LName + "]不存在"); } if (labelMod.LableType == 3) { LabelType = 1; } else { LabelType = labelMod.LableType; } if (string.IsNullOrEmpty(labelMod.Param)) { function.Script(this, "submitdate();"); return; } //创建table StringBuilder builder = new StringBuilder(); builder.Append("<table class='table table-bordered table-striped'>"); int ptype = 0; string aname = ""; string avalue = ""; string aintro = ""; //分割参数 string[] pa = labelMod.Param.Split(new char[] { '|' }); for (int i = 0; i < pa.Length; i++) { //pageid,默认值,2,参数说明 ptype = DataConverter.CLng(pa[i].Split(',')[2]); if (ptype == 1) { aname = pa[i].Split(new char[] { ',' })[0]; avalue = pa[i].Split(new char[] { ',' })[1]; aintro = pa[i].Split(new char[] { ',' })[3]; builder.Append("<tr><td class='text-right td_l'><SPAN sid=\"" + aname + "\" stype=\"0\" title=\"" + aname + "\">" + aintro + "</SPAN>:</td><td class='text-left'>"); builder.Append("<input type=\"text\" id=\"" + aname + "\" value=\"" + avalue + "\"/></td></tr>"); } else if (ptype == 2) { } //页面参数不需要处理 else if (ptype == 3) //单选 { aname = pa[i].Split(new char[] { ',' })[0]; avalue = pa[i].Split(new char[] { ',' })[1]; aintro = pa[i].Split(new char[] { ',' })[3]; builder.Append("<tr><td class='text-right td_l'><SPAN sid=\"" + aname + "\" stype=\"0\" title=\"" + aname + "\">" + aintro + "</SPAN>:</td><td align=\"left\">"); builder.Append("<select id=\"" + aname + "\" style=\"width:156px;\">"); string[] item = avalue.Split('$'); foreach (string iten in item) { builder.Append("<option value=\"" + iten + "\">" + iten + "</option>"); } builder.Append("</select></td></tr>"); } else if (ptype == 4)//多选 { aname = pa[i].Split(new char[] { ',' })[0]; avalue = pa[i].Split(new char[] { ',' })[1]; aintro = pa[i].Split(new char[] { ',' })[3]; builder.Append("<tr><td class='text-right td_l'><SPAN sid=\"" + aname + "\" stype=\"1\" title=\"" + aname + "\">" + aintro + "</SPAN>:</td><td align=\"left\">"); builder.Append("<input id=\"h" + aname + "\" type=\"hidden\" />"); builder.Append("<div id=\"d" + aname + "\" style=\"display:block;\">"); string[] items = avalue.Split('$'); foreach (string itens in items) { builder.Append("<input type=\"checkbox\" name=\"c" + aname + "\" onclick=\"selectchecked(this)\" value=\"" + itens + "\" />" + itens + "</br>"); } builder.Append("</div></td></tr>"); } } if (!builder.ToString().Contains("<tr>")) { function.Script(this, "submitdate();"); return; } builder.Append("</table>"); this.labelbody.Text = builder.ToString(); this.labelintro.Text = labelMod.Desc; } }
protected void EBtnSubmit_Click(object sender, EventArgs e) { if (this.Page.IsValid) { if (!String.IsNullOrEmpty(this.TxtTableName.Text)) { string str = this.TxtTableName.Text; bool b = this.bll.isExistTableName("ZL_P_" + str); if (b) { function.WriteErrMsg("数据库表名已存在,请重新输入!"); return; } } M_ModelInfo info = new M_ModelInfo(); info.ModelID = DataConverter.CLng(this.HdnModelId.Value); info.ModelName = this.TxtModelName.Text; if (info.ModelID > 0) { info.TableName = this.TxtTableName.Text; } else { info.TableName = this.LblTablePrefix.Text + this.TxtTableName.Text; } info.ItemName = this.TxtItemName.Text; info.ItemUnit = this.TxtItemUnit.Text; info.ItemIcon = this.TxtItemIcon.Text; info.Description = this.TxtDescription.Text; info.ModelType = 2; info.MultiFlag = true; if (info.ModelID == 0) { //创建数据源标签 M_Label lab = new M_Label(); lab.LableName = info.ModelName + "数据源标签"; lab.LabelCate = "数据源标签"; lab.LableType = 3; lab.LabelTable = "ZL_Commodities left join " + info.TableName + " on ZL_Commodities.ItemID=" + info.TableName + ".ID"; lab.LabelField = "ZL_Commodities.*," + info.TableName + ".*"; lab.LabelWhere = "ZL_Commodities.ID=@InfoID"; lab.Param = "InfoID,0,2,商品ID"; lab.LabelOrder = ""; lab.LabelCount = ""; lab.Content = ""; lab.Desc = info.ModelName + "数据源标签"; lab.LabelNodeID = 0; B_Label blab = new B_Label(); //blab.AddLabel(lab); blab.AddLabelXML(lab); //创建空白内容页模板并绑定到模型 string strPath = "默认" + info.ModelName + "内容页.html"; info.ContentModule = "/内容页/" + strPath; SafeSC.WriteFile(SiteConfig.SiteOption.TemplateDir + "/内容页/" + strPath, info.ModelName + "内容页"); bool iscrate = this.bll.AddModel(info); if (iscrate) { Response.Redirect("ModelManage.aspx"); } } else { if (this.bll.UpdateModel(info)) { Response.Redirect("ModelManage.aspx"); } } } Response.Redirect("ModelManage.aspx"); }
private void DealInvoke() { M_Label labelinfo = labelBll.GetLabelXML(LabelName); function.Script(this, "cit2('" + labelinfo.LableType + "','" + labelinfo.LableName + "');"); }