Click here to Skip to main content
15,885,216 members
Articles / Desktop Programming / WPF

DBTool for Oracle - Part 1

Rate me:
Please Sign up or sign in to vote.
4.92/5 (45 votes)
13 Apr 2014CPOL18 min read 135.7K   5.1K   88  
Enhance productivity and reliability, write your own tools.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.ComponentModel;
using Harlinn.Common;
using Harlinn.DBTool.Common;
using Harlinn.DBTool.DataSources.Oracle.DB;

namespace Harlinn.DBTool.DataSources.Oracle
{
    public abstract class DBOracleUserObject : DBOracleElement
    {
        private static readonly log4net.ILog sfLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        private static void LogException(Exception exc, System.Reflection.MethodBase method)
        {
            Logger.LogException(sfLog, exc, method);
        }

        private string owner;
        private string subobjectName;
        private decimal objectId;
        private decimal? dataObjectId;
        private ObjectType objectType;
        private DateTime created;
        private DateTime lastDdlTime;
        private string timestamp;
        private string status;
        private string temporary;
        private string generated;
        private string secondary;
        private decimal namespace_;
        private string editionName;

        private DBOracleUserObjectReferences references;
        private DBOracleUserObjectReferencedBy referencedBy;

        public DBOracleUserObject()
        {
            
        }
        public DBOracleUserObject(NodeBase parent, ObjectReader reader)
            : base(parent, reader.ObjectName)
        {
            Owner = reader.Owner;
            SubobjectName = reader.SubobjectName;
            ObjectId = reader.ObjectId;
            DataObjectId = reader.DataObjectId;
            ObjectType = reader.ObjectType;
            Created = reader.Created;
            LastDdlTime = reader.LastDdlTime;
            Timestamp = reader.Timestamp;
            Status = reader.Status;
            Temporary = reader.Temporary;
            Generated = reader.Generated;
            Secondary = reader.Secondary;
            Namespace = reader.Namespace;
            EditionName = reader.EditionName;

        }


        public abstract ObjectType GetObjectType();

        public string GetDDL()
        {
            try
            {
                string result = MetaData.GetDDL(Owner, Name, GetObjectType());
                return result;
            }
            catch (Exception exc)
            {
                LogException(exc, MethodBase.GetCurrentMethod());
                throw;
            }
        }


        [Browsable(false)]
        public DBOracleUserObjectReferences References
        {
            get
            {
                if (references == null)
                {
                    Refresh();
                }
                return references;
            }
        }

        [Browsable(false)]
        public DBOracleUserObjectReferencedBy ReferencedBy
        {
            get
            {
                if (referencedBy == null)
                {
                    Refresh();
                }
                return referencedBy;
            }
        }


        public override void Refresh()
        {
            base.Refresh();

            if (references == null)
            {
                references = new DBOracleUserObjectReferences(this);
                references.Refresh();
                Children.Add(references);
            }

            if (referencedBy == null)
            {
                referencedBy = new DBOracleUserObjectReferencedBy(this);
                referencedBy.Refresh();
                Children.Add(referencedBy);
            }

        }


        [Category("Object Information")]
        [Description("Username of the owner of the object")]
        public string Owner
        {
            get
            {
                return owner;
            }
            set
            {
                if (this.owner == value)
                {
                    return;
                }
                this.owner = value;
                OnPropertyChanged("Owner");
            }
        }

        [Category("Object Information")]
        [Description("Name of the sub-object (for example, partititon)")]
        [DisplayName("Subobject Name")]
        public string SubobjectName
        {
            get
            {
                return subobjectName;
            }
            set
            {
                if (this.subobjectName == value)
                {
                    return;
                }
                this.subobjectName = value;
                OnPropertyChanged("SubobjectName");
            }
        }


        [Category("Object Information")]
        [Description("Object number of the object")]
        [DisplayName("Object Id")]
        public decimal ObjectId
        {
            get
            {
                return objectId;
            }
            set
            {
                if (this.objectId == value)
                {
                    return;
                }
                this.objectId = value;
                OnPropertyChanged("ObjectId");
            }
        }


        [Category("Object Information")]
        [Description("Object number of the segment which contains the object")]
        [DisplayName("Data Object Id")]
        public decimal? DataObjectId
        {
            get
            {
                return dataObjectId;
            }
            set
            {
                if (this.dataObjectId == value)
                {
                    return;
                }
                this.dataObjectId = value;
                OnPropertyChanged("DataObjectId");
            }
        }


        [Category("Object Information")]
        [Description("Type of the object")]
        [DisplayName("Object Type")]
        public ObjectType ObjectType
        {
            get
            {
                return objectType;
            }
            set
            {
                if (this.objectType == value)
                {
                    return;
                }
                this.objectType = value;
                OnPropertyChanged("ObjectType");
            }
        }

        [Category("Object Information")]
        [Description("Timestamp for the creation of the object")]
        public DateTime Created
        {
            get
            {
                return created;
            }
            set
            {
                if (this.created == value)
                {
                    return;
                }
                this.created = value;
                OnPropertyChanged("Created");
            }
        }


        [Category("Object Information")]
        [Description("Timestamp for the last DDL change (including GRANT and REVOKE) to the object")]
        [DisplayName("Last DDL Time")]
        public DateTime LastDdlTime
        {
            get
            {
                return lastDdlTime;
            }
            set
            {
                if (this.lastDdlTime == value)
                {
                    return;
                }
                this.lastDdlTime = value;
                OnPropertyChanged("LastDdlTime");
            }
        }


        [Category("Object Information")]
        [Description("Timestamp for the specification of the object")]
        public string Timestamp
        {
            get
            {
                return timestamp;
            }
            set
            {
                if (this.timestamp == value)
                {
                    return;
                }
                this.timestamp = value;
                OnPropertyChanged("Timestamp");
            }
        }

        [Category("Object Information")]
        [Description("Status of the object")]
        public string Status
        {
            get
            {
                return status;
            }
            set
            {
                if (this.status == value)
                {
                    return;
                }
                this.status = value;
                OnPropertyChanged("Status");
            }
        }

        [Category("Object Information")]
        [Description("Can the current session only see data that it placed in this object itself?")]
        public string Temporary
        {
            get
            {
                return temporary;
            }
            set
            {
                if (this.temporary == value)
                {
                    return;
                }
                this.temporary = value;
                OnPropertyChanged("Temporary");
            }
        }

        [Category("Object Information")]
        [Description("Was the name of this object system generated?")]
        public string Generated
        {
            get
            {
                return generated;
            }
            set
            {
                if (this.generated == value)
                {
                    return;
                }
                this.generated = value;
                OnPropertyChanged("Generated");
            }
        }


        [Category("Object Information")]
        [Description("Is this a secondary object created as part of icreate for domain indexes?")]
        public string Secondary
        {
            get
            {
                return secondary;
            }
            set
            {
                if (this.secondary == value)
                {
                    return;
                }
                this.secondary = value;
                OnPropertyChanged("Secondary");
            }
        }


        [Category("Object Information")]
        [Description("Namespace for the object")]
        public decimal Namespace
        {
            get
            {
                return namespace_;
            }
            set
            {
                if (this.namespace_ == value)
                {
                    return;
                }
                this.namespace_ = value;
                OnPropertyChanged("Namespace");
            }
        }

        [Category("Object Information")]
        [Description("Name of the edition in which the object is actual")]
        [DisplayName("Edition Name")]
        public string EditionName
        {
            get
            {
                return editionName;
            }
            set
            {
                if (this.editionName == value)
                {
                    return;
                }
                this.editionName = value;
                OnPropertyChanged("EditionName");
            }
        }
    }

}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Sea Surveillance AS
Norway Norway
Chief Architect - Sea Surveillance AS.

Specializing in integrated operations and high performance computing solutions.

I’ve been fooling around with computers since the early eighties, I’ve even done work on CP/M and MP/M.

Wrote my first “real” program on a BBC micro model B based on a series in a magazine at that time. It was fun and I got hooked on this thing called programming ...

A few Highlights:

  • High performance application server development
  • Model Driven Architecture and Code generators
  • Real-Time Distributed Solutions
  • C, C++, C#, Java, TSQL, PL/SQL, Delphi, ActionScript, Perl, Rexx
  • Microsoft SQL Server, Oracle RDBMS, IBM DB2, PostGreSQL
  • AMQP, Apache qpid, RabbitMQ, Microsoft Message Queuing, IBM WebSphereMQ, Oracle TuxidoMQ
  • Oracle WebLogic, IBM WebSphere
  • Corba, COM, DCE, WCF
  • AspenTech InfoPlus.21(IP21), OsiSoft PI


More information about what I do for a living can be found at: harlinn.com or LinkedIn

You can contact me at espen@harlinn.no

Comments and Discussions