├── BoletoOnline.Class ├── Manual_Registro_de_Boleto_Bancario_Online_Mar18.pdf ├── packages.config ├── Uteis │ ├── ParametrosUteis.cs │ └── MetodosUteis.cs ├── App.config ├── Properties │ └── AssemblyInfo.cs ├── BoletoOnline.Class.csproj ├── RemessaCobrancaOnlineService.cs └── Objetos │ ├── EnvioRemessaCobrancaBradescoJson.cs │ └── RetornoRemessaCobrancaBradescoJson.cs ├── BoletoOnline.Test ├── Program.cs ├── App.config ├── Properties │ └── AssemblyInfo.cs └── BoletoOnline.Test.csproj ├── README.md ├── BoletoOnline.Solucao.sln └── .gitignore /BoletoOnline.Class/Manual_Registro_de_Boleto_Bancario_Online_Mar18.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hgmauri/registro-boleto-online-bradesco/HEAD/BoletoOnline.Class/Manual_Registro_de_Boleto_Bancario_Online_Mar18.pdf -------------------------------------------------------------------------------- /BoletoOnline.Class/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /BoletoOnline.Test/Program.cs: -------------------------------------------------------------------------------- 1 | using BoletoOnline.Class; 2 | using BoletoOnline.Class.Objetos; 3 | 4 | namespace BoletoOnline.Test 5 | { 6 | class Program 7 | { 8 | static void Main(string[] args) 9 | { 10 | RemessaCobrancaOnlineService teste = new RemessaCobrancaOnlineService(); 11 | 12 | teste.AssinarCriptografar(new EnvioRemessaCobrancaBradescoJson()); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /BoletoOnline.Test/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /BoletoOnline.Class/Uteis/ParametrosUteis.cs: -------------------------------------------------------------------------------- 1 | using System.Configuration; 2 | 3 | namespace BoletoOnline.Class.Uteis 4 | { 5 | public class ParametrosUteis 6 | { 7 | public static string RetornaImpressaoDigitalCertificado() 8 | { 9 | #if DEBUG 10 | { 11 | return ConfigurationManager.AppSettings["ImpressaoDigitalCertificadoHomologacao"]; 12 | 13 | } 14 | #endif 15 | return ConfigurationManager.AppSettings["ImpressaoDigitalCertificadoProducao"]; 16 | } 17 | 18 | public static string RetornaUrlEnvio() 19 | { 20 | #if DEBUG 21 | { 22 | return "https://cobranca.bradesconetempresa.b.br/ibpjregistrotitulows/registrotitulohomologacao"; 23 | 24 | } 25 | #endif 26 | return "https://cobranca.bradesconetempresa.b.br/ibpjregistrotitulows/registrotitulo"; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /BoletoOnline.Class/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /BoletoOnline.Test/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("BoletoOnline.Test")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("BoletoOnline.Test")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("252c2d9f-4aed-422f-a737-8bd6f66b7500")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /BoletoOnline.Class/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("BoletoOnline.Class")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("BoletoOnline.Class")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("839967a8-e775-47a0-85eb-8121c13912d3")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # registro-boleto-online-bradesco 2 | Integração com banco Bradesco de remessa de cobrança online em formato JSON 3 | 4 | Pré-Requisitos: 5 | 6 | - Certificado tipo A1 e-cpf ou e-cnpj com chave privada emitido por autoridade participante do ICP-Brasil 7 | - Biblioteca Bouncy Castle: http://www.bouncycastle.org/csharp/index.html 8 | - Biblioteca Newtonsoft.Json 9 | - JSON com aspas duplas 10 | - Todos os campos não obrigatórios numéricos do JSON devem ser: "0" e os alfanuméricos deverm ser: "" 11 | - Ler o manual: [Manual Registro de Boleto Bancário On-line_v 2_0.pdf] 12 | 13 | Erros comuns: 14 | 15 | - Permissão do certificado: após instalado na máquina se faz necessário conceder permissão ao usuário que está executando o código. (CryptographicException 'Keyset does not exist') Solução: https://stackoverflow.com/questions/12106011/system-security-cryptography-cryptographicexception-keyset-does-not-exist 16 | - Não encontrou o certificado: o código lê certificados que se encontram na pasta Pessoal da máquina local, é possível instalar certificado em diversos grupos/pastas e em repositórios distintos como máquina local ou usuários específicos, atentar a isso. 17 | - Não está assinando o documento: Verificar se o certificado é do tipo A1 emitido pelo ICP-Brasil 18 | 19 | Agradecimentos 20 | - @Gread pelo apoio, dicas e códigos 21 | - @BoletoNet pelo forum de conhecimento 22 | 23 | [Manual Registro de Boleto Bancário On-line_v 2_0.pdf]: 24 | -------------------------------------------------------------------------------- /BoletoOnline.Solucao.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26730.12 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BoletoOnline.Class", "BoletoOnline.Class\BoletoOnline.Class.csproj", "{839967A8-E775-47A0-85EB-8121C13912D3}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BoletoOnline.Test", "BoletoOnline.Test\BoletoOnline.Test.csproj", "{252C2D9F-4AED-422F-A737-8BD6F66B7500}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {839967A8-E775-47A0-85EB-8121C13912D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {839967A8-E775-47A0-85EB-8121C13912D3}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {839967A8-E775-47A0-85EB-8121C13912D3}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {839967A8-E775-47A0-85EB-8121C13912D3}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {252C2D9F-4AED-422F-A737-8BD6F66B7500}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {252C2D9F-4AED-422F-A737-8BD6F66B7500}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {252C2D9F-4AED-422F-A737-8BD6F66B7500}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {252C2D9F-4AED-422F-A737-8BD6F66B7500}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {ADC5AA7B-0384-445B-90EE-6E41F89C67E0} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /BoletoOnline.Test/BoletoOnline.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {252C2D9F-4AED-422F-A737-8BD6F66B7500} 8 | Exe 9 | BoletoOnline.Test 10 | BoletoOnline.Test 11 | v4.6.1 12 | 512 13 | SAK 14 | SAK 15 | SAK 16 | SAK 17 | 18 | 19 | 20 | AnyCPU 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | false 29 | 30 | 31 | AnyCPU 32 | pdbonly 33 | true 34 | bin\Release\ 35 | TRACE 36 | prompt 37 | 4 38 | false 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | {839967a8-e775-47a0-85eb-8121c13912d3} 56 | BoletoOnline.Class 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /BoletoOnline.Class/BoletoOnline.Class.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {839967A8-E775-47A0-85EB-8121C13912D3} 8 | Library 9 | Properties 10 | BoletoOnline.Class 11 | BoletoOnline.Class 12 | v4.6.1 13 | 512 14 | SAK 15 | SAK 16 | SAK 17 | SAK 18 | 19 | 20 | 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | false 29 | 30 | 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | false 38 | 39 | 40 | 41 | ..\packages\BouncyCastle.1.8.4\lib\BouncyCastle.Crypto.dll 42 | 43 | 44 | ..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /BoletoOnline.Class/RemessaCobrancaOnlineService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Net; 6 | using System.Security.Cryptography.X509Certificates; 7 | using System.Text; 8 | using System.Xml.Linq; 9 | using BoletoOnline.Class.Objetos; 10 | using BoletoOnline.Class.Uteis; 11 | using Newtonsoft.Json; 12 | using Org.BouncyCastle.Cms; 13 | using Org.BouncyCastle.Crypto.Operators; 14 | using Org.BouncyCastle.Security; 15 | using Org.BouncyCastle.X509.Store; 16 | 17 | namespace BoletoOnline.Class 18 | { 19 | public class RemessaCobrancaOnlineService 20 | { 21 | public void AssinarCriptografar(EnvioRemessaCobrancaBradescoJson model) 22 | { 23 | try 24 | { 25 | var utilClass = new MetodosUteis(); 26 | var encoding = new UTF8Encoding(); 27 | var generator = new CmsSignedDataGenerator(); 28 | var signerInfoGeneratorBuilder = new SignerInfoGeneratorBuilder(); 29 | var certList = new ArrayList(); 30 | 31 | var criticas = utilClass.Criticas(model); 32 | if (criticas.Any()) 33 | { 34 | return; 35 | } 36 | 37 | var data = utilClass.ConverterParaJsonAspasSimples(model); 38 | 39 | var privateCert = this.RetornaCertificado(); 40 | 41 | //convertendo certificado para objeto que o bouncycastle conhece 42 | var bouncyCastleKey = DotNetUtilities.GetKeyPair(privateCert.PrivateKey).Private; 43 | var x5091 = new X509Certificate(privateCert.RawData); 44 | var x509CertBouncyCastle = DotNetUtilities.FromX509Certificate(x5091); 45 | 46 | generator.AddSignerInfoGenerator(signerInfoGeneratorBuilder.Build(new Asn1SignatureFactory("SHA256WithRSA", bouncyCastleKey), x509CertBouncyCastle)); 47 | 48 | //criando certstore que o bouncycastle conhece 49 | certList.Add(x509CertBouncyCastle); 50 | 51 | var store509BouncyCastle = X509StoreFactory.Create("Certificate/Collection", new X509CollectionStoreParameters(certList)); 52 | generator.AddCertificates(store509BouncyCastle); 53 | 54 | var messageBytes = encoding.GetBytes(data); 55 | var cmsdata = new CmsProcessableByteArray(messageBytes); 56 | 57 | //assina 58 | var signeddata = generator.Generate(cmsdata, true); 59 | var mensagemFinal = signeddata.GetEncoded(); 60 | 61 | //converte para base64 que eh o formato que o serviço espera 62 | var mensagemConvertidaparaBase64 = Convert.ToBase64String(mensagemFinal); 63 | 64 | //chama serviço convertendo a string na base64 em bytes 65 | EnviaParaWebService(ParametrosUteis.RetornaUrlEnvio(), encoding.GetBytes(mensagemConvertidaparaBase64)); 66 | } 67 | catch (Exception ex) 68 | { 69 | throw ex; 70 | } 71 | } 72 | 73 | private X509Certificate2 RetornaCertificado() 74 | { 75 | var impressaDigitalCertificado = ParametrosUteis.RetornaImpressaoDigitalCertificado(); 76 | 77 | var store = new X509Store(StoreLocation.LocalMachine); 78 | 79 | store.Open(OpenFlags.ReadOnly); 80 | 81 | var privateCert = store.Certificates.Cast().FirstOrDefault(cert => cert.Thumbprint == impressaDigitalCertificado && cert.HasPrivateKey); 82 | 83 | if (privateCert == null) 84 | throw new Exception("Certificado não localizado."); 85 | if (privateCert.PrivateKey == null) 86 | throw new Exception("chave privada não localizada no certificado."); 87 | 88 | return privateCert; 89 | } 90 | 91 | private void EnviaParaWebService(string uri, byte[] sig) 92 | { 93 | //TLS 1.2 94 | ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; 95 | 96 | var request = WebRequest.Create(uri); 97 | 98 | request.Method = "POST"; 99 | request.ContentType = "application/pkcs7-signature"; 100 | request.ContentLength = sig.Length; 101 | 102 | using (var requestStream = request.GetRequestStream()) 103 | { 104 | requestStream.Write(sig, 0, sig.Length); 105 | } 106 | 107 | var response = request.GetResponse(); 108 | 109 | using (var stream = response.GetResponseStream()) 110 | { 111 | if (stream == null) 112 | { 113 | throw new ApplicationException("erro ao obter resposta"); 114 | } 115 | 116 | var reader = new StreamReader(stream); 117 | 118 | // resultado FINAL aqui 119 | var retorno = reader.ReadToEnd(); 120 | 121 | var respostaAqui = JsonConvert.DeserializeObject(XDocument.Parse(retorno).Root.Value); 122 | } 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # MSTest test Results 33 | [Tt]est[Rr]esult*/ 34 | [Bb]uild[Ll]og.* 35 | 36 | # NUNIT 37 | *.VisualState.xml 38 | TestResult.xml 39 | 40 | # Build Results of an ATL Project 41 | [Dd]ebugPS/ 42 | [Rr]eleasePS/ 43 | dlldata.c 44 | 45 | # .NET Core 46 | project.lock.json 47 | project.fragment.lock.json 48 | artifacts/ 49 | **/Properties/launchSettings.json 50 | 51 | *_i.c 52 | *_p.c 53 | *_i.h 54 | *.ilk 55 | *.meta 56 | *.obj 57 | *.pch 58 | *.pdb 59 | *.pgc 60 | *.pgd 61 | *.rsp 62 | *.sbr 63 | *.tlb 64 | *.tli 65 | *.tlh 66 | *.tmp 67 | *.tmp_proj 68 | *.log 69 | *.vspscc 70 | *.vssscc 71 | .builds 72 | *.pidb 73 | *.svclog 74 | *.scc 75 | 76 | # Chutzpah Test files 77 | _Chutzpah* 78 | 79 | # Visual C++ cache files 80 | ipch/ 81 | *.aps 82 | *.ncb 83 | *.opendb 84 | *.opensdf 85 | *.sdf 86 | *.cachefile 87 | *.VC.db 88 | *.VC.VC.opendb 89 | 90 | # Visual Studio profiler 91 | *.psess 92 | *.vsp 93 | *.vspx 94 | *.sap 95 | 96 | # TFS 2012 Local Workspace 97 | $tf/ 98 | 99 | # Guidance Automation Toolkit 100 | *.gpState 101 | 102 | # ReSharper is a .NET coding add-in 103 | _ReSharper*/ 104 | *.[Rr]e[Ss]harper 105 | *.DotSettings.user 106 | 107 | # JustCode is a .NET coding add-in 108 | .JustCode 109 | 110 | # TeamCity is a build add-in 111 | _TeamCity* 112 | 113 | # DotCover is a Code Coverage Tool 114 | *.dotCover 115 | 116 | # Visual Studio code coverage results 117 | *.coverage 118 | *.coveragexml 119 | 120 | # NCrunch 121 | _NCrunch_* 122 | .*crunch*.local.xml 123 | nCrunchTemp_* 124 | 125 | # MightyMoose 126 | *.mm.* 127 | AutoTest.Net/ 128 | 129 | # Web workbench (sass) 130 | .sass-cache/ 131 | 132 | # Installshield output folder 133 | [Ee]xpress/ 134 | 135 | # DocProject is a documentation generator add-in 136 | DocProject/buildhelp/ 137 | DocProject/Help/*.HxT 138 | DocProject/Help/*.HxC 139 | DocProject/Help/*.hhc 140 | DocProject/Help/*.hhk 141 | DocProject/Help/*.hhp 142 | DocProject/Help/Html2 143 | DocProject/Help/html 144 | 145 | # Click-Once directory 146 | publish/ 147 | 148 | # Publish Web Output 149 | *.[Pp]ublish.xml 150 | *.azurePubxml 151 | # TODO: Comment the next line if you want to checkin your web deploy settings 152 | # but database connection strings (with potential passwords) will be unencrypted 153 | *.pubxml 154 | *.publishproj 155 | 156 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 157 | # checkin your Azure Web App publish settings, but sensitive information contained 158 | # in these scripts will be unencrypted 159 | PublishScripts/ 160 | 161 | # NuGet Packages 162 | *.nupkg 163 | # The packages folder can be ignored because of Package Restore 164 | **/packages/* 165 | # except build/, which is used as an MSBuild target. 166 | !**/packages/build/ 167 | # Uncomment if necessary however generally it will be regenerated when needed 168 | #!**/packages/repositories.config 169 | # NuGet v3's project.json files produces more ignorable files 170 | *.nuget.props 171 | *.nuget.targets 172 | 173 | # Microsoft Azure Build Output 174 | csx/ 175 | *.build.csdef 176 | 177 | # Microsoft Azure Emulator 178 | ecf/ 179 | rcf/ 180 | 181 | # Windows Store app package directories and files 182 | AppPackages/ 183 | BundleArtifacts/ 184 | Package.StoreAssociation.xml 185 | _pkginfo.txt 186 | 187 | # Visual Studio cache files 188 | # files ending in .cache can be ignored 189 | *.[Cc]ache 190 | # but keep track of directories ending in .cache 191 | !*.[Cc]ache/ 192 | 193 | # Others 194 | ClientBin/ 195 | ~$* 196 | *~ 197 | *.dbmdl 198 | *.dbproj.schemaview 199 | *.jfm 200 | *.pfx 201 | *.publishsettings 202 | orleans.codegen.cs 203 | 204 | # Since there are multiple workflows, uncomment next line to ignore bower_components 205 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 206 | #bower_components/ 207 | 208 | # RIA/Silverlight projects 209 | Generated_Code/ 210 | 211 | # Backup & report files from converting an old project file 212 | # to a newer Visual Studio version. Backup files are not needed, 213 | # because we have git ;-) 214 | _UpgradeReport_Files/ 215 | Backup*/ 216 | UpgradeLog*.XML 217 | UpgradeLog*.htm 218 | 219 | # SQL Server files 220 | *.mdf 221 | *.ldf 222 | *.ndf 223 | 224 | # Business Intelligence projects 225 | *.rdl.data 226 | *.bim.layout 227 | *.bim_*.settings 228 | 229 | # Microsoft Fakes 230 | FakesAssemblies/ 231 | 232 | # GhostDoc plugin setting file 233 | *.GhostDoc.xml 234 | 235 | # Node.js Tools for Visual Studio 236 | .ntvs_analysis.dat 237 | node_modules/ 238 | 239 | # Typescript v1 declaration files 240 | typings/ 241 | 242 | # Visual Studio 6 build log 243 | *.plg 244 | 245 | # Visual Studio 6 workspace options file 246 | *.opt 247 | 248 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 249 | *.vbw 250 | 251 | # Visual Studio LightSwitch build output 252 | **/*.HTMLClient/GeneratedArtifacts 253 | **/*.DesktopClient/GeneratedArtifacts 254 | **/*.DesktopClient/ModelManifest.xml 255 | **/*.Server/GeneratedArtifacts 256 | **/*.Server/ModelManifest.xml 257 | _Pvt_Extensions 258 | 259 | # Paket dependency manager 260 | .paket/paket.exe 261 | paket-files/ 262 | 263 | # FAKE - F# Make 264 | .fake/ 265 | 266 | # JetBrains Rider 267 | .idea/ 268 | *.sln.iml 269 | 270 | # CodeRush 271 | .cr/ 272 | 273 | # Python Tools for Visual Studio (PTVS) 274 | __pycache__/ 275 | *.pyc 276 | 277 | # Cake - Uncomment if you are using it 278 | # tools/** 279 | # !tools/packages.config 280 | 281 | # Telerik's JustMock configuration file 282 | *.jmconfig 283 | 284 | # BizTalk build output 285 | *.btp.cs 286 | *.btm.cs 287 | *.odx.cs 288 | *.xsd.cs 289 | -------------------------------------------------------------------------------- /BoletoOnline.Class/Objetos/EnvioRemessaCobrancaBradescoJson.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace BoletoOnline.Class.Objetos 5 | { 6 | [DataContract] 7 | public class EnvioRemessaCobrancaBradescoJson 8 | { 9 | [DataMember] 10 | public string nuCPFCNPJ { get; set; } 11 | 12 | [DataMember] 13 | public string filialCPFCNPJ { get; set; } 14 | 15 | [DataMember] 16 | public string ctrlCPFCNPJ { get; set; } 17 | 18 | [DataMember] 19 | public string cdTipoAcesso { get; set; } 20 | 21 | [DataMember] 22 | public string clubBanco { get; set; } 23 | 24 | [DataMember] 25 | public string cdTipoContrato { get; set; } 26 | 27 | [DataMember] 28 | public string nuSequenciaContrato { get; set; } 29 | 30 | [DataMember] 31 | public string idProduto { get; set; } 32 | 33 | [DataMember] 34 | public string nuNegociacao { get; set; } 35 | 36 | [DataMember] 37 | public string cdBanco { get; set; } 38 | 39 | [DataMember] 40 | public string eNuSequenciaContrato { get; set; } 41 | 42 | [DataMember] 43 | public string tpRegistro { get; set; } 44 | 45 | [DataMember] 46 | public string cdProduto { get; set; } 47 | 48 | [DataMember] 49 | public string nuTitulo { get; set; } 50 | 51 | [DataMember] 52 | public string nuCliente { get; set; } 53 | 54 | [DataMember] 55 | public string dtEmissaoTitulo { get; set; } 56 | 57 | [DataMember] 58 | public string dtVencimentoTitulo { get; set; } 59 | 60 | [DataMember] 61 | public string tpVencimento { get; set; } 62 | 63 | [DataMember] 64 | public string vlNominalTitulo { get; set; } 65 | 66 | [DataMember] 67 | public string cdEspecieTitulo { get; set; } 68 | 69 | [DataMember] 70 | public string tpProtestoAutomaticoNegativacao { get; set; } 71 | 72 | [DataMember] 73 | public string prazoProtestoAutomaticoNegativacao { get; set; } 74 | 75 | [DataMember] 76 | public string controleParticipante { get; set; } 77 | 78 | [DataMember] 79 | public string cdPagamentoParcial { get; set; } 80 | 81 | [DataMember] 82 | public string qtdePagamentoParcial { get; set; } 83 | 84 | [DataMember] 85 | public string percentualJuros { get; set; } 86 | 87 | [DataMember] 88 | public string vlJuros { get; set; } 89 | 90 | [DataMember] 91 | public string qtdeDiasJuros { get; set; } 92 | 93 | [DataMember] 94 | public string percentualMulta { get; set; } 95 | 96 | [DataMember] 97 | public string vlMulta { get; set; } 98 | 99 | [DataMember] 100 | public string qtdeDiasMulta { get; set; } 101 | 102 | [DataMember] 103 | public string percentualDesconto1 { get; set; } 104 | 105 | [DataMember] 106 | public string vlDesconto1 { get; set; } 107 | 108 | [DataMember] 109 | public string dataLimiteDesconto1 { get; set; } 110 | 111 | [DataMember] 112 | public string percentualDesconto2 { get; set; } 113 | 114 | [DataMember] 115 | public string vlDesconto2 { get; set; } 116 | 117 | [DataMember] 118 | public string dataLimiteDesconto2 { get; set; } 119 | 120 | [DataMember] 121 | public string percentualDesconto3 { get; set; } 122 | 123 | [DataMember] 124 | public string vlDesconto3 { get; set; } 125 | 126 | [DataMember] 127 | public string dataLimiteDesconto3 { get; set; } 128 | 129 | [DataMember] 130 | public string prazoBonificacao { get; set; } 131 | 132 | [DataMember] 133 | public string percentualBonificacao { get; set; } 134 | 135 | [DataMember] 136 | public string vlBonificacao { get; set; } 137 | 138 | [DataMember] 139 | public string dtLimiteBonificacao { get; set; } 140 | 141 | [DataMember] 142 | public string vlAbatimento { get; set; } 143 | 144 | [DataMember] 145 | public string vlIOF { get; set; } 146 | 147 | [DataMember] 148 | public string nomePagador { get; set; } 149 | 150 | [DataMember] 151 | public string logradouroPagador { get; set; } 152 | 153 | [DataMember] 154 | public string nuLogradouroPagador { get; set; } 155 | 156 | [DataMember] 157 | public string complementoLogradouroPagador { get; set; } 158 | 159 | [DataMember] 160 | public string cepPagador { get; set; } 161 | 162 | [DataMember] 163 | public string complementoCepPagador { get; set; } 164 | 165 | [DataMember] 166 | public string bairroPagador { get; set; } 167 | 168 | [DataMember] 169 | public string municipioPagador { get; set; } 170 | 171 | [DataMember] 172 | public string ufPagador { get; set; } 173 | 174 | [DataMember] 175 | public string cdIndCpfcnpjPagador { get; set; } 176 | 177 | [DataMember] 178 | public string nuCpfcnpjPagador { get; set; } 179 | 180 | [DataMember] 181 | public string endEletronicoPagador { get; set; } 182 | [DataMember] 183 | public string nomeSacadorAvalista { get; set; } 184 | [DataMember] 185 | public string logradouroSacadorAvalista { get; set; } 186 | [DataMember] 187 | public string nuLogradouroSacadorAvalista { get; set; } 188 | [DataMember] 189 | public string complementoLogradouroSacadorAvalista { get; set; } 190 | [DataMember] 191 | public string cepSacadorAvalista { get; set; } 192 | [DataMember] 193 | public string complementoCepSacadorAvalista { get; set; } 194 | 195 | [DataMember] 196 | public string bairroSacadorAvalista { get; set; } 197 | [DataMember] 198 | public string municipioSacadorAvalista { get; set; } 199 | [DataMember] 200 | public string ufSacadorAvalista { get; set; } 201 | [DataMember] 202 | public string cdIndCpfcnpjSacadorAvalista { get; set; } 203 | [DataMember] 204 | public string nuCpfcnpjSacadorAvalista { get; set; } 205 | [DataMember] 206 | public string endEletronicoSacadorAvalista { get; set; } 207 | } 208 | } 209 | -------------------------------------------------------------------------------- /BoletoOnline.Class/Objetos/RetornoRemessaCobrancaBradescoJson.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Serialization; 2 | 3 | namespace BoletoOnline.Class.Objetos 4 | { 5 | public class RetornoRemessaCobrancaBradescoJson 6 | { 7 | [DataMember] 8 | public string cdErro { get; set; } 9 | 10 | [DataMember] 11 | public string msgErro { get; set; } 12 | 13 | [DataMember] 14 | public string idProduto { get; set; } 15 | 16 | [DataMember] 17 | public string negociação { get; set; } 18 | 19 | [DataMember] 20 | public string clubBanco { get; set; } 21 | 22 | [DataMember] 23 | public string tpContrato { get; set; } 24 | 25 | [DataMember] 26 | public string nuSequenciaContrato { get; set; } 27 | 28 | [DataMember] 29 | public string cdProduto { get; set; } 30 | 31 | [DataMember] 32 | public string nuTituloGerado { get; set; } 33 | 34 | [DataMember] 35 | public string agenciaCreditoBeneficiario { get; set; } 36 | 37 | [DataMember] 38 | public string contaCreditoBeneficiario { get; set; } 39 | 40 | [DataMember] 41 | public string digCreditoBeneficiario { get; set; } 42 | 43 | [DataMember] 44 | public string cdCipTitulo { get; set; } 45 | 46 | [DataMember] 47 | public string statusTitulo { get; set; } 48 | 49 | [DataMember] 50 | public string descStatusTitulo { get; set; } 51 | 52 | [DataMember] 53 | public string nomeBeneficiario { get; set; } 54 | 55 | [DataMember] 56 | public string logradouroBeneficiario { get; set; } 57 | 58 | [DataMember] 59 | public string nuLogradouroBeneficiario { get; set; } 60 | 61 | [DataMember] 62 | public string complementoLogradouroBeneficiario { get; set; } 63 | 64 | [DataMember] 65 | public string cepBeneficiario { get; set; } 66 | 67 | [DataMember] 68 | public string cepComplementoBeneficiario { get; set; } 69 | 70 | [DataMember] 71 | public string municipioBeneficiario { get; set; } 72 | 73 | [DataMember] 74 | public string ufBeneficiario { get; set; } 75 | 76 | [DataMember] 77 | public string razaoContaBeneficiario { get; set; } 78 | 79 | [DataMember] 80 | public string nomePagador { get; set; } 81 | 82 | [DataMember] 83 | public string cpfcnpjPagador { get; set; } 84 | 85 | [DataMember] 86 | public string enderecoPagador { get; set; } 87 | 88 | [DataMember] 89 | public string bairroPagador { get; set; } 90 | 91 | [DataMember] 92 | public string municipioPagador { get; set; } 93 | 94 | [DataMember] 95 | public string ufPagador { get; set; } 96 | 97 | [DataMember] 98 | public string cepPagador { get; set; } 99 | 100 | [DataMember] 101 | public string cepComplementoPagador { get; set; } 102 | 103 | [DataMember] 104 | public string endEletronicoPagador { get; set; } 105 | 106 | [DataMember] 107 | public string nomeSacadorAvalista { get; set; } 108 | 109 | [DataMember] 110 | public string cpfcnpjSacadorAvalista { get; set; } 111 | 112 | [DataMember] 113 | public string enderecoSacadorAvalista { get; set; } 114 | 115 | [DataMember] 116 | public string municipioSacadorAvalista { get; set; } 117 | 118 | [DataMember] 119 | public string ufSacadorAvalista { get; set; } 120 | 121 | [DataMember] 122 | public string cepSacadorAvalista { get; set; } 123 | 124 | [DataMember] 125 | public string cepComplementoSacadorAvalista { get; set; } 126 | 127 | [DataMember] 128 | public string numeroTitulo { get; set; } 129 | 130 | [DataMember] 131 | public string dtRegistro { get; set; } 132 | 133 | [DataMember] 134 | public string especieDocumentoTitulo { get; set; } 135 | 136 | [DataMember] 137 | public string descEspecie { get; set; } 138 | 139 | [DataMember] 140 | public string vlIOF { get; set; } 141 | 142 | [DataMember] 143 | public string dtEmissao { get; set; } 144 | 145 | [DataMember] 146 | public string dtVencimento { get; set; } 147 | 148 | [DataMember] 149 | public string vlTitulo { get; set; } 150 | 151 | [DataMember] 152 | public string vlAbatimento { get; set; } 153 | 154 | [DataMember] 155 | public string dtInstrucaoProtestoNegativação { get; set; } 156 | 157 | [DataMember] 158 | public string diasInstrucaoProtestoNegativação { get; set; } 159 | 160 | [DataMember] 161 | public string dtMulta { get; set; } 162 | 163 | [DataMember] 164 | public string vlMulta { get; set; } 165 | 166 | [DataMember] 167 | public string qtdeCasasDecimaisMulta { get; set; } 168 | 169 | [DataMember] 170 | public string cdValorMulta { get; set; } 171 | 172 | [DataMember] 173 | public string descCdMulta { get; set; } 174 | 175 | [DataMember] 176 | public string dtJuros { get; set; } 177 | 178 | [DataMember] 179 | public string vlJurosAoDia { get; set; } 180 | [DataMember] 181 | public string dtDesconto1Bonificacao { get; set; } 182 | [DataMember] 183 | public string vlDesconto1Bonificacao { get; set; } 184 | [DataMember] 185 | public string qtdeCasasDecimaisDesconto1Bonificacao { get; set; } 186 | [DataMember] 187 | public string cdValorDesconto1Bonificacao { get; set; } 188 | [DataMember] 189 | public string descCdDesconto1Bonificacao { get; set; } 190 | [DataMember] 191 | public string dtDesconto2 { get; set; } 192 | 193 | [DataMember] 194 | public string vlDesconto2 { get; set; } 195 | [DataMember] 196 | public string qtdeCasasDecimaisDesconto2 { get; set; } 197 | [DataMember] 198 | public string cdValorDesconto2 { get; set; } 199 | [DataMember] 200 | public string descCdDesconto2 { get; set; } 201 | [DataMember] 202 | public string dtDesconto3 { get; set; } 203 | [DataMember] 204 | public string vlDesconto3 { get; set; } 205 | [DataMember] 206 | public string qtdeCasasDecimaisDesconto3 { get; set; } 207 | [DataMember] 208 | public string cdValorDesconto3 { get; set; } 209 | [DataMember] 210 | public string descCdDesconto3 { get; set; } 211 | [DataMember] 212 | public string diasDispensaMulta { get; set; } 213 | [DataMember] 214 | public string diasDispensaJuros { get; set; } 215 | [DataMember] 216 | public string cdBarras { get; set; } 217 | [DataMember] 218 | public string linhaDigitavel { get; set; } 219 | [DataMember] 220 | public string cdAcessorioEscrituralEmpresa { get; set; } 221 | [DataMember] 222 | public string tpVencimento { get; set; } 223 | [DataMember] 224 | public string indInstrucaoProtesto { get; set; } 225 | [DataMember] 226 | public string tipoAbatimentoTitulo { get; set; } 227 | [DataMember] 228 | public string cdValorJuros { get; set; } 229 | [DataMember] 230 | public string tpDesconto1 { get; set; } 231 | [DataMember] 232 | public string tpDesconto2 { get; set; } 233 | [DataMember] 234 | public string tpDesconto3 { get; set; } 235 | [DataMember] 236 | public string nuControleParticipante { get; set; } 237 | [DataMember] 238 | public string diasJuros { get; set; } 239 | [DataMember] 240 | public string cdJuros { get; set; } 241 | [DataMember] 242 | public string vlJuros { get; set; } 243 | [DataMember] 244 | public string cpfcnpjBeneficiário { get; set; } 245 | [DataMember] 246 | public string vlTituloEmitidoBoleto { get; set; } 247 | [DataMember] 248 | public string dtVencimentoBoleto { get; set; } 249 | [DataMember] 250 | public string indTituloPertenceBaseTitulos { get; set; } 251 | [DataMember] 252 | public string dtLimitePagamentoBoleto { get; set; } 253 | [DataMember] 254 | public string cdIdentificacaoTituloDDACIP { get; set; } 255 | [DataMember] 256 | public string indPagamentoParcial { get; set; } 257 | [DataMember] 258 | public string qtdePagamentoParciais { get; set; } 259 | } 260 | } 261 | -------------------------------------------------------------------------------- /BoletoOnline.Class/Uteis/MetodosUteis.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.IO; 3 | using System.Linq; 4 | using System.Text; 5 | using BoletoOnline.Class.Objetos; 6 | using Newtonsoft.Json; 7 | 8 | namespace BoletoOnline.Class.Uteis 9 | { 10 | public class MetodosUteis 11 | { 12 | public bool EhValido(EnvioRemessaCobrancaBradescoJson entidade) 13 | { 14 | return !Criticas(entidade).Any(); 15 | } 16 | 17 | public IEnumerable Criticas(EnvioRemessaCobrancaBradescoJson entidade) 18 | { 19 | //Campos Obrigatórios e condicionalmente obrigatórios 20 | if (EstaVazio(entidade.nuCpfcnpjPagador) || entidade.nuCpfcnpjPagador.Length > 9) 21 | yield return "Campo nuCpfcnpjPagador não pode ser vazio e precisa ter tamanho máximo de 9"; 22 | 23 | if (EstaVazio(entidade.filialCPFCNPJ) || entidade.filialCPFCNPJ.Length > 4) 24 | yield return "Campo filialCPFCNPJ não pode ser vazio e precisa ter tamanho máximo de 4"; 25 | 26 | if (EstaVazio(entidade.ctrlCPFCNPJ) || entidade.ctrlCPFCNPJ.Length > 2) 27 | yield return "Campo ctrlCPFCNPJ não pode ser vazio e precisa ter tamanho máximo de 2"; 28 | 29 | if (EstaVazio(entidade.cdTipoAcesso) || entidade.cdTipoAcesso.Length > 1) 30 | yield return "Campo cdTipoAcesso não pode ser vazio e precisa ter tamanho máximo de 1"; 31 | 32 | if (EstaVazio(entidade.idProduto) || entidade.idProduto.Length > 2) 33 | yield return "Campo idProduto não pode ser vazio e precisa ter tamanho máximo de 2"; 34 | 35 | if (EstaVazio(entidade.nuNegociacao) || entidade.nuNegociacao.Length > 18) 36 | yield return "Campo nuNegociacao não pode ser vazio e precisa ter tamanho máximo de 18"; 37 | 38 | if (EstaVazio(entidade.cdBanco) || entidade.cdBanco.Length > 3) 39 | yield return "Campo cdBanco não pode ser vazio e precisa ter tamanho máximo de 3"; 40 | 41 | if (EstaVazio(entidade.tpRegistro) || entidade.tpRegistro.Length > 3) 42 | yield return "Campo tpRegistro não pode ser vazio e precisa ter tamanho máximo de 3"; 43 | 44 | if (EstaVazio(entidade.nuCliente) || entidade.nuCliente.Length > 10) 45 | yield return "Campo nuCliente não pode ser vazio e precisa ter tamanho máximo de 10"; 46 | 47 | if (EstaVazio(entidade.dtEmissaoTitulo) || entidade.dtEmissaoTitulo.Length > 10) 48 | yield return "Campo dtEmissaoTitulo não pode ser vazio e precisa ter tamanho máximo de 10"; 49 | 50 | if (EstaVazio(entidade.dtVencimentoTitulo) || entidade.dtVencimentoTitulo.Length > 10) 51 | yield return "Campo dtVencimentoTitulo não pode ser vazio e precisa ter tamanho máximo de 10"; 52 | 53 | if (EstaVazio(entidade.tpVencimento) || entidade.tpVencimento.Length > 1) 54 | yield return "Campo tpVencimento não pode ser vazio e precisa ter tamanho máximo de 1"; 55 | 56 | if (EstaVazio(entidade.vlNominalTitulo) || entidade.vlNominalTitulo.Length > 17) 57 | yield return "Campo vlNominalTitulo não pode ser vazio e precisa ter tamanho máximo de 17"; 58 | 59 | if (EstaVazio(entidade.cdEspecieTitulo) || entidade.cdEspecieTitulo.Length > 2) 60 | yield return "Campo cdEspecieTitulo não pode ser vazio e precisa ter tamanho máximo de 2"; 61 | 62 | if (EstaVazio(entidade.cdEspecieTitulo) || entidade.cdEspecieTitulo.Length > 2) 63 | yield return "Campo cdEspecieTitulo não pode ser vazio e precisa ter tamanho máximo de 2"; 64 | 65 | if (!EstaVazio(entidade.tpProtestoAutomaticoNegativacao)) 66 | { 67 | if (EstaVazio(entidade.prazoProtestoAutomaticoNegativacao) || entidade.prazoProtestoAutomaticoNegativacao.Length > 2) 68 | yield return "Campo prazoProtestoAutomaticoNegativacao não pode ser vazio e precisa ter tamanho máximo de 2, pois tpProtestoAutomaticoNegativacao não está vazio"; 69 | } 70 | 71 | if (!(EstaVazio(entidade.vlDesconto1) || EstaVazio(entidade.percentualDesconto1))) 72 | { 73 | if (EstaVazio(entidade.dataLimiteDesconto1) || entidade.dataLimiteDesconto1.Length > 10) 74 | yield return "Campo dataLimiteDesconto1 não pode ser vazio e precisa ter tamanho máximo de 10, pois vlDesconto1 ou percentualDesconto1 foi informado"; 75 | } 76 | 77 | if (!(EstaVazio(entidade.vlDesconto2) || EstaVazio(entidade.percentualDesconto2))) 78 | { 79 | if (EstaVazio(entidade.dataLimiteDesconto2) || entidade.dataLimiteDesconto2.Length > 10) 80 | yield return "Campo dataLimiteDesconto2 não pode ser vazio e precisa ter tamanho máximo de 10, pois vlDesconto2 ou percentualDesconto2 foi informado"; 81 | } 82 | 83 | if (!(EstaVazio(entidade.vlDesconto3) || EstaVazio(entidade.percentualDesconto3))) 84 | { 85 | if (EstaVazio(entidade.dataLimiteDesconto3) || entidade.dataLimiteDesconto3.Length > 10) 86 | yield return "Campo dataLimiteDesconto3 não pode ser vazio e precisa ter tamanho máximo de 10, pois vlDesconto3 ou percentualDesconto3 foi informado"; 87 | } 88 | 89 | if (!(EstaVazio(entidade.percentualBonificacao) || EstaVazio(entidade.vlBonificacao))) 90 | { 91 | if (EstaVazio(entidade.prazoBonificacao) || entidade.prazoBonificacao.Length > 2) 92 | yield return "Campo prazoBonificacao não pode ser vazio e precisa ter tamanho máximo de 2, pois percentualBonificacao ou vlBonificacao foi informado"; 93 | 94 | if (EstaVazio(entidade.dtLimiteBonificacao) || entidade.dtLimiteBonificacao.Length > 10) 95 | yield return "Campo dtLimiteBonificacao não pode ser vazio e precisa ter tamanho máximo de 10, pois percentualBonificacao ou vlBonificacao foi informado"; 96 | } 97 | 98 | if (!(EstaVazio(entidade.cdPagamentoParcial) && entidade.cdPagamentoParcial == "S")) 99 | { 100 | if (EstaVazio(entidade.qtdePagamentoParcial) || entidade.qtdePagamentoParcial.Length > 3) 101 | yield return "Campo qtdePagamentoParcial não pode ser vazio e precisa ter tamanho máximo de 3, pois cdPagamentoParcial foi informado"; 102 | } 103 | 104 | //Somente para cobrança carteira de seguros (????) 105 | if (EstaVazio(entidade.vlIOF) || entidade.vlIOF.Length > 17) 106 | yield return "Campo vlIOF não pode ser vazio e precisa ter tamanho máximo de 17"; 107 | 108 | if (EstaVazio(entidade.nomePagador) || entidade.nomePagador.Length > 70) 109 | yield return "Campo nomePagador não pode ser vazio e precisa ter tamanho máximo de 70"; 110 | 111 | if (EstaVazio(entidade.logradouroPagador) || entidade.logradouroPagador.Length > 40) 112 | yield return "Campo logradouroPagador não pode ser vazio e precisa ter tamanho máximo de 40"; 113 | 114 | if (EstaVazio(entidade.nuLogradouroPagador) || entidade.nuLogradouroPagador.Length > 10) 115 | yield return "Campo nuLogradouroPagador não pode ser vazio e precisa ter tamanho máximo de 10"; 116 | 117 | if (EstaVazio(entidade.cepPagador) || entidade.cepPagador.Length > 5) 118 | yield return "Campo cepPagador não pode ser vazio e precisa ter tamanho máximo de 5"; 119 | 120 | if (EstaVazio(entidade.complementoCepPagador) || entidade.complementoCepPagador.Length > 3) 121 | yield return "Campo complementoCepPagador não pode ser vazio e precisa ter tamanho máximo de 3"; 122 | 123 | if (EstaVazio(entidade.bairroPagador) || entidade.bairroPagador.Length > 40) 124 | yield return "Campo bairroPagador não pode ser vazio e precisa ter tamanho máximo de 40"; 125 | 126 | if (EstaVazio(entidade.municipioPagador) || entidade.municipioPagador.Length > 30) 127 | yield return "Campo municipioPagador não pode ser vazio e precisa ter tamanho máximo de 30"; 128 | 129 | if (EstaVazio(entidade.ufPagador) || entidade.ufPagador.Length > 2) 130 | yield return "Campo ufPagador não pode ser vazio e precisa ter tamanho máximo de 2"; 131 | 132 | if (EstaVazio(entidade.cdIndCpfcnpjPagador) || entidade.cdIndCpfcnpjPagador.Length > 1) 133 | yield return "Campo cdIndCpfcnpjPagador não pode ser vazio e precisa ter tamanho máximo de 1"; 134 | 135 | if (EstaVazio(entidade.nuCpfcnpjPagador) || entidade.nuCpfcnpjPagador.Length > 14) 136 | yield return "Campo nuCpfcnpjPagador não pode ser vazio e precisa ter tamanho máximo de 14"; 137 | 138 | if (!EstaVazio(entidade.nomeSacadorAvalista)) 139 | { 140 | if (EstaVazio(entidade.logradouroSacadorAvalista) || entidade.logradouroSacadorAvalista.Length > 40) 141 | yield return "Campo logradouroSacadorAvalista não pode ser vazio e precisa ter tamanho máximo de 40, pois nomeSacadorAvalista foi informado"; 142 | 143 | if (EstaVazio(entidade.nuLogradouroSacadorAvalista) || entidade.nuLogradouroSacadorAvalista.Length > 10) 144 | yield return "Campo nuLogradouroSacadorAvalista não pode ser vazio e precisa ter tamanho máximo de 10, pois nomeSacadorAvalista foi informado"; 145 | 146 | if (EstaVazio(entidade.cepSacadorAvalista) || entidade.cepSacadorAvalista.Length > 5) 147 | yield return "Campo cepSacadorAvalista não pode ser vazio e precisa ter tamanho máximo de 5, pois nomeSacadorAvalista foi informado"; 148 | 149 | if (EstaVazio(entidade.complementoCepSacadorAvalista) || entidade.complementoCepSacadorAvalista.Length > 3) 150 | yield return "Campo complementoCepSacadorAvalista não pode ser vazio e precisa ter tamanho máximo de 3, pois nomeSacadorAvalista foi informado"; 151 | 152 | if (EstaVazio(entidade.bairroSacadorAvalista) || entidade.bairroSacadorAvalista.Length > 40) 153 | yield return "Campo bairroSacadorAvalista não pode ser vazio e precisa ter tamanho máximo de 40, pois nomeSacadorAvalista foi informado"; 154 | 155 | if (EstaVazio(entidade.municipioSacadorAvalista) || entidade.municipioSacadorAvalista.Length > 40) 156 | yield return "Campo municipioSacadorAvalista não pode ser vazio e precisa ter tamanho máximo de 40, pois nomeSacadorAvalista foi informado"; 157 | 158 | if (EstaVazio(entidade.ufSacadorAvalista) || entidade.ufSacadorAvalista.Length > 2) 159 | yield return "Campo ufSacadorAvalista não pode ser vazio e precisa ter tamanho máximo de 2, pois nomeSacadorAvalista foi informado"; 160 | 161 | if (EstaVazio(entidade.cdIndCpfcnpjSacadorAvalista) || entidade.cdIndCpfcnpjSacadorAvalista.Length > 1) 162 | yield return "Campo cdIndCpfcnpjSacadorAvalista não pode ser vazio e precisa ter tamanho máximo de 1, pois nomeSacadorAvalista foi informado"; 163 | 164 | if (EstaVazio(entidade.nuCpfcnpjSacadorAvalista) || entidade.nuCpfcnpjSacadorAvalista.Length > 14) 165 | yield return "Campo nuCpfcnpjSacadorAvalista não pode ser vazio e precisa ter tamanho máximo de 14, pois nomeSacadorAvalista foi informado"; 166 | } 167 | 168 | //Campos não obrigatórios 169 | if (!EstaVazio(entidade.clubBanco) && entidade.clubBanco.Length > 10) 170 | { 171 | yield return "Campo clubBanco precisa ter tamanho máximo de 10"; 172 | } 173 | 174 | if (!EstaVazio(entidade.cdTipoContrato) && entidade.cdTipoContrato.Length > 3) 175 | { 176 | yield return "Campo cdTipoContrato precisa ter tamanho máximo de 3"; 177 | } 178 | 179 | if (!EstaVazio(entidade.nuSequenciaContrato) && entidade.nuSequenciaContrato.Length > 10) 180 | { 181 | yield return "Campo nuSequenciaContrato precisa ter tamanho máximo de 10"; 182 | } 183 | 184 | if (!EstaVazio(entidade.eNuSequenciaContrato) && entidade.eNuSequenciaContrato.Length > 10) 185 | { 186 | yield return "Campo eNuSequenciaContrato precisa ter tamanho máximo de 10"; 187 | } 188 | 189 | if (!EstaVazio(entidade.cdProduto) && entidade.cdProduto.Length > 8) 190 | { 191 | yield return "Campo cdProduto precisa ter tamanho máximo de 8"; 192 | } 193 | 194 | if (!EstaVazio(entidade.nuTitulo) && entidade.nuTitulo.Length > 11) 195 | { 196 | yield return "Campo nuTitulo precisa ter tamanho máximo de 11"; 197 | } 198 | 199 | if (!EstaVazio(entidade.tpProtestoAutomaticoNegativacao) && entidade.tpProtestoAutomaticoNegativacao.Length > 11) 200 | { 201 | yield return "Campo tpProtestoAutomaticoNegativacao precisa ter tamanho máximo de 2"; 202 | } 203 | 204 | if (!EstaVazio(entidade.controleParticipante) && entidade.controleParticipante.Length > 25) 205 | { 206 | yield return "Campo controleParticipante precisa ter tamanho máximo de 25"; 207 | } 208 | 209 | if (!EstaVazio(entidade.cdPagamentoParcial) && entidade.cdPagamentoParcial.Length > 1) 210 | { 211 | yield return "Campo cdPagamentoParcial precisa ter tamanho máximo de 1"; 212 | } 213 | 214 | if (!EstaVazio(entidade.percentualJuros) && entidade.percentualJuros.Length > 8) 215 | { 216 | yield return "Campo percentualJuros precisa ter tamanho máximo de 8"; 217 | } 218 | 219 | if (!EstaVazio(entidade.vlJuros) && entidade.vlJuros.Length > 17) 220 | { 221 | yield return "Campo vlJuros precisa ter tamanho máximo de 17"; 222 | } 223 | 224 | if (!EstaVazio(entidade.qtdeDiasJuros) && entidade.qtdeDiasJuros.Length > 2) 225 | { 226 | yield return "Campo qtdeDiasJuros precisa ter tamanho máximo de 2"; 227 | } 228 | 229 | if (!EstaVazio(entidade.percentualMulta) && entidade.percentualMulta.Length > 8) 230 | { 231 | yield return "Campo percentualMulta precisa ter tamanho máximo de 8"; 232 | } 233 | 234 | if (!EstaVazio(entidade.vlMulta) && entidade.vlMulta.Length > 17) 235 | { 236 | yield return "Campo vlMulta precisa ter tamanho máximo de 17"; 237 | } 238 | 239 | if (!EstaVazio(entidade.qtdeDiasMulta) && entidade.qtdeDiasMulta.Length > 3) 240 | { 241 | yield return "Campo qtdeDiasMulta precisa ter tamanho máximo de 3"; 242 | } 243 | 244 | if (!EstaVazio(entidade.percentualDesconto1) && entidade.percentualDesconto1.Length > 8) 245 | { 246 | yield return "Campo percentualDesconto1 precisa ter tamanho máximo de 8"; 247 | } 248 | 249 | if (!EstaVazio(entidade.vlDesconto1) && entidade.vlDesconto1.Length > 17) 250 | { 251 | yield return "Campo vlDesconto1 precisa ter tamanho máximo de 17"; 252 | } 253 | 254 | if (!EstaVazio(entidade.percentualDesconto2) && entidade.percentualDesconto2.Length > 8) 255 | { 256 | yield return "Campo percentualDesconto2 precisa ter tamanho máximo de 8"; 257 | } 258 | 259 | if (!EstaVazio(entidade.vlDesconto2) && entidade.vlDesconto2.Length > 17) 260 | { 261 | yield return "Campo vlDesconto2 precisa ter tamanho máximo de 17"; 262 | } 263 | 264 | if (!EstaVazio(entidade.percentualDesconto3) && entidade.percentualDesconto3.Length > 8) 265 | { 266 | yield return "Campo percentualDesconto3 precisa ter tamanho máximo de 8"; 267 | } 268 | 269 | if (!EstaVazio(entidade.vlDesconto3) && entidade.vlDesconto3.Length > 17) 270 | { 271 | yield return "Campo vlDesconto3 precisa ter tamanho máximo de 17"; 272 | } 273 | 274 | if (!EstaVazio(entidade.percentualBonificacao) && entidade.percentualBonificacao.Length > 8) 275 | { 276 | yield return "Campo percentualBonificacao precisa ter tamanho máximo de 8"; 277 | } 278 | 279 | if (!EstaVazio(entidade.vlBonificacao) && entidade.vlBonificacao.Length > 17) 280 | { 281 | yield return "Campo vlBonificacao precisa ter tamanho máximo de 17"; 282 | } 283 | 284 | if (!EstaVazio(entidade.vlAbatimento) && entidade.vlAbatimento.Length > 17) 285 | { 286 | yield return "Campo vlAbatimento precisa ter tamanho máximo de 17"; 287 | } 288 | 289 | if (!EstaVazio(entidade.complementoLogradouroPagador) && entidade.complementoLogradouroPagador.Length > 15) 290 | { 291 | yield return "Campo complementoLogradouroPagador precisa ter tamanho máximo de 15"; 292 | } 293 | 294 | if (!EstaVazio(entidade.endEletronicoPagador) && entidade.endEletronicoPagador.Length > 70) 295 | { 296 | yield return "Campo endEletronicoPagador precisa ter tamanho máximo de 70"; 297 | } 298 | 299 | if (!EstaVazio(entidade.nomeSacadorAvalista) && entidade.nomeSacadorAvalista.Length > 40) 300 | { 301 | yield return "Campo nomeSacadorAvalista precisa ter tamanho máximo de 40"; 302 | } 303 | 304 | if (!EstaVazio(entidade.complementoLogradouroSacadorAvalista) && entidade.complementoLogradouroSacadorAvalista.Length > 15) 305 | { 306 | yield return "Campo complementoLogradouroSacadorAvalista precisa ter tamanho máximo de 15"; 307 | } 308 | 309 | if (!EstaVazio(entidade.endEletronicoSacadorAvalista) && entidade.endEletronicoSacadorAvalista.Length > 70) 310 | { 311 | yield return "Campo endEletronicoSacadorAvalista precisa ter tamanho máximo de 70"; 312 | } 313 | 314 | } 315 | 316 | private bool EstaVazio(string param) 317 | { 318 | if (string.IsNullOrWhiteSpace(param)) 319 | return true; 320 | var converteu = long.TryParse(param, out long resultado); 321 | return converteu && resultado == 0; 322 | } 323 | 324 | public string ConverterParaJsonAspasSimples(EnvioRemessaCobrancaBradescoJson data) 325 | { 326 | var sb = new StringBuilder(); 327 | using (var sw = new StringWriter(sb)) 328 | { 329 | using (var writer = new JsonTextWriter(sw)) 330 | { 331 | writer.QuoteChar = '\"'; 332 | 333 | var ser = new JsonSerializer(); 334 | ser.Serialize(writer, data); 335 | } 336 | } 337 | return sb?.ToString().Replace("null", "\"0\""); ; 338 | } 339 | } 340 | } 341 | --------------------------------------------------------------------------------