コード例 #1
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);
                }
            }
        }
コード例 #2
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);
                }
            }
        }
コード例 #3
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);
                }
            }
        }
コード例 #4
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
            }
        }
コード例 #5
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);
                    }
                }
            }
        }
コード例 #6
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);
            }
        }
コード例 #7
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);
                    }
                }
            }
        }