Click here to Skip to main content
15,892,059 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 137.8K   5.1K   88  
Enhance productivity and reliability, write your own tools.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Harlinn.Oracle.DBTool.Types.Common;
using System.Reflection;
using System.ComponentModel;
using Harlinn.Oracle.DBTool.Utils.DB;

namespace Harlinn.Oracle.DBTool.Types.Database
{
    public class DBUserView : DBUserObject, IDBTabular
    {
        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 decimal? textLength;
        private string text;
        private decimal? typeTextLength;
        private string typeText;
        private decimal? oidTextLength;
        private string oidText;
        private string viewTypeOwner;
        private string viewType;
        private string superviewName;
        private string editioningView;
        private string readOnly;


        public DBUserView()
        {
            
        }

        public DBUserView(NodeBase parent, ObjectReader reader)
            : base(parent, reader)
        {
            ViewReader viewReader = ViewReader.CreateViewReader(this.Owner, Name);
            using (viewReader)
            {
                if (viewReader.Read())
                {
                    TextLength = viewReader.TextLength;
                    Text = viewReader.Text;
                    TypeTextLength = viewReader.TypeTextLength;
                    TypeText = viewReader.TypeText;
                    OidTextLength = viewReader.OidTextLength;
                    OidText = viewReader.OidText;
                    ViewTypeOwner = viewReader.ViewTypeOwner;
                    ViewType = viewReader.ViewType;
                    SuperviewName = viewReader.SuperviewName;
                    EditioningView = viewReader.EditioningView;
                    ReadOnly = viewReader.ReadOnly;
                }
            }
        }

        [Browsable(false)]
        public DBUserViews Views
        {
            get
            {
                DBUserViews result = (DBUserViews)Parent;
                return result;
            }
        }


        public override DBElementType ElementType
        {
            get 
            {
                return DBElementType.UserView;
            }
        }

        public override ObjectType GetObjectType()
        {
            return ObjectType.View;
        }


        public override void Refresh()
        {
            base.Refresh();
            try
            {
                string userName = Parent.Parent.Parent.Name;
                string qualifiedName = userName + "." + Name;
                DBFields fields = new DBFields(this, qualifiedName);
                Children.Add(fields);



            }
            catch (Exception exc)
            {
                LogException(exc, MethodBase.GetCurrentMethod());
                throw;
            }
        }

        [Browsable(false)]
        public DBFields Fields
        {
            get
            {
                DBFields result = GetChildByName<DBFields>("Fields");
                return result;
            }
        }


        public string GetOwner()
        {
            return Parent.Parent.Parent.Name;
        }

        public string GetName()
        {
            return Name;
        }

        public List<DBField> GetFields()
        {
            List<DBField> result = new List<DBField>();
            DBFields fields = GetChildByName<DBFields>("Fields");
            foreach (DBField field in fields.Children)
            {
                result.Add(field);
            }
            return result;
        }

        [Browsable(false)]
        public bool IsTable
        {
            get
            {
                return false;
            }
        }

        [Browsable(false)]
        public bool IsView
        {
            get
            {
                return true;
            }
        }

        public List<DBField> GetPrimaryKeyFields()
        {
            return null;
        }

        public DBField GetOptimisticLockField()
        {
            return null;
        }


        [Description("Length of the view text")]
        [DisplayName("Text Length")]
        public decimal? TextLength
        {
            get
            {
                return textLength;
            }
            set
            {
                if (this.textLength == value)
                {
                    return;
                }
                this.textLength = value;
                OnPropertyChanged("TextLength");
            }
        }


        [Description("View text")]
        public string Text
        {
            get
            {
                return text;
            }
            set
            {
                if (this.text == value)
                {
                    return;
                }
                this.text = value;
                OnPropertyChanged("Text");
            }
        }


        [Description("Length of the type clause of the object view")]
        [DisplayName("Type Text Length")]
        public decimal? TypeTextLength
        {
            get
            {
                return typeTextLength;
            }
            set
            {
                if (this.typeTextLength == value)
                {
                    return;
                }
                this.typeTextLength = value;
                OnPropertyChanged("TypeTextLength");
            }
        }


        [Description("Type clause of the object view")]
        [DisplayName("Type Text")]
        public string TypeText
        {
            get
            {
                return typeText;
            }
            set
            {
                if (this.typeText == value)
                {
                    return;
                }
                this.typeText = value;
                OnPropertyChanged("TypeText");
            }
        }


        [Description("Length of the WITH OBJECT OID clause of the object view")]
        [DisplayName("Oid Text Length")]
        public decimal? OidTextLength
        {
            get
            {
                return oidTextLength;
            }
            set
            {
                if (this.oidTextLength == value)
                {
                    return;
                }
                this.oidTextLength = value;
                OnPropertyChanged("OidTextLength");
            }
        }


        [Description("WITH OBJECT OID clause of the object view")]
        [DisplayName("Oid Text")]
        public string OidText
        {
            get
            {
                return oidText;
            }
            set
            {
                if (this.oidText == value)
                {
                    return;
                }
                this.oidText = value;
                OnPropertyChanged("OidText");
            }
        }


        [Description("Owner of the type of the view if the view is an object view")]
        [DisplayName("View Type Owner")]
        public string ViewTypeOwner
        {
            get
            {
                return viewTypeOwner;
            }
            set
            {
                if (this.viewTypeOwner == value)
                {
                    return;
                }
                this.viewTypeOwner = value;
                OnPropertyChanged("ViewTypeOwner");
            }
        }


        [Description("Type of the view if the view is an object view")]
        [DisplayName("View Type")]
        public string ViewType
        {
            get
            {
                return viewType;
            }
            set
            {
                if (this.viewType == value)
                {
                    return;
                }
                this.viewType = value;
                OnPropertyChanged("ViewType");
            }
        }


        [Description("Name of the superview, if view is a subview")]
        [DisplayName("Superview Name")]
        public string SuperviewName
        {
            get
            {
                return superviewName;
            }
            set
            {
                if (this.superviewName == value)
                {
                    return;
                }
                this.superviewName = value;
                OnPropertyChanged("SuperviewName");
            }
        }


        [Description("An indicator of whether the view is an Editioning View")]
        [DisplayName("Editioning View")]
        public string EditioningView
        {
            get
            {
                return editioningView;
            }
            set
            {
                if (this.editioningView == value)
                {
                    return;
                }
                this.editioningView = value;
                OnPropertyChanged("EditioningView");
            }
        }


        [Description("An indicator of whether the view is a Read Only View")]
        [DisplayName("Read Only")]
        public string ReadOnly
        {
            get
            {
                return readOnly;
            }
            set
            {
                if (this.readOnly == value)
                {
                    return;
                }
                this.readOnly = value;
                OnPropertyChanged("ReadOnly");
            }
        }


    }
}

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