/// <summary> /// 根据分类检索 /// </summary> /// <param name="typeId">分类id</param> /// <param name="belong">级别</param> public void Search(string typeId, string belong) { T_Res_Type type = new T_Res_Type(); T_Res_Type fatherType = new T_Res_Type(); using (JSZX_ResourceEntities db = new JSZX_ResourceEntities()) { ResourceList relist = new ResourceList(); type = relist.GetTypeById(typeId, db); if (type.BELONG_ID != null && type.BELONG_ID != "") { fatherType = relist.GetTypeById(type.BELONG_ID, db); } } string ahtml = ""; if (belong == "2") { ahtml = "<span>></span> <a href='javascript:doSearch2(\"" + fatherType.ID + "\",\"1\")' class='ml5 mr5'>" + fatherType.NAME + "</a> <span>></span> <a href='javascript:doSearch2(\"" + type.ID + "\",\"2\")' class='ml5 mr5'>" + type.NAME + "</a>"; } else { ahtml = "<span>></span> <a href='javascript:doSearch2(\"" + type.ID + "\",\"1\")' class='ml5 mr5'>" + type.NAME + "</a>"; } HttpContext.Response.Write(ahtml); }
/// <summary> /// 根据分类查询资源 /// </summary> /// <returns></returns> public ActionResult ListByType(string typeId, string belong) { T_Res_Type type = new T_Res_Type(); T_Res_Type fatherType = new T_Res_Type(); // List <V_Public_Type> models = new List <V_Public_Type>(); using (JSZX_ResourceEntities db = new JSZX_ResourceEntities()) { models = db.V_Public_Type.OrderBy(t => t.CREATETIME).ToList(); ResourceList relist = new ResourceList(); string retStr = ""; GetTypeListString(relist, db, typeId, ref retStr); ViewData["retStr"] = retStr; if (typeId != null && typeId != "") { type = relist.GetTypeById(typeId, db); if (type.BELONG_ID != null && type.BELONG_ID != "") { fatherType = relist.GetTypeById(type.BELONG_ID, db); } if (belong == "2") { ViewData["TypeName_1"] = fatherType.NAME; ViewData["TypeId_1"] = fatherType.ID; ViewData["belong_1"] = "1"; ViewData["TypeName_2"] = type.NAME; ViewData["TypeId_2"] = type.ID; ViewData["belong_2"] = "2"; } else { ViewData["TypeName_2"] = type.NAME; ViewData["TypeId_2"] = type.ID; ViewData["belong_2"] = "1"; } ViewData["typeId"] = typeId; } else { ViewData["typeId"] = null; } } JavaScriptSerializer js = new JavaScriptSerializer(); js.MaxJsonLength = Int32.MaxValue; string json = js.Serialize(models); ViewData["typeTree"] = json; return(View()); }
private void GetTypeListString(ResourceList relist, JSZX_ResourceEntities db, string typeId, ref string retString) { if (typeId != null && typeId != "") { T_Res_Type type = relist.GetTypeById(typeId, db); string str = "<span>></span> "; str += "<a href=\"javascript:doSearch2(\'" + type.ID + "\',\'" + type.BELONG_ID + "\')\" class=\"ml5 mr5\">" + type.NAME + "</a>"; retString = str + retString; GetTypeListString(relist, db, type.BELONG_ID, ref retString); } else { return; } }