示例#1
0
        public db_schema conn_db(string name_conn, bool open = true, bool reconnect = false, string throw_msg = "")
        {
            if (string.IsNullOrEmpty(name_conn))
            {
                if (throw_msg != "")
                {
                    throw new Exception(throw_msg);
                }
                else
                {
                    throw new Exception("non hai specificato la connessione da aprire!");
                }
            }

            // vedo se la connessione è già stata aperta
            if (_dbconns.ContainsKey(name_conn))
            {
                if (!reconnect)
                {
                    return(_dbconns[name_conn]);
                }
                else
                {
                    _dbconns[name_conn].close_conn();
                    _dbconns.Remove(name_conn);
                }
            }

            XmlNode   dbconn  = conn_node(name_conn);
            db_schema newconn = db_schema.create_provider(name_conn, web_conn(name_conn), web_conn_provider(name_conn), xmlDoc.node_val(conn_group(name_conn), "curver")
                                                          , cfg_value_int("/root/dbconns", "timeout", -1), xmlDoc.node_val(dbconn, "group"), xmlDoc.node_val(dbconn, "language"), xmlDoc.node_val(dbconn.SelectSingleNode("formats"), "datetoquery")
                                                          , xmlDoc.node_val(dbconn.SelectSingleNode("formats"), "datetoquery2"), xmlDoc.node_val(dbconn, "des")
                                                          , schema_path_fromconn(name_conn, false), schema_path_fromconn(name_conn, false, false, true), group_scripts(xmlDoc.node_val(dbconn, "group")));

            _dbconns.Add(name_conn, newconn);

            if (open)
            {
                newconn.open_conn();
            }

            return(newconn);
        }