Exemplo n.º 1
0
 public static Boolean CompareDefault(UserDataType origen, UserDataType destino)
 {
     if (destino == null)
     {
         throw new ArgumentNullException("destino");
     }
     if (origen == null)
     {
         throw new ArgumentNullException("origen");
     }
     if ((origen.Default.Name != null) && (destino.Default.Name == null))
     {
         return(false);
     }
     if ((origen.Default.Name == null) && (destino.Default.Name != null))
     {
         return(false);
     }
     if (origen.Default.Name != null)
     {
         if (!origen.Default.Name.Equals(destino.Default.Name))
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 2
0
 public static Boolean CompareRule(UserDataType origin, UserDataType destination)
 {
     if (destination == null)
     {
         throw new ArgumentNullException("destination");
     }
     if (origin == null)
     {
         throw new ArgumentNullException("origin");
     }
     if ((origin.Rule.Name != null) && (destination.Rule.Name == null))
     {
         return(false);
     }
     if ((origin.Rule.Name == null) && (destination.Rule.Name != null))
     {
         return(false);
     }
     if (origin.Rule.Name != null)
     {
         if (!origin.Rule.Name.Equals(destination.Rule.Name))
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 3
0
        public void Fill(Database database, string connectionString, List<MessageLog> messages)
        {
            //not supported in azure yet http://msdn.microsoft.com/en-us/library/ee336233.aspx
            if (database.Info.Version == DatabaseInfo.VersionTypeEnum.SQLServerAzure10) return;

            try
            {
                if (database.Options.Ignore.FilterUserDataType)
                {
                    root.RaiseOnReading(new ProgressEventArgs("Reading UDT...", Constants.READING_UDT));
                    using (SqlConnection conn = new SqlConnection(connectionString))
                    {
                        using (SqlCommand command = new SqlCommand(UserDataTypeCommand.Get(database.Info.Version), conn))
                        {
                            conn.Open();
                            command.CommandTimeout = 0;
                            using (SqlDataReader reader = command.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    root.RaiseOnReadingOne(reader["Name"]);
                                    UserDataType item = new UserDataType(database);
                                    item.Id = (int)reader["tid"];
                                    item.AllowNull = (bool)reader["is_nullable"];
                                    item.Size = (short)reader["max_length"];
                                    item.Name = reader["Name"].ToString();
                                    item.Owner = reader["owner"].ToString();
                                    item.Precision = int.Parse(reader["precision"].ToString());
                                    item.Scale = int.Parse(reader["scale"].ToString());
                                    if (!String.IsNullOrEmpty(reader["defaultname"].ToString()))
                                    {
                                        item.Default.Name = reader["defaultname"].ToString();
                                        item.Default.Owner = reader["defaultowner"].ToString();
                                    }
                                    if (!String.IsNullOrEmpty(reader["rulename"].ToString()))
                                    {
                                        item.Rule.Name = reader["rulename"].ToString();
                                        item.Rule.Owner = reader["ruleowner"].ToString();
                                    }
                                    item.Type = reader["basetypename"].ToString();
                                    item.IsAssembly = (bool)reader["is_assembly_type"];
                                    item.AssemblyId = (int)reader["assembly_id"];
                                    item.AssemblyName = reader["assembly_name"].ToString();
                                    item.AssemblyClass = reader["assembly_class"].ToString();
                                    database.UserTypes.Add(item);
                                }
                            }
                        }
                    }
                    if (database.Options.Ignore.FilterTable)
                        FillColumnsDependencies(database.UserTypes, connectionString);
                }
            }
            catch (Exception ex)
            {
                messages.Add(new MessageLog(ex.Message, ex.StackTrace, MessageLog.LogType.Error));
            }
        }
Exemplo n.º 4
0
        private string SQLDropOlder()
        {
            UserDataType other =
                ((Database)Parent).UserTypes.Find(
                    item =>
                    (item.Status == Enums.ObjectStatusType.DropStatus) &&
                    (item.AssemblyName + "." + item.AssemblyClass).Equals((AssemblyName + "." + AssemblyClass)));

            return(other.ToSqlDrop());
        }
Exemplo n.º 5
0
 public bool Compare(UserDataType obj)
 {
     if (obj == null)
     {
         throw new ArgumentNullException("obj");
     }
     if (Scale != obj.Scale)
     {
         return(false);
     }
     if (Precision != obj.Precision)
     {
         return(false);
     }
     if (AllowNull != obj.AllowNull)
     {
         return(false);
     }
     if (Size != obj.Size)
     {
         return(false);
     }
     if (!Type.Equals(obj.Type))
     {
         return(false);
     }
     if (IsAssembly != obj.IsAssembly)
     {
         return(false);
     }
     if (!AssemblyClass.Equals(obj.AssemblyClass))
     {
         return(false);
     }
     if (!AssemblyName.Equals(obj.AssemblyName))
     {
         return(false);
     }
     if (!CompareDefault(this, obj))
     {
         return(false);
     }
     if (!CompareRule(this, obj))
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 6
0
 private Boolean HasAnotherUDTClass()
 {
     if (IsAssembly)
     {
         /*Si existe otro UDT con el mismo assembly que se va a crear, debe ser borrado ANTES de crearse el nuevo*/
         UserDataType other =
             ((Database)Parent).UserTypes.Find(
                 item =>
                 (item.Status == Enums.ObjectStatusType.DropStatus) &&
                 (item.AssemblyName + "." + item.AssemblyClass).Equals((AssemblyName + "." + AssemblyClass)));
         if (other != null)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Clona el objeto Column en una nueva instancia.
 /// </summary>
 public override ISchemaBase Clone(ISchemaBase parent)
 {
     var item = new UserDataType(parent)
                    {
                        Name = Name,
                        Id = Id,
                        Owner = Owner,
                        Guid = Guid,
                        AllowNull = AllowNull,
                        Precision = Precision,
                        Scale = Scale,
                        Size = Size,
                        Type = Type,
                        Default = Default.Clone(this),
                        Rule = Rule.Clone(this),
                        Dependencys = Dependencys,
                        IsAssembly = IsAssembly,
                        AssemblyClass = AssemblyClass,
                        AssemblyId = AssemblyId,
                        AssemblyName = AssemblyName
                    };
     return item;
 }
Exemplo n.º 8
0
        /// <summary>
        /// Clona el objeto Column en una nueva instancia.
        /// </summary>
        public override ISchemaBase Clone(ISchemaBase parent)
        {
            var item = new UserDataType(parent)
            {
                Name          = Name,
                Id            = Id,
                Owner         = Owner,
                Guid          = Guid,
                AllowNull     = AllowNull,
                Precision     = Precision,
                Scale         = Scale,
                Size          = Size,
                Type          = Type,
                Default       = Default.Clone(this),
                Rule          = Rule.Clone(this),
                Dependencys   = Dependencys,
                IsAssembly    = IsAssembly,
                AssemblyClass = AssemblyClass,
                AssemblyId    = AssemblyId,
                AssemblyName  = AssemblyName
            };

            return(item);
        }
Exemplo n.º 9
0
 public static Boolean CompareDefault(UserDataType origen, UserDataType destino)
 {
     if (destino == null) throw new ArgumentNullException("destino");
     if (origen == null) throw new ArgumentNullException("origen");
     if ((origen.Default.Name != null) && (destino.Default.Name == null)) return false;
     if ((origen.Default.Name == null) && (destino.Default.Name != null)) return false;
     if (origen.Default.Name != null)
         if (!origen.Default.Name.Equals(destino.Default.Name)) return false;
     return true;
 }
Exemplo n.º 10
0
 public bool Compare(UserDataType obj)
 {
     if (obj == null) throw new ArgumentNullException("obj");
     if (Scale != obj.Scale) return false;
     if (Precision != obj.Precision) return false;
     if (AllowNull != obj.AllowNull) return false;
     if (Size != obj.Size) return false;
     if (!Type.Equals(obj.Type)) return false;
     if (IsAssembly != obj.IsAssembly) return false;
     if (!AssemblyClass.Equals(obj.AssemblyClass)) return false;
     if (!AssemblyName.Equals(obj.AssemblyName)) return false;
     if (!CompareDefault(this, obj)) return false;
     if (!CompareRule(this, obj)) return false;
     return true;
 }