コード例 #1
0
ファイル: AssemblyFile.cs プロジェクト: modulexcite/SQLoogle
 public AssemblyFile(ISchemaBase parent, AssemblyFile assemblyFile, Enums.ObjectStatusType status)
     : base(parent, Enums.ObjectType.AssemblyFile)
 {
     this.Name = assemblyFile.Name;
     this.content = assemblyFile.content;
     this.Status = status;
 }
コード例 #2
0
ファイル: FormatCode.cs プロジェクト: pclancy/ODBX
        public static string FormatAlter(string ObjectType, string body, ISchemaBase item, Boolean quitSchemaBinding)
        {
            string prevText = null;
            try
            {
                prevText = (string)body.Clone();
                SearchItem sitem = FindCreate(ObjectType, item, prevText);
                Regex regAlter = new Regex("CREATE");

                if (!quitSchemaBinding)
                    return regAlter.Replace(sitem.Body, "ALTER", 1, sitem.FindPosition);
                    //return prevText.Substring(0, iFind) + "ALTER " + sitem.ObjectType + " " + prevText.Substring(iFind + sitem.ObjectType.Length + 7, prevText.Length - (iFind + sitem.ObjectType.Length + 7)).TrimStart();
                else
                {
                    string text = regAlter.Replace(sitem.Body, "ALTER", 1, sitem.FindPosition);
                    Regex regex = new Regex("WITH SCHEMABINDING", RegexOptions.IgnoreCase);
                    return regex.Replace(text, "");
                }
                //return "";
            }
            catch
            {
                return prevText;
            }
        }
コード例 #3
0
 public CLRFunction(ISchemaBase parent)
     : base(parent, Enums.ObjectType.CLRFunction, Enums.ScripActionType.AddFunction, Enums.ScripActionType.DropFunction)
 {
     parameters = new List<Parameter>();
     returnType = new Parameter();
     isAggrFunc = false;
 }
コード例 #4
0
ファイル: Index.cs プロジェクト: elayaraja007/sql-dbdiff
 public override ISchemaBase Clone(ISchemaBase parent)
 {
     Index index = new Index(parent)
                       {
                           AllowPageLocks = this.AllowPageLocks,
                           AllowRowLocks = this.AllowRowLocks,
                           Columns = this.Columns.Clone(),
                           FillFactor = this.FillFactor,
                           FileGroup = this.FileGroup,
                           Id = this.Id,
                           IgnoreDupKey = this.IgnoreDupKey,
                           IsAutoStatistics = this.IsAutoStatistics,
                           IsDisabled = this.IsDisabled,
                           IsPadded = this.IsPadded,
                           IsPrimaryKey = this.IsPrimaryKey,
                           IsUniqueKey = this.IsUniqueKey,
                           Name = this.Name,
                           SortInTempDb = this.SortInTempDb,
                           Status = this.Status,
                           Type = this.Type,
                           Owner = this.Owner,
                           FilterDefintion = this.FilterDefintion
                       };
     ExtendedProperties.ForEach(item => index.ExtendedProperties.Add(item));
     return index;
 }
コード例 #5
0
 public UserDataType(ISchemaBase parent)
     : base(parent, Enums.ObjectType.UserDataType)
 {
     Default = new Default(this);
     Rule = new Rule(this);
     Dependencys = new List<ObjectDependency>();
 }
コード例 #6
0
ファイル: View.cs プロジェクト: mi-tettamanti/opendbiff
 public View(ISchemaBase parent)
     : base(parent, Enums.ObjectType.View, Enums.ScripActionType.AddView, Enums.ScripActionType.DropView)
 {
     Indexes = new SchemaList<Index, View>(this, ((Database)parent).AllObjects);
     Triggers = new SchemaList<Trigger, View>(this, ((Database)parent).AllObjects);
     CLRTriggers = new SchemaList<CLRTrigger, View>(this, ((Database)parent).AllObjects);
 }
コード例 #7
0
ファイル: TableOption.cs プロジェクト: facingup/opendbdiff
 /// <summary>
 /// Clona el objeto en una nueva instancia.
 /// </summary>
 public override ISchemaBase Clone(ISchemaBase parent)
 {
     TableOption option = new TableOption(parent);
     option.Name = this.Name;
     option.Status = this.Status;
     option.Value = this.Value;
     return option;
 }
コード例 #8
0
ファイル: Default.cs プロジェクト: modulexcite/SQLoogle
 public new Default Clone(ISchemaBase parent)
 {
     Default item = new Default(parent);
     item.Id = this.Id;
     item.Name = this.Name;
     item.Owner = this.Owner;
     item.Value = this.Value;
     return item;
 }
コード例 #9
0
ファイル: Dependencies.cs プロジェクト: qxguoxing/OpenDBDiff
        public void Add(Database database, int objectId, ISchemaBase objectSchema)
        {
            Dependency dependency = new Dependency();

            dependency.ObjectId = objectId;
            dependency.FullName = objectSchema.FullName;
            dependency.Type     = objectSchema.ObjectType;
            this.Database       = database;
            base.Add(dependency);
        }
コード例 #10
0
ファイル: Synonym.cs プロジェクト: pclancy/ODBX
 public override ISchemaBase Clone(ISchemaBase parent)
 {
     Synonym item = new Synonym(parent);
     item.Id = this.Id;
     item.Name = this.Name;
     item.Owner = this.Owner;
     item.Value = this.Value;
     item.Guid = this.Guid;
     return item;
 }
コード例 #11
0
        public void Add(int tableId, int columnId, int ownerTableId, ISchemaBase constraint)
        {
            ConstraintDependence depends = new ConstraintDependence();

            depends.ColumnId         = columnId;
            depends.TableId          = tableId;
            depends.OwnerTableId     = ownerTableId;
            depends.ObjectConstraint = constraint; //SE COMENTO SIMPLEMENTE QUE QUE SIGA, HAY QUE ARREGLARLO!!!
            base.Add(depends);
        }
コード例 #12
0
ファイル: Default.cs プロジェクト: ftabangcura/sql-dbdiff
        public Default Clone(ISchemaBase parent)
        {
            Default item = new Default(parent);

            item.Id    = this.Id;
            item.Name  = this.Name;
            item.Owner = this.Owner;
            item.Value = this.Value;
            return(item);
        }
コード例 #13
0
ファイル: Dependencies.cs プロジェクト: sbane/SQLoogle
        public void Add(Database database, int objectId, ISchemaBase objectSchema)
        {
            Dependence depends = new Dependence();

            depends.ObjectId = objectId;
            depends.FullName = objectSchema.FullName;
            depends.Type     = objectSchema.ObjectType;
            this.database    = database;
            base.Add(depends);
        }
コード例 #14
0
ファイル: Rule.cs プロジェクト: pclancy/ODBX
 public Rule Clone(ISchemaBase parent)
 {
     Rule item = new Rule(parent);
     item.Id = this.Id;
     item.Name = this.Name;
     item.Owner = this.Owner;
     item.Text = this.Text;
     item.Guid = this.Guid;
     return item;
 }
コード例 #15
0
ファイル: SqlAction.cs プロジェクト: facingup/opendbdiff
 public SqlAction(ISchemaBase item)
 {
     if ((item.ObjectType == Enums.ObjectType.Column) || (item.ObjectType == Enums.ObjectType.Index) || (item.ObjectType == Enums.ObjectType.Constraint))
         this.name = item.Name;
     else
         this.name = item.FullName;
     this.action = item.Status;
     this.type = item.ObjectType;
     childs = new List<SqlAction>();
 }
コード例 #16
0
        public void FillCheck(Database database, string connectionString)
        {
            int         parentId = 0;
            ISchemaBase table    = null;

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                using (SqlCommand command = new SqlCommand(ConstraintSQLCommand.GetCheck(database.Info.Version), conn))
                {
                    root.RaiseOnReading(new ProgressEventArgs("Reading constraint...", Constants.READING_CONSTRAINTS));
                    conn.Open();
                    command.CommandTimeout = 0;
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        Constraint item = null;
                        while (reader.Read())
                        {
                            root.RaiseOnReadingOne(reader["Name"]);
                            if (parentId != (int)reader["parent_object_id"])
                            {
                                parentId = (int)reader["parent_object_id"];
                                if (reader["ObjectType"].ToString().Trim().Equals("U"))
                                {
                                    table = database.Tables.Find(parentId);
                                }
                                else
                                {
                                    table = database.TablesTypes.Find(parentId);
                                }
                            }
                            item             = new Constraint(table);
                            item.Id          = (int)reader["id"];
                            item.Name        = reader["Name"].ToString();
                            item.Type        = Constraint.ConstraintType.Check;
                            item.Definition  = reader["Definition"].ToString();
                            item.WithNoCheck = (bool)reader["WithCheck"];
                            item.IsDisabled  = (bool)reader["is_disabled"];
                            item.Owner       = reader["Owner"].ToString();
                            if (database.Options.Ignore.FilterNotForReplication)
                            {
                                item.NotForReplication = (bool)reader["is_not_for_replication"];
                            }
                            if (reader["ObjectType"].ToString().Trim().Equals("U"))
                            {
                                ((Table)table).Constraints.Add(item);
                            }
                            else
                            {
                                ((TableType)table).Constraints.Add(item);
                            }
                        }
                    }
                }
            }
        }
コード例 #17
0
        /// <summary>
        /// Busca la primer entrada con el nombre completo dentro de una funcion, store, vista, trigger o rule.
        /// Ignora los comentarios.
        /// </summary>
        private static SearchItem FindCreate(string ObjectType, ISchemaBase item, string prevText)
        {
            SearchItem sitem = new SearchItem();
            Regex      regex = new Regex(@"((/\*)(\w|\s|\d|\[|\]|\.)*(\*/))|((\-\-)(.)*)", RegexOptions.IgnoreCase);
            Regex      reg2  = new Regex(@"CREATE( )+" + ObjectType + @"(\s|\r|\n|\t|\w|\/|\*|-|@|_|&|#)*((\[)?" + item.Owner + @"(\])?((\s)*)?\.)?((\s)*)?(\[)?" + item.Name + @"(\])?", (RegexOptions)((int)RegexOptions.IgnoreCase + (int)RegexOptions.Multiline));
            //Regex reg2_1 = new Regex(@"CREATE( )+" + ObjectType + @"(\s|\r|\n|\t|\w|\/|\*|-|@|_|&|#)*((\[)?" + item.Name + @"(\])?", (RegexOptions)((int)RegexOptions.IgnoreCase + (int)RegexOptions.Multiline));

            Regex reg3 = new Regex(@"((\[)?" + item.Owner + @"(\])?\.)?((\s)+\.)?(\s)*(\[)?" + item.Name + @"(\])?", RegexOptions.IgnoreCase);
            Regex reg4 = new Regex(@"( )*\[");

            MatchCollection abiertas   = regex.Matches(prevText);
            Boolean         finish     = false;
            int             indexStart = 0;
            int             indexBegin = 0;
            int             iAux       = -1;

            while (!finish)
            {
                Match match = reg2.Match(prevText, indexBegin);
                if (match.Success)
                {
                    iAux = match.Index;
                }

                else
                {
                    iAux = -1;
                }

                if ((abiertas.Count == indexStart) || (!match.Success))
                {
                    finish = true;
                }
                else
                {
                    if ((iAux < abiertas[indexStart].Index) || (iAux > abiertas[indexStart].Index + abiertas[indexStart].Length))
                    {
                        finish = true;
                    }
                    else
                    {
                        indexBegin = iAux + 1;
                        indexStart++;
                    }
                }
            }
            string result = reg3.Replace(prevText, " " + item.FullName, 1, iAux + 1);

            if (iAux != -1)
            {
                sitem.Body = reg4.Replace(result, " [", 1, iAux);
            }
            sitem.FindPosition = iAux;
            return(sitem);
        }
コード例 #18
0
ファイル: StoreProcedure.cs プロジェクト: facingup/opendbdiff
 /// <summary>
 /// Clona el objeto en una nueva instancia.
 /// </summary>
 public override ISchemaBase Clone(ISchemaBase parent)
 {
     StoreProcedure item = new StoreProcedure(parent);
     item.Text = this.Text;
     item.Status = this.Status;
     item.Name = this.Name;
     item.Id = this.Id;
     item.Owner = this.Owner;
     item.Guid = this.Guid;
     return item;
 }
コード例 #19
0
        /// <summary>
        /// Find the first entry with the full name within a function, store, view, trigger or rule.
        /// Ignore comments.
        /// </summary>
        public static SearchItem FindAndNormalizeCreate(ISchemaBase item, string prevText)
        {
            var result = FindCreate(prevText) ?? throw new InvalidOperationException($"Could not find the CREATE statement for object '{item.Name}'");

            // normalize the object name for better comparison
            var body = prevText.Substring(0, result.TypeEndPosition + 1) + " " + item.FullName + prevText.Substring(result.NameEndPosition + 1);

            return(new SearchItem {
                Body = body, FindPosition = result.CreateBeginPosition
            });
        }
コード例 #20
0
ファイル: Synonym.cs プロジェクト: wushian/OpenDBDiff
        public override ISchemaBase Clone(ISchemaBase parent)
        {
            Synonym item = new Synonym(parent);

            item.Id    = this.Id;
            item.Name  = this.Name;
            item.Owner = this.Owner;
            item.Value = this.Value;
            item.Guid  = this.Guid;
            return(item);
        }
コード例 #21
0
        public new Rule Clone(ISchemaBase parent)
        {
            Rule item = new Rule(parent);

            item.Id    = this.Id;
            item.Name  = this.Name;
            item.Owner = this.Owner;
            item.Text  = this.Text;
            item.Guid  = this.Guid;
            return(item);
        }
コード例 #22
0
ファイル: StoreProcedure.cs プロジェクト: Thomas89/SQLoogle
        /// <summary>
        /// Clona el objeto en una nueva instancia.
        /// </summary>
        public override ISchemaBase Clone(ISchemaBase parent)
        {
            StoreProcedure item = new StoreProcedure(parent);

            item.Text   = this.Text;
            item.Status = this.Status;
            item.Name   = this.Name;
            item.Id     = this.Id;
            item.Owner  = this.Owner;
            item.Guid   = this.Guid;
            return(item);
        }
コード例 #23
0
ファイル: FileGroup.cs プロジェクト: facingup/opendbdiff
 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;
 }
コード例 #24
0
ファイル: XMLSchema.cs プロジェクト: modulexcite/SQLoogle
 /// <summary>
 /// Clona el objeto en una nueva instancia.
 /// </summary>
 public new XMLSchema Clone(ISchemaBase parent)
 {
     XMLSchema item = new XMLSchema(parent);
     item.Text = this.Text;
     item.Status = this.Status;
     item.Name = this.Name;
     item.Id = this.Id;
     item.Owner = this.Owner;
     item.Guid = this.Guid;
     item.Dependencys = this.Dependencys;
     return item;
 }
コード例 #25
0
 public new PartitionFunction Clone(ISchemaBase parent)
 {
     PartitionFunction item = new PartitionFunction(parent);
     item.Id = this.Id;
     item.IsBoundaryRight = this.IsBoundaryRight;
     item.Name = this.Name;
     item.Precision = this.Precision;
     item.Scale = this.Scale;
     item.Size = this.Size;
     item.Type = this.Type;
     this.Values.ForEach(value => { item.Values.Add(value); });
     return item;
 }
コード例 #26
0
        public IndexColumn Clone(ISchemaBase parent)
        {
            IndexColumn column = new IndexColumn(parent);

            column.Id         = this.Id;
            column.IsIncluded = this.IsIncluded;
            column.Name       = this.Name;
            column.Order      = this.Order;
            column.Status     = this.Status;
            column.KeyOrder   = this.KeyOrder;
            column.DataTypeId = this.DataTypeId;
            return(column);
        }
コード例 #27
0
ファイル: FileGroup.cs プロジェクト: ftabangcura/sql-dbdiff
        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);
        }
コード例 #28
0
        /// <summary>
        /// Clona el objeto en una nueva instancia.
        /// </summary>
        public new XMLSchema Clone(ISchemaBase parent)
        {
            XMLSchema item = new XMLSchema(parent);

            item.Text        = this.Text;
            item.Status      = this.Status;
            item.Name        = this.Name;
            item.Id          = this.Id;
            item.Owner       = this.Owner;
            item.Guid        = this.Guid;
            item.Dependencys = this.Dependencys;
            return(item);
        }
コード例 #29
0
ファイル: Table.cs プロジェクト: Thomas89/SQLoogle
 public Table(ISchemaBase parent)
     : base(parent, Enums.ObjectType.Table)
 {
     dependenciesCount = -1;
     columns           = new Columns <Table>(this);
     Constraints       = new SchemaList <Constraint, Table>(this, ((Database)parent).AllObjects);
     Options           = new SchemaList <TableOption, Table>(this);
     Triggers          = new SchemaList <Trigger, Table>(this, ((Database)parent).AllObjects);
     CLRTriggers       = new SchemaList <CLRTrigger, Table>(this, ((Database)parent).AllObjects);
     Indexes           = new SchemaList <Index, Table>(this, ((Database)parent).AllObjects);
     Partitions        = new SchemaList <TablePartition, Table>(this, ((Database)parent).AllObjects);
     FullTextIndex     = new SchemaList <FullTextIndex, Table>(this);
 }
コード例 #30
0
ファイル: Database.cs プロジェクト: cmontana88/OpenDBDiff
        public override ISchemaBase Clone(ISchemaBase parent)
        {
            var item = new Database
            {
                Assemblies = Assemblies.Clone(this),
                Tables     = Tables.Clone(this),
                Procedures = Procedures.Clone(this),
                Functions  = Functions.Clone(this),
                Views      = Views.Clone(this),
                AllObjects = AllObjects
            };

            return(item);
        }
コード例 #31
0
        private SQLScriptList RebuildDependencys(Table table)
        {
            var list = new SQLScriptList();
            List <ISchemaBase> items = ((Database)table.Parent).Dependencies.Find(table.Id);

            items.ForEach(item => {
                ISchemaBase realItem = ((Database)table.Parent).Find(item.FullName);
                if (realItem.IsCodeType)
                {
                    list.AddRange(((ICode)realItem).Rebuild());
                }
            });
            return(list);
        }
コード例 #32
0
ファイル: Function.cs プロジェクト: elayaraja007/sql-dbdiff
 /// <summary>
 /// Clona el objeto en una nueva instancia.
 /// </summary>
 public override ISchemaBase Clone(ISchemaBase parent)
 {
     Function item = new Function(parent);
     item.Text = this.Text;
     item.Status = this.Status;
     item.Name = this.Name;
     item.Id = this.Id;
     item.Owner = this.Owner;
     item.Guid = this.Guid;
     item.IsSchemaBinding = this.IsSchemaBinding;
     this.DependenciesIn.ForEach(dep => item.DependenciesIn.Add(dep));
     this.DependenciesOut.ForEach(dep => item.DependenciesOut.Add(dep));
     return item;
 }
コード例 #33
0
 public override ISchemaBase Clone(ISchemaBase parent)
 {
     FileGroupFile file = new FileGroupFile(parent);
     file.Growth = this.Growth;
     file.Id = this.Id;
     file.IsPercentGrowth = this.IsPercentGrowth;
     file.IsSparse = this.IsSparse;
     file.MaxSize = this.MaxSize;
     file.Name = this.Name;
     file.PhysicalName = this.PhysicalName;
     file.Size = this.Size;
     file.Type = this.Type;
     return file;
 }
コード例 #34
0
        public new PartitionFunction Clone(ISchemaBase parent)
        {
            PartitionFunction item = new PartitionFunction(parent);

            item.Id = this.Id;
            item.IsBoundaryRight = this.IsBoundaryRight;
            item.Name            = this.Name;
            item.Precision       = this.Precision;
            item.Scale           = this.Scale;
            item.Size            = this.Size;
            item.Type            = this.Type;
            this.Values.ForEach(value => { item.Values.Add(value); });
            return(item);
        }
コード例 #35
0
ファイル: SqlAction.cs プロジェクト: posttk421/OpenDBDiff
 public SqlAction(ISchemaBase item)
 {
     if ((item.ObjectType == Enums.ObjectType.Column) || (item.ObjectType == Enums.ObjectType.Index) || (item.ObjectType == Enums.ObjectType.Constraint))
     {
         this.Name = item.Name;
     }
     else
     {
         this.Name = item.FullName;
     }
     this.Action = item.Status;
     this.Type   = item.ObjectType;
     Childs      = new List <SqlAction>();
 }
コード例 #36
0
 public bool IsMatch(ISchemaBase item)
 {
     if (item.ObjectType.Equals(this.ObjectType) && ValueSatisfiesCriteria(item.Name, this.FilterPattern))
     {
         return(true);
     }
     else if (this.IsSchemaMatch(item))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #37
0
ファイル: Trigger.cs プロジェクト: elayaraja007/sql-dbdiff
 /// <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;
 }
コード例 #38
0
ファイル: View.cs プロジェクト: mi-tettamanti/opendbiff
 /// <summary>
 /// Clona el objeto en una nueva instancia.
 /// </summary>
 public override ISchemaBase Clone(ISchemaBase parent)
 {
     View item = new View(parent);
     item.Text = this.Text;
     item.Status = this.Status;
     item.Name = this.Name;
     item.Id = this.Id;
     item.Owner = this.Owner;
     item.IsSchemaBinding = this.IsSchemaBinding;
     item.DependenciesIn  = this.DependenciesIn;
     item.DependenciesOut = this.DependenciesOut;
     item.Indexes = this.Indexes.Clone(item);
     item.Triggers = this.Triggers.Clone(item);
     return item;
 }
コード例 #39
0
ファイル: Code.cs プロジェクト: ftabangcura/sql-dbdiff
 public Code(ISchemaBase parent, Enums.ObjectType type, Enums.ScripActionType addAction, Enums.ScripActionType dropAction)
     : base(parent, type)
 {
     dependenciesIn  = new List <String>();
     dependenciesOut = new List <String>();
     typeName        = GetObjectTypeName(ObjectType);
     /*Por el momento, solo los Assemblys manejan deep de dependencias*/
     if (this.ObjectType == Enums.ObjectType.Assembly)
     {
         deepMax = 501;
         deepMin = 500;
     }
     this.addAction  = addAction;
     this.dropAction = dropAction;
 }
コード例 #40
0
ファイル: Code.cs プロジェクト: facingup/opendbdiff
 public Code(ISchemaBase parent, Enums.ObjectType type, Enums.ScripActionType addAction, Enums.ScripActionType dropAction)
     : base(parent, type)
 {
     dependenciesIn = new List<String>();
     dependenciesOut = new List<String>();
     typeName = GetObjectTypeName(ObjectType);
     /*Por el momento, solo los Assemblys manejan deep de dependencias*/
     if (this.ObjectType == Enums.ObjectType.Assembly)
     {
         deepMax = 501;
         deepMin = 500;
     }
     this.addAction = addAction;
     this.dropAction = dropAction;
 }
コード例 #41
0
        public override ISchemaBase Clone(ISchemaBase parent)
        {
            FileGroupFile file = new FileGroupFile(parent);

            file.Growth          = this.Growth;
            file.Id              = this.Id;
            file.IsPercentGrowth = this.IsPercentGrowth;
            file.IsSparse        = this.IsSparse;
            file.MaxSize         = this.MaxSize;
            file.Name            = this.Name;
            file.PhysicalName    = this.PhysicalName;
            file.Size            = this.Size;
            file.Type            = this.Type;
            return(file);
        }
コード例 #42
0
        /// <summary>
        /// Clona el objeto en una nueva instancia.
        /// </summary>
        public override ISchemaBase Clone(ISchemaBase parent)
        {
            Function item = new Function(parent);

            item.Text            = this.Text;
            item.Status          = this.Status;
            item.Name            = this.Name;
            item.Id              = this.Id;
            item.Owner           = this.Owner;
            item.Guid            = this.Guid;
            item.IsSchemaBinding = this.IsSchemaBinding;
            this.DependenciesIn.ForEach(dep => item.DependenciesIn.Add(dep));
            this.DependenciesOut.ForEach(dep => item.DependenciesOut.Add(dep));
            return(item);
        }
コード例 #43
0
        /// <summary>
        /// Clona el objeto Column en una nueva instancia.
        /// </summary>
        public Column Clone(ISchemaBase parent)
        {
            Column col;

            if (parent == null)
            {
                col = new Column(this.Parent);
            }
            else
            {
                col = new Column(parent);
            }
            col.ComputedFormula = this.ComputedFormula;
            col.DataUserTypeId  = this.DataUserTypeId;
            col.Id                       = this.Id;
            col.Guid                     = this.Guid;
            col.Owner                    = this.Owner;
            col.IdentityIncrement        = this.IdentityIncrement;
            col.IdentitySeed             = this.IdentitySeed;
            col.IsIdentity               = this.IsIdentity;
            col.IsIdentityForReplication = this.IsIdentityForReplication;
            col.IsComputed               = this.IsComputed;
            col.IsRowGuid                = this.IsRowGuid;
            col.IsPersisted              = this.IsPersisted;
            col.IsFileStream             = this.IsFileStream;
            col.IsSparse                 = this.IsSparse;
            col.IsXmlDocument            = this.IsXmlDocument;
            col.IsUserDefinedType        = this.IsUserDefinedType;
            col.HasComputedDependencies  = this.HasComputedDependencies;
            col.HasIndexDependencies     = this.HasIndexDependencies;
            col.Name                     = this.Name;
            col.IsNullable               = this.IsNullable;
            col.Position                 = this.Position;
            col.Precision                = this.Precision;
            col.Scale                    = this.Scale;
            col.Collation                = this.Collation;
            col.Size                     = this.Size;
            col.Status                   = this.Status;
            col.Type                     = this.Type;
            col.XmlSchema                = this.XmlSchema;
            col.Default                  = this.Default.Clone(this);
            col.Rule                     = this.Rule.Clone(this);
            if (this.DefaultConstraint != null)
            {
                col.DefaultConstraint = this.DefaultConstraint.Clone(this);
            }
            return(col);
        }
コード例 #44
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            ISchemaBase item = ((ISchemaBase)e.Node.Tag);

            if (item != null)
            {
                if (item.ObjectType == Enums.ObjectType.Table)
                {
                    ReadPropertys(item.GetType(), e.Node.Nodes, item);
                }
                if (OnSelectItem != null)
                {
                    OnSelectItem(item.FullName);
                }
            }
        }
コード例 #45
0
ファイル: FullTextIndex.cs プロジェクト: pclancy/ODBX
 public override ISchemaBase Clone(ISchemaBase parent)
 {
     FullTextIndex index = new FullTextIndex(parent);
     index.ChangeTrackingState = this.ChangeTrackingState;
     index.FullText = this.FullText;
     index.Name = this.Name;
     index.FileGroup = this.FileGroup;
     index.Id = this.Id;
     index.Index = this.Index;
     index.IsDisabled = this.IsDisabled;
     index.Status = this.Status;
     index.Owner = this.Owner;
     index.Columns = this.Columns;
     this.ExtendedProperties.ForEach(item => index.ExtendedProperties.Add(item));
     return index;
 }
コード例 #46
0
ファイル: FormatCode.cs プロジェクト: pclancy/ODBX
 public static string FormatCreate(string ObjectType, string body, ISchemaBase item)
 {
     try
     {
         string prevText = (string)body.Clone();
         prevText = FindCreate(ObjectType, item, prevText).Body;
         if (String.IsNullOrEmpty(prevText))
             prevText = body;
         prevText = CleanLast(prevText);
         return SmartGO(prevText);
     }
     catch
     {
         return SmartGO(CleanLast(body));
     }
 }
コード例 #47
0
ファイル: Trigger.cs プロジェクト: wangqun2494/Open-DBDiff
        /// <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);
        }
コード例 #48
0
        public void Add(ISchemaBase item)
        {
            if (objectTypes.ContainsKey(item.FullName.ToUpper()))
                objectTypes.Remove(item.FullName.ToUpper());
            objectTypes.Add(item.FullName.ToUpper(), item.ObjectType);
            if ((item.ObjectType == Enums.ObjectType.Constraint) || (item.ObjectType == Enums.ObjectType.Index) || (item.ObjectType == Enums.ObjectType.Trigger) || (item.ObjectType == Enums.ObjectType.CLRTrigger))
            {
                if (objectParent.ContainsKey(item.FullName.ToUpper()))
                    objectParent.Remove(item.FullName.ToUpper());
                objectParent.Add(item.FullName.ToUpper(), item.Parent.FullName);

                if (objectId.ContainsKey(item.Id))
                    objectId.Remove(item.Id);
                objectId.Add(item.Id, item.FullName);
            }
        }
コード例 #49
0
 private void ReadProperties(Type item, TreeNodeCollection nodes, ISchemaBase schema)
 {
     PropertyInfo[] pi = item.GetProperties();
     nodes.Clear();
     foreach (PropertyInfo p in pi)
     {
         object[] attrs = p.GetCustomAttributes(typeof(ShowItemAttribute), true);
         if (attrs.Length > 0)
         {
             ShowItemAttribute show = (ShowItemAttribute)attrs[0];
             TreeNode          node = nodes.Add(p.Name, show.Name);
             node.ImageKey = "Folder";
             ReadPropertyDetail(node, p, schema, show);
         }
     }
 }
コード例 #50
0
ファイル: View.cs プロジェクト: wushian/OpenDBDiff
        /// <summary>
        /// Clona el objeto en una nueva instancia.
        /// </summary>
        public override ISchemaBase Clone(ISchemaBase parent)
        {
            View item = new View(parent);

            item.Text            = this.Text;
            item.Status          = this.Status;
            item.Name            = this.Name;
            item.Id              = this.Id;
            item.Owner           = this.Owner;
            item.IsSchemaBinding = this.IsSchemaBinding;
            item.DependenciesIn  = this.DependenciesIn;
            item.DependenciesOut = this.DependenciesOut;
            item.Indexes         = this.Indexes.Clone(item);
            item.Triggers        = this.Triggers.Clone(item);
            return(item);
        }
コード例 #51
0
ファイル: Updater.cs プロジェクト: posttk421/OpenDBDiff
        public static string alter(ISchemaBase target, string connectionString)
        {
            var db = target.RootParent as IDatabase;

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                if (db != null && DialogResult.Yes != MessageBox.Show(String.Format("Alter {0} {1} in {2}..{3}?\n(WARNING: No automatic backup is made!)",
                                                                                    target.ObjectType,
                                                                                    target.Name,
                                                                                    connection.DataSource,
                                                                                    connection.Database), "ALTER Destination?", MessageBoxButtons.YesNo, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button2))
                {
                    return("Cancelled.");
                }

                string        result   = string.Empty;
                SQLScriptList SqlDiff  = target.ToSqlDiff(new List <ISchemaBase>());
                string[]      splitOn  = { "GO" };
                string[]      tempList = SqlDiff.ToSQL().Split(splitOn, StringSplitOptions.RemoveEmptyEntries);
                List <string> scripts  = new List <string>(tempList);

                foreach (string sql in scripts)
                {
                    string script = sql;
                    //script = script.Replace("\r", "");
                    //script = script.Replace("\t", "");
                    //script = script.Replace("\n", " ");
                    if (target.ObjectType == Enums.ObjectType.StoredProcedure)
                    {
                        script = sql.Replace("CREATE PROCEDURE", "ALTER PROCEDURE");
                    }
                    SqlCommand command = new SqlCommand(script, connection);
                    try
                    {
                        connection.Open();
                        command.ExecuteNonQuery();
                        connection.Close();
                    }
                    catch (Exception e)
                    {
                        result += target.Name + ": " + e.Message + "\n\n";
                        connection.Close();
                    }
                }
                return(result);
            }
        }
コード例 #52
0
        private void ReadPropertyDetail(TreeNode node, PropertyInfo p, ISchemaBase schema, ShowItemAttribute attr)
        {
            Color NodeColor = Color.Black;
            IList items     = (IList)p.GetValue(schema, null);

            node.Nodes.Clear();
            int itemChkCount = 0;

            foreach (ISchemaBase item in items)
            {
                if (CanNodeAdd(item))
                {
                    itemChkCount += 1;
                    TreeNode subnode = node.Nodes.Add(item.Id.ToString(), (attr.IsFullName ? item.FullName : item.Name));
                    if (item.Status == Enums.ObjectStatusType.DropStatus)
                    {
                        subnode.ForeColor = Color.Red;
                        NodeColor         = (NodeColor == Color.Black || NodeColor == Color.Red ? Color.Red : Color.Plum);
                    }
                    if (item.Status == Enums.ObjectStatusType.CreateStatus)
                    {
                        subnode.ForeColor = Color.Green;
                        NodeColor         = (NodeColor == Color.Black || NodeColor == Color.Green ? Color.Green : Color.Plum);
                    }
                    if ((item.HasState(Enums.ObjectStatusType.AlterStatus)) || (item.HasState(Enums.ObjectStatusType.DisabledStatus)))
                    {
                        subnode.ForeColor = Color.Blue;
                        NodeColor         = (NodeColor == Color.Black || NodeColor == Color.Blue ? Color.Blue : Color.Plum);
                    }
                    if (item.HasState(Enums.ObjectStatusType.AlterWhitespaceStatus))
                    {
                        subnode.ForeColor = Color.DarkGoldenrod;
                        NodeColor         = (NodeColor == Color.Black || NodeColor == Color.DarkGoldenrod ? Color.DarkGoldenrod : Color.Plum);
                    }
                    if (item.HasState(Enums.ObjectStatusType.RebuildStatus))
                    {
                        subnode.ForeColor = Color.Purple;
                        NodeColor         = (NodeColor == Color.Black || NodeColor == Color.Purple ? Color.Purple : Color.Plum);
                    }
                    subnode.Tag              = item;
                    subnode.ImageKey         = attr.Image;
                    subnode.SelectedImageKey = attr.Image;
                }
            }
            node.Text      = node.Text + " (" + itemChkCount + ")";
            node.ForeColor = NodeColor;
        }
コード例 #53
0
ファイル: Updater.cs プロジェクト: biddyweb/opendbiff
        public static string rebuild(ISchemaBase target, string connectionString)
        {
            SQLScriptList SqlDiff = target.ToSqlDiff();

            string[]      splitOn  = { "GO" };
            string[]      tempList = SqlDiff.ToSQL().Split(splitOn, StringSplitOptions.RemoveEmptyEntries);
            List <string> scripts  = new List <string>(tempList);
            string        result   = string.Empty;
            string        script   = scripts[0];

            if (target.ObjectType == Enums.ObjectType.Table)
            {
                script = script.Replace("CREATE TABLE", "ALTER TABLE");
            }
            MessageBox.Show(script);
            return(result);
        }
コード例 #54
0
ファイル: Updater.cs プロジェクト: pclancy/ODBX
        public static string alter(ISchemaBase target, string connectionString)
        {
            var db = target.RootParent as Database;
            if (db != null && DialogResult.Yes != MessageBox.Show(String.Format("Alter {0} {1} in {2}..{3}?\n(WARNING: No automatic backup is made!)",
                    target.ObjectType,
                    target.Name,
                    db.Info.Server,
                    db.Info.Database), "ALTER Destination?", MessageBoxButtons.YesNo, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button2))
            {
                return "Cancelled.";
            }

            string result = string.Empty;

            SqlConnection connection = new SqlConnection(connectionString);
            SQLScriptList SqlDiff = target.ToSqlDiff();
            string[] splitOn = {"GO"};
            string[] tempList = SqlDiff.ToSQL().Split(splitOn, StringSplitOptions.RemoveEmptyEntries);
            List<string> scripts = new List<string>(tempList);

            foreach (string sql in scripts)
            {
                string script = sql;
                //script = script.Replace("\r", "");
                //script = script.Replace("\t", "");
                //script = script.Replace("\n", " ");
                if (target.ObjectType == Enums.ObjectType.StoreProcedure)
                {
                    script = sql.Replace("CREATE PROCEDURE", "ALTER PROCEDURE");
                }
                SqlCommand command = new SqlCommand(script, connection);
                try
                {
                    connection.Open();
                    command.ExecuteNonQuery();
                    connection.Close();
                }
                catch(Exception e)
                {
                    result += target.Name + ": " + e.Message + "\n\n";
                    connection.Close();
                }
            }
            return result;
        }
コード例 #55
0
ファイル: Assembly.cs プロジェクト: facingup/opendbdiff
 public override ISchemaBase Clone(ISchemaBase parent)
 {
     Assembly item = new Assembly(parent)
                         {
                             Id = this.Id,
                             Name = this.Name,
                             Owner = this.Owner,
                             Visible = this.Visible,
                             Text = this.Text,
                             PermissionSet = this.PermissionSet,
                             CLRName = this.CLRName,
                             Guid = this.Guid,
                             Files = this.Files
                         };
     this.DependenciesOut.ForEach(dep => item.DependenciesOut.Add(dep));
     this.ExtendedProperties.ForEach(ep => item.ExtendedProperties.Add(ep));
     return item;
 }
コード例 #56
0
ファイル: FormatCode.cs プロジェクト: elayaraja007/sql-dbdiff
        /// <summary>
        /// Busca la primer entrada con el nombre completo dentro de una funcion, store, vista, trigger o rule.
        /// Ignora los comentarios.
        /// </summary>
        private static SearchItem FindCreate(string ObjectType, ISchemaBase item, string prevText)
        {
            SearchItem sitem = new SearchItem();
            Regex regex = new Regex(@"((/\*)(\w|\s|\d|\[|\]|\.)*(\*/))|((\-\-)(.)*)", RegexOptions.IgnoreCase);
            Regex reg2 = new Regex(@"CREATE( )+" + ObjectType + @"(\s|\r|\n|\t|\w|\/|\*|-|@|_|&|#)*((\[)?" + item.Owner + @"(\])?((\s)*)?\.)?((\s)*)?(\[)?" + item.Name + @"(\])?", (RegexOptions)((int)RegexOptions.IgnoreCase + (int)RegexOptions.Multiline));
            //Regex reg2_1 = new Regex(@"CREATE( )+" + ObjectType + @"(\s|\r|\n|\t|\w|\/|\*|-|@|_|&|#)*((\[)?" + item.Name + @"(\])?", (RegexOptions)((int)RegexOptions.IgnoreCase + (int)RegexOptions.Multiline));
            
            Regex reg3 = new Regex(@"((\[)?" + item.Owner + @"(\])?\.)?((\s)+\.)?(\s)*(\[)?" + item.Name + @"(\])?", RegexOptions.IgnoreCase);
            Regex reg4 = new Regex(@"( )*\[");

            MatchCollection abiertas = regex.Matches(prevText);
            Boolean finish = false;
            int indexStart = 0;
            int indexBegin = 0;
            int iAux = -1;

            while (!finish)
            {
                Match match = reg2.Match(prevText, indexBegin);
                if (match.Success)
                    iAux = match.Index;

                    else iAux = -1;                   

                if ((abiertas.Count == indexStart) || (!match.Success))
                    finish = true;
                else
                {
                    if ((iAux < abiertas[indexStart].Index) || (iAux > abiertas[indexStart].Index + abiertas[indexStart].Length))
                        finish = true;
                    else
                    {
                        indexBegin = iAux + 1;
                        indexStart++;
                    }
                }
            }
            string result = reg3.Replace(prevText, " " + item.FullName, 1, iAux + 1);
            if (iAux != -1)
                sitem.Body = reg4.Replace(result, " [", 1, iAux);
            sitem.FindPosition = iAux;
            return sitem;
        }
コード例 #57
0
ファイル: Constraint.cs プロジェクト: modulexcite/SQLoogle
 /// <summary>
 /// Clona el objeto Column en una nueva instancia.
 /// </summary>
 public override ISchemaBase Clone(ISchemaBase parent)
 {
     Constraint col = new Constraint(parent);
     col.Id = this.Id;
     col.Name = this.Name;
     col.NotForReplication = this.NotForReplication;
     col.RelationalTableFullName = this.RelationalTableFullName;
     col.Status = this.Status;
     col.Type = this.Type;
     col.WithNoCheck = this.WithNoCheck;
     col.OnDeleteCascade = this.OnDeleteCascade;
     col.OnUpdateCascade = this.OnUpdateCascade;
     col.Owner = this.Owner;
     col.Columns = this.Columns.Clone();
     col.Index = (Index)this.Index.Clone(parent);
     col.IsDisabled = this.IsDisabled;
     col.Definition = this.Definition;
     col.Guid = this.Guid;
     return col;
 }
コード例 #58
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;
 }
コード例 #59
0
ファイル: Updater.cs プロジェクト: mi-tettamanti/opendbiff
        public static string addNew(ISchemaBase target, string connectionString)
        {
            string result = string.Empty;
            string script = target.ToSqlAdd();
            script = script.Replace("GO", "");
            //script = script.Replace("\r", "");
            //script = script.Replace("\t", "");
            //script = script.Replace("\n", "");

            SqlConnection connection = new SqlConnection(connectionString);
            SqlCommand command = new SqlCommand(script, connection);

            try
            {
                connection.Open();
                command.ExecuteNonQuery();
                connection.Close();
            }
            catch (Exception e)
            {
                result = e.Message + "\n";
            }
            return result;
        }
コード例 #60
0
ファイル: SchemaTreeView.cs プロジェクト: facingup/opendbdiff
 private void ReadPropertys(Type item, TreeNodeCollection nodes, ISchemaBase schema)
 {
     PropertyInfo[] pi = item.GetProperties();
     nodes.Clear();
     foreach (PropertyInfo p in pi)
     {
         object[] attrs = p.GetCustomAttributes(typeof(ShowItemAttribute), true);
         if (attrs.Length > 0)
         {
             ShowItemAttribute show = (ShowItemAttribute)attrs[0];
             TreeNode node = nodes.Add(p.Name, show.Name);
             node.ImageKey = "Folder";
             ReadPropertyDetail(node, p, schema, show);
         }
     }
 }