}        //decompressRule(Rule r, System.Data.DataTable dataTable)

        private List <System.Data.DataTable> loadTemplateData(string path)
        {
            List <System.Data.DataTable> dataTables = new List <System.Data.DataTable>();

            System.Data.DataTable dataTable = null;
            foreach (ResourceFile rf in this.ResourceFiles)
            {
                if (rf.Filetype == ResourceFileType.TemplateDataFile)
                {
                    string                dataFilename = path + rf.Filename;
                    StreamReader          sr           = new StreamReader(dataFilename, System.Text.Encoding.Default, true);
                    string                data         = sr.ReadToEnd();
                    List <List <string> > lines        = ConversiveGeneralTextToolbox.SplitCSV(data, ',', '"');
                    if (lines.Count > 1)
                    {
                        dataTable = new System.Data.DataTable();
                        foreach (string colName in lines[0])
                        {
                            System.Data.DataColumn dc = new System.Data.DataColumn();
                            dc.DataType   = System.Type.GetType("System.String");
                            dc.ColumnName = colName.ToLower();
                            dc.Caption    = colName;
                            dataTable.Columns.Add(dc);
                        }
                        for (int i = 1; i < lines.Count; i++)
                        {
                            List <string>       fieldValues = lines[i];
                            System.Data.DataRow dr          = dataTable.NewRow();
                            for (int j = 0; j < fieldValues.Count; j++)
                            {
                                dr[j] = (string)fieldValues[j];
                            }
                            dataTable.Rows.Add(dr);
                        } //for each data line
                        dataTables.Add(dataTable);
                    }     //if we have a valid file
                }         //end if TemplateDataFile
            }             //foreach resource file
            return(dataTables);
        }//loadTemplateData(List<System.Data.DataTable> resourceFiles)
Exemple #2
0
 public static string MakeCSV(List <Dictionary <string, string> > data, char fieldDelimiter, char textDelimiter)
 {
     return(ConversiveGeneralTextToolbox.MakeCSV(data, fieldDelimiter, textDelimiter, true));
 }