public void Fill(Database database, string connectionString) { if (database.Options.Ignore.FilterDDLTriggers) { using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); using (SqlCommand command = new SqlCommand(GetSQL(), conn)) { command.CommandTimeout = 0; using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { Trigger trigger = new Trigger(database); trigger.Text = reader["Text"].ToString(); trigger.Name = reader["Name"].ToString(); trigger.InsteadOf = (bool)reader["is_instead_of_trigger"]; trigger.IsDisabled = (bool)reader["is_disabled"]; trigger.IsDDLTrigger = true; trigger.NotForReplication = (bool)reader["is_not_for_replication"]; trigger.Owner = ""; database.DDLTriggers.Add(trigger); } } } } } }
/// <summary> /// Clona el objeto en una nueva instancia. /// </summary> public override ISchemaBase Clone(ISchemaBase parent) { Trigger trigger = new Trigger(parent); trigger.Text = this.Text; trigger.Status = this.Status; trigger.Name = this.Name; trigger.IsDisabled = this.IsDisabled; trigger.InsteadOf = this.InsteadOf; trigger.NotForReplication = this.NotForReplication; trigger.Owner = this.Owner; trigger.Id = this.Id; trigger.IsDDLTrigger = this.IsDDLTrigger; trigger.Guid = this.Guid; return trigger; }
public void Fill(Database database, string connectionString, List<MessageLog> messages) { int parentId = 0; ISchemaBase parent = null; string type; try { if (database.Options.Ignore.FilterTrigger) { root.RaiseOnReading(new ProgressEventArgs("Reading Triggers...", Constants.READING_TRIGGERS)); using (SqlConnection conn = new SqlConnection(connectionString)) { using (SqlCommand command = new SqlCommand(GetSQL(database.Info.Version, database.Options), conn)) { conn.Open(); command.CommandTimeout = 0; using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { root.RaiseOnReadingOne(reader["Name"]); type = reader["ObjectType"].ToString().Trim(); if (parentId != (int)reader["parent_id"]) { parentId = (int)reader["parent_id"]; if (type.Equals("V")) parent = database.Views.Find(parentId); else parent = database.Tables.Find(parentId); } if (reader["type"].Equals("TR")) { Trigger item = new Trigger(parent); item.Id = (int)reader["object_id"]; item.Name = reader["Name"].ToString(); item.InsteadOf = (bool)reader["is_instead_of_trigger"]; item.IsDisabled = (bool)reader["is_disabled"]; item.IsDDLTrigger = false; item.Owner = reader["Owner"].ToString(); if (database.Options.Ignore.FilterNotForReplication) item.NotForReplication = (bool)reader["is_not_for_replication"]; if (type.Equals("V")) ((View)parent).Triggers.Add(item); else ((Table)parent).Triggers.Add(item); } else { CLRTrigger item = new CLRTrigger(parent); item.Id = (int)reader["object_id"]; item.Name = reader["Name"].ToString(); item.IsDelete = (bool)reader["IsDelete"]; item.IsUpdate = (bool)reader["IsUpdate"]; item.IsInsert = (bool)reader["IsInsert"]; item.Owner = reader["Owner"].ToString(); item.IsAssembly = true; item.AssemblyId = (int)reader["assembly_id"]; item.AssemblyName = reader["assembly_name"].ToString(); item.AssemblyClass = reader["assembly_class"].ToString(); item.AssemblyExecuteAs = reader["ExecuteAs"].ToString(); item.AssemblyMethod = reader["assembly_method"].ToString(); if (type.Equals("V")) ((View)parent).CLRTriggers.Add(item); else ((Table)parent).CLRTriggers.Add(item); /*if (!database.Options.Ignore.FilterIgnoreNotForReplication) trigger.NotForReplication = (bool)reader["is_not_for_replication"];*/ } } } } } } } catch (Exception ex) { messages.Add(new MessageLog(ex.Message, ex.StackTrace, MessageLog.LogType.Error)); } }