mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-17 01:25:40 -05:00
Add Database status to OE tree node (#485)
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using Microsoft.SqlServer.Management.Smo;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Status for databases
|
||||
/// </summary>
|
||||
internal partial class DatabasesChildFactory : SmoChildFactoryBase
|
||||
{
|
||||
public override string GetNodeStatus(object context)
|
||||
{
|
||||
return DatabasesCustomNodeHelper.GetStatus(context);
|
||||
}
|
||||
}
|
||||
|
||||
internal static class DatabasesCustomNodeHelper
|
||||
{
|
||||
internal static string GetStatus(object context)
|
||||
{
|
||||
Database db = context as Database;
|
||||
if (db != null)
|
||||
{
|
||||
if ((db.Status & DatabaseStatus.Offline) == DatabaseStatus.Offline)
|
||||
{
|
||||
return "Offline";
|
||||
}
|
||||
else if ((db.Status & DatabaseStatus.Recovering) == DatabaseStatus.Recovering)
|
||||
{
|
||||
return "Recovering";
|
||||
}
|
||||
else if ((db.Status & DatabaseStatus.RecoveryPending) == DatabaseStatus.RecoveryPending)
|
||||
{
|
||||
return "Recovery Pending";
|
||||
}
|
||||
else if ((db.Status & DatabaseStatus.Restoring) == DatabaseStatus.Restoring)
|
||||
{
|
||||
return "Restoring";
|
||||
}
|
||||
else if ((db.Status & DatabaseStatus.EmergencyMode) == DatabaseStatus.EmergencyMode)
|
||||
{
|
||||
return "Emergency Mode";
|
||||
}
|
||||
else if ((db.Status & DatabaseStatus.Inaccessible) == DatabaseStatus.Inaccessible)
|
||||
{
|
||||
return "Inaccessible";
|
||||
}
|
||||
else if ((db.Status & DatabaseStatus.Shutdown) == DatabaseStatus.Shutdown)
|
||||
{
|
||||
return "Shutdown";
|
||||
}
|
||||
else if ((db.Status & DatabaseStatus.Standby) == DatabaseStatus.Standby)
|
||||
{
|
||||
return "Standby";
|
||||
}
|
||||
else if ((db.Status & DatabaseStatus.Suspect) == DatabaseStatus.Suspect)
|
||||
{
|
||||
return "Suspect";
|
||||
}
|
||||
else if ((db.Status & DatabaseStatus.AutoClosed) == DatabaseStatus.AutoClosed)
|
||||
{
|
||||
return "Auto Closed";
|
||||
}
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user