Ejemplo n.º 1
0
        public ActionResult Connections(string node)
        {
            var i = SQLInstance.Get(node);

            var vd = new DashboardModel
            {
                View            = SQLViews.Connections,
                CurrentInstance = i
            };

            return(View(vd));
        }
Ejemplo n.º 2
0
        public ActionResult DatabaseTables(string node, string database)
        {
            var i = SQLInstance.Get(node);

            var vd = new DatabasesModel
            {
                Instance = i,
                Database = database
            };

            return(View("Databases.Modal.Tables", vd));
        }
Ejemplo n.º 3
0
        public ActionResult Databases(string node)
        {
            var i = SQLInstance.Get(node);

            var vd = new DashboardModel
            {
                View            = SQLViews.Databases,
                CurrentInstance = i,
                Refresh         = 2 * 60
            };

            return(View(vd));
        }
Ejemplo n.º 4
0
        private OperationsTopModel GetOperationsModel(string node, SQLInstance.TopSearchOptions options)
        {
            var i = SQLInstance.Get(node);

            options.SetDefaults();

            return(new OperationsTopModel
            {
                View = SQLViews.Top,
                CurrentInstance = i,
                TopSearchOptions = options
            });
        }
Ejemplo n.º 5
0
        public ActionResult Kill(string node, string database, int sid)
        {
            var activeSearchOptions = new SQLInstance.ActiveSearchOptions();

            var i         = SQLInstance.Get(node);
            var activeOps = i.GetActiveOperations(activeSearchOptions);
            var model     = activeOps.Data.FirstOrDefault(x => x.SessionId == sid);

            ViewData["node"] = node;
            ViewData["sid"]  = sid;

            return(View("Operations.Active.Kill", model));
        }
Ejemplo n.º 6
0
        public ActionResult SQLRemovePlan(string node, string handle)
        {
            var planHandle = HttpServerUtility.UrlTokenDecode(handle);
            var instance   = SQLInstance.Get(node);

            if (instance == null)
            {
                return(JsonError("Could not find server " + node));
            }
            var result = instance.RemovePlan(planHandle);

            return(result != 0 ? Json(true) : JsonError("There was an error removing the plan from cache"));
        }
Ejemplo n.º 7
0
        public ActionResult Instance(string node)
        {
            var i = SQLInstance.Get(node);

            var vd = new InstanceModel
            {
                View            = SQLViews.Instance,
                Refresh         = node.HasValue() ? 10 : 5,
                CurrentInstance = i
            };

            return(View("Instance", vd));
        }
Ejemplo n.º 8
0
        public ActionResult Top(string node, SQLInstance.TopSearchOptions options, bool?detailed = false)
        {
            options.SetDefaults();

            var vd = new DashboardModel
            {
                View             = DashboardModel.Views.Top,
                Detailed         = detailed.GetValueOrDefault(),
                CurrentInstance  = SQLInstance.Get(node),
                TopSearchOptions = options
            };

            return(View("Dashboard", vd));
        }
Ejemplo n.º 9
0
        public ActionResult TopDetail(string node, string handle, int?offset = null)
        {
            var planHandle = HttpServerUtility.UrlTokenDecode(handle);

            var i = SQLInstance.Get(node);

            var vd = new OperationsTopDetailModel
            {
                Instance = i,
                Op       = i.GetTopOperation(planHandle, offset).Data
            };

            return(View("Operations.Top.Detail", vd));
        }
Ejemplo n.º 10
0
        public ActionResult Instance(string node)
        {
            var i = SQLInstance.Get(node);

            var vd = new DashboardModel
            {
                View = SQLViews.Instance,
                StandaloneInstances = SQLInstance.AllStandalone,
                Refresh             = node.HasValue() ? 10 : 5,
                CurrentInstance     = i
            };

            return(View("Instance", vd));
        }
Ejemplo n.º 11
0
        public async Task <ActionResult> Connections(string node)
        {
            var i = SQLInstance.Get(node);

            var vd = new DashboardModel
            {
                View            = SQLViews.Connections,
                CurrentInstance = i,
                Cache           = i?.Connections,
                Connections     = i == null ? null : await i.Connections.GetData().ConfigureAwait(false)
            };

            return(View(vd));
        }
Ejemplo n.º 12
0
        public ActionResult TopPlan(string node, string handle)
        {
            var planHandle = HttpServerUtility.UrlTokenDecode(handle);
            var i          = SQLInstance.Get(node);
            var op         = i.GetTopOperation(planHandle).Data;

            if (op == null)
            {
                return(ContentNotFound("Plan was not found."));
            }

            var ms = new MemoryStream(Encoding.UTF8.GetBytes(op.QueryPlan));

            return(File(ms, "text/xml", $"QueryPlan-{Math.Abs(handle.GetHashCode())}.sqlplan"));
        }
Ejemplo n.º 13
0
        public ActionResult DatabaseDetail(string node, string database, string view, string objectName)
        {
            var i = SQLInstance.Get(node);

            var vd = new DatabasesModel
            {
                Instance   = i,
                Database   = database,
                ObjectName = objectName
            };

            switch (view)
            {
            case "backups":
                vd.View = DatabasesModel.Views.Backups;
                return(View("Databases.Modal.Backups", vd));

            case "restores":
                vd.View = DatabasesModel.Views.Restores;
                return(View("Databases.Modal.Restores", vd));

            case "storage":
                vd.View = DatabasesModel.Views.Storage;
                return(View("Databases.Modal.Storage", vd));

            case "tables":
                vd.View = DatabasesModel.Views.Tables;
                return(View("Databases.Modal.Tables", vd));

            case "views":
                vd.View = DatabasesModel.Views.Views;
                return(View("Databases.Modal.Views", vd));

            case "unusedindexes":
                vd.View = DatabasesModel.Views.UnusedIndexes;
                return(View("Databases.Modal.UnusedIndexes", vd));

            case "missingindexes":
                vd.View = DatabasesModel.Views.MissingIndexes;
                return(View("Databases.Modal.MissingIndexes", vd));

            case "storedprocedures":
                vd.View = DatabasesModel.Views.StoredProcedures;
                return(View("Databases.Modal.StoredProcedures", vd));
            }
            return(View("Databases.Modal.Tables", vd));
        }
Ejemplo n.º 14
0
        public ActionResult Connections(string node, bool refresh = false)
        {
            var instance = SQLInstance.Get(node);

            if (refresh && instance != null)
            {
                instance.Connections.Purge();
            }

            var vd = new DashboardModel
            {
                View            = DashboardModel.Views.Connections,
                CurrentInstance = instance
            };

            return(View("Dashboard", vd));
        }
Ejemplo n.º 15
0
        public ActionResult TopPlan(string node, string handle)
        {
            var planHandle = HttpServerUtility.UrlTokenDecode(handle);
            var i          = SQLInstance.Get(node);
            var op         = i.GetTopOperation(planHandle).Data;

            if (op == null)
            {
                return(ContentNotFound("Plan was not found."));
            }

            var ms = new MemoryStream(Encoding.UTF8.GetBytes(op.QueryPlan));

            var dt = DateTime.Now.ToString("yyyyMMddHHmm");

            return(File(ms, "text/xml", $"QueryPlan-{dt}-{op.CompiledOnDatabase}-{op.StoredProcedure}.sqlplan"));
        }
Ejemplo n.º 16
0
        public ActionResult SQLCPUSpark(string node)
        {
            var instance = SQLInstance.Get(node);

            if (instance == null)
            {
                return(ContentNotFound($"SQLNode not found with name = '{node}'"));
            }
            var start  = DateTime.UtcNow.AddHours(-1);
            var points = instance.ResourceHistory.Data?.Where(p => p.EventTime >= start).ToList();

            if (points == null || points.Count == 0)
            {
                return(EmptySparkSVG());
            }

            return(SparkSVG(points, 100, p => p.ProcessUtilization, start));
        }
Ejemplo n.º 17
0
        public ActionResult TopDetail(string node, string handle, int?offset = null)
        {
            var planHandle = HttpServerUtility.UrlTokenDecode(handle);
            var instance   = SQLInstance.Get(node);

            if (instance == null)
            {
                return(ContentNotFound("Server " + node + " not found."));
            }

            var vd = new OpsTopDetailModel
            {
                Instance = instance,
                Op       = instance.GetTopOperation(planHandle, offset).Data
            };

            return(View("Operations.Top.Detail", vd));
        }
Ejemplo n.º 18
0
        public ActionResult Instance(string node, bool ajax = false)
        {
            var instance = SQLInstance.Get(node);

            if (instance == null && ajax)
            {
                return(ContentNotFound("Instance " + node + " was not found."));
            }

            var vd = new DashboardModel
            {
                StandaloneInstances = SQLInstance.AllStandalone,
                Refresh             = node.HasValue() ? 10 : 5,
                View            = DashboardModel.Views.Instance,
                CurrentInstance = instance
            };

            return(View(ajax ? "Instance" : "Dashboard", vd));
        }
Ejemplo n.º 19
0
        public ActionResult DatabaseDetail(string node, string database, string view)
        {
            var vd = new DatabasesModel
            {
                Instance = SQLInstance.Get(node),
                Database = database
            };

            switch (view)
            {
            case "tables":
                vd.View = DatabasesModel.Views.Tables;
                return(View("Databases.Modal.Tables", vd));

            case "views":
                vd.View = DatabasesModel.Views.Views;
                return(View("Databases.Modal.Views", vd));
            }
            return(View("Databases.Modal.Tables", vd));
        }
Ejemplo n.º 20
0
        public ActionResult Top(string node, SQLInstance.TopSearchOptions options, bool?detailed = false)
        {
            var i = SQLInstance.Get(node);

            options.SetDefaults();


            var vd = new OperationsTopModel
            {
                View             = SQLViews.Top,
                Detailed         = detailed.GetValueOrDefault(),
                CurrentInstance  = i,
                TopSearchOptions = options
            };

            if (i != null)
            {
                var cache = i.GetTopOperations(options);
                vd.TopOperations = cache.SafeData(true);
                vd.ErrorMessage  = cache.ErrorMessage;
            }

            return(View("Operations.Top", vd));
        }
Ejemplo n.º 21
0
        public ActionResult ToggleAgentJob(string node, Guid guid, bool enable)
        {
            var instance = SQLInstance.Get(node);

            return(Json(instance.ToggleJob(guid, enable)));
        }
Ejemplo n.º 22
0
        public async Task <ActionResult> KillSpid(string node, int spid)
        {
            var instance = SQLInstance.Get(node);

            return(Json(await instance.KillSpid(spid)));
        }
Ejemplo n.º 23
0
        public async Task <ActionResult> StartAgentJob(string node, Guid guid)
        {
            var instance = SQLInstance.Get(node);

            return(Json(await instance.StartJobAsync(guid)));
        }
        public async Task <ActionResult> ToggleAgentJob(string node, Guid guid, bool enable)
        {
            var instance = SQLInstance.Get(node);

            return(Json(await instance.ToggleJobAsync(guid, enable).ConfigureAwait(false)));
        }
        public async Task <ActionResult> StopAgentJob(string node, Guid guid)
        {
            var instance = SQLInstance.Get(node);

            return(Json(await instance.StopJobAsync(guid).ConfigureAwait(false)));
        }
Ejemplo n.º 26
0
        public ActionResult StopAgentJob(string node, Guid guid)
        {
            var instance = SQLInstance.Get(node);

            return(Json(instance.StopJob(guid)));
        }