void load_tree() { var pid = Request.QueryString["pid"]; var swm = new SqlWhereMerge(); swm.equal("f_fdChild", 0); swm.equal("f_fdTask", 1); swm.equal("f_deleted", 0); if (!string.IsNullOrEmpty(pid)) { swm.equal("f_pid", pid); } DBConfig cfg = new DBConfig(); SqlExec se = cfg.se(); JArray arr = new JArray(); var data = se.select("up6_files" , "f_id,f_pid,f_pidRoot,f_nameLoc" , swm.to_sql() , string.Empty); //查子目录 if (!string.IsNullOrEmpty(pid)) { data = se.select("up6_folders" , "f_id,f_pid,f_pidRoot,f_nameLoc" , new SqlParam[] { new SqlParam("f_pid", pid) , new SqlParam("f_deleted", false) }); } foreach (var f in data) { var item = new JObject(); item["id"] = f["f_id"].ToString(); item["text"] = f["f_nameLoc"].ToString(); item["parent"] = "#"; item["nodeSvr"] = f; arr.Add(item); } this.toContent(arr); }
void search() { var pid = this.reqString("pid"); var pathRel = this.reqStringDecode("pathRel"); pathRel += '/'; var key = this.reqStringDecode("key"); SqlWhereMerge swm = new SqlWhereMerge(); DBConfig cfg = new DBConfig(); if (!string.IsNullOrEmpty(pid)) { if (cfg.m_isOracle || cfg.m_isOdbc) { swm.add("f_pathRel", string.Format("f_pathRel=CONCAT('{0}',f_nameLoc)", pathRel)); } else { swm.add("f_pathRel", string.Format("f_pathRel='{0}'+f_nameLoc", pathRel)); } } swm.equal("f_complete", true); swm.equal("f_deleted", false); swm.equal("f_uid", this.reqToInt("uid")); if (!string.IsNullOrEmpty(key)) { swm.add("key", string.Format("f_nameLoc like '%{0}%'", key)); } string where = swm.to_sql(); DbBase bs = cfg.bs(); //文件表 var files = (JArray)bs.page2("up6_files" , "f_id" , "f_id,f_pid,f_nameLoc,f_sizeLoc,f_lenLoc,f_time,f_pidRoot,f_fdTask,f_pathSvr,f_pathRel" , where , "f_fdTask desc,f_time desc"); //根目录不加载 up6_folders 表数据 JArray folders = new JArray(); //目录表 folders = (JArray)bs.page2("up6_folders" , "f_id" , "f_id,f_nameLoc,f_pid,f_sizeLoc,f_time,f_pidRoot,f_pathRel" , where , "f_time desc"); foreach (var fd in folders) { fd["f_fdTask"] = true; fd["f_fdChild"] = false; fd["f_pathSvr"] = string.Empty; } foreach (var f in files) { folders.Add(f); } JObject o = new JObject(); o["count"] = folders.Count; o["code"] = 0; o["msg"] = string.Empty; o["data"] = folders; this.toContent(o); }
/// <summary> /// 获取目录和文件列表 /// 1.根据相对路径获取数据 /// </summary> /// <param name="toParam">注册到变量?</param> void load_data(bool toParam) { var pid = Request.QueryString["pid"]; var pathRel = this.reqStringDecode("pathRel"); pathRel += '/'; SqlWhereMerge swm = new SqlWhereMerge(); DBConfig cfg = new DBConfig(); //if (!string.IsNullOrEmpty(pid)) swm.equal("f_pid", pid); if (!string.IsNullOrEmpty(pid)) { if (cfg.m_isOracle || cfg.m_isOdbc) { swm.add("f_pathRel", string.Format("f_pathRel=CONCAT('{0}',f_nameLoc)", pathRel)); } else { swm.add("f_pathRel", string.Format("f_pathRel='{0}'+f_nameLoc", pathRel)); } } swm.equal("f_complete", true); swm.equal("f_deleted", false); swm.equal("f_uid", this.reqToInt("uid")); bool isRoot = string.IsNullOrEmpty(pid); if (isRoot) { swm.equal("f_fdChild", false); } else { swm.equal("f_fdChild", true); } string where = swm.to_sql(); DbBase bs = cfg.bs(); //文件表 var files = (JArray)bs.page2("up6_files" , "f_id" , "f_id,f_pid,f_nameLoc,f_sizeLoc,f_lenLoc,f_time,f_pidRoot,f_fdTask,f_pathSvr,f_pathRel" , where , "f_fdTask desc,f_time desc"); //根目录不加载 up6_folders 表数据 JArray folders = new JArray(); if (!isRoot) { //目录表 swm.del("f_fdChild"); where = swm.to_sql(); folders = (JArray)bs.page2("up6_folders" , "f_id" , "f_id,f_nameLoc,f_pid,f_sizeLoc,f_time,f_pidRoot,f_pathRel" , where , "f_time desc"); foreach (var fd in folders) { fd["f_fdTask"] = true; fd["f_fdChild"] = false; fd["f_pathSvr"] = string.Empty; } } foreach (var f in files) { folders.Add(f); } int count = bs.count("up6_files", "f_id", where); if (!isRoot) { count += bs.count("up6_folders", "f_id", where); } JObject o = new JObject(); o["count"] = count; o["code"] = 0; o["msg"] = string.Empty; o["data"] = folders; if (toParam) { this.param.Add("items", o); } else { this.toContent(o); } }