private static string GetFilesInFileGroup2008(FileGroup filegroup)
		{
			StringBuilder sql = new StringBuilder();
			sql.Append("select file_id,type,name,physical_name,size,max_size,growth,is_sparse,is_percent_growth ");
			sql.Append("from sys.database_files WHERE data_space_id = " + filegroup.Id.ToString());
			return sql.ToString();
		}
		public static string GetFilesInFileGroup(DatabaseInfo.VersionNumber version, FileGroup filegroup)
		{
			if (version == DatabaseInfo.VersionNumber.SQLServer2000) return GetFilesInFileGroup2000(filegroup);
			if (version == DatabaseInfo.VersionNumber.SQLServer2005) return GetFilesInFileGroup2005(filegroup);
			if (version == DatabaseInfo.VersionNumber.SQLServer2008) return GetFilesInFileGroup2008(filegroup);
			return "";
		}
		private static string GetFilesInFileGroup2000(FileGroup filegroup)
		{
			StringBuilder sql = new StringBuilder();
			sql.Append("select convert(int,fileid) as file_id,type=convert(tinyint,(status&64)/64),name,filename as physical_name,size,maxsize as max_size,growth,convert(bit,0) as is_sparse,is_percent_growth =convert(bit,status & 1048576) ");
			sql.Append("FROM  sysfiles where groupid="+filegroup.Id.ToString());
			return sql.ToString();
		}
Exemplo n.º 4
0
 private static void FillFiles(FileGroup filegroup, string connectionString)
 {
     using (SqlConnection conn = new SqlConnection(connectionString))
     {
         using (SqlCommand command = new SqlCommand(GetSQLFile(filegroup), conn))
         {
             conn.Open();
             using (SqlDataReader reader = command.ExecuteReader())
             {
                 while (reader.Read())
                 {
                     FileGroupFile item = new FileGroupFile(filegroup);
                     item.Id = (int)reader["file_id"];
                     item.Name = reader["name"].ToString();
                     item.Owner = "";
                     item.Growth = (int)reader["growth"];
                     item.IsPercentGrowth = (bool)reader["is_percent_growth"];
                     item.IsSparse = (bool)reader["is_sparse"];
                     item.MaxSize = (int)reader["max_size"];
                     item.PhysicalName = reader["physical_name"].ToString();
                     item.Size = (int)reader["size"];
                     item.Type = (byte)reader["type"];
                     filegroup.Files.Add(item);
                 }
             }
         }
     }
 }
Exemplo n.º 5
0
 public void Fill(Database database, string connectionString)
 {
     try
     {
         if (database.Options.Ignore.FilterTableFileGroup)
         {
             using (SqlConnection conn = new SqlConnection(connectionString))
             {
                 using (SqlCommand command = new SqlCommand(GetSQL(), conn))
                 {
                     conn.Open();
                     using (SqlDataReader reader = command.ExecuteReader())
                     {
                         while (reader.Read())
                         {
                             FileGroup item = new FileGroup(database);
                             item.Id = (int)reader["ID"];
                             item.Name = reader["name"].ToString();
                             item.Owner = "";
                             item.IsDefaultFileGroup = (bool)reader["is_default"];
                             item.IsReadOnly = (bool)reader["is_read_only"];
                             item.IsFileStream = reader["type"].Equals("FD");
                             FillFiles(item,connectionString);
                             database.FileGroups.Add(item);
                         }
                     }
                 }
             }
         }
     }
     catch
     {
         throw;
     }
 }
Exemplo n.º 6
0
 public static Boolean Compare(FileGroup origen, FileGroup destino)
 {
     if (destino == null) throw new ArgumentNullException("destino");
     if (origen == null) throw new ArgumentNullException("origen");
     if (origen.IsReadOnly != destino.IsReadOnly) return false;
     if (origen.IsDefaultFileGroup != destino.IsDefaultFileGroup) return false;
     if (origen.IsFileStream != destino.IsFileStream) return false;
     return true;
 }
Exemplo n.º 7
0
        /// <summary>
        /// Clona el objeto FileGroups en una nueva instancia.
        /// </summary>
        public FileGroupFiles Clone(FileGroup parentObject)
        {
            FileGroupFiles columns = new FileGroupFiles(parentObject);

            for (int index = 0; index < this.Count; index++)
            {
                columns.Add((FileGroupFile)this[index].Clone(parentObject));
            }
            return(columns);
        }
Exemplo n.º 8
0
 public override ISchemaBase Clone(ISchemaBase parent)
 {
     FileGroup file = new FileGroup(parent);
     file.IsDefaultFileGroup = this.IsDefaultFileGroup;
     file.IsReadOnly = this.IsReadOnly;
     file.Name = this.Name;
     file.Id = this.Id;
     file.Files = this.Files.Clone(file);
     file.Guid = this.Guid;
     file.IsFileStream = this.IsFileStream;
     return file;
 }
Exemplo n.º 9
0
        public override ISchemaBase Clone(ISchemaBase parent)
        {
            FileGroup file = new FileGroup(parent);

            file.IsDefaultFileGroup = this.IsDefaultFileGroup;
            file.IsReadOnly         = this.IsReadOnly;
            file.Name         = this.Name;
            file.Id           = this.Id;
            file.Files        = this.Files.Clone(file);
            file.Guid         = this.Guid;
            file.IsFileStream = this.IsFileStream;
            return(file);
        }
Exemplo n.º 10
0
 public static Boolean Compare(FileGroup origen, FileGroup destino)
 {
     if (destino == null)
     {
         throw new ArgumentNullException("destino");
     }
     if (origen == null)
     {
         throw new ArgumentNullException("origen");
     }
     if (origen.IsReadOnly != destino.IsReadOnly)
     {
         return(false);
     }
     if (origen.IsDefaultFileGroup != destino.IsDefaultFileGroup)
     {
         return(false);
     }
     if (origen.IsFileStream != destino.IsFileStream)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 11
0
 private static string GetSQLFile(FileGroup filegroup)
 {
     string sql;
     sql = "select file_id,";
     sql += "type,";
     sql += "name,";
     sql += "physical_name,";
     sql += "size,";
     sql += "max_size,";
     sql += "growth,";
     sql += "is_sparse,";
     sql += "is_percent_growth ";
     sql += "from sys.database_files WHERE data_space_id = " + filegroup.Id.ToString();
     return sql;
 }
Exemplo n.º 12
0
 /// <summary>
 /// Constructor de la clase.
 /// </summary>
 /// <param name="parent">
 /// Objeto Database padre.
 /// </param>
 public FileGroupFiles(FileGroup parent)
 {
     this.Parent = parent;
 }