/// <summary> /// Called when batch is done /// </summary> /// <param name="sender"></param> /// <param name="e"></param> static void OnBatchParserExecutionFinished(object sender, BatchParserExecutionFinishedEventArgs e) { Console.WriteLine("ON_BATCH_PARSER_EXECUTION_FINISHED : Done executing batch \n\t{0}\n\t with result... {1} ", e.Batch.Text, e.ExecutionResult); if (execResult == ScriptExecutionResult.All) { execResult = e.ExecutionResult; } else { execResult = execResult | e.ExecutionResult; } }
private void OnBatchParserExecutionFinished(object sender, BatchParserExecutionFinishedEventArgs args) { try { if (args != null && args.Batch != null) { Tuple <int /*startLine*/, int /*startColumn*/> position = new Tuple <int, int>(args.Batch.TextSpan.iStartLine, args.Batch.TextSpan.iStartIndex); // PS168371 // // There is a bug in the batch parser where it appends a '\n' to the end of the last // batch if a GO or statement appears at the end of the string without a \r\n. This is // throwing off length calculations in other places in the code because the length of // the string returned is longer than the length of the actual string // // To work around this issue we detect this case (a single \n without a preceding \r // and then adjust the length accordingly string batchText = args.Batch.Text; int batchTextLength = batchText.Length; if (!batchText.EndsWith(Environment.NewLine, StringComparison.Ordinal) && batchText.EndsWith("\n", StringComparison.Ordinal)) { batchTextLength -= 1; } // Add the script info startLineColumns.Add(position); lengths.Add(batchTextLength); } } catch (NotImplementedException) { // intentionally swallow } catch (Exception e) { // adding this for debugging Logger.Write(LogLevel.Warning, "Exception Caught in BatchParserWrapper.OnBatchParserExecutionFinished(...)" + e.ToString()); throw; } }
// Capture the event once batch finish execution. private void OnBatchParserExecutionFinished(object sender, BatchParserExecutionFinishedEventArgs e) { executionResult = e.ExecutionResult; }