public static bool ImportData(string folder, bool clearTable) { foreach (var table in GlobalInfo.Tables) { if (!table.Value.ToExport) { continue; } var tableName = table.Value.Table.GetField("Name").GetValue(null).ToString(); var filename = Path.ChangeExtension(Path.Combine(folder, tableName), ".xml"); if (!File.Exists(filename)) { continue; } if (clearTable) { ImportExportData.DeleteData(tableName); } using (var dataset = new DataSet()) { dataset.ReadXml(filename, XmlReadMode.ReadSchema); RowToElaborate?.Invoke(null, tableName); var result = WriteData(tableName, dataset); RowElaborated?.Invoke(null, new Tuple <int, bool>(dataset.Tables[tableName].Rows.Count, result)); } } return(true); }
public static bool ExportData(string folder) { foreach (var table in GlobalInfo.Tables) { if (!table.Value.ToExport) { continue; } var tableName = table.Value.Table.GetField("Name").GetValue(null).ToString(); using (var dataset = ReadData(tableName)) { if (dataset.Tables[tableName].Rows.Count == 0) { continue; } var filename = Path.ChangeExtension(Path.Combine(folder, tableName), ".xml"); RowToElaborate?.Invoke(null, tableName); dataset.WriteXml(filename, XmlWriteMode.WriteSchema); RowElaborated?.Invoke(null, new Tuple <int, bool>(dataset.Tables[tableName].Rows.Count, true)); } } return(true); }