コード例 #1
0
        protected DifferenceModel AppendDifference(object source, bool ToRemove)
        {
            var type = source.GetType().Name;

            var d = new DifferenceModel()
            {
                Source = source,
                Kind   = ToRemove
                    ? TypeDifferenceEnum.MissingInSource
                    : TypeDifferenceEnum.MissingInTarget,
            };

            this._lst.Add(d);

            if (source is DoublonModel)
            {
                log(string.Format("{2} {0} is duplicated in the source. Files : {1}", GetName(source), GetFilename(source), type));
            }

            else
            {
                if (ToRemove)
                {
                    log(string.Format("{2} {0} must be removed in the target. Files : {1}", GetName(source), GetFilename(source), type));
                }
                else
                {
                    log(string.Format("{2} {0} is missing in the target. Files : {1}", GetName(source), GetFilename(source), type));
                }
            }

            return(d);
        }
コード例 #2
0
        private void Append(SynonymModel source, DifferenceModel d)
        {
            string        p  = BuildPath(Path.Combine(this.folderForTarget, source.ObjectTargetOwner), "Synonyms", source.Name);
            StringBuilder sb = new StringBuilder();

            if (!File.Exists(p))
            {
                var file = source.Files.OfType <FileElement>().FirstOrDefault();
                if (file != null && file.Exist(this.rootFolderSource))
                {
                    sb = new StringBuilder(Helpers.ContentHelper.LoadContentFromFile(this.rootFolderSource, file.Path));
                }

                else
                {
                    sb.Append(string.Format("CREATE OR REPLACE {0} SYNONYM {1}.{2} FOR {3};", "PUBLIC", source.ObjectTargetOwner, source.Name, source.ObjectTargetName));
                }

                if (sb.Length > 0)
                {
                    WriteFile(p, sb.ToString());
                    d.Addfile(p);
                }
            }
        }
コード例 #3
0
        private void Append(SequenceModel source, DifferenceModel d)
        {
            string p = BuildPath(Path.Combine(this.folderForTarget, source.Owner), "Sequences", source.Key);

            if (!File.Exists(p))
            {
                d.Addfile(p);
                StringBuilder sb = new StringBuilder();

                var file = source.Files.OfType <FileElement>().FirstOrDefault();

                if (file != null && file.Exist(this.rootFolderSource))
                {
                    sb = new StringBuilder(ContentHelper.LoadContentFromFile(this.rootFolderSource, file.Path));
                }

                else
                {
                }

                if (sb.Length > 0)
                {
                    WriteFile(p, sb.ToString());
                    d.Addfile(p);
                }
            }
        }
コード例 #4
0
        private void Append(TypeItem source, DifferenceModel d)
        {
            string        p  = BuildPath(Path.Combine(this.folderForTarget, source.Owner), "Types", source.Name);
            StringBuilder sb = new StringBuilder();

            if (!File.Exists(p))
            {
                var file = source.Files.OfType <FileElement>().FirstOrDefault();
                if (file != null && file.Exist(this.rootFolderSource))
                {
                    sb = new StringBuilder(Helpers.ContentHelper.LoadContentFromFile(this.rootFolderSource, file.Path));
                }

                else
                {
                    sb = new StringBuilder(Helpers.ContentHelper.LoadContentFromFile(this.rootFolderSource, file.Path));
                    sb.Append(CreateOrReplace);
                    sb.Append(source.Code.GetSource());
                    sb.AppendLine("\r\n");
                    sb.Append(source.CodeBody.GetSource());
                }

                if (sb.Length > 0)
                {
                    WriteFile(p, sb.ToString());
                    d.Addfile(p);
                }
            }
        }
コード例 #5
0
        private void Append(TableModel source, DifferenceModel d)
        {
            string typeObject = "Tables";

            if (source.IsMaterializedView)
            {
                typeObject = "MaterializedViews";
            }

            else if (source.IsView)
            {
                typeObject = "Views";
            }
            else
            {
                typeObject = "Tables";
            }

            string p = BuildPath(Path.Combine(this.folderForTarget, source.Owner), typeObject, source.Name);

            if (!File.Exists(p))
            {
                StringBuilder sb = new StringBuilder();

                var file = source.Files.OfType <FileElement>().FirstOrDefault();

                if (file != null && file.Exist(this.rootFolderSource))
                {
                    sb.Append(Helpers.ContentHelper.LoadContentFromFile(this.rootFolderSource, file.Path));
                }

                else
                {
                    if (source.IsView)
                    {
                        sb.Append(Utils.Unserialize(source.CodeView, true));
                    }
                    else
                    {
                        // generer le script de la table
                    }
                }

                if (sb.Length > 0)
                {
                    WriteFile(p, sb.ToString());
                    d.Addfile(p);
                }

                // dans le cas ou la source est une instance de base

                //      Gerer les commentaires qui sont sur les tables

                //      Gerer les trigers qui sont sur les tables

                //      Gerer les index qui sont sur les tables

                //      Gerer les contraints qui sont sur les tables
            }
        }
コード例 #6
0
        public virtual void AppendMissingReference(IndexModel index, ReferenceTable table)
        {
            var d = new DifferenceModel()
            {
                Source    = index,
                Kind      = TypeDifferenceEnum.Orphean,
                Reference = "Table " + table.ToString(),
            };

            this._lst.Add(d);
        }
コード例 #7
0
        private void Append(GrantModel source, DifferenceModel d)
        {
            string        p   = BuildPath(Path.Combine(this.folderForTarget, source.ObjectSchema), "UserObjectPrivileges", source.Role);
            StringBuilder sb  = new StringBuilder();
            string        sql = string.Format(@"GRANT {0} ON {1} TO {2}{3};", string.Join(", ", source.Privileges), source.FullObjectName.Replace(@"""", ""), source.Role, source.Grantable ? " WITH GRANT OPTION" : string.Empty);

            sb.AppendLine(sql);

            if (sb.Length > 0)
            {
                WriteFile(p, sb.ToString());
                d.Addfile(p);
            }
        }
コード例 #8
0
        public virtual void AppendChange(IndexModel source, IndexModel target, string propertyName, string columnsources = "", string columntarget = "")
        {
            var d = new DifferenceModel()
            {
                Source       = source,
                Target       = target,
                Kind         = TypeDifferenceEnum.Change,
                PropertyName = propertyName,
                ColumnSource = columnsources,
                ColumnTarget = columntarget
            };

            this._lst.Add(d);
        }
コード例 #9
0
        public virtual void AppendMissingReference(ConstraintModel constraint, ReferenceTable table)
        {
            var d = new DifferenceModel()
            {
                Source    = constraint,
                Kind      = TypeDifferenceEnum.Orphean,
                Reference = "Table " + table.ToString(),
            };

            this._lst.Add(d);

            //if (generateSource)
            //{
            //    string p = BuildPath(Path.Combine(this.folderForSource, constraint.TableReference.Owner), "Triggers", constraint.Name);
            //    WriteFile(p, CreateOrReplace + Utils.Unserialize(constraint.Code, true));
            //}
        }
コード例 #10
0
        public virtual void AppendMissingReference(TriggerModel trigger, ReferenceTable table)
        {
            var d = new DifferenceModel()
            {
                Source    = trigger,
                Kind      = TypeDifferenceEnum.Orphean,
                Reference = "Table " + table.ToString(),
            };

            this._lst.Add(d);

            if (generateSource)
            {
                string p = BuildPath(Path.Combine(this.folderForSource, trigger.TableReference.Owner), "Triggers", trigger.Name);
                WriteFile(p, CreateOrReplace + Utils.Unserialize(trigger.Code, true));
            }
        }
コード例 #11
0
        private void Append(ProcedureModel source, DifferenceModel d, ProcedureModel target)
        {
            string        p  = BuildPath(Path.Combine(this.folderForTarget, source.Owner), "Procedures", source.Name);
            StringBuilder sb = new StringBuilder();

            if (!File.Exists(p))
            {
                var txt = CreateOrReplace + source.Code.GetSource().Trim();
                if (!txt.EndsWith(@"\"))
                {
                    txt = txt + Environment.NewLine + @"\";
                }
                sb.AppendLine(txt);

                if (sb.Length > 0)
                {
                    WriteFile(p, sb.ToString());
                    d.Addfile(p);
                }
            }

            if (target != null)
            {
                p  = BuildPath(Path.Combine(this.folderForTarget, source.Owner), "Procedures", source.Name, true);
                sb = new StringBuilder();

                if (!File.Exists(p))
                {
                    var txt = CreateOrReplace + target.Code.GetSource().Trim();
                    if (!txt.EndsWith(@"\"))
                    {
                        txt = txt + Environment.NewLine + @"\";
                    }
                    sb.AppendLine(txt);

                    if (sb.Length > 0)
                    {
                        WriteFile(p, sb.ToString());
                        d.Addfile(p);
                    }
                }
            }
        }
コード例 #12
0
        protected DifferenceModel AppendDifference(object source, object target, string propertyName)
        {
            var type = source.GetType().Name;

            if (propertyName == "Name")
            {
                log(string.Format("{2} {0} is renamed in {1} in the target", GetName(source), GetName(target), type));
            }
            else
            {
                log(string.Format("{2} property '{1}' in '{0}' is changed in the target", GetName(source), propertyName, type));
            }

            var d = new DifferenceModel()
            {
                Source       = source,
                Target       = target,
                Kind         = TypeDifferenceEnum.Change,
                PropertyName = propertyName
            };

            this._lst.Add(d);
            return(d);
        }
コード例 #13
0
ファイル: ProcessorBase.cs プロジェクト: radtek/Oracle.Parser
 protected virtual void Visit(ConstraintModel source, ConstraintModel target, TypeDifferenceEnum kind, string propertyName, DifferenceModel item)
 {
 }
コード例 #14
0
ファイル: ProcessorBase.cs プロジェクト: radtek/Oracle.Parser
 protected virtual void Visit(TypeItem source, TypeItem target, TypeDifferenceEnum kind, string propertyName, DifferenceModel item)
 {
 }
コード例 #15
0
ファイル: ProcessorBase.cs プロジェクト: radtek/Oracle.Parser
        private void VisitBase(object source, object target, TypeDifferenceEnum kind, string propertyName, DifferenceModel item)
        {
            if (source is TypeItem)
            {
                Visit(source as TypeItem, target as TypeItem, kind, propertyName, item);
            }

            else if (source is SynonymModel)
            {
                Visit(source as SynonymModel, target as SynonymModel, kind, propertyName, item);
            }

            else if (source is ProcedureModel)
            {
                Visit(source as ProcedureModel, target as ProcedureModel, kind, propertyName, item);
            }

            else if (source is SequenceModel)
            {
                Visit(source as SequenceModel, target as SequenceModel, kind, propertyName, item);
            }

            else if (source is PackageModel)
            {
                Visit(source as PackageModel, target as PackageModel, kind, propertyName, item);
            }

            else if (source is GrantModel)
            {
                Visit(source as GrantModel, target as GrantModel, kind, propertyName, item);
            }

            else if (source is ConstraintModel)
            {
                Visit(source as ConstraintModel, target as ConstraintModel, kind, propertyName, item);
            }

            else if (source is PropertyModel)
            {
                Visit(source as PropertyModel, target as PropertyModel, kind, propertyName, item);
            }

            else if (source is ColumnModel)
            {
                Visit(source as ColumnModel, target as ColumnModel, kind, propertyName, item);
            }

            else if (source is TableModel)
            {
                Visit(source as TableModel, target as TableModel, kind, propertyName, item);
            }

            else if (source is ArgumentModel)
            {
                Visit(source as ArgumentModel, target as ArgumentModel, kind, propertyName, item);
            }

            else if (source is IndexModel)
            {
                Visit(source as IndexModel, target as IndexModel, kind, propertyName, item);
            }

            else if (source is TriggerModel)
            {
                Visit(source as TriggerModel, target as TriggerModel, kind, propertyName, item);
            }
        }
コード例 #16
0
 private bool IsRollBack(DifferenceModel c, bool isRollBack)
 {
     return(true);
 }
コード例 #17
0
        private void Append(PackageModel source, DifferenceModel d, PackageModel target)
        {
            string p = BuildPath(Path.Combine(this.folderForTarget, source.Owner), "PackageBodies", source.Name);

            if (d.PropertyName == "CodeBody")
            {
                if (!File.Exists(p))
                {
                    string txt = CreateOrReplace + source.CodeBody.GetSource().Trim();
                    if (!txt.EndsWith(@"\"))
                    {
                        txt = txt + Environment.NewLine + @"\";
                    }
                    WriteFile(p, txt);
                    d.Addfile(p);
                }
            }
            else
            {
                p = BuildPath(Path.Combine(this.folderForTarget, source.Owner), "Packages", source.Name);
                if (!File.Exists(p))
                {
                    string txt = CreateOrReplace + source.Code.GetSource().Trim();
                    if (!txt.EndsWith(@"\"))
                    {
                        txt = txt + Environment.NewLine + @"\";
                    }
                    WriteFile(p, txt);
                    d.Addfile(p);
                }
            }

            if (target != null)
            {
                if (d.PropertyName == "CodeBody")
                {
                    p = BuildPath(Path.Combine(this.folderForTarget, target.Owner), "PackageBodies", target.Name, true);
                    if (!File.Exists(p))
                    {
                        string txt = CreateOrReplace + target.CodeBody.GetSource().Trim();
                        if (!txt.EndsWith(@"\"))
                        {
                            txt = txt + Environment.NewLine + @"\";
                        }
                        WriteFile(p, txt);
                        d.Addfile(p);
                    }
                }
                else
                {
                    p = BuildPath(Path.Combine(this.folderForTarget, target.Owner), "Packages", target.Name, true);
                    if (!File.Exists(p))
                    {
                        string txt = CreateOrReplace + target.Code.GetSource().Trim();
                        if (!txt.EndsWith(@"\"))
                        {
                            txt = txt + Environment.NewLine + @"\";
                        }
                        WriteFile(p, txt);
                        d.Addfile(p);
                    }
                }
            }
        }
コード例 #18
0
ファイル: ProcessorBase.cs プロジェクト: radtek/Oracle.Parser
 protected virtual void Visit(SynonymModel source, SynonymModel target, TypeDifferenceEnum kind, string propertyName, DifferenceModel item)
 {
 }