public override Collection <FeatureSourceColumn> GetColumnToAdd(string filePath, string customParameter) { Collection <FeatureSourceColumn> result = new Collection <FeatureSourceColumn>(); using (GeoDbf geoDbf = new GeoDbf(filePath, GeoFileReadWriteMode.Read)) { geoDbf.Open(); var columns = geoDbf.GetAllColumns(); foreach (var item in columns) { DataJoinFeatureSourceColumn csvColumn = new DataJoinFeatureSourceColumn(item.ColumnName, item.TypeName, item.MaxLength); result.Add(csvColumn); } geoDbf.Close(); } return(result); }
public override DataTable ReadDataToDataGrid(string filePath, string customParameter) { DataTable PreviewDataTable = new DataTable(); if (File.Exists(filePath)) { DataTable dataTable = new DataTable(); using (GeoDbf geoDbf = new GeoDbf(filePath, GeoFileReadWriteMode.Read)) { geoDbf.Open(); dataTable = new DataTable(); var columns = geoDbf.GetAllColumns(); foreach (var item in columns) { dataTable.Columns.Add(item.ColumnName); } for (int i = 1; i <= geoDbf.RecordCount; i++) { DataRow dr = dataTable.NewRow(); var dictionary = geoDbf.ReadRecordAsString(i); for (int j = 1; j <= geoDbf.ColumnCount; j++) { string value; dictionary.TryGetValue(geoDbf.GetColumnName(j), out value); dr[j - 1] = value; } dataTable.Rows.Add(dr); } geoDbf.Close(); } PreviewDataTable = dataTable; } return(PreviewDataTable); }