Пример #1
0
        public void ProcessProgress(ProcessorContext processorContext, string progressInfo)
        {
            string statement = "print '" + progressInfo.Replace("'", "''") + "'\r\n";

            ProcessBatch(processorContext, statement);
        }
Пример #2
0
        public virtual void Process()
        {
            ProcessorContext processorContext = new ProcessorContext(m_options.ScriptFile);

            try {
                using (Stream stream = OpenInputFile())
                    using (StreamReader reader = new StreamReader(stream, Encoding.Default, true)) {
                        m_ppTraces.Flush();
                        while (!reader.EndOfStream && !PreprocessorExitedWithError && !m_isCanceled)
                        {
                            string   line = reader.ReadLine();
                            LineType type = GetLineType(line);
                            switch (type)
                            {
                            case LineType.Text:
                                ProcessText(processorContext, line);
                                break;

                            case LineType.Line:
                                ProcessLine(processorContext, line);
                                break;

                            case LineType.Exec:
                                string batch = processorContext.CurrentBatch;
                                if (!IsWhiteSpaceOnly(batch))
                                {
                                    ProcessBatch(processorContext, batch);
                                    processorContext.IncrementBatchNumber();
                                }
                                processorContext.IncrementLineNumber();
                                processorContext.StartNextBatch();
                                break;

                            default:
                                throw new NotSupportedException("Unexepected line type: " + type);
                            }
                            m_ppTraces.Flush();
                        }
                    }
                if (!PreprocessorExitedWithError)
                {
                    string lastBatch = processorContext.CurrentBatch;
                    if (!IsWhiteSpaceOnly(lastBatch))
                    {
                        ProcessBatch(processorContext, lastBatch);
                        processorContext.IncrementBatchNumber();
                    }
                }
            }
            catch (TerminateException) {
                ++m_errorCount;
                throw;
            }
            catch (Exception ex) {
                string message = String.Format("{0}({1}): Error: {2}", processorContext.CurrentFile, processorContext.CurrentBatchLineNo, ex.Message);
                Trace.WriteLineIf(GlobalSettings.Verbosity.TraceError, message);
                string lastBatch = processorContext.CurrentBatch;
                if (!String.IsNullOrEmpty(lastBatch) && GlobalSettings.Verbosity.TraceInfo)
                {
                    Trace.Indent();
                    Trace.WriteLine(lastBatch);
                    Trace.Unindent();
                }
                ++m_errorCount;
                throw new TerminateException(ExitCode.SqlCommandError);
            }
        }
Пример #3
0
        /// <summary>
        /// Formats the error message for the output.
        /// </summary>
        /// <param name="severity">
        /// The severity of the (error) message.
        /// </param>
        /// <param name="message">
        /// The error message.
        /// </param>
        /// <param name="errorLineNumber">
        /// The line number where error was reported.
        /// </param>
        /// <returns>The formated message.</returns>
        internal static string FormatError(ProcessorContext processorContext, TraceLevel severity, string message, int errorLineNumber)
        {
            string error = processorContext.FormatError(severity, message, errorLineNumber);

            return(error);
        }
Пример #4
0
 public void ProcessProgress(ProcessorContext context, string progressInfo)
 {
     m_context = context;
     Trace.WriteLineIf(GlobalSettings.Verbosity.TraceInfo, progressInfo);
 }