public void OrdersExtractToFile() { SqlServerStorage storage = new SqlServerStorage(typeof(OrdersVerticalBar)); storage.ServerName = "NEON-64"; storage.DatabaseName = "Northwind"; storage.SelectSql = "SELECT * FROM Orders"; storage.FillRecordCallback = new FillRecordHandler(FillRecordOrder); FileDataLink.EasyExtractToFile(storage, "tempord.txt"); FileDataLink link = new FileDataLink(storage); link.ExtractToFile("tempord.txt"); OrdersVerticalBar[] res = CommonEngine.ReadFile(typeof(OrdersVerticalBar), "tempord.txt") as OrdersVerticalBar[]; if (File.Exists("tempord.txt")) { File.Delete("tempord.txt"); } Assert.AreEqual(830, res.Length); Assert.AreEqual("VINET", res[0].CustomerID); Assert.AreEqual("TOMSP", res[1].CustomerID); Assert.AreEqual("HANAR", res[2].CustomerID); }
public void CurrencyOracleExtractToFile( ) { GenericDatabaseStorage <OracleConnection, OracleCommand> storage = new GenericDatabaseStorage <OracleConnection, OracleCommand>(typeof(TestRecord), "User Id=SHELL;Password=shell;Data Source=ora9dev"); storage.SelectSql = "SELECT * FROM CURRENCY"; storage.FillRecordCallback = new FillRecordHandler(FillRecordOrder); FileDataLink.EasyExtractToFile(storage, "tempord.txt"); FileDataLink link = new FileDataLink(storage); link.ExtractToFile("tempord.txt"); TestRecord[] res = CommonEngine.ReadFile(typeof(TestRecord), "tempord.txt") as TestRecord[]; if (File.Exists("tempord.txt")) { File.Delete("tempord.txt"); } Assert.AreEqual(3, res.Length); Assert.AreEqual("AED", res[0].CurrencyCode); Assert.AreEqual("AFA", res[1].CurrencyCode); Assert.AreEqual("ALL", res[2].CurrencyCode); }
public void CurrencySqlExtractToFile( ) { GenericDatabaseStorage <SqlConnection, SqlCommand> storage = new GenericDatabaseStorage <SqlConnection, SqlCommand>(typeof(TestRecord), "Data Source=FRENZY;Initial Catalog=Pruebas;User Id=sa;Password=Toshiba;"); storage.SelectSql = "SELECT * FROM Currency"; storage.FillRecordCallback = new FillRecordHandler(FillRecordOrder); FileDataLink.EasyExtractToFile(storage, "tempord.txt"); FileDataLink link = new FileDataLink(storage); link.ExtractToFile("tempord.txt"); TestRecord[] res = CommonEngine.ReadFile(typeof(TestRecord), "tempord.txt") as TestRecord[]; if (File.Exists("tempord.txt")) { File.Delete("tempord.txt"); } Assert.AreEqual(105, res.Length); Assert.AreEqual("AED", res[0].CurrencyCode); Assert.AreEqual("AFA", res[1].CurrencyCode); Assert.AreEqual("ALL", res[2].CurrencyCode); }
private void cmdRun_Click(object sender, EventArgs e) { try { cmdRun.Enabled = false; lblStatus.Text = "Creating the DataLinkEngine"; AccessStorage storage = new AccessStorage(typeof(CustomersVerticalBar), "TestData.mdb"); storage.SelectSql = "SELECT * FROM Customers"; storage.FillRecordCallback = new FillRecordHandler(FillRecord); storage.InsertSqlCallback = new InsertSqlHandler(GetInsertSql); FileDataLink mLink = new FileDataLink(storage); Application.DoEvents(); Thread.Sleep(800); // Db -> File lblStatus.Text = "Extracting records from the access db to a file"; mLink.ExtractToFile(@"temp.txt"); Application.DoEvents(); Thread.Sleep(800); // File -> Db lblStatus.Text = "Inserting records from a file to the access db"; mLink.InsertFromFile(@"temp.txt"); if (File.Exists(@"temp.txt")) { File.Delete(@"temp.txt"); } Application.DoEvents(); Thread.Sleep(800); lblStatus.Text = "DONE !!!"; } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Unexpected Error !!", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { cmdRun.Enabled = true; } }
public void CustomersDbToFile() { var storage = new AccessStorage(typeof(CustomersVerticalBar), @"..\data\TestData.mdb"); storage.SelectSql = "SELECT * FROM Customers"; storage.FillRecordCallback = new FillRecordHandler(FillRecordCustomers); mLink = new FileDataLink(storage); mLink.ExtractToFile(@"..\data\temp.txt"); int extractNum = mLink.LastExtractedRecords.Length; var records = (CustomersVerticalBar[])mLink.FileHelperEngine.ReadFile(@"..\data\temp.txt"); Assert.AreEqual(extractNum, records.Length); }
public void OrdersExtractToFile() { var storage = new SqlServerStorage(typeof(OrdersVerticalBar)); storage.ServerName = "NEON-64"; storage.DatabaseName = "Northwind"; storage.SelectSql = "SELECT * FROM Orders"; storage.FillRecordCallback = new FillRecordHandler(FillRecordOrder); try { FileDataLink.EasyExtractToFile(storage, "tempord.txt"); } catch (SqlException ex) { if (ex.Number == 208) { Assert.Ignore("You dont have this tables in your SqlServer"); } if (ex.Number == 6) { Assert.Ignore("SqlServer not found, skipping this test."); } Assert.Ignore(ex.ToString()); } var link = new FileDataLink(storage); link.ExtractToFile("tempord.txt"); var res = CommonEngine.ReadFile(typeof(OrdersVerticalBar), "tempord.txt") as OrdersVerticalBar[]; if (File.Exists("tempord.txt")) { File.Delete("tempord.txt"); } Assert.AreEqual(830, res.Length); Assert.AreEqual("VINET", res[0].CustomerID); Assert.AreEqual("TOMSP", res[1].CustomerID); Assert.AreEqual("HANAR", res[2].CustomerID); }