Exemplo n.º 1
0
 public static Table getTableFromFile(String filePath)
 {
     int counter = 0;
     String line = "";
     Table table = new Table();
     table.Columns = new List<Column>();
     table.Rows = new List<Row>();
     try
     {
         StreamReader reader = new StreamReader(new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), Encoding.Default);
         while ((line = reader.ReadLine()) != null)// && counter < 50)
         {
             String[] fields = line.Split(';');
             if (counter == 0)
             {
                 int i = 1;
                 foreach (String s in fields)
                 {
                     table.Columns.Add(new Column("column" + i));
                     i++;
                 }
             }
             Row row = new Row();
             row.Values = new List<KeyValue>();
             int index = 1;
             foreach (String s in fields)
             {
                 row.Values.Add(new KeyValue("column" + index, cleanValue(s).Replace("\"", "")));
                 index++;
             }
             table.Rows.Add(row);
             counter++;
         }
     }
     catch (Exception e)
     {
         Console.Out.Write(e);
     }
     table.TableName = "Table1";
     table.OriginalTableName = "Table1";
     return table;
 }
Exemplo n.º 2
0
        public static List<Table> getTablesFromXMLFileNew(String filePath)
        {
            XElement xml = XElement.Load(getXMLReader(filePath));
            Row row = new Row();
           
            //inicializa tabelas com a tabela do elemento root e add coluna do id do elemento root
            List<Table> tables = new List<Table>();

            addNodeToTables(xml, ref tables);
            
           // getTableRows(xml, ref tables, 50);
            
            return tables;
        }
Exemplo n.º 3
0
        public static void getTableRows(XElement element, ref List<Table> tables, int maxRows)
        {
            int index = getElementIndexInTables(element, tables);
            if (index >= 0) //if table exists
            { 
                Table table = tables[index];
                table.Rows = new List<Row>();
                Row row = new Row();
                row.Values = new List<KeyValue>();

                foreach (Column c in table.Columns)
                {
                    if (c.IsIDGenerated)
                    {
                        if (c.IsFK)
                        {
                           // KeyValue value = new KeyValue(c.ColumnName, );
                            //row.Values.Add(value);
                        }
                        if (c.IsPK)
                        {
                            KeyValue value = new KeyValue(c.ColumnName, element.Element(c.ColumnName));
                            row.Values.Add(value);
                        }
                        
                    }
                }

                foreach (XElement x in element.Elements())
                {
                    if (x.HasElements)
                    {

                    }
                    else
                    {

                    }

                }
            }
        }
Exemplo n.º 4
0
 public static String insertRow(List<Column> excludedColumns, Row r)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("(" + r.ToString(excludedColumns) + ");");
     return sql.ToString();
 }