Beispiel #1
0
        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);
        }
        private void cmdRun_Click(object sender, EventArgs e)
        {
            try
            {
                cmdRun.Enabled = false;

                lblStatus.Text = "Creating the DataLinkEngine";

                AccessStorage storage = new AccessStorage(typeof(CustomersVerticalBar), MainClass.GlobalTestMdb);

                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;
            }
        }
Beispiel #3
0
        public void CustomersFileToDb()
        {
            var storage = new AccessStorage(typeof(CustomersVerticalBar), @"..\data\TestData.mdb");
            storage.InsertSqlCallback = new InsertSqlHandler(GetInsertSqlCust);

            mLink = new FileDataLink(storage);
            ClearData(((AccessStorage) mLink.DataStorage).AccessFileName, "CustomersTemp");

            int count = Count(((AccessStorage) mLink.DataStorage).AccessFileName, "CustomersTemp");
            Assert.AreEqual(0, count);

            mLink.InsertFromFile(@"..\data\UpLoadCustomers.txt");

            count = Count(((AccessStorage) mLink.DataStorage).AccessFileName, "CustomersTemp");
            Assert.AreEqual(91, count);

            ClearData(((AccessStorage) mLink.DataStorage).AccessFileName, "CustomersTemp");
        }
		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);

			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());
			}


			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 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 );
        }
Beispiel #6
0
        /// <summary>The short way to Insert Records from a file to a DataStorage</summary>
        /// <param name="storage">The DataStorage where store the records.</param>
        /// <param name="filename">The file with the SourceRecords</param>
        /// <returns>The Inserted records</returns>
        public static object[] EasyInsertFromFile(DataStorage storage, string filename)
        {
            FileDataLink link = new FileDataLink(storage);

            return(link.InsertFromFile(filename));
        }
Beispiel #7
0
        /// <summary>The short way to Extract the records from a DataStorage to a file</summary>
        /// <param name="storage">The DataStorage from where get the records</param>
        /// <param name="filename">The file where to write the records to.</param>
        /// <returns>The Extracted records.</returns>
        public static object[] EasyExtractToFile(DataStorage storage, string filename)
        {
            FileDataLink link = new FileDataLink(storage);

            return(link.ExtractToFile(filename));
        }
Beispiel #8
0
 /// <summary>The short way to Insert Records from a file to a DataStorage</summary>
 /// <param name="storage">The DataStorage where store the records.</param>
 /// <param name="filename">The file with the SourceRecords</param>
 /// <returns>The Inserted records</returns>
 public static object[] EasyInsertFromFile(DataStorage storage, string filename)
 {
     FileDataLink link = new FileDataLink(storage);
     return link.InsertFromFile(filename);
 }
Beispiel #9
0
 /// <summary>The short way to Extract the records from a DataStorage to a file</summary>
 /// <param name="storage">The DataStorage from where get the records</param>
 /// <param name="filename">The file where to write the records to.</param>
 /// <returns>The Extracted records.</returns>
 public static object[] EasyExtractToFile(DataStorage storage, string filename)
 {
     FileDataLink link = new FileDataLink(storage);
     return link.ExtractToFile(filename);
 }
Beispiel #10
0
		public void OrdersFileToDb()
		{

			AccessStorage storage = new AccessStorage(typeof(OrdersFixed), @"..\data\TestData.mdb");
			storage.InsertSqlCallback = new InsertSqlHandler(GetInsertSqlOrder);

			mLink = new FileDataLink(storage);
			ClearData(((AccessStorage) mLink.DataStorage).AccessFileName, "OrdersTemp");

			int count = Count(((AccessStorage) mLink.DataStorage).AccessFileName, "OrdersTemp");
			Assert.AreEqual(0, count);

			mLink.InsertFromFile(@"..\data\UpLoadOrders.txt");

			count = Count(((AccessStorage) mLink.DataStorage).AccessFileName, "OrdersTemp");
			Assert.AreEqual(830, count);

			ClearData(((AccessStorage) mLink.DataStorage).AccessFileName, "OrdersTemp");
		}
        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 );
        }