Skip to content

Commit e70a53e

Browse files
authored
Merge pull request #347 from adrianotrentim/main
Implementação DSF v2.03
2 parents 018042e + ae6ff36 commit e70a53e

6 files changed

Lines changed: 516 additions & 6 deletions

File tree

src/OpenAC.Net.NFSe/Providers/DSF/DSFServiceClient.cs renamed to src/OpenAC.Net.NFSe/Providers/DSF/DSF100ServiceClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@
4040

4141
namespace OpenAC.Net.NFSe.Providers;
4242

43-
internal sealed class DSFServiceClient : NFSeSoapServiceClient, IServiceClient
43+
internal sealed class DSF100ServiceClient : NFSeSoapServiceClient, IServiceClient
4444
{
4545
#region Constructors
4646

47-
public DSFServiceClient(ProviderDSF provider, TipoUrl tipoUrl) : base(provider, tipoUrl, SoapVersion.Soap11)
47+
public DSF100ServiceClient(ProviderDSF100 provider, TipoUrl tipoUrl) : base(provider, tipoUrl, SoapVersion.Soap11)
4848
{
4949
}
5050

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
// ***********************************************************************
2+
// Assembly : OpenAC.Net.NFSe
3+
// Author : Felipe Silveira/Transis
4+
// Created : 02-13-2023
5+
//
6+
// ***********************************************************************
7+
// <copyright file="Pronim2ServiceClient.cs" company="OpenAC .Net">
8+
// The MIT License (MIT)
9+
// Copyright (c) 2014 - 2024 Projeto OpenAC .Net
10+
//
11+
// Permission is hereby granted, free of charge, to any person obtaining
12+
// a copy of this software and associated documentation files (the "Software"),
13+
// to deal in the Software without restriction, including without limitation
14+
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
15+
// and/or sell copies of the Software, and to permit persons to whom the
16+
// Software is furnished to do so, subject to the following conditions:
17+
// The above copyright notice and this permission notice shall be
18+
// included in all copies or substantial portions of the Software.
19+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22+
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
23+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25+
// DEALINGS IN THE SOFTWARE.
26+
// </copyright>
27+
// <summary></summary>
28+
// ***********************************************************************
29+
30+
using System;
31+
using System.Security.Cryptography.X509Certificates;
32+
using System.Text;
33+
using System.Xml.Linq;
34+
using OpenAC.Net.Core.Extensions;
35+
using OpenAC.Net.DFe.Core;
36+
using OpenAC.Net.NFSe.Commom;
37+
using OpenAC.Net.NFSe.Commom.Client;
38+
using OpenAC.Net.NFSe.Commom.Interface;
39+
using OpenAC.Net.NFSe.Commom.Types;
40+
41+
namespace OpenAC.Net.NFSe.Providers;
42+
43+
internal sealed class DSF203ServiceClient : NFSeSoapServiceClient, IServiceClient
44+
{
45+
#region Constructors
46+
47+
public DSF203ServiceClient(ProviderDSF203 provider, TipoUrl tipoUrl, X509Certificate2 certificado) : base(provider, tipoUrl, certificado, SoapVersion.Soap11)
48+
{
49+
}
50+
51+
public DSF203ServiceClient(ProviderDSF203 provider, TipoUrl tipoUrl) : base(provider, tipoUrl, SoapVersion.Soap11)
52+
{
53+
}
54+
55+
#endregion Constructors
56+
57+
#region Methods
58+
59+
public string Enviar(string cabec, string msg)
60+
{
61+
var message = new StringBuilder();
62+
message.Append("<nfse:RecepcionarLoteRps>");
63+
message.Append(msg);
64+
message.Append("</nfse:RecepcionarLoteRps>");
65+
return Execute(message.ToString(), "RecepcionarLoteRpsResponse");
66+
}
67+
68+
public string EnviarSincrono(string cabec, string msg)
69+
{
70+
var message = new StringBuilder();
71+
message.Append("<nfse:RecepcionarLoteRpsSincrono>");
72+
message.Append(msg);
73+
message.Append("</nfse:RecepcionarLoteRpsSincrono>");
74+
return Execute(message.ToString(), "RecepcionarLoteRpsSincronoResponse");
75+
}
76+
77+
public string CancelarNFSe(string cabec, string msg)
78+
{
79+
var message = new StringBuilder();
80+
message.Append("<nfse:CancelarNfse>");
81+
message.Append(msg);
82+
message.Append("</nfse:CancelarNfse>");
83+
return Execute(message.ToString(), "CancelarNfseResponse");
84+
}
85+
86+
public string CancelarNFSeLote(string cabec, string msg)
87+
{
88+
throw new NotImplementedException();
89+
}
90+
91+
public string ConsultarLoteRps(string cabec, string msg)
92+
{
93+
var message = new StringBuilder();
94+
message.Append("<nfse:ConsultarLoteRps>");
95+
message.Append(msg);
96+
message.Append("</nfse:ConsultarLoteRps>");
97+
return Execute(message.ToString(), "ConsultarLoteRpsResponse");
98+
}
99+
100+
public string ConsultarNFSe(string cabec, string msg)
101+
{
102+
var message = new StringBuilder();
103+
message.Append("<nfse:ConsultarNfseServicoPrestado>");
104+
message.Append(msg);
105+
message.Append("</nfse:ConsultarNfseServicoPrestado>");
106+
return Execute(message.ToString(), "ConsultarNfseServicoPrestadoResponse");
107+
}
108+
109+
public string ConsultarNFSeRps(string cabec, string msg)
110+
{
111+
var message = new StringBuilder();
112+
message.Append("<nfse:ConsultarNfsePorRps>");
113+
message.Append(msg);
114+
message.Append("</nfse:ConsultarNfsePorRps>");
115+
return Execute(message.ToString(), "ConsultarNfsePorRpsResponse");
116+
}
117+
118+
public string ConsultarSequencialRps(string cabec, string msg)
119+
{
120+
throw new NotImplementedException();
121+
}
122+
123+
public string ConsultarSituacao(string cabec, string msg)
124+
{
125+
throw new NotImplementedException();
126+
}
127+
128+
public string SubstituirNFSe(string cabec, string msg)
129+
{
130+
var message = new StringBuilder();
131+
message.Append("<nfse:SubstituirNfse>");
132+
message.Append(msg);
133+
message.Append("</nfse:SubstituirNfse>");
134+
return Execute(message.ToString(), "SubstituirNfseResponse");
135+
}
136+
137+
protected override string TratarRetorno(XElement xmlDocument, string[] responseTag)
138+
{
139+
var element = xmlDocument.ElementAnyNs("Fault");
140+
if (element != null)
141+
{
142+
var exMessage =
143+
$"{element.ElementAnyNs("faultcode").GetValue<string>()} - {element.ElementAnyNs("faultstring").GetValue<string>()}";
144+
throw new OpenDFeCommunicationException(exMessage);
145+
}
146+
147+
return xmlDocument.ElementAnyNs(responseTag[0]).ToString();
148+
}
149+
150+
private string Execute(string message, string responseTag) =>
151+
Execute("", message, "", [responseTag], ["xmlns:nfse=\"http://nfse.abrasf.org.br\""]);
152+
153+
#endregion Methods
154+
}

src/OpenAC.Net.NFSe/Providers/DSF/ProviderDSF.cs renamed to src/OpenAC.Net.NFSe/Providers/DSF/ProviderDSF100.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@
4040

4141
namespace OpenAC.Net.NFSe.Providers;
4242

43-
internal sealed class ProviderDSF : ProviderABRASF
43+
internal sealed class ProviderDSF100 : ProviderABRASF
4444
{
4545
#region Constructors
4646

47-
public ProviderDSF(ConfigNFSe config, OpenMunicipioNFSe municipio) : base(config, municipio)
47+
public ProviderDSF100(ConfigNFSe config, OpenMunicipioNFSe municipio) : base(config, municipio)
4848
{
4949
Name = "DSF";
5050
}
@@ -53,7 +53,7 @@ public ProviderDSF(ConfigNFSe config, OpenMunicipioNFSe municipio) : base(config
5353

5454
#region Private Methods
5555

56-
protected override IServiceClient GetClient(TipoUrl tipo) => new DSFServiceClient(this, tipo);
56+
protected override IServiceClient GetClient(TipoUrl tipo) => new DSF100ServiceClient(this, tipo);
5757

5858
protected override string GerarCabecalho()
5959
{

0 commit comments

Comments
 (0)