OE system folders and removing some nodes (#353)

* OE system objects for system database
This commit is contained in:
Leila Lali
2017-05-19 12:02:34 -07:00
committed by GitHub
parent 7ec5549a13
commit 6920e6bfd3
15 changed files with 608 additions and 526 deletions

View File

@@ -26,9 +26,11 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
/// <summary>
/// Expands an element in the
/// </summary>
/// <param name="parent"></param>
/// <param name="parent">Parent Node</param>
/// <param name="refresh">force to refresh</param>
/// <param name="refresh">name of the sql object to filter</param>
/// <returns></returns>
public abstract IEnumerable<TreeNode> Expand(TreeNode parent, bool refresh);
public abstract IEnumerable<TreeNode> Expand(TreeNode parent, bool refresh, string name, bool includeSystemObjects);
/// <summary>
/// The list of filters that should be applied on the smo object list

View File

@@ -69,13 +69,18 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
for (int i = 0; i < values.Count; i++)
{
var value = values[i];
object proeprtyValue = value;
object propertyValue = value;
if (Type == typeof(string))
{
propertyValue = $"'{propertyValue}'";
}
if (Type == typeof(Enum))
{
proeprtyValue = (int)Convert.ChangeType(value, Type);
propertyValue = (int)Convert.ChangeType(value, Type);
}
string orPrefix = i == 0 ? string.Empty : "or";
filter = $"{filter} {orPrefix} @{Property} = {proeprtyValue}";
filter = $"{filter} {orPrefix} @{Property} = {propertyValue}";
}
}
filter = $"({filter})";

View File

@@ -44,6 +44,9 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
ServerLevelServerTriggers,
ServerLevelLinkedServers,
ServerLevelEndpoints,
SystemScalarValuedFunctions,
SystemTableValuedFunctions,
SystemFunctions,
DacInstancesFolder,
Tables,
Views,

View File

@@ -62,6 +62,11 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
/// </summary>
public string NodeType { get; set; }
/// <summary>
// True if the node includes system object
/// </summary>
public bool IsSystemObject { get; set; }
/// <summary>
/// Enum defining the type of the node - for example Server, Database, Folder, Table
/// </summary>
@@ -196,17 +201,26 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
/// Expands this node and returns its children
/// </summary>
/// <returns>Children as an IList. This is the raw children collection, not a copy</returns>
public IList<TreeNode> Expand()
public IList<TreeNode> Expand(string name= null)
{
// TODO consider why solution explorer has separate Children and Items options
if (children.IsInitialized)
{
return children;
}
PopulateChildren(false);
PopulateChildren(false, name);
return children;
}
/// <summary>
/// Expands this node and returns its children
/// </summary>
/// <returns>Children as an IList. This is the raw children collection, not a copy</returns>
public IList<TreeNode> Expand()
{
return Expand(null);
}
/// <summary>
/// Refresh this node and returns its children
/// </summary>
@@ -214,7 +228,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
public virtual IList<TreeNode> Refresh()
{
// TODO consider why solution explorer has separate Children and Items options
PopulateChildren(true);
PopulateChildren(true, null);
return children;
}
@@ -266,13 +280,16 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
return Parent as T;
}
protected void PopulateChildren(bool refresh)
protected void PopulateChildren(bool refresh, string name = null)
{
Logger.Write(LogLevel.Verbose, string.Format(CultureInfo.InvariantCulture, "Populating oe node :{0}", this.GetNodePath()));
Debug.Assert(IsAlwaysLeaf == false);
SmoQueryContext context = this.GetContextAs<SmoQueryContext>();
bool includeSystemObjects = context != null && context.Database != null ? ObjectExplorerUtils.IsSystemDatabaseConnection(context.Database.Name) : true;
if (children.IsPopulating || context == null)
if (children.IsPopulating || context == null)
return;
children.Clear();
@@ -285,7 +302,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
{
foreach (var factory in childFactories)
{
IEnumerable<TreeNode> items = factory.Expand(this, refresh);
IEnumerable<TreeNode> items = factory.Expand(this, refresh, name, includeSystemObjects);
if (items != null)
{
foreach (TreeNode item in items)
@@ -300,7 +317,9 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
}
catch(Exception ex)
{
Logger.Write(LogLevel.Error, $"Failed populating oe children. error:{ex.Message} {ex.StackTrace}");
string error = string.Format(CultureInfo.InvariantCulture, "Failed populating oe children. error:{0} inner:{1} stacktrace:{2}",
ex.Message, ex.InnerException != null ? ex.InnerException.Message : "", ex.StackTrace);
Logger.Write(LogLevel.Error, error);
}
finally
{