예제 #1
0
        public void Import(string fileName)
        {
            int lineHeader = 0;

            Sample2 sample2Layout = new Sample2();

            ImportFile = new ImportFile(sample2Layout);
            if (ImportFile.PrepareFile(fileName))
            {
                Lines.Clear();

                while (ImportFile.ReadLine() && !ImportFile.ReadFailure)
                {
                    Lines.Append(ImportFile.Line + Environment.NewLine);

                    //The Sample2 line Identifier is encountered in column 1
                    //Delimited layout should always mark the column identifier
                    ImportFile.SetIdentificadorCorrente(ImportFile.CurrentLine["Col_1"].ToString());

                    switch ((Sample2.RecordType) int.Parse(ImportFile.CurrentIdentifier))
                    {
                    case Sample2.RecordType.Header:

                        lineHeader = ImportFile.CurrentLineNumber;
                        sample2Layout.HeaderRows.Add(new Sample2.HeaderRow(ImportFile.CurrentLine));
                        sample2Layout.HeaderRows.Last().LineNumber = ImportFile.CurrentLineNumber;
                        break;

                    case Sample2.RecordType.Detail:

                        sample2Layout.DetailRows.Add(new Sample2.DetailRow(ImportFile.CurrentLine));
                        sample2Layout.DetailRows.Last().LineNumber       = ImportFile.CurrentLineNumber;
                        sample2Layout.DetailRows.Last().ParentLineNumber = lineHeader;
                        break;

                    case Sample2.RecordType.Trailer:
                        sample2Layout.TrailerRows.Add(new Sample2.TrailerRow(ImportFile.CurrentLine));
                        sample2Layout.TrailerRows.Last().LineNumber       = ImportFile.CurrentLineNumber;
                        sample2Layout.TrailerRows.Last().ParentLineNumber = lineHeader;
                        break;
                    }

                    if (this.ImportOnlyFirstLine)
                    {
                        break;
                    }
                }

                if (ImportFile.Error)
                {
                    AddLineError("INTERNAL", ImportFile.ErrorDescription, ImportFile.CurrentLineNumber);
                }
            }
            else
            {
                AddLineError("INTERNAL", ImportFile.ErrorDescription, ImportFile.CurrentLineNumber);
            }
        }
예제 #2
0
        public void Import(string fileName)
        {
            int lineHeader = 0;

            Sample1 sample1Layout = new Sample1();

            ImportFile = new ImportFile(sample1Layout);
            if (ImportFile.PrepareFile(fileName))
            {
                Lines.Clear();

                while (ImportFile.ReadLine() && !ImportFile.ReadFailure)
                {
                    Lines.Append(ImportFile.Line + Environment.NewLine);

                    switch ((Sample1.RecordType) int.Parse(ImportFile.CurrentIdentifier))
                    {
                    case Sample1.RecordType.Header:

                        lineHeader = ImportFile.CurrentLineNumber;
                        sample1Layout.HeaderRows.Add(new Sample1.HeaderRow(ImportFile.CurrentLine));
                        sample1Layout.HeaderRows.Last().LineNumber = ImportFile.CurrentLineNumber;
                        break;

                    case Sample1.RecordType.Detail:

                        sample1Layout.DetailRows.Add(new Sample1.DetailRow(ImportFile.CurrentLine));
                        sample1Layout.DetailRows.Last().LineNumber       = ImportFile.CurrentLineNumber;
                        sample1Layout.DetailRows.Last().ParentLineNumber = lineHeader;
                        break;

                    case Sample1.RecordType.Trailer:
                        sample1Layout.TrailerRows.Add(new Sample1.TrailerRow(ImportFile.CurrentLine));
                        sample1Layout.TrailerRows.Last().LineNumber       = ImportFile.CurrentLineNumber;
                        sample1Layout.TrailerRows.Last().ParentLineNumber = lineHeader;
                        break;
                    }

                    if (this.ImportOnlyFirstLine)
                    {
                        break;
                    }
                }

                if (ImportFile.Error)
                {
                    AddLineError("INTERNAL", ImportFile.ErrorDescription, ImportFile.CurrentLineNumber);
                }
            }
            else
            {
                AddLineError("INTERNAL", ImportFile.ErrorDescription, ImportFile.CurrentLineNumber);
            }
        }
예제 #3
0
        public void Import(string fileName)
        {
            int lineHeader    = 0;
            int linePagamento = 0;
            int lineSOC       = 0;

            Amex amexLayout = new Amex();

            ImportFile = new ImportFile(amexLayout);
            if (ImportFile.PrepareFile(fileName))
            {
                Lines.Clear();

                while (ImportFile.ReadLine() && !ImportFile.ReadFailure)
                {
                    Lines.Append(ImportFile.Line + Environment.NewLine);

                    //The Amex line Identifier is encountered in column 6
                    //Delimited layout should always mark the column identifier
                    ImportFile.SetIdentificadorCorrente(ImportFile.CurrentLine["Col_6"].ToString());

                    switch ((Amex.RecordType) int.Parse(ImportFile.CurrentIdentifier))
                    {
                    case Amex.RecordType.Header:

                        lineHeader = ImportFile.CurrentLineNumber;
                        amexLayout.HeaderRows.Add(new Amex.HeaderRow(ImportFile.CurrentLine));
                        amexLayout.HeaderRows.Last().LineNumber = ImportFile.CurrentLineNumber;
                        break;

                    case Amex.RecordType.Pagamento:

                        linePagamento = ImportFile.CurrentLineNumber;
                        amexLayout.PagamentoRows.Add(new Amex.PagamentoRow(ImportFile.CurrentLine));
                        amexLayout.PagamentoRows.Last().LineNumber       = ImportFile.CurrentLineNumber;
                        amexLayout.PagamentoRows.Last().ParentLineNumber = lineHeader;
                        break;

                    case Amex.RecordType.SOC:

                        lineSOC = ImportFile.CurrentLineNumber;
                        amexLayout.SOCRows.Add(new Amex.SOCRow(ImportFile.CurrentLine));
                        amexLayout.SOCRows.Last().LineNumber       = ImportFile.CurrentLineNumber;
                        amexLayout.SOCRows.Last().ParentLineNumber = linePagamento;
                        break;

                    case Amex.RecordType.ROC:
                        amexLayout.ROCRows.Add(new Amex.ROCRow(ImportFile.CurrentLine));
                        amexLayout.ROCRows.Last().LineNumber       = ImportFile.CurrentLineNumber;
                        amexLayout.ROCRows.Last().ParentLineNumber = lineSOC;
                        break;

                    case Amex.RecordType.Ajustes:
                        amexLayout.AjustesRows.Add(new Amex.AjustesRow(ImportFile.CurrentLine));
                        amexLayout.AjustesRows.Last().LineNumber       = ImportFile.CurrentLineNumber;
                        amexLayout.AjustesRows.Last().ParentLineNumber = linePagamento;
                        break;

                    case Amex.RecordType.Trailer:
                        amexLayout.TrailerRows.Add(new Amex.TrailerRow(ImportFile.CurrentLine));
                        amexLayout.TrailerRows.Last().LineNumber       = ImportFile.CurrentLineNumber;
                        amexLayout.TrailerRows.Last().ParentLineNumber = lineHeader;
                        break;
                    }

                    if (this.ImportOnlyFirstLine)
                    {
                        break;
                    }
                }

                if (ImportFile.Error)
                {
                    AddLineError("INTERNAL", ImportFile.ErrorDescription, ImportFile.CurrentLineNumber);
                }
            }
            else
            {
                AddLineError("INTERNAL", ImportFile.ErrorDescription, ImportFile.CurrentLineNumber);
            }
        }
예제 #4
0
        public void Import(string fileName)
        {
            int lineHeader   = 0;
            int lineCapaLote = 0;

            Hipercard hipercardLayout = new Hipercard();

            this.ImportFile = new ImportFile(hipercardLayout);
            if (ImportFile.PrepareFile(fileName))
            {
                Lines.Clear();

                while ((ImportFile.ReadLine() && !ImportFile.ReadFailure))
                {
                    Lines.Append(ImportFile.Line + Environment.NewLine);

                    switch ((Hipercard.RecordType) int.Parse(ImportFile.CurrentIdentifier))
                    {
                    case Hipercard.RecordType.Header:

                        lineHeader = ImportFile.CurrentLineNumber;
                        hipercardLayout.HeaderRows.Add(new Hipercard.HeaderRow(ImportFile.CurrentLine));
                        hipercardLayout.HeaderRows.Last().LineNumber = ImportFile.CurrentLineNumber;
                        break;

                    case Hipercard.RecordType.CapaLote:

                        lineCapaLote = ImportFile.CurrentLineNumber;
                        hipercardLayout.CapaLoteRows.Add(new Hipercard.CapaLoteRow(ImportFile.CurrentLine));
                        hipercardLayout.CapaLoteRows.Last().LineNumber       = ImportFile.CurrentLineNumber;
                        hipercardLayout.CapaLoteRows.Last().ParentLineNumber = lineHeader;

                        break;

                    case Hipercard.RecordType.MovimentoVenda:

                        hipercardLayout.MovVendaRows.Add(new Hipercard.MovimentoVendaRow(ImportFile.CurrentLine));
                        hipercardLayout.MovVendaRows.Last().LineNumber       = ImportFile.CurrentLineNumber;
                        hipercardLayout.MovVendaRows.Last().ParentLineNumber = lineCapaLote;

                        break;

                    case Hipercard.RecordType.PrevisaoPagamento:

                        hipercardLayout.PrevPagtoRows.Add(new Hipercard.PrevisaoPagamentoRow(ImportFile.CurrentLine));
                        hipercardLayout.PrevPagtoRows.Last().LineNumber       = ImportFile.CurrentLineNumber;
                        hipercardLayout.PrevPagtoRows.Last().ParentLineNumber = lineCapaLote;

                        break;

                    case Hipercard.RecordType.Desagendamento:

                        hipercardLayout.DesagendaRows.Add(new Hipercard.DesagendamentoRow(ImportFile.CurrentLine));
                        hipercardLayout.DesagendaRows.Last().LineNumber       = ImportFile.CurrentLineNumber;
                        hipercardLayout.DesagendaRows.Last().ParentLineNumber = lineCapaLote;

                        break;

                    case Hipercard.RecordType.Ajustes:

                        hipercardLayout.AjustesRows.Add(new Hipercard.AjustesRow(ImportFile.CurrentLine));
                        hipercardLayout.AjustesRows.Last().LineNumber       = ImportFile.CurrentLineNumber;
                        hipercardLayout.AjustesRows.Last().ParentLineNumber = lineCapaLote;

                        break;

                    case Hipercard.RecordType.Tarifas:

                        hipercardLayout.TarifasRows.Add(new Hipercard.TarifasRow(ImportFile.CurrentLine));
                        hipercardLayout.TarifasRows.Last().LineNumber       = ImportFile.CurrentLineNumber;
                        hipercardLayout.TarifasRows.Last().ParentLineNumber = lineCapaLote;

                        break;

                    case Hipercard.RecordType.Trailer:

                        hipercardLayout.TrailerRows.Add(new Hipercard.TrailerRow(ImportFile.CurrentLine));
                        hipercardLayout.TrailerRows.Last().LineNumber       = ImportFile.CurrentLineNumber;
                        hipercardLayout.TrailerRows.Last().ParentLineNumber = lineHeader;

                        break;
                    }

                    if (this.ImportOnlyFirstLine)
                    {
                        break;
                    }
                }

                if (ImportFile.Error)
                {
                    AddLineError("INTERNAL", ImportFile.ErrorDescription, ImportFile.CurrentLineNumber);
                }
            }
        }