Ejemplo n.º 1
0
        /// <summary>
        /// Close the underlining Readers and Writers. (if any)
        /// </summary>
        public void Close()
        {
            try
            {
                if (mAsyncReader != null)
                {
                    mAsyncReader.Close();
                }

                mAsyncReader = null;
            }
            catch { }

            try
            {
                if (mAsyncWriter != null)
                {
                    WriteFooter(mAsyncWriter);

                    mAsyncWriter.Close();
                    mAsyncWriter = null;
                }
            }
            catch { }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Close the underlining Readers and Writers. (if any)
        /// </summary>
        public void Close()
        {
            try {
                if (mAsyncReader != null)
                {
                    mAsyncReader.Close();
                }

                mAsyncReader = null;
            }
            catch {}

            try {
                if (mAsyncWriter != null)
                {
                    if (!string.IsNullOrEmpty(mFooterText))
                    {
                        if (mFooterText.EndsWith(StringHelper.NewLine))
                        {
                            mAsyncWriter.Write(mFooterText);
                        }
                        else
                        {
                            mAsyncWriter.WriteLine(mFooterText);
                        }
                    }

                    mAsyncWriter.Close();
                    mAsyncWriter = null;
                }
            }
            catch {}
        }
Ejemplo n.º 3
0
        private void ReadNextRecord()
        {
            string currentLine = mAsyncReader.ReadNextLine();

            mLineNumber++;

            bool byPass = false;

#if !GENERICS
            mLastRecord = null;
#else
            mLastRecord = default(T);
#endif
            while (true)
            {
                if (currentLine != null)
                {
                    try
                    {
                        mTotalRecords++;

#if !GENERICS
                        mLastRecord = mRecordInfo.StringToRecord(currentLine, mAsyncReader);
#else
                        mLastRecord = (T)mRecordInfo.StringToRecord(currentLine, mAsyncReader);
#endif

                        if (mLastRecord != null)
                        {
                            byPass = true;
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        switch (mErrorManager.ErrorMode)
                        {
                        case ErrorMode.ThrowException:
                            byPass = true;
                            throw;

                        case ErrorMode.IgnoreAndContinue:
                            break;

                        case ErrorMode.SaveAndContinue:
                            ErrorInfo err = new ErrorInfo();
                            err.mLineNumber    = mAsyncReader.LineNumber;
                            err.mExceptionInfo = ex;
                            //							err.mColumnNumber = mColumnNum;
                            err.mRecordString = currentLine;

                            mErrorManager.AddError(err);
                            break;
                        }
                    }
                    finally
                    {
                        if (byPass == false)
                        {
                            currentLine = mAsyncReader.ReadNextLine();
                            mLineNumber = mAsyncReader.LineNumber;
                        }
                    }
                }
                else
                {
#if !GENERICS
                    mLastRecord = null;
#else
                    mLastRecord = default(T);
#endif


                    if (mRecordInfo.mIgnoreLast > 0)
                    {
                        mFooterText = mAsyncReader.RemainingText;
                    }

                    try
                    {
                        mAsyncReader.Close();
                    }
                    catch
                    {
                    }

                    return;
                }
            }
        }