public static ITRetConsReciNFe ConsultarProcessamentoEnvelope( System.Web.Services.Protocols.SoapHttpClientProtocol oServico, ITConsReciNFe oConsReciNFe, Parametro oParam, VersaoXML versao) { return((ITRetConsReciNFe)XMLUtils.LoadXML(ExecutaServico(oServico, oConsReciNFe, oParam), versao, "TRetConsReciNFe")); }
public static ITRetEnvEvento EnviarEnvelopeEvento( System.Web.Services.Protocols.SoapHttpClientProtocol oServico, ITEnvEvento oEnvEvento, Parametro oParam, VersaoXML versao) { return((ITRetEnvEvento)XMLUtils.LoadXML(ExecutaServico(oServico, oEnvEvento, oParam), versao, "TRetEnvEvento")); }
public static ITRetEnviNFe EnviarEnvelope( System.Web.Services.Protocols.SoapHttpClientProtocol oServico, ITEnviNFe oEnviNFe, Parametro oParam, VersaoXML versao) { return((ITRetEnviNFe)XMLUtils.CarregaXML_STR(ExecutaServico(oServico, oEnviNFe, oParam), versao, "TRetEnviNFe")); }
public static Type GetXMLType(VersaoXML version, string stType) { Type tipo = null; if (version == VersaoXML.NFe_v200) { tipo = Type.GetType(NFeSchema200ns + stType); } else if (version == VersaoXML.NFe_v300) { tipo = Type.GetType(NFeSchema300ns + stType); } else if (version == VersaoXML.NFe_v310) { tipo = Type.GetType(NFeSchema310ns + stType); } else if (version == VersaoXML.Integracao) { tipo = Type.GetType("SchemaXML." + stType); } else if (version == VersaoXML.GNRE) { tipo = Type.GetType(GNRESchema100ns + stType); } else { throw new Exception("Tipo não pode ser definido."); } return(tipo); }
public static ITRetInutNFe InutilizarNFe( System.Web.Services.Protocols.SoapHttpClientProtocol oServico, ITInutNFe oInutNFe, Parametro oParam, VersaoXML versao) { return((ITRetInutNFe)XMLUtils.CarregaXML_STR(ExecutaServico(oServico, oInutNFe, oParam), versao, "TRetInutNFe")); }
public static String GetXML(Object oXML, VersaoXML versao) { string stNamespace = ""; if (versao == VersaoXML.GNRE) { stNamespace = GNRENAMESPACE; } else if (versao == VersaoXML.NFe_v200 || versao == VersaoXML.NFe_v300 || versao == VersaoXML.NFe_v310) { stNamespace = NFeNAMESPACE; } else if (versao == VersaoXML.Integracao) { stNamespace = RDINAMESPACE; } else { stNamespace = "";//padrao } MemoryStream memoryStream = new MemoryStream(); XmlSerializerNamespaces xsn = new XmlSerializerNamespaces(); xsn.Add("", stNamespace); System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(oXML.GetType()); XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, new System.Text.UTF8Encoding(false)); xs.Serialize(xmlTextWriter, oXML, xsn); memoryStream = (MemoryStream)xmlTextWriter.BaseStream; Byte[] characters = memoryStream.ToArray(); System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); return(encoding.GetString(characters)); }
public static ITRetConsSitNFe ConsultarSituacaoNFe( System.Web.Services.Protocols.SoapHttpClientProtocol oServico, ITConsSitNFe oConsSitNFe, Parametro oParam, VersaoXML versao) { return((ITRetConsSitNFe)XMLUtils.CarregaXML_STR(ExecutaServico(oServico, oConsSitNFe, oParam), versao, "TRetConsSitNFe")); }
public static void SaveXML(string fileName, object oXML, VersaoXML versao) { string stNamespace = GetXMLNamespace(versao); if (System.IO.File.Exists(fileName)) { System.IO.File.Delete(fileName); } MemoryStream memoryStream = new MemoryStream(); XmlSerializerNamespaces xsn = new XmlSerializerNamespaces(); xsn.Add("", stNamespace); XmlSerializer xs = new XmlSerializer(oXML.GetType()); XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, new System.Text.UTF8Encoding(false)); xs.Serialize(xmlTextWriter, oXML, xsn); memoryStream = (MemoryStream)xmlTextWriter.BaseStream; Byte[] characters = memoryStream.ToArray(); System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); StreamWriter oSW = File.CreateText(fileName); oSW.Write(encoding.GetString(characters)); oSW.Close(); }
public static ITRetConsStatServ ConsultarStatusServidor( System.Web.Services.Protocols.SoapHttpClientProtocol oServico, ITConsStatServ oConsStatServ, Parametro oParam, VersaoXML versao) { return((ITRetConsStatServ)XMLUtils.CarregaXML_STR(ExecutaServico(oServico, oConsStatServ, oParam), versao, "TRetConsStatServ")); }
public static object XMLFactory(VersaoXML version, string stType, int size = -1) { Type type = GetXMLType(version, stType); if (size == -1) { return(Activator.CreateInstance(type)); } else { return(Activator.CreateInstance(type, size)); } }
public static object CarregaXML_HD(string filename, VersaoXML versao, string stTipo) { String _xml = String.Empty; using (StreamReader SR = File.OpenText(filename)) { _xml = SR.ReadToEnd(); SR.Close(); SR.Dispose(); } GC.Collect(); return(CarregaXML_STR(_xml, versao, stTipo)); }
public static object LoadXMLFile(string fileName, VersaoXML versao, string stTipo) { String _xml = String.Empty; using (StreamReader SR = File.OpenText(fileName)) { _xml = SR.ReadToEnd(); SR.Close(); SR.Dispose(); } GC.Collect(); return(LoadXML(_xml, versao, stTipo)); }
public static object LoadXML(string XML, VersaoXML versao, string stTipo) { try { XmlSerializer xs = new XmlSerializer(GetXMLType(versao, stTipo)); MemoryStream memoryStream = new MemoryStream(StringToUTF8ByteArray(XML)); XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8); return(xs.Deserialize(memoryStream)); } catch (Exception ex) { throw new XMLValidationException("Erro ao carregar o XML", ex); } }
public static Type GetXMLType(VersaoXML version, string stType) { Type tipo = null; switch (version) { case VersaoXML.NFe_v200: tipo = Type.GetType(NFeSchema200ns + stType); break; case VersaoXML.NFe_v300: tipo = Type.GetType(NFeSchema300ns + stType); break; case VersaoXML.NFe_v310: tipo = Type.GetType(NFeSchema310ns + stType); break; case VersaoXML.Integracao: tipo = Type.GetType(IntegracaoSchema100ns + stType); break; case VersaoXML.GNRE: tipo = Type.GetType(GNRESchema100ns + stType); break; case VersaoXML.NFe_v400: tipo = Type.GetType(NFeSchema400ns + stType); break; case VersaoXML.Eventos_v100: tipo = Type.GetType(EventosSchema100ns + stType); break; case VersaoXML.ConsultaCadastro_v100: tipo = Type.GetType(ConsCad100ns + stType); break; case VersaoXML.DocumentosFiscaisEletronicos_v101: tipo = Type.GetType(DFeSchema101ns + stType); break; default: break; } return(tipo); }
public static string GetXMLNamespace(VersaoXML version) { var stNamespace = string.Empty; switch (version) { case VersaoXML.NFe_v200: stNamespace = NFeNAMESPACE; break; case VersaoXML.NFe_v300: stNamespace = NFeNAMESPACE; break; case VersaoXML.NFe_v310: stNamespace = NFeNAMESPACE; break; case VersaoXML.Integracao: stNamespace = RDINAMESPACE; break; case VersaoXML.GNRE: stNamespace = GNRENAMESPACE; break; case VersaoXML.NFe_v400: stNamespace = NFeNAMESPACE; break; case VersaoXML.Eventos_v100: stNamespace = NFeNAMESPACE; break; case VersaoXML.ConsultaCadastro_v100: stNamespace = NFeNAMESPACE; break; case VersaoXML.DocumentosFiscaisEletronicos_v101: stNamespace = NFeNAMESPACE; break; default: break; } return(stNamespace); }
//chamadas com retornos em string public static KeyValuePair <string, ITRetEnvEvento> Interface_EnviarEnvelopeEvento( System.Web.Services.Protocols.SoapHttpClientProtocol oServico, ITEnvEvento oEnvEvento, Parametro oParam, VersaoXML versao) { var Key = ExecutaServico(oServico, oEnvEvento, oParam); try { var Value = (ITRetEnvEvento)XMLUtils.CarregaXML_STR(Key, versao, "TRetEnvEvento"); return(new KeyValuePair <string, ITRetEnvEvento>(Key, Value)); } catch (Exception ex) { Key = ex.Message + " - " + Key; return(new KeyValuePair <string, ITRetEnvEvento>(Key, null)); } }
public static KeyValuePair <string, ITRetInutNFe> Interface_InutilizarNFe( System.Web.Services.Protocols.SoapHttpClientProtocol oServico, ITInutNFe oInutNFe, Parametro oParam, VersaoXML versao) { var Key = ExecutaServico(oServico, oInutNFe, oParam); try { var Value = (ITRetInutNFe)XMLUtils.LoadXML(Key, versao, "TRetInutNFe"); return(new KeyValuePair <string, ITRetInutNFe>(Key, Value)); } catch (Exception ex) { Key = ex.Message + " - " + Key; return(new KeyValuePair <string, ITRetInutNFe>(Key, null)); } }
public static KeyValuePair <string, ITRetConsSitNFe> Interface_ConsultarSituacaoNFe( System.Web.Services.Protocols.SoapHttpClientProtocol oServico, ITConsSitNFe oConsSitNFe, Parametro oParam, VersaoXML versao) { var Key = ExecutaServico(oServico, oConsSitNFe, oParam); try { var Value = (ITRetConsSitNFe)XMLUtils.CarregaXML_STR(Key, versao, "TRetConsSitNFe"); return(new KeyValuePair <string, ITRetConsSitNFe>(Key, Value)); } catch (Exception ex) { Key = ex.Message + " - " + Key; return(new KeyValuePair <string, ITRetConsSitNFe>(Key, null)); } }
public static KeyValuePair <string, ITRetConsStatServ> Interface_ConsultarStatusServidor( System.Web.Services.Protocols.SoapHttpClientProtocol oServico, ITConsStatServ oConsStatServ, Parametro oParam, VersaoXML versao) { var Key = ExecutaServico(oServico, oConsStatServ, oParam); try { var Value = (ITRetConsStatServ)XMLUtils.LoadXML(Key, versao, "TRetConsStatServ"); return(new KeyValuePair <string, ITRetConsStatServ>(Key, Value)); } catch (Exception ex) { Key = ex.Message + " - " + Key; return(new KeyValuePair <string, ITRetConsStatServ>(Key, null)); } }
public static string GetXML(object oXML, VersaoXML versao) { string stNamespace = GetXMLNamespace(versao); MemoryStream memoryStream = new MemoryStream(); XmlSerializerNamespaces xsn = new XmlSerializerNamespaces(); xsn.Add("", stNamespace); System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(oXML.GetType()); XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, new System.Text.UTF8Encoding(false)); xs.Serialize(xmlTextWriter, oXML, xsn); memoryStream = (MemoryStream)xmlTextWriter.BaseStream; Byte[] characters = memoryStream.ToArray(); System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); return(encoding.GetString(characters)); }
public static void SalvaXML(string filename, Object oXML, VersaoXML versao) { string stNamespace = ""; if (versao == VersaoXML.GNRE) { stNamespace = GNRENAMESPACE; } else if (versao == VersaoXML.NFe_v200 || versao == VersaoXML.NFe_v300 || versao == VersaoXML.NFe_v310) { stNamespace = NFeNAMESPACE; } else if (versao == VersaoXML.Integracao) { stNamespace = RDINAMESPACE; } else { stNamespace = "";//padrao } if (System.IO.File.Exists(filename)) { System.IO.File.Delete(filename); } MemoryStream memoryStream = new MemoryStream(); XmlSerializerNamespaces xsn = new XmlSerializerNamespaces(); xsn.Add("", stNamespace); XmlSerializer xs = new XmlSerializer(oXML.GetType()); XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, new System.Text.UTF8Encoding(false)); xs.Serialize(xmlTextWriter, oXML, xsn); memoryStream = (MemoryStream)xmlTextWriter.BaseStream; Byte[] characters = memoryStream.ToArray(); System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); StreamWriter oSW = File.CreateText(filename); oSW.Write(encoding.GetString(characters)); oSW.Close(); }
public static ITRetDownloadNFe DownloadNF(SoapHttpClientProtocol oServico, ITDownloadNFe xmlEnvio, Parametro oParam, VersaoXML versao) { return((ITRetDownloadNFe)XMLUtils.CarregaXML_STR(ExecutaServico(oServico, xmlEnvio, oParam), versao, "TRetDownloadNFe")); }
public static KeyValuePair <string, ITRetConsCad> Interface_ConsultarCadastro(SoapHttpClientProtocol oServico, ITConsCad oEnviNFe3, Parametro oParam, VersaoXML versao) { var Key = ExecutaServico(oServico, oEnviNFe3, oParam); try { var Value = (ITRetConsCad)XMLUtils.CarregaXML_STR(Key, versao, "TRetConsCad"); return(new KeyValuePair <string, ITRetConsCad>(Key, Value)); } catch (Exception ex) { Key = ex.Message + " - " + Key; return(new KeyValuePair <string, ITRetConsCad>(Key, null)); } }
public static KeyValuePair <string, IRetDistDFeInt> Interface_ConsultarDFe(SoapHttpClientProtocol oServico, IDistDFeInt xmlEnvio, Parametro oParam, VersaoXML versao) { var Key = ExecutaServico(oServico, xmlEnvio, oParam); try { var Value = (IRetDistDFeInt)XMLUtils.CarregaXML_STR(Key, versao, "retDistDFeInt"); return(new KeyValuePair <string, IRetDistDFeInt>(Key, Value)); } catch (Exception ex) { Key = ex.Message + " - " + Key; return(new KeyValuePair <string, IRetDistDFeInt>(Key, null)); } }
public static KeyValuePair <string, ITRetDownloadNFe> Interface_DownloadNF(SoapHttpClientProtocol oServico, ITDownloadNFe xmlEnvio, Parametro oParam, VersaoXML versao) { var Key = ExecutaServico(oServico, xmlEnvio, oParam); try { var Value = (ITRetDownloadNFe)XMLUtils.CarregaXML_STR(Key, versao, "TRetDownloadNFe"); return(new KeyValuePair <string, ITRetDownloadNFe>(Key, Value)); } catch (Exception ex) { Key = ex.Message + " - " + Key; return(new KeyValuePair <string, ITRetDownloadNFe>(Key, null)); } }
public static KeyValuePair <string, RDI.NFe2.GNRE.TConfigUf> Interface_GNREConfigUF(SoapHttpClientProtocol oServico, RDI.NFe2.GNRE.TConsultaConfigUf xmlEnvio, Parametro oParam, VersaoXML versao) { var Key = ExecutaServico(oServico, xmlEnvio, oParam); try { var Value = (RDI.NFe2.GNRE.TConfigUf)XMLUtils.CarregaXML_STR(Key, versao, "TConfigUf"); return(new KeyValuePair <string, RDI.NFe2.GNRE.TConfigUf>(Key, Value)); } catch (Exception ex) { Key = ex.Message + " - " + Key; return(new KeyValuePair <string, RDI.NFe2.GNRE.TConfigUf>(Key, null)); } }
public static ITRetConsCad ConsultarCadastro(SoapHttpClientProtocol oServico, ITConsCad oEnviNFe3, Parametro oParam, VersaoXML versao) { return((ITRetConsCad)XMLUtils.CarregaXML_STR(ExecutaServico(oServico, oEnviNFe3, oParam), versao, "TRetConsCad")); }
public static INotaFiscalEletronica NotaFiscalEletronicaFactory(VersaoXML _versaoXml, TipoEmissao _tipoServidor, cwkAmbiente _ambiente, TipoDoCertificado _tipoCertificado , string diretorioPadrao, Int16 indFinal, IndPres indPres, bool bDevolucao, int modeloDocumento, int componenteDfe, ConfiguracaoManager configManager = null) { INotaFiscalEletronica retorno; if (modeloDocumento == 55) { switch (_versaoXml) { case VersaoXML.v3: retorno = new NotaFiscalEletronica30(_tipoServidor, _ambiente, _tipoCertificado, diretorioPadrao); break; case VersaoXML.v4: retorno = new NotaFiscalEletronica40(_tipoServidor, _ambiente, _tipoCertificado, diretorioPadrao); break; case VersaoXML.v5a: retorno = new NotaFiscalEletronica50a(_tipoServidor, _ambiente, _tipoCertificado, diretorioPadrao, indFinal, indPres, bDevolucao); break; case VersaoXML.v6: if (componenteDfe == 0) //0 = Tecnospeed / 1 = Zeus Automação { retorno = new NotaFiscalEletronica60(_tipoServidor, _ambiente, _tipoCertificado, diretorioPadrao, indFinal, indPres, bDevolucao); } else { retorno = new NotaFiscalEletronicaZeus60(_tipoServidor, _ambiente, _tipoCertificado, diretorioPadrao, indFinal, indPres, bDevolucao); } break; default: throw new Exception("Versão do XML " + _versaoXml + " não implementado para a NF-e"); //return null; } } else { switch (_versaoXml) { case VersaoXML.v5a: retorno = new NotaFiscalEletronicaConsumidor50a(_tipoServidor, _ambiente, _tipoCertificado, diretorioPadrao, indFinal, indPres, bDevolucao, configManager); break; case VersaoXML.v6: if (componenteDfe == 0) //0 = Tecnospeed / 1 = Zeus Automação { retorno = new NotaFiscalEletronicaConsumidor60(_tipoServidor, _ambiente, _tipoCertificado, diretorioPadrao, indFinal, indPres, bDevolucao, configManager); } else { retorno = new NotaFiscalEletronicaConsumidorZeus60(_tipoServidor, _ambiente, _tipoCertificado, diretorioPadrao, indFinal, indPres, bDevolucao); } break; default: throw new Exception("Versão do XML " + _versaoXml + "não implementado para a NFC-e"); } } retorno.FormaEmissao = _tipoServidor; retorno.TipoDoCertificado = _tipoCertificado; return(retorno); }
public static INotaFiscalEletronica NotaFiscalEletronicaFactory(VersaoXML _versaoXml, TipoEmissao _tipoServidor, cwkAmbiente _ambiente, TipoDoCertificado _tipoCertificado , string diretorioPadrao, Int16 indFinal, IndPres indPres, bool bDevolucao, int modeloDocumento = 55, int componenteDfe = 1) { return(NotaFiscalEletronicaFactory(_versaoXml, _tipoServidor, _ambiente, _tipoCertificado, diretorioPadrao, indFinal, indPres, bDevolucao, modeloDocumento, componenteDfe, new ConfiguracaoManager())); }
public static IRetDistDFeInt ConsultarDFe(SoapHttpClientProtocol oServico, IDistDFeInt xmlEnvio, Parametro oParam, VersaoXML versao) { return((IRetDistDFeInt)XMLUtils.CarregaXML_STR(ExecutaServico(oServico, xmlEnvio, oParam), versao, "retDistDFeInt")); }