@@ -19,15 +19,17 @@ export function activate(context: vscode.ExtensionContext) {
1919 context . subscriptions . push ( disposable_oediag ) ;
2020
2121 // checking spblitz versioning
22- var getblitzversion = async ( context : sqlops . ObjectExplorerContext ) => {
22+ var getblitzversion = async ( context ? : sqlops . ObjectExplorerContext ) => {
2323 var amIUPD = new updatecheck ( ) ;
2424 let updateReturn = await amIUPD . checkForUpdates ( context ) ;
25+ if ( updateReturn ) {
26+ if ( updateReturn == 'update' ) {
27+ getblitzall ( ) ;
28+ } else if ( updateReturn != '' ) {
29+ let versionURL = 'https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/releases/tag/' + updateReturn ;
30+ vscode . commands . executeCommand ( 'vscode.open' , vscode . Uri . parse ( versionURL ) ) ;
31+ }
2532
26- if ( updateReturn == 'update' ) {
27- getblitzall ( ) ;
28- } else if ( updateReturn != '' ) {
29- let versionURL = 'https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/releases/tag/' + updateReturn ;
30- vscode . commands . executeCommand ( 'vscode.open' , vscode . Uri . parse ( versionURL ) ) ;
3133 } else {
3234 // do nothing
3335 }
@@ -222,6 +224,57 @@ export function activate(context: vscode.ExtensionContext) {
222224 var disposable_runspblitzfirst = vscode . commands . registerCommand ( 'extension.run_sp_blitzfirst' , runspblitzfirst ) ;
223225 context . subscriptions . push ( disposable_runspblitzfirst ) ;
224226
227+ //creating the quickrun script for blitzlock
228+ var runspblitzlock = async ( context ?: sqlops . ObjectExplorerContext ) => {
229+ let fileName = "exec_sp_blitzlock.sql" ;
230+ let scriptText = '' ;
231+ if ( context && context . nodeInfo ) {
232+ let scriptType = context . nodeInfo . nodeType ;
233+ fileName = context . nodeInfo . label + '-' + fileName ;
234+ var nodeBreakdown = context . nodeInfo . nodePath . split ( "/" ) ;
235+ let dbName = nodeBreakdown [ 2 ] ;
236+ switch ( scriptType ) {
237+ case "Database" : {
238+ scriptText = `EXEC [dbo].[sp_BlitzLock]
239+ @DatabaseName = '${ dbName } ',
240+ --@TableName = '',
241+ @Top = 10` ;
242+ break ;
243+ }
244+ default : {
245+ scriptText = `EXEC [dbo].[sp_BlitzLock]
246+ @Top = 10` ;
247+ break ;
248+ }
249+ }
250+ } else {
251+ scriptText = `EXEC [dbo].[sp_BlitzLock]
252+ @Top = 10
253+ --@DatabaseName = '',` ;
254+ }
255+ scriptText += `
256+ -- for more info: https://www.brentozar.com/archive/2017/12/introducing-sp_blitzlock-troubleshooting-sql-server-deadlocks/
257+ ` ;
258+ new placeScript ( ) . placescript ( fileName , scriptText , context ) ;
259+ } ;
260+ var disposable_runspblitzlock = vscode . commands . registerCommand ( 'extension.run_sp_blitzlock' , runspblitzlock ) ;
261+ context . subscriptions . push ( disposable_runspblitzlock ) ;
262+
263+ //creating the quickrun script for whoisactive
264+ var runspwhoisactive = async ( context ?: sqlops . ObjectExplorerContext ) => {
265+ let fileName = "exec_sp_whoisactive.sql" ;
266+ console . log ( 'Preparing sample run script.' ) ;
267+ const scriptText = `EXEC sp_WhoIsActive
268+ @find_block_leaders = 1,
269+ @sort_order = '[blocked_session_count] DESC'
270+
271+ -- for more info: http://whoisactive.com/docs/
272+ ` ;
273+ new placeScript ( ) . placescript ( fileName , scriptText , context ) ;
274+ } ;
275+ var disposable_runspwhoisactive = vscode . commands . registerCommand ( 'extension.run_sp_whoisactive' , runspwhoisactive ) ;
276+ context . subscriptions . push ( disposable_runspwhoisactive ) ;
277+
225278}
226279
227280export function deactivate ( ) {
0 commit comments