public static NotaFiscal LoadFromFile(Stream stream) => ACBrIniFile.Load(stream);
public static NotaFiscal LoadFromFile(string filePath) => ACBrIniFile.Load(filePath);
public static Manifesto LoadFromFile(Stream stream) => ACBrIniFile.Load(stream);
/// <summary> /// Função para importar endereços no padrão de Ini do ACBr. /// </summary> /// <param name="stream"></param> public static void ImportIniACBr(Stream stream) { var ini = ACBrIniFile.Load(stream); var dataSource = (from DFeSiglaUF value in Enum.GetValues(typeof(DFeSiglaUF)) where !value.IsIn(DFeSiglaUF.EX, DFeSiglaUF.AN, DFeSiglaUF.SU) orderby value.GetDescription() select value).ToArray(); var servicoCTes = (from TipoServicoCTe value in Enum.GetValues(typeof(TipoServicoCTe)) select value).ToArray(); var getVersion = new Func <CTeVersao, string>(versao => { switch (versao) { case CTeVersao.v200: return("2.00"); case CTeVersao.v300: return("3.00"); default: throw new ArgumentOutOfRangeException(nameof(versao), versao, null); } }); // Emissão Normal foreach (var codUf in dataSource) { var sectionName = $"CTe_{codUf}_H"; var sessao = ini[sectionName]; var sessaoUsar = ini[sectionName]; while (sessaoUsar.ContainsKey("Usar")) { sessaoUsar = ini[sessaoUsar["Usar"]]; } foreach (var service in servicoCTes) { var key = $"{service.GetDescription()}_{getVersion(CTeVersao.v300)}"; var url = sessao.ContainsKey(key) ? sessao[key] : sessaoUsar.ContainsKey(key) ? sessaoUsar[key] : ""; Servicos[CTeVersao.v300, DFeTipoEmissao.Normal][DFeTipoAmbiente.Homologacao, codUf].Enderecos[service] = url; } sectionName = $"CTe_{codUf.GetDescription()}_P"; sessao = ini[sectionName]; sessaoUsar = ini[sectionName]; while (sessaoUsar.ContainsKey("Usar")) { sessaoUsar = ini[sessaoUsar["Usar"]]; } foreach (var service in servicoCTes) { var key = $"{service.GetDescription()}_{getVersion(CTeVersao.v300)}"; var url = sessao.ContainsKey(key) ? sessao[key] : sessaoUsar.ContainsKey(key) ? sessaoUsar[key] : ""; Servicos[CTeVersao.v300, DFeTipoEmissao.Normal][DFeTipoAmbiente.Producao, codUf] .Enderecos[service] = url; } } //Emissão DPEC foreach (var codUf in dataSource) { var sectionName = string.Empty; switch (codUf) { case DFeSiglaUF.PE: case DFeSiglaUF.SP: case DFeSiglaUF.MS: case DFeSiglaUF.MT: sectionName = "CTe_SVC-RS_"; break; default: sectionName = "CTe_SVC-SP_"; break; } var sessao = ini[sectionName + "H"]; foreach (var service in servicoCTes) { if (service == TipoServicoCTe.RecepcaoEventoAN) { continue; } var key = $"{service.GetDescription()}_{getVersion(CTeVersao.v300)}"; var url = sessao[key]; Servicos[CTeVersao.v300, DFeTipoEmissao.DPEC][DFeTipoAmbiente.Homologacao, codUf][service] = url; } sessao = ini[sectionName + "P"]; foreach (var service in servicoCTes) { if (service == TipoServicoCTe.RecepcaoEventoAN) { continue; } var key = $"{service.GetDescription()}_{getVersion(CTeVersao.v300)}"; var url = sessao[key]; Servicos[CTeVersao.v300, DFeTipoEmissao.DPEC][DFeTipoAmbiente.Producao, codUf][service] = url; } } //Emissão SVCRS foreach (var codUf in dataSource) { var sectionName = "CTe_SVC-RS_"; var sessao = ini[sectionName + "H"]; foreach (var service in servicoCTes) { if (service == TipoServicoCTe.RecepcaoEventoAN) { continue; } var key = $"{service.GetDescription()}_{getVersion(CTeVersao.v300)}"; var url = sessao[key]; Servicos[CTeVersao.v300, DFeTipoEmissao.SVCRS][DFeTipoAmbiente.Homologacao, codUf][service] = url; } sessao = ini[sectionName + "P"]; foreach (var service in servicoCTes) { if (service == TipoServicoCTe.RecepcaoEventoAN) { continue; } var key = $"{service.GetDescription()}_{getVersion(CTeVersao.v300)}"; var url = sessao[key]; Servicos[CTeVersao.v300, DFeTipoEmissao.SVCRS][DFeTipoAmbiente.Producao, codUf][service] = url; } } //Emissão SVCSP foreach (var codUf in dataSource) { var sectionName = "CTe_SVC-SP_"; var sessao = ini[sectionName + "H"]; foreach (var service in servicoCTes) { if (service == TipoServicoCTe.RecepcaoEventoAN) { continue; } var key = $"{service.GetDescription()}_{getVersion(CTeVersao.v300)}"; var url = sessao[key]; Servicos[CTeVersao.v300, DFeTipoEmissao.SVCSP][DFeTipoAmbiente.Homologacao, codUf][service] = url; } sessao = ini[sectionName + "P"]; foreach (var service in servicoCTes) { if (service == TipoServicoCTe.RecepcaoEventoAN) { continue; } var key = $"{service.GetDescription()}_{getVersion(CTeVersao.v300)}"; var url = sessao[key]; Servicos[CTeVersao.v300, DFeTipoEmissao.SVCSP][DFeTipoAmbiente.Producao, codUf][service] = url; } } }
public static Manifesto LoadFromFile(string filePath) => ACBrIniFile.Load(filePath);