Exemple #1
0
        protected void read_cols(string path, schema_doc sch = null)
        {
            _path = path;

            _cols = new List <Dictionary <string, string> >();
            _flds = new List <schema_field>();

            // carico le colonne di struttura + schema campi
            using (GotDotNet.XPath.XPathReader xr = new GotDotNet.XPath.XPathReader(_path, "/root/cols/col")) {
                while (xr.ReadUntilMatch())
                {
                    Dictionary <string, string> col = new Dictionary <string, string>();
                    while (xr.MoveToNextAttribute())
                    {
                        col.Add(xr.Name, xr.Value);
                    }

                    _flds.Add(new schema_field(dbType.xml, col["name"], col["type"], col.ContainsKey("nullable") ? bool.Parse(col["nullable"]) : false
                                               , col.ContainsKey("maxlength") ? int.Parse(col["maxlength"]) : (int?)null, col.ContainsKey("numprec") ? int.Parse(col["numprec"]) : (int?)null
                                               , col.ContainsKey("numscale") ? int.Parse(col["numscale"]) : (int?)null, col.ContainsKey("default") ? col["numscale"] : ""
                                               , col.ContainsKey("autonumber") ? bool.Parse(col["autonumber"]) : false
                                               , col["level"] == "1" && col.ContainsKey("pkfield") && col["pkfield"] == "1", 0));

                    _cols.Add(col);
                }
            }

            // carico i campi
            using (GotDotNet.XPath.XPathReader xr = new GotDotNet.XPath.XPathReader(_path, "/root/data")) {
                if (xr.ReadUntilMatch())
                {
                    schema_doc sk = _db_xml != null ? _db_xml.schema : sch;
                    if (_flds.Count == 0)
                    {
                        for (int i = 0; i < xr.AttributeCount; i++)
                        {
                            _flds.Add(sk.new_schema_field(sk.field_node(table, xr.GetAttribute("f" + i.ToString("00")))
                                                          , "f" + i.ToString("00")));
                        }
                    }
                    else
                    {
                        for (int i = 0; i < xr.AttributeCount; i++)
                        {
                            _flds.Find(x => x.Name.ToUpper() == xr.GetAttribute("f" + i.ToString("00")).ToUpper()).AttrName = "f" + i.ToString("00");
                        }
                    }
                }
            }

            to_begin();
        }
Exemple #2
0
 public meta_doc(XmlDocument doc, schema_doc sch)
 {
     _doc = new xmlDoc(doc); _schema = sch;
 }
Exemple #3
0
 public xml_data(string path, string table = null, schema_doc sch = null, int?level = null)
 {
     _table = table;
     read_cols(path, sch);
     _level = level.HasValue ? level.Value : _level;
 }
Exemple #4
0
 public meta_doc(string path, schema_doc sch)
 {
     _doc = new xmlDoc(path); _schema = sch;
 }