protected override void EndProcessing() { for (int l = 0; l < _logins.Count; l++) { if (this.Force || base.ShouldProcess(this.InputObject.Name + " on " + _server.Name, "Remove")) { var activeProcs = SqlProcessCollection.GetProcesses(this.InputObject.Name, _server); if (activeProcs.Count > 0) { activeProcs.KillAll(); } this.InputObject.Drop(); } } _server.Refresh(); }
protected override void ProcessRecord() { if (_server == null && this.InputObject != null) { _server = this.InputObject.Parent; } if (_server == null) { throw new SmoContextNotSetException(); } if (!string.IsNullOrEmpty(this.LoginName) && base.GetLoginFromName(this.LoginName, out SmoLogin found)) { this.InputObject = found; } if (this.MyInvocation.BoundParameters.ContainsKey("ProcessId")) { base.WriteObject(this.FindProcess(this.ProcessId)); } else { SqlProcessCollection col = this.InputObject != null ? this.FindProcess(this.InputObject) : this.FindProcess(); if (this.Status.HasValue) { col = (SqlProcessCollection)col.FindAll(x => x.Status.HasValue && x.Status.Value == this.Status.Value); } switch (this.SortBy) { case "Id": { if (_dynLib.ParameterHasValue("Ascending") && _dynLib.GetParameterValue <bool>("Ascending")) { col.SortBySpid(true); } else { col.SortBySpid(false); } break; } case "Login": col.SortByLogin(); break; case "Program": col.SortByProgram(); break; default: col.SortBySpid(false); break; } base.WriteObject(col, true); } }
protected private SqlProcessCollection FindProcess(SmoLogin login) => SqlProcessCollection.GetProcesses(login.Name, _server);
protected private SqlProcess FindProcess(int processId) => SqlProcessCollection.GetProcess(processId, _server);
protected private SqlProcessCollection FindProcess() => SqlProcessCollection.GetProcesses(_server);