public void SetDatabaseReader(Project project)
 {
     if (project.DatabaseType == DatabaseTypes.SQLServer && databaseSchemaReader == null)
     {
         databaseSchemaReader = new SQLServerDatabaseExtractor();
         conn = new System.Data.SqlClient.SqlConnection(connectionString);
     }
     else if (project.DatabaseType == DatabaseTypes.Access && databaseSchemaReader == null)
     {
         databaseSchemaReader = null;
     }
     else if (project.DatabaseType == DatabaseTypes.Oracle && databaseSchemaReader == null)
     {
         databaseSchemaReader = null;
     }
     else if (project.DatabaseType == DatabaseTypes.MySQL && databaseSchemaReader == null)
     {
         databaseSchemaReader = null;
     }
 }
        public void SetConnectionString(Project project,string databaseName)
        {
            connectionString = "";
            if (project.DatabaseType == DatabaseTypes.SQLServer)
            {
                if (project.IsWindowsAuthentication)
                {

                    connectionString = DataStructure.SQLConn;
                    connectionString = connectionString.Replace("##DS##", project.ServerName);
                    Entities.MetaDataSchema.Database database = Entities.MetaDataSchema.Database.GetByName(project.Databases, databaseName);

                    if (database != null)
                        connectionString = connectionString.Replace("##IC##", database.Name);
                    else
                        connectionString = connectionString.Replace("initial catalog=##IC##", "");
                }
                else
                {
                    connectionString = DataStructure.SQLPassConn;
                    connectionString = connectionString.Replace("##DS##", project.ServerName);
                    connectionString = connectionString.Replace("##UID##", project.UserName);
                    connectionString = connectionString.Replace("##PASS##", project.Password);
                    if (project.Databases != null)
                    {
                        Entities.MetaDataSchema.Database database = Entities.MetaDataSchema.Database.GetByName(project.Databases, databaseName);

                        if (database != null)
                            connectionString = connectionString.Replace("##IC##", database.Name);
                        else
                            connectionString = connectionString.Replace("initial catalog=##IC##;", "");
                    }
                    else
                    {
                        connectionString = connectionString.Replace("initial catalog=##IC##;", "");
                    }
                }
            }
        }
 public abstract void GetDatabases(Project project);
        public Project Connect(DatabaseTypes type,string userName,string password,string database,string serverName,bool winAuth)
        {
            Project project = null;

            try
            {
                project = new Project();
                project.DatabaseType = type;
                project.UserName = userName;
                project.Password = password;
                project.ServerName = serverName;
                project.IsWindowsAuthentication = winAuth;
                SetDatabaseReader(project);
                SetConnectionString(project, database);

                //System.Data.Common.DbConnection conn = null;
                //if (databaseSchemaReader is SQLServerDatabaseExtractor)
                //{
                //    conn = new System.Data.SqlClient.SqlConnection(connectionString);
                //}
                //conn.Open();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return project;
        }
 public abstract void GetFunctions(Project project);
 public abstract void GetStoredProcedures(Project project);
 public abstract void GetViews(Project project);
 public abstract void GetTableRelations(Project project);
 public abstract void GetTables(Project project);