示例#1
0
 //Criar
 MemoryStream CreateCNAB240ReturnFile(CNAB240ReturnFileHeader Header, List <CNAB240ReturnFileLote> Lotes, CNAB240ReturnFileTrailerArquivo Trailer) => new CNAB240ReturnFile(Header, Lotes, Trailer).GeraArquivoCNAB240BB();
示例#2
0
        void FillReturnFile(FileDto CNAB240File)
        {
            //Fill Header
            var header = new CNAB240ReturnFileHeader()
            {
                Inscricao   = "123123123",
                Convenio    = "222222222",
                CodAgencia  = "1234",
                DVAgencia   = "1",
                NumeroConta = "123123123",
                DVConta     = "2",
                Nome        = "Alvaro Augusto de Marco Neto ME",
                Sequencia   = "1",
                Ocorrencias = CNAB240File.Status.Occurrence,
            };

            //Fill Lote
            int Lote        = 1;
            var lstLotes    = new List <CNAB240ReturnFileLote>();
            var retFileLote = new CNAB240ReturnFileLote()
            {
                //Fill Header Lote
                HeaderLote = new CNAB240ReturnFileHeaderLote()
                {
                    Lote             = Lote.ToString(),
                    Inscricao        = "123123",
                    Convenio         = "123123",
                    CodAgencia       = "123",
                    DVAgencia        = "3",
                    NumeroConta      = "123123",
                    DVConta          = "4",
                    Nome             = "Alvaro Augusto de Marco Neto ME",
                    Logradouro       = "Rua Rudi Schaly",
                    NumeroLogradouro = "146",
                    CasaAptoSala     = "",
                    Cidade           = "São Paulo",
                    CEP         = "05101",
                    ComplemCEP  = "060",
                    Estado      = "SP",
                    Ocorrencias = CNAB240File.Status.Occurrence,
                },
                SegmentoA = new List <CNAB240ReturnFileSegmentoA>(),

                //Fill Trailer Lote
                TrailerLote = new CNAB240ReturnFileTrailerLote()
                {
                    Lote = Lote.ToString(),
                }
            };

            //Iteração dos depósitos
            foreach (var depositDetail in CNAB240File.DepositDetails)
            {
                //Fill Segmento J
                retFileLote.SegmentoA.Add(new CNAB240ReturnFileSegmentoA()
                {
                    Lote       = Lote.ToString(),
                    Banco      = "123",
                    DataPagto  = depositDetail.Date,
                    ValorPagto = depositDetail.Value,
                    DataRealEfetivacaoPagto  = depositDetail.Date,
                    ValorRealEfetivacaoPagto = depositDetail.Value,
                    Ocorrencias = depositDetail.Status.Occurrence,
                    NrDocumentoAtribuidoEmpresa = depositDetail.ChaveBuscaUsuario,
                    NomeFavorecido = depositDetail.Nome,
                });
            }
            lstLotes.Add(retFileLote);

            //Fill Trailer
            var Trailer = new CNAB240ReturnFileTrailerArquivo()
            {
                Lote  = Lote.ToString(),
                Banco = "123",
            };

            CNAB240File.ReturnFile = CreateCNAB240ReturnFile(header, lstLotes, Trailer);

            SaveMemoryStream(CNAB240File.ReturnFile, Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "ArquivoRetorno.txt"));
        }