using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Harlinn.Oracle.DBTool.Types.Common;
using Harlinn.Oracle.DBTool.Utils.DB;
using System.Reflection;
using System.ComponentModel;
namespace Harlinn.Oracle.DBTool.Types.Database
{
public class DBUserIndexPartition : DBUserObject
{
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);
}
public DBUserIndexPartition()
{
}
public DBUserIndexPartition(NodeBase parent, ObjectReader reader)
: base(parent, reader)
{
}
public override DBElementType ElementType
{
get
{
return DBElementType.UserIndexPartition;
}
}
public override ObjectType GetObjectType()
{
return ObjectType.IndexPartition;
}
}
public class DBUserIndexPartitions : DBUserObjectCollection<DBUserIndexPartition>
{
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);
}
public DBUserIndexPartitions()
{
}
public DBUserIndexPartitions(DBUserObjects parent)
: base(parent, "Index Partitions")
{
}
public override DBElementType ElementType
{
get
{
return DBElementType.UserIndexPartitions;
}
}
public override void Refresh()
{
try
{
base.Refresh();
string userName = Parent.Parent.Name;
ObjectReader reader = ObjectReader.CreateIndexPartitionReader(userName);
using (reader)
{
while (reader.Read())
{
DBUserIndexPartition element = new DBUserIndexPartition(this, reader);
Children.Add(element);
}
}
if (Children.Count > 0)
{
DBUserObjects userObjects = (DBUserObjects)Parent;
if (userObjects.GetChildByName(Name) == null)
{
userObjects.Children.Add(this);
}
}
}
catch (Exception exc)
{
LogException(exc, MethodBase.GetCurrentMethod());
throw;
}
}
}
}