public DataTable GetLabelList(string categoryId) { DataTable dt = null; if (int.Parse(categoryId) >= 0) { B_LabelContent bll = new B_LabelContent(); int recordCount = 0; dt = bll.GetLbCategoryIdList(int.Parse(categoryId), 1, 1000000, ref recordCount); } else { B_SuperLabel bll = new B_SuperLabel(); dt = bll.GetList(1, 1000000).Tables[0]; } return dt; }
public string GetSuperLabel(string Name, int UserId) { object obj2; string str = ""; B_SuperLabel label = new B_SuperLabel(); M_SuperLabel model = new M_SuperLabel(); int superId = label.GetSuperId(Name); model = label.GetModel(superId); if (superId == 0) { return "该超级标签名称出错!"; } if ((model.DataBaseType == 1) || (model.DataBaseType == 3)) { if (model.IsHtml) { string sqlStr = model.SqlStr; MatchCollection matchs = Regex.Matches(sqlStr, "{#(.*?)}", RegexOptions.IgnoreCase); if (matchs.Count > 0) { DataRow userAllInfo = new B_User().GetUserAllInfo(UserId); foreach (Match match in matchs) { sqlStr = sqlStr.Replace("{#" + match.Groups[1].Value + "}", userAllInfo["" + match.Groups[1].Value + ""].ToString()); } } DataTable table = new DataTable(); if (model.DataBaseType == 3) { table = label.DataBaseTypeSql(model.DataBaseConn, model.DataBaseType.ToString(), sqlStr); } else { table = label.CheckSql(sqlStr); } this.SqlContent = model.Content; this.MySqlContent = new string[3]; this.GetStyle(this.MySqlContent); this.ColumnsContent = this.MySqlContent[1]; this.MyColumnsContent = new string[3]; this.GetStyleColumns(this.MyColumnsContent); int numColumns = model.NumColumns; int num4 = table.Rows.Count / numColumns; str = str + this.MySqlContent[0]; for (int i = 0; i < table.Rows.Count; i++) { if ((this.MySqlContent[1].Trim().ToLower().IndexOf("<ky_loop_columns>") > 0) && (this.MySqlContent[1].Trim().ToLower().IndexOf("</ky_loop_columns>") > 0)) { str = str + this.MyColumnsContent[0]; int num6 = 0; while (num6 < model.NumColumns) { if (i == table.Rows.Count) { str = str + this.MyColumnsContent[0] + this.MyColumnsContent[2]; } else { str = str + "" + this.StrValue(table.Rows[i], model.HostTable, this.MyColumnsContent[1]) + ""; } num6++; i++; } str = str + this.MyColumnsContent[2]; } else { str = str + "" + this.StrValue(table.Rows[i], model.HostTable, this.MySqlContent[1]) + ""; } } str = str + this.MySqlContent[2]; } else { obj2 = str + "<!---" + Name.Replace("{Ky_S_", "").Replace("}", "") + "超级标签开始-->"; obj2 = string.Concat(new object[] { obj2, "<div id='SuperLabel_Div_", superId, "'></div>" }); str = string.Concat(new object[] { obj2, "<script language=\"javascript\">var data = XmlHttpPostMethodText(\"", Param.ApplicationRootPath, "/common/SuperLabelList.aspx?SuperId=", superId, "&UserId=", UserId, "\",\"\");document.getElementById('SuperLabel_Div_", superId, "').innerHTML=data;</script>" }) + "<!---" + Name.Replace("{Ky_S_", "").Replace("}", "") + "超级标签结束-->"; } } if (model.DataBaseType != 2) { return str; } if (model.IsHtml) { try { WebClient client = new WebClient(); client.Encoding = Encoding.GetEncoding("utf-8"); byte[] bytes = client.DownloadData("" + model.SqlStr + ""); return Encoding.GetEncoding("utf-8").GetString(bytes); } catch { return "读取外部数据错误"; } } obj2 = str + "<!---" + Name.Replace("{Ky_S_", "").Replace("}", "") + "超级标签开始-->"; obj2 = string.Concat(new object[] { obj2, "<div id='SuperLabel_Div_", superId, "'></div>" }); return (string.Concat(new object[] { obj2, "<script language=\"javascript\">var data = XmlHttpPostMethodText(\"", model.SqlStr, "\",\"\");document.getElementById('SuperLabel_Div_", superId, "').innerHTML=data;</script>" }) + "<!---" + Name.Replace("{Ky_S_", "").Replace("}", "") + "超级标签结束-->"); }