コード例 #1
0
        public string[] fields_name(string table, bool without_pk = false)
        {
            string pk_field = pk_of_table(table);

            return(_doc.nodes("/root/tables/table[@name-upper='" + table.ToUpper() + "']/cols/col")
                   .Cast <XmlNode>().Where(x => without_pk ? x.Attributes["name-upper"].Value != pk_field.ToUpper() : true).Select(node => node.Attributes["name"].Value).ToArray());
        }
コード例 #2
0
        public void read_vars(xml_doc doc, Dictionary <string, var> dv, string var_key = "", string doc_key = "", bool for_pg = false
                              , string xpath = "")
        {
            // vars
            string nkey = "";

            try {
                foreach (xml_node vars in doc.nodes(xpath == "" ? "/config/vars" : xpath))
                {
                    string network = vars.get_attr("network"), bname = vars.get_attr("name");
                    foreach (xml_node var in vars.nodes("var"))
                    {
                        string network2 = var.get_attr("network") != "" ? var.get_attr("network") : network;
                        if (network2 != "" && _core.network_key() != network2.ToLower())
                        {
                            continue;
                        }
                        nkey = var_key + bname + var.get_attr("name");
                        if (dv.Keys.Contains(nkey))
                        {
                            dv.Remove(nkey);
                        }
                        dv.Add(nkey, new var(doc_key, nkey, _core.parse(var.get_val()), for_pg));
                    }
                }
            } catch (Exception ex) { throw new Exception("chiave vars.'" + nkey + "' - " + ex.Message); }
        }
コード例 #3
0
        public void load_base_config(string doc_key, string vars_key, xml_doc doc, bool for_pg = false)
        {
            string var_key = !string.IsNullOrEmpty(vars_key) ? vars_key + "." : "";

            // vars
            string nkey = "";

            try {
                foreach (xml_node vars in doc.nodes("/config/vars"))
                {
                    string machine = vars.get_attr("machine");
                    string bname   = vars.get_attr("name");
                    foreach (xml_node var in vars.nodes("var"))
                    {
                        string machine2 = var.get_attr("machine") != "" ? var.get_attr("machine") : machine;
                        if (machine2 != "" && core.machine_name().ToLower() != machine2.ToLower())
                        {
                            continue;
                        }
                        nkey = var_key + bname + var.get_attr("name");
                        _vars.Add(nkey, new var(doc_key, nkey, _core.parse(var.get_val()), for_pg));
                    }
                }
            } catch (Exception ex) { throw new Exception("chiave vars.'" + nkey + "' - " + ex.Message); }

            // conns
            nkey = "";
            try {
                foreach (xml_node var in doc.nodes("/config//conns/conn"))
                {
                    nkey = var_key + var.get_attr("name");
                    _conns.Add(nkey, new conn(doc_key, nkey, var.get_attr("conn-string"), var.get_attr("provider"), var.get_attr("des")
                                              , var.get_attr("date-format"), var.get_int("timeout", 0), var.get_attr("key"), var.sub_node("sql_key").text, for_pg));
                }
            } catch (Exception ex) { throw new Exception("chiave conns.'" + nkey + "' - " + ex.Message); }
        }
コード例 #4
0
        public void load_base_config(string doc_key, string vars_key, xml_doc doc, bool for_pg = false)
        {
            string var_key = !string.IsNullOrEmpty(vars_key) ? vars_key + "." : "";

            // vars
            read_vars(doc, _vars, var_key, doc_key, for_pg);

            // conns
            string nkey = "";

            try {
                foreach (xml_node var in doc.nodes("/config//conns/conn"))
                {
                    nkey = var_key + var.get_attr("name");
                    _conns.Add(nkey, new conn(doc_key, nkey, var.get_attr("conn-string"), var.get_attr("provider"), var.get_attr("des")
                                              , var.get_attr("date-format"), var.get_int("timeout", 0), var.get_attr("key"), var.sub_node("sql_key").text, for_pg));
                }
            } catch (Exception ex) { throw new Exception("chiave lib-conns.'" + nkey + "' - " + ex.Message); }
        }
コード例 #5
0
 public IEnumerable <meta_link> table_links(string table)
 {
     return(_doc.nodes("/root/tables/table/links//link[@table-upper='" + table.ToUpper() + "']").Cast <XmlNode>().Select(x => link(x)));
 }
コード例 #6
0
        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); }
        }