public bool there_pk(string table) { return(_doc.exists("/root/tables/table[@name-upper='" + table.ToUpper() + "']/indexes/index[@primary='true']/fields/field")); }
protected string tables_attr(string attr_name) { return(_doc.exists("/root/tables", attr_name) ? _doc.get_value("/root/tables", attr_name) : null); }
public void load_doc(string doc_key, string vars_key, xml_doc doc, db_provider conn, Dictionary <string, object> keys = null, bool for_pg = false) { string var_key = !string.IsNullOrEmpty(vars_key) ? vars_key + "." : ""; // sql-select if (doc.exists("//sql-select")) { foreach (xml_node s in doc.nodes("//sql-select")) { xml_node ref_node = s; foreach (DataRow r in conn.dt_table(_core.parse(s.get_attr("qry"), keys)).Rows) { foreach (xml_node n in _core.parse_nodes(s.clone_childs(s), keys, r)) { ref_node = ref_node.add_after(n); } } } while (true) { xml_node s = doc.node("//sql-select"); if (!s.remove()) { break; } } } // aggiungo string nkey = ""; try { foreach (xml_node var in doc.nodes("/config//folders/folder")) { nkey = var_key + var.get_attr("name"); _folders.Add(nkey, new folder(doc_key, nkey, _core.parse(var.get_val()), for_pg)); } } catch (Exception ex) { throw new Exception("chiave folders.'" + nkey + "' - " + ex.Message); } nkey = ""; try { foreach (xml_node tbl in doc.nodes("/config//tables/table")) { nkey = var_key + tbl.get_attr("name"); _tables.Add(nkey, new table(doc_key, nkey, tbl, for_pg)); } } catch (Exception ex) { throw new Exception("chiave tables.'" + nkey + "' - " + ex.Message); } nkey = ""; try { foreach (xml_node tbl in doc.nodes("/config/html-blocks/html-block")) { nkey = var_key + tbl.get_attr("name"); html_block b = new html_block(doc_key, nkey, tbl.text, for_pg); foreach (xml_node f in tbl.nodes("cond")) { b.add_cond(f.get_attr("name"), f.text); } _html_blocks.Add(nkey, b); } } catch (Exception ex) { throw new Exception("chiave html-blocks.'" + nkey + "' - " + ex.Message); } nkey = ""; try { foreach (xml_node qry in doc.nodes("/config//queries/*")) { if (qry.name == "query") { nkey = var_key + qry.get_attr("name"); query q = new query(doc_key, nkey, qry.text, qry.get_attr("des"), for_pg); foreach (xml_node f in qry.nodes("cond")) { q.add_cond(f.get_attr("name"), f.text); } _queries.Add(nkey, q); } else if (qry.name == "query_do") { nkey = var_key + qry.get_attr("name"); _queries.Add(nkey, new query(doc_key, nkey, qry.get_attr("des"), for_pg) { tp = query.tp_query.do_while, text_do = qry.sub_node("do").text, text_while = qry.sub_node("while").text }); } else if (qry.name == "queries") { nkey = var_key + qry.get_attr("name"); query q = new query(doc_key, nkey, qry.get_attr("des"), for_pg); _queries.Add(nkey, q); foreach (xml_node q2 in qry.nodes("*")) { if (q2.name == "query") { q.add_query(q2.text); } else if (q2.name == "exec_query") { foreach (string q3 in _queries[q2.get_attr("name")].queries) { q.add_query(q3); } } } } } } catch (Exception ex) { throw new Exception("chiave queries.'" + nkey + "' - " + ex.Message); } }