public ImportConfiguration(TableMapping[] tableMappings, ConnectionSetup connectionSetup, string databaseName, ErrorHandling errorHandling)
 {
     this.tableMappings = tableMappings;
     this.connectionSetup = connectionSetup;
     this.databaseName = databaseName;
     this.errorHandling = errorHandling;
 }
        public void NonWindowsLoginTest()
        {
            ConnectionSetup connectionSetup = new ConnectionSetup(hostName, "TestUser", "TestPass", false);
            connectionSetup.Timeout = 1;
            SQLServerConnector conn = new SQLServerConnector(connectionSetup);

            Assert.IsNotEmpty(conn.GetDatabaseNames());
        }
        public void DatabaseExistsTest()
        {
            ConnectionSetup connectionSetup = new ConnectionSetup(hostName, "", "", true);
            connectionSetup.Timeout = 1;
            SQLServerConnector conn = new SQLServerConnector(connectionSetup);

            Assert.Contains(dbTestName, conn.GetDatabaseNames().ToList());
        }
 public static string SQLServerConnectionString(ConnectionSetup connectionSetup)
 {
     if (connectionSetup.UseWindowsAuthentication)
     {
         return String.Format("server={0};Integrated Security=SSPI;Trusted_Connection=yes;connection timeout={1}",
             connectionSetup.ServerName, connectionSetup.Timeout);
     }
     else
     {
         return String.Format("user id={0};password={1};server={2};Trusted_Connection=no;connection timeout={3}",
             connectionSetup.UserName, connectionSetup.Password, connectionSetup.ServerName, connectionSetup.Timeout);
     }
 }
 public static string SQLServerConnectionString(ConnectionSetup connectionSetup)
 {
     if (connectionSetup.UseWindowsAuthentication)
     {
         return(String.Format("server={0};Integrated Security=SSPI;Trusted_Connection=yes;connection timeout={1}",
                              connectionSetup.ServerName, connectionSetup.Timeout));
     }
     else
     {
         return(String.Format("user id={0};password={1};server={2};Trusted_Connection=no;connection timeout={3}",
                              connectionSetup.UserName, connectionSetup.Password, connectionSetup.ServerName, connectionSetup.Timeout));
     }
 }
        public void TimeoutTest()
        {
            string hostNameDoesntExist = "testest";
            ConnectionSetup connectionSetup = new ConnectionSetup(hostNameDoesntExist, "", "", true);
            connectionSetup.Timeout = 1;

            ImportConfiguration config = new ImportConfiguration(null, connectionSetup, "", null);

            ImportStatement[] statements = new ImportStatement[0];

            SQLServerDataImporter importer = new SQLServerDataImporter(config);

            importer.ImportData(statements);
        }
        public void ColumnsExistsTest()
        {
            ConnectionSetup connectionSetup = new ConnectionSetup(hostName, "", "", true);
            connectionSetup.Timeout = 1;
            SQLServerConnector conn = new SQLServerConnector(connectionSetup);

            Database db = conn.GetDatabase(dbTestName);
            DBTable personTable = db.Tables.Where(t => t.Name == "Person").First();
            string[] columnNames = personTable.Columns.Select(c => c.Name).ToArray();

            Assert.Contains("p_id", columnNames);
            Assert.Contains("FirstName", columnNames);
            Assert.Contains("LastName", columnNames);
            Assert.Contains("a_id", columnNames);
        }
        public void TablesExistsTest()
        {
            ConnectionSetup connectionSetup = new ConnectionSetup(hostName, "", "", true);
            connectionSetup.Timeout = 1;
            SQLServerConnector conn = new SQLServerConnector(connectionSetup);

            Database db = conn.GetDatabase(dbTestName);

            string[] tableNames = db.Tables.Select(t => t.Name).ToArray();

            Assert.AreEqual(4, db.Tables.Count);
            Assert.Contains("Address", tableNames);
            Assert.Contains("Person", tableNames);
            Assert.Contains("ContactInfo", tableNames);
            Assert.Contains("ContactInfoType", tableNames);
        }
        private ConnectionSetup readConnectionSetup(XmlReader reader)
        {
            ConnectionSetup connnectionSetup = null;

            if (reader.ReadToFollowing("ConnectionSetup"))
            {
                string serverName = reader.GetAttribute("serverName");
                bool windowsAuthentication = bool.Parse(reader.GetAttribute("windowsAuthentication"));
                string userName = reader.GetAttribute("userName");
                string password = reader.GetAttribute("password");
                int timeout = int.Parse(reader.GetAttribute("timeout"));

                connnectionSetup = new ConnectionSetup(serverName, userName, password, windowsAuthentication, timeout);
            }

            return connnectionSetup;
        }
 public SQLServerConnector(ConnectionSetup connectionSetup)
 {
     this.connectionSetup = connectionSetup;
 }
 public SQLServerConnector(ConnectionSetup connectionSetup)
 {
     this.connectionSetup = connectionSetup;
 }
 private ImportConfiguration getConfig()
 {
     string hostName = @"UNKIE\SQLExpress";
     string dbTestName = "BATEST";
     ConnectionSetup connectionSetup = new ConnectionSetup(hostName, "", "", true);
     return new ImportConfiguration(null, connectionSetup, dbTestName, null);
 }
        public void TimeoutTest()
        {
            string hostNameDoesntExist = "testest";
            ConnectionSetup connectionSetup = new ConnectionSetup(hostNameDoesntExist, "", "", true);
            connectionSetup.Timeout = 1;
            SQLServerConnector conn = new SQLServerConnector(connectionSetup);

            conn.GetDatabaseNames();
        }
        private void Refresh_Button_Click(object sender, RoutedEventArgs e)
        {
            var serverNameTextBox = (TextBox)FindName("serverNameTextBox");
            var userNameTextBox = (TextBox)FindName("userNameTextBox");
            var passwordPasswordBox = (PasswordBox)FindName("passwordPasswordBox");
            var winauthRadiobutton = (RadioButton)FindName("winauthRadiobutton");

            string serverName = serverNameTextBox.Text;
            string userName = userNameTextBox.Text;
            string password = passwordPasswordBox.Password;
            bool useWinauth = false;

            if (winauthRadiobutton.IsChecked.HasValue
                    && winauthRadiobutton.IsChecked.Value)
            {
                useWinauth = true;
            }

            ConnectionSetup connSetup = new ConnectionSetup(serverName, userName, password, useWinauth);
            viewModel.ConnectionSetup = connSetup;
        }