/// <summary> /// Throw error with IPM /// </summary> /// <param name="pm"></param> /// <param name="level">Selected level.</param> public IncorrectNodeException(IPM pm, int level = 0) : this() { if(pm != null) { pm.fail(level, (new StackTrace()).GetFrame(1).GetMethod().Name); } }
protected string dataPack(IPM pm, string name, bool eval) { if (pm.FirstLevel.Type != LevelType.RightOperandColon) { throw new IncorrectNodeException(pm); // #[Box data.pack(name, eval): content] } if (content.ContainsKey(name)) { throw new LimitException($"Package of data with name '{name}' is already defined before. Use `data.free` to release data and avoid this error."); } Log.Trace($"`data.pack('{name}', {eval}): {pm.FirstLevel.Data}`"); content[name] = eval ? evaluate(pm.FirstLevel.Data) : pm.FirstLevel.Data; Log.Trace($"packed as `{content[name]}`"); return(String.Empty); }
protected string stStartUpProject(IPM pm) { if (!pm.It(LevelType.Property, "StartUpProject")) { throw new IncorrectNodeException(pm); } // get if (pm.IsRight(LevelType.RightOperandEmpty)) { return(env.StartupProjectString); } // set if (!pm.IsRight(LevelType.RightOperandStd)) { throw new IncorrectNodeException(pm); } ILevel level = pm.FirstLevel; var val = (new PM()).arguments(level.Data); if (val == null || val.Length < 1) { env.updateStartupProject(null); return(Value.Empty); } Argument pname = val[0]; if (val.Length > 1 || (pname.type != ArgumentType.StringDouble && pname.type != ArgumentType.EnumOrConst && pname.type != ArgumentType.Mixed)) { throw new ArgumentPMException(level, "= string name"); } env.updateStartupProject(pname.data.ToString()); return(Value.Empty); }
protected string CopyFile(IPM pm, string src, string dest, bool overwrite, RArgs except = null) { if (string.IsNullOrWhiteSpace(src) || string.IsNullOrWhiteSpace(dest)) { throw new ArgumentException("The source file or the destination path argument is empty."); } if (except != null && except.Any(p => p.type != ArgumentType.StringDouble)) { throw new PMArgException(except, "'except' argument. Define as {\"f1\", \"f2\", ...}"); } dest = GetLocation(dest.TrimEnd()); string destDir = Path.GetDirectoryName(dest); string destFile = Path.GetFileName(dest); src = GetLocation(src); string[] input = new[] { src }.ExtractFiles(Exer.BasePath); #if DEBUG LSender.Send(this, $"Found files to copy `{string.Join(", ", input)}`", MsgLevel.Trace); #endif if (except != null) { string path = Path.GetDirectoryName(src); input = input.Except ( except .Where(f => !string.IsNullOrWhiteSpace((string)f.data)) .Select(f => GetLocation((string)f.data, path)) .ToArray() .ExtractFiles(Exer.BasePath) ) .ToArray(); } if (input.Length < 1) { throw new ArgumentException("The input files was not found. Check your mask and the exception list if used."); } CopyFile(destDir, destFile, overwrite, input); return(Value.Empty); }
protected string stLog(IPM pm) { if (pm.It(LevelType.Property, "log")) { if (pm.It(LevelType.Property, "Message")) { return(Value.from(logcopy.Message)); } if (pm.It(LevelType.Property, "Level")) { return(Value.from(logcopy.Level)); } throw new IncorrectNodeException(pm); } throw new IncorrectNodeException(pm); }
protected string StExec(IPM pm) { if (!pm.It(LevelType.Property, "exec") || !pm.IsRight(LevelType.RightOperandColon)) { throw new IncorrectNodeException(pm); } string cmd = pm.FirstLevel.Data.Trim(); if (string.IsNullOrWhiteSpace(cmd)) { throw new ArgumentException("The command cannot be empty."); } LSender.Send(this, $"Execute command `{cmd}`"); env.Execute(cmd); return(Value.Empty); }
protected string stEventItem(SolutionEventType type, IPM pm) { ILevel level = pm.FirstLevel; int index = -1; ISolutionEvent evt; if (level.Is(ArgumentType.StringDouble)) { evt = getEventByName(type, (string)level.Args[0].data, out index); } else if (level.Is(ArgumentType.Integer)) { index = (int)level.Args[0].data; evt = getEventByIndex(type, index); } else { throw new InvalidArgumentException("Incorrect arguments to `item( string name | integer index )`"); } // .item(...). if (pm.Is(1, LevelType.Property, "Enabled")) { return(pEnabled(evt, pm.pinTo(2))); } if (pm.Is(1, LevelType.Property, "Status")) { return(itemStatus(type, index, pm.pinTo(1))); } if (pm.Is(1, LevelType.Property, "stdout")) { return(pStdout(evt, pm.pinTo(2))); } if (pm.Is(1, LevelType.Property, "stderr")) { return(pStderr(evt, pm.pinTo(2))); } throw new IncorrectNodeException(pm, 1); }
protected string StSlnPMap(string sln, IPM pm) { if (string.IsNullOrWhiteSpace(sln)) { throw new ArgumentException($"Failed {nameof(StSlnPMap)}: sln is empty"); } ProjectsMap map = GetProjectsMap(sln); if (pm.Is(LevelType.Property, "First")) { return(UseProjectsMap(map.FirstBy(env.IsCleanOperation), pm.PinTo(1))); } if (pm.Is(LevelType.Property, "Last")) { return(UseProjectsMap(map.LastBy(env.IsCleanOperation), pm.PinTo(1))); } if (pm.Is(LevelType.Property, "FirstRaw")) { return(UseProjectsMap(map.First, pm.PinTo(1))); } if (pm.Is(LevelType.Property, "LastRaw")) { return(UseProjectsMap(map.Last, pm.PinTo(1))); } if (pm.FinalEmptyIs(LevelType.Property, "GuidList")) { return(Value.From(map.GuidList)); } if (pm.Is(LevelType.Method, "projectBy")) { ILevel lvlPrjBy = pm.FirstLevel; lvlPrjBy.Is("projectBy(string guid)", ArgumentType.StringDouble); return(UseProjectsMap(map.GetProjectBy((string)lvlPrjBy.Args[0].data), pm.PinTo(1))); } throw new IncorrectNodeException(pm); }
protected string stSlnPMap(string sln, IPM pm) { if (String.IsNullOrWhiteSpace(sln)) { throw new InvalidArgumentException("Failed stSlnPMap: sln is empty"); } ProjectsMap map = getProjectsMap(sln); if (pm.Is(LevelType.Property, "First")) { return(projectsMap(map.FirstBy(env.BuildType), pm.pinTo(1))); } if (pm.Is(LevelType.Property, "Last")) { return(projectsMap(map.LastBy(env.BuildType), pm.pinTo(1))); } if (pm.Is(LevelType.Property, "FirstRaw")) { return(projectsMap(map.First, pm.pinTo(1))); } if (pm.Is(LevelType.Property, "LastRaw")) { return(projectsMap(map.Last, pm.pinTo(1))); } if (pm.FinalEmptyIs(LevelType.Property, "GuidList")) { return(Value.from(map.GuidList)); } if (pm.Is(LevelType.Method, "projectBy")) { ILevel lvlPrjBy = pm.FirstLevel; lvlPrjBy.Is("projectBy(string guid)", ArgumentType.StringDouble); return(projectsMap(map.getProjectBy((string)lvlPrjBy.Args[0].data), pm.pinTo(1))); } throw new IncorrectNodeException(pm); }
protected string stPack(IPM pm) { if (!pm.It(LevelType.Property, "pack")) { throw new IncorrectNodeException(pm); } ILevel level = pm.FirstLevel; // level of the pack property if (pm.FinalEmptyIs(LevelType.Method, "files")) { return(packFiles(level, pm)); } if (pm.FinalEmptyIs(LevelType.Method, "directory")) { return(packDirectory(level, pm)); } throw new IncorrectNodeException(pm); }
/// <summary> /// Prepares signatures: /// pack.directory(string dir, string output [, enum format, enum method, integer level]) /// </summary> /// <param name="level"></param> /// <param name="pm"></param> /// <returns></returns> protected string packDirectory(ILevel level, IPM pm) { if (level.Is(ArgumentType.StringDouble, ArgumentType.StringDouble)) { return(stPackDirectory((string)level.Args[0].data, (string)level.Args[1].data, pm.pinTo(1))); } if (level.Is(ArgumentType.StringDouble, ArgumentType.StringDouble, ArgumentType.EnumOrConst, ArgumentType.EnumOrConst, ArgumentType.Integer)) { return(stPackDirectory( (string)level.Args[0].data, (string)level.Args[1].data, (OutArchiveFormat)Enum.Parse(typeof(OutArchiveFormat), (string)level.Args[2].data), (CompressionMethod)Enum.Parse(typeof(CompressionMethod), (string)level.Args[3].data), (CompressionLevel)(int)level.Args[4].data, pm.pinTo(1))); } throw new ArgumentPMException(level, "pack.directory(string dir, string output [, enum format, enum method, integer level])"); }
protected string StItemWrite(string name, bool newline, IPM pm) { if (!pm.IsMethodWithArgs("write", ArgumentType.Boolean) && !pm.IsMethodWithArgs("writeLine", ArgumentType.Boolean)) { throw new IncorrectNodeException(pm); } bool createIfNo = (bool)pm.FirstLevel.Args[0].data; if (pm.Levels[1].Type != LevelType.RightOperandColon) { throw new IncorrectNodeException(pm); } string content = pm.Levels[1].Data; env.Write(content, newline, name, createIfNo); return(Value.Empty); }
protected string StWriteFamily(IPM pm) { if (pm.FinalIs(LevelType.Method, "write")) { return(StWrite(pm, false, false)); } if (pm.FinalIs(LevelType.Method, "append")) { return(StWrite(pm, true, false)); } if (pm.FinalIs(LevelType.Method, "writeLine")) { return(StWrite(pm, false, true)); } if (pm.FinalIs(LevelType.Method, "appendLine")) { return(StWrite(pm, true, true)); } throw new IncorrectNodeException(pm); }
protected string CopyFile(ILevel level, IPM pm) { if (level.Is(ArgumentType.StringDouble, ArgumentType.StringDouble, ArgumentType.Boolean)) { return(CopyFile(pm.PinTo(1), (string)level.Args[0].data, (string)level.Args[1].data, (bool)level.Args[2].data)); } if (level.Is(ArgumentType.StringDouble, ArgumentType.StringDouble, ArgumentType.Boolean, ArgumentType.Object)) { return(CopyFile(pm.PinTo(1), (string)level.Args[0].data, (string)level.Args[1].data, (bool)level.Args[2].data, (RArgs)level.Args[3].data)); } if (level.Is(ArgumentType.Object, ArgumentType.StringDouble, ArgumentType.Boolean)) { return(CopyFile(pm.PinTo(1), (RArgs)level.Args[0].data, (string)level.Args[1].data, (bool)level.Args[2].data)); } if (level.Is(ArgumentType.Object, ArgumentType.StringDouble, ArgumentType.Boolean, ArgumentType.Object)) { return(CopyFile(pm.PinTo(1), (RArgs)level.Args[0].data, (string)level.Args[1].data, (bool)level.Args[2].data, (RArgs)level.Args[3].data)); } throw new PMLevelException(level, "copy.file((string src | object srclist), string dest, bool overwrite [, object except])"); }
protected string dataClone(IPM pm, string name, int count, bool forceEval = false) { if (!content.ContainsKey(name)) { throw new NotFoundException($"Package of data with name '{name}' was not found."); } if (count < 1) { return(String.Empty); } string val = forceEval ? evaluate(content[name]) : content[name]; string ret = String.Empty; for (int i = 0; i < count; ++i) { ret += val; } return(ret); }
protected string stItemWrite(string name, bool newline, IPM pm) { if (!pm.IsMethodWithArgs("write", ArgumentType.Boolean) && !pm.IsMethodWithArgs("writeLine", ArgumentType.Boolean)) { throw new IncorrectNodeException(pm); } bool createIfNotExist = (bool)pm.FirstLevel.Args[0].data; if (pm.Levels[1].Type != LevelType.RightOperandColon) { throw new IncorrectNodeException(pm); } string content = pm.Levels[1].Data; EnvDTE.OutputWindowPane pane; if (!createIfNotExist) { try { pane = OWP.getByName(name, false); } catch (ArgumentException) { throw new NotFoundException("The item '{0}' does not exist. Use 'force' flag for automatic creation if needed.", name); } } else { pane = OWP.getByName(name, true); } if (newline) { content += System.Environment.NewLine; } pane.OutputString(content); return(Value.Empty); }
protected string DataClone(IPM pm, string name, int count, bool forceEval = false) { if (!content.ContainsKey(name)) { throw new NotFoundException(name); } if (count < 1) { return(string.Empty); } string val = forceEval ? Evaluate(content[name]) : content[name]; string ret = string.Empty; for (int i = 0; i < count; ++i) { ret += val; } return(ret); }
/// <summary> /// Unpacking archive for signature: /// unpack(string file [, string output][, boolean delete][, string pwd]) /// </summary> /// <param name="pm"></param> /// <param name="file">Archive for unpacking.</param> /// <param name="output">Output path to unpacking archive data.</param> /// <param name="delete">To delete archive after extracting data if true.</param> /// <param name="pwd">password of archive if used.</param> /// <returns></returns> protected string stUnpackMethod(IPM pm, string file, string output = null, bool delete = false, string pwd = null) { Log.Trace("stUnpackMethod: `{0}` -> `{1}` : delete({2}), pwd({3})", file, output, delete, (pwd == null)? "none" : "***"); file = pathToFile(file); if (output == null) { output = getDirectoryFromFile(file); // same path } else if (String.IsNullOrWhiteSpace(output)) { throw new InvalidArgumentException("The `output` argument can't be empty."); } else { output = location(output); } extractArchive(file, output, delete, pwd); return(Value.Empty); }
protected string StRemote(IPM pm) { if (!pm.It(LevelType.Property, "remote")) { throw new IncorrectNodeException(pm); } ILevel level = pm.FirstLevel; if (pm.FinalEmptyIs(LevelType.Method, "download")) { if (level.Is(ArgumentType.StringDouble, ArgumentType.StringDouble)) { return(Download((string)level.Args[0].data, (string)level.Args[1].data)); } if (level.Is(ArgumentType.StringDouble, ArgumentType.StringDouble, ArgumentType.StringDouble, ArgumentType.StringDouble)) { return(Download((string)level.Args[0].data, (string)level.Args[1].data, (string)level.Args[2].data, (string)level.Args[3].data)); } throw new PMLevelException(level, "(string addr, string output [, string user, string pwd])"); } throw new IncorrectNodeException(pm); }
protected string StCall(IPM pm, bool stdOut, bool silent) { ILevel level = pm.FirstLevel; string file; string args = String.Empty; int timeout = STCALL_TIMEOUT_DEFAULT; if (level.Is(ArgumentType.StringDouble)) { file = (string)level.Args[0].data; } else if (level.Is(ArgumentType.StringDouble, ArgumentType.StringDouble)) { file = (string)level.Args[0].data; args = (string)level.Args[1].data; } else if (level.Is(ArgumentType.StringDouble, ArgumentType.StringDouble, ArgumentType.Integer)) { file = (string)level.Args[0].data; args = (string)level.Args[1].data; timeout = (int)level.Args[2].data; } else { throw new PMLevelException(level, level.Data + "(string filename [, string args [, uinteger timeout]])"); } string pfile = FindFile(file); if (String.IsNullOrEmpty(pfile)) { throw new NotFoundException(file); } return(Run(pfile, args, silent, stdOut, timeout)); }
private protected string UseProjectsMap(ProjectItem project, IPM pm) { if (pm.FinalEmptyIs(LevelType.Property, "name")) { return(project.name); } if (pm.FinalEmptyIs(LevelType.Property, "path")) { return(project.path); } if (pm.FinalEmptyIs(LevelType.Property, "type")) { return(project.type); } if (pm.FinalEmptyIs(LevelType.Property, "guid")) { return(project.guid); } throw new IncorrectNodeException(pm); }
public override void Execute() { int emp = Empresas.FindEmpresaByThread(); //Definir o serviço que será executado para a classe Servico = Servicos.NFSeRecepcionarLoteRps; try { Functions.DeletarArquivo(Empresas.Configuracoes[emp].PastaXmlRetorno + "\\" + Functions.ExtrairNomeArq(NomeArquivoXML, Propriedade.Extensao(Propriedade.TipoEnvio.EnvLoteRps).EnvioXML) + Propriedade.ExtRetorno.RetEnvLoteRps_ERR); Functions.DeletarArquivo(Empresas.Configuracoes[emp].PastaXmlErro + "\\" + NomeArquivoXML); oDadosEnvLoteRps = new DadosEnvLoteRps(emp); EnvLoteRps(emp, NomeArquivoXML); //Criar objetos das classes dos serviços dos webservices do SEFAZ PadroesNFSe padraoNFSe = Functions.PadraoNFSe(oDadosEnvLoteRps.cMunicipio); WebServiceProxy wsProxy = null; object envLoteRps = null; if (IsUtilizaCompilacaoWs(padraoNFSe, Servico, oDadosEnvLoteRps.cMunicipio)) { wsProxy = ConfiguracaoApp.DefinirWS(Servico, emp, oDadosEnvLoteRps.cMunicipio, oDadosEnvLoteRps.tpAmb, oDadosEnvLoteRps.tpEmis, padraoNFSe, oDadosEnvLoteRps.cMunicipio); if (wsProxy != null) { envLoteRps = wsProxy.CriarObjeto(wsProxy.NomeClasseWS); } } System.Net.SecurityProtocolType securityProtocolType = WebServiceProxy.DefinirProtocoloSeguranca(oDadosEnvLoteRps.cMunicipio, oDadosEnvLoteRps.tpAmb, oDadosEnvLoteRps.tpEmis, padraoNFSe, Servico); string cabecMsg = ""; switch (padraoNFSe) { case PadroesNFSe.IPM: //código da cidade da receita federal, este arquivo pode ser encontrado em ~\uninfe\doc\Codigos_Cidades_Receita_Federal.xls</para> //O código da cidade está hardcoded pois ainda está sendo usado apenas para campo mourão IPM ipm = new IPM((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, oDadosEnvLoteRps.cMunicipio); if (ConfiguracaoApp.Proxy) { ipm.Proxy = Proxy.DefinirProxy(ConfiguracaoApp.ProxyServidor, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyPorta); } ipm.EmiteNF(NomeArquivoXML, false); break; case PadroesNFSe.GINFES: switch (oDadosEnvLoteRps.cMunicipio) { case 2304400: //Fortaleza - CE cabecMsg = "<ns2:cabecalho versao=\"3\" xmlns:ns2=\"http://www.ginfes.com.br/cabecalho_v03.xsd\"><versaoDados>3</versaoDados></ns2:cabecalho>"; break; case 4125506: //São José dos Pinhais - PR cabecMsg = "<ns2:cabecalho versao=\"3\" xmlns:ns2=\"http://nfe.sjp.pr.gov.br/cabecalho_v03.xsd\"><versaoDados>3</versaoDados></ns2:cabecalho>"; break; default: cabecMsg = "<ns2:cabecalho versao=\"3\" xmlns:ns2=\"http://www.ginfes.com.br/cabecalho_v03.xsd\"><versaoDados>3</versaoDados></ns2:cabecalho>"; break; } break; case PadroesNFSe.ABASE: cabecMsg = "<cabecalho xmlns=\"http://nfse.abase.com.br/nfse.xsd\" versao =\"1.00\"><versaoDados>1.00</versaoDados></cabecalho>"; break; case PadroesNFSe.BETHA: #region Betha string versao = Functions.GetAttributeXML("LoteRps", "versao", NomeArquivoXML); if (versao.Equals("2.02")) { padraoNFSe = PadroesNFSe.BETHA202; Components.Betha.NewVersion.Betha betha = new Components.Betha.NewVersion.Betha((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor); AssinaturaDigital signbetha = new AssinaturaDigital(); signbetha.Assinar(NomeArquivoXML, emp, 202); if (GetTipoServicoSincrono(Servico, NomeArquivoXML, PadroesNFSe.BETHA202) == Servicos.NFSeRecepcionarLoteRpsSincrono) { betha.EmiteNFSincrono(NomeArquivoXML); } else { betha.EmiteNF(NomeArquivoXML); } } else { wsProxy = new WebServiceProxy(Empresas.Configuracoes[emp].X509Certificado); wsProxy.Betha = new Betha(); } break; #endregion Betha case PadroesNFSe.ABACO: case PadroesNFSe.CANOAS_RS: cabecMsg = "<cabecalho versao=\"201001\"><versaoDados>V2010</versaoDados></cabecalho>"; break; case PadroesNFSe.BLUMENAU_SC: EncryptAssinatura(); break; case PadroesNFSe.BHISS: cabecMsg = "<cabecalho xmlns=\"http://www.abrasf.org.br/nfse.xsd\" versao=\"1.00\"><versaoDados >1.00</versaoDados ></cabecalho>"; Servico = GetTipoServicoSincrono(Servico, NomeArquivoXML, PadroesNFSe.BHISS); break; case PadroesNFSe.SH3: cabecMsg = "<cabecalho xmlns=\"http://www.abrasf.org.br/nfse.xsd\" versao=\"1.00\"><versaoDados >1.00</versaoDados ></cabecalho>"; Servico = GetTipoServicoSincrono(Servico, NomeArquivoXML, PadroesNFSe.SH3); break; case PadroesNFSe.WEBISS: cabecMsg = "<cabecalho xmlns=\"http://www.abrasf.org.br/nfse.xsd\" versao=\"1.00\"><versaoDados >1.00</versaoDados ></cabecalho>"; break; case PadroesNFSe.WEBISS_202: Servico = GetTipoServicoSincrono(Servico, NomeArquivoXML, PadroesNFSe.WEBISS_202); cabecMsg = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><cabecalho xmlns=\"http://www.abrasf.org.br/nfse.xsd\" versao=\"2.02\"><versaoDados>2.02</versaoDados></cabecalho>"; break; case PadroesNFSe.PAULISTANA: wsProxy = new WebServiceProxy(Empresas.Configuracoes[emp].X509Certificado); if (oDadosEnvLoteRps.tpAmb == 1) { envLoteRps = new Components.PSaoPauloSP.LoteNFe(); } else { throw new Exception("Município de São Paulo-SP não dispõe de ambiente de homologação para envio de NFS-e em teste."); } EncryptAssinatura(); break; case PadroesNFSe.NA_INFORMATICA: Servico = GetTipoServicoSincrono(Servico, NomeArquivoXML, PadroesNFSe.VVISS); wsProxy = new WebServiceProxy(Empresas.Configuracoes[emp].X509Certificado); //if (oDadosEnvLoteRps.tpAmb == 1) // envLoteRps = new Components.PCorumbaMS.NfseWSService(); //else // envLoteRps = new Components.HCorumbaMS.NfseWSService(); break; case PadroesNFSe.BSITBR: Servico = GetTipoServicoSincrono(Servico, NomeArquivoXML, PadroesNFSe.BSITBR); wsProxy = new WebServiceProxy(Empresas.Configuracoes[emp].X509Certificado); if (oDadosEnvLoteRps.tpAmb == 1) { envLoteRps = new Components.PJaraguaGO.nfseWS(); } else { throw new Exception("Município de Jaraguá-GO não dispõe de ambiente de homologação para envio de NFS-e em teste."); } break; case PadroesNFSe.PORTOVELHENSE: cabecMsg = "<cabecalho versao=\"2.00\" xmlns:ns2=\"http://www.w3.org/2000/09/xmldsig#\" xmlns=\"http://www.abrasf.org.br/nfse.xsd\"><versaoDados>2.00</versaoDados></cabecalho>"; break; case PadroesNFSe.DSF: EncryptAssinatura(); break; case PadroesNFSe.TECNOSISTEMAS: cabecMsg = "<?xml version=\"1.0\" encoding=\"utf-8\"?><cabecalho xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" versao=\"20.01\" xmlns=\"http://www.nfse-tecnos.com.br/nfse.xsd\"><versaoDados>20.01</versaoDados></cabecalho>"; break; case PadroesNFSe.FINTEL: cabecMsg = "<cabecalho versao=\"2.02\" xmlns=\"http://iss.irati.pr.gov.br/Arquivos/nfseV202.xsd\"><versaoDados>2.02</versaoDados></cabecalho>"; Servico = GetTipoServicoSincrono(Servico, NomeArquivoXML, PadroesNFSe.FINTEL); break; case PadroesNFSe.PORTALFACIL_ACTCON: cabecMsg = "<cabecalho><versaoDados>2.01</versaoDados></cabecalho>"; Servico = GetTipoServicoSincrono(Servico, NomeArquivoXML, PadroesNFSe.PORTALFACIL_ACTCON); break; case PadroesNFSe.PORTALFACIL_ACTCON_202: cabecMsg = "<cabecalho><versaoDados>2.02</versaoDados></cabecalho>"; Servico = GetTipoServicoSincrono(Servico, NomeArquivoXML, PadroesNFSe.PORTALFACIL_ACTCON_202); break; case PadroesNFSe.SYSTEMPRO: #region SystemPro SystemPro syspro = new SystemPro((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, Empresas.Configuracoes[emp].X509Certificado); AssinaturaDigital ad = new AssinaturaDigital(); ad.Assinar(NomeArquivoXML, emp, oDadosEnvLoteRps.cMunicipio); syspro.EmiteNF(NomeArquivoXML); break; #endregion SystemPro case PadroesNFSe.SIGCORP_SIGISS: #region SigCorp SigCorp sigcorp = new SigCorp((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio); sigcorp.EmiteNF(NomeArquivoXML); break; #endregion SigCorp case PadroesNFSe.FIORILLI: #region Fiorilli Fiorilli fiorilli = new Fiorilli((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor, Empresas.Configuracoes[emp].X509Certificado); AssinaturaDigital ass = new AssinaturaDigital(); ass.Assinar(NomeArquivoXML, emp, oDadosEnvLoteRps.cMunicipio); // Validar o Arquivo XML ValidarXML validar = new ValidarXML(NomeArquivoXML, Empresas.Configuracoes[emp].UnidadeFederativaCodigo, false); string resValidacao = validar.ValidarArqXML(NomeArquivoXML); if (resValidacao != "") { throw new Exception(resValidacao); } fiorilli.EmiteNF(NomeArquivoXML); break; #endregion Fiorilli case PadroesNFSe.SIMPLISS: #region Simpliss SimplISS simpliss = new SimplISS((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor); AssinaturaDigital sign = new AssinaturaDigital(); sign.Assinar(NomeArquivoXML, emp, oDadosEnvLoteRps.cMunicipio); simpliss.EmiteNF(NomeArquivoXML); break; #endregion Simpliss case PadroesNFSe.CONAM: #region Conam Conam conam = new Conam((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS); conam.EmiteNF(NomeArquivoXML); break; #endregion Conam case PadroesNFSe.RLZ_INFORMATICA: #region RLZ Rlz_Informatica rlz = new Rlz_Informatica((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio); rlz.EmiteNF(NomeArquivoXML); break; #endregion RLZ case PadroesNFSe.EGOVERNE: #region E-Governe EGoverne egoverne = new EGoverne((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor, Empresas.Configuracoes[emp].X509Certificado); AssinaturaDigital assEGovoverne = new AssinaturaDigital(); assEGovoverne.Assinar(NomeArquivoXML, emp, oDadosEnvLoteRps.cMunicipio); egoverne.EmiteNF(NomeArquivoXML); break; #endregion E-Governe case PadroesNFSe.EL: #region E&L EL el = new EL((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, (ConfiguracaoApp.Proxy ? ConfiguracaoApp.ProxyUsuario : ""), (ConfiguracaoApp.Proxy ? ConfiguracaoApp.ProxySenha : ""), (ConfiguracaoApp.Proxy ? ConfiguracaoApp.ProxyServidor : "")); el.EmiteNF(NomeArquivoXML); break; #endregion E&L case PadroesNFSe.GOVDIGITAL: #region GOV-Digital GovDigital govdig = new GovDigital((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, Empresas.Configuracoes[emp].X509Certificado, oDadosEnvLoteRps.cMunicipio, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor); AssinaturaDigital adgovdig = new AssinaturaDigital(); adgovdig.Assinar(NomeArquivoXML, emp, oDadosEnvLoteRps.cMunicipio); govdig.EmiteNF(NomeArquivoXML); break; #endregion GOV-Digital case PadroesNFSe.EQUIPLANO: cabecMsg = "1"; break; case PadroesNFSe.NATALENSE: cabecMsg = "<cabecalho xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" versao=\"1\" xmlns=\"http://www.abrasf.org.br/ABRASF/arquivos/nfse.xsd\"><versaoDados>1</versaoDados></cabecalho>"; break; case PadroesNFSe.PRODATA: cabecMsg = "<cabecalho><versaoDados>2.01</versaoDados></cabecalho>"; break; case PadroesNFSe.VVISS: Servico = GetTipoServicoSincrono(Servico, NomeArquivoXML, PadroesNFSe.VVISS); break; case PadroesNFSe.ELOTECH: #region EloTech EloTech elotech = new EloTech((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor, Empresas.Configuracoes[emp].X509Certificado); elotech.EmiteNF(NomeArquivoXML); break; #endregion EloTech case PadroesNFSe.METROPOLIS: #region METROPOLIS Metropolis metropolis = new Metropolis((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor, Empresas.Configuracoes[emp].X509Certificado); AssinaturaDigital metropolisdig = new AssinaturaDigital(); metropolisdig.Assinar(NomeArquivoXML, emp, oDadosEnvLoteRps.cMunicipio); metropolis.EmiteNF(NomeArquivoXML); break; #endregion METROPOLIS case PadroesNFSe.MGM: #region MGM MGM mgm = new MGM((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS); mgm.EmiteNF(NomeArquivoXML); break; #endregion MGM case PadroesNFSe.CONSIST: #region Consist Consist consist = new Consist((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor); consist.EmiteNF(NomeArquivoXML); break; #endregion Consist case PadroesNFSe.NOTAINTELIGENTE: #region Nota Inteligente wsProxy = new WebServiceProxy(Empresas.Configuracoes[emp].X509Certificado); if (oDadosEnvLoteRps.tpAmb == 1) { //envLoteRps = new NFe.Components.PClaudioMG.api_portClient(); } else { throw new Exception("Município de São Paulo-SP não dispõe de ambiente de homologação para envio de NFS-e em teste."); } #endregion Nota Inteligente break; case PadroesNFSe.COPLAN: #region Coplan Coplan coplan = new Coplan((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor, Empresas.Configuracoes[emp].X509Certificado); AssinaturaDigital assCoplan = new AssinaturaDigital(); assCoplan.Assinar(NomeArquivoXML, emp, oDadosEnvLoteRps.cMunicipio); coplan.EmiteNF(NomeArquivoXML); break; #endregion Coplan case PadroesNFSe.FREIRE_INFORMATICA: cabecMsg = "<cabecalho xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://www.abrasf.org.br/nfse.xsd\" versao=\"2.02\"><versaoDados>2.02</versaoDados></cabecalho>"; break; case PadroesNFSe.MEMORY: #region Memory Memory memory = new Memory((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor); AssinaturaDigital sigMem = new AssinaturaDigital(); sigMem.Assinar(NomeArquivoXML, emp, oDadosEnvLoteRps.cMunicipio); memory.EmiteNF(NomeArquivoXML); break; #endregion Memory case PadroesNFSe.CAMACARI_BA: Servico = GetTipoServicoSincrono(Servico, NomeArquivoXML, PadroesNFSe.CAMACARI_BA); cabecMsg = "<cabecalho><versaoDados>2.01</versaoDados><versao>2.01</versao></cabecalho>"; break; case PadroesNFSe.CARIOCA: Servico = GetTipoServicoSincrono(Servico, NomeArquivoXML, PadroesNFSe.CARIOCA); break; case PadroesNFSe.PRONIN: if (oDadosEnvLoteRps.cMunicipio == 4109401 || oDadosEnvLoteRps.cMunicipio == 3131703 || oDadosEnvLoteRps.cMunicipio == 4303004) { Pronin pronin = new Pronin((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor, Empresas.Configuracoes[emp].X509Certificado); AssinaturaDigital assPronin = new AssinaturaDigital(); assPronin.Assinar(NomeArquivoXML, emp, oDadosEnvLoteRps.cMunicipio); pronin.EmiteNF(NomeArquivoXML); } break; case PadroesNFSe.EGOVERNEISS: #region EGoverne ISS EGoverneISS egoverneiss = new EGoverneISS((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor); egoverneiss.EmiteNF(NomeArquivoXML); break; #endregion EGoverne ISS case PadroesNFSe.SUPERNOVA: Servico = GetTipoServicoSincrono(Servico, NomeArquivoXML, PadroesNFSe.SUPERNOVA); break; case PadroesNFSe.MARINGA_PR: Servico = GetTipoServicoSincrono(Servico, NomeArquivoXML, PadroesNFSe.MARINGA_PR); break; case PadroesNFSe.BAURU_SP: #region BAURU_SP Bauru_SP bauru_SP = new Bauru_SP((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio); bauru_SP.EmiteNF(NomeArquivoXML); break; #endregion BAURU_SP #region Tinus case PadroesNFSe.TINUS: Tinus tinus = new Tinus((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor, Empresas.Configuracoes[emp].X509Certificado); AssinaturaDigital tinusAss = new AssinaturaDigital(); tinusAss.Assinar(NomeArquivoXML, emp, oDadosEnvLoteRps.cMunicipio); tinus.EmiteNF(NomeArquivoXML); break; #endregion Tinus #region SOFTPLAN case PadroesNFSe.SOFTPLAN: SOFTPLAN softplan = new SOFTPLAN((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, Empresas.Configuracoes[emp].ClientID, Empresas.Configuracoes[emp].ClientSecret); AssinaturaDigital softplanAssinatura = new AssinaturaDigital(); softplanAssinatura.Assinar(NomeArquivoXML, emp, oDadosEnvLoteRps.cMunicipio); // Validar o Arquivo XML ValidarXML softplanValidar = new ValidarXML(NomeArquivoXML, Empresas.Configuracoes[emp].UnidadeFederativaCodigo, false); string validacao = softplanValidar.ValidarArqXML(NomeArquivoXML); if (validacao != "") { throw new Exception(validacao); } if (ConfiguracaoApp.Proxy) { softplan.Proxy = Proxy.DefinirProxy(ConfiguracaoApp.ProxyServidor, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyPorta); } AssinaturaDigital softplanAss = new AssinaturaDigital(); softplanAss.Assinar(NomeArquivoXML, emp, oDadosEnvLoteRps.cMunicipio, AlgorithmType.Sha256); softplan.EmiteNF(NomeArquivoXML); break; #endregion SOFTPLAN case PadroesNFSe.INTERSOL: cabecMsg = "<?xml version=\"1.0\" encoding=\"utf-8\"?><p:cabecalho versao=\"1\" xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:p=\"http://ws.speedgov.com.br/cabecalho_v1.xsd\" xmlns:p1=\"http://ws.speedgov.com.br/tipos_v1.xsd\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://ws.speedgov.com.br/cabecalho_v1.xsd cabecalho_v1.xsd \"><versaoDados>1</versaoDados></p:cabecalho>"; break; } if (IsInvocar(padraoNFSe, Servico, oDadosEnvLoteRps.cMunicipio)) { //Assinar o XML AssinaturaDigital ad = new AssinaturaDigital(); ad.Assinar(NomeArquivoXML, emp, oDadosEnvLoteRps.cMunicipio); //Invocar o método que envia o XML para o SEFAZ oInvocarObj.InvocarNFSe(wsProxy, envLoteRps, NomeMetodoWS(Servico, oDadosEnvLoteRps.cMunicipio), cabecMsg, this, Propriedade.Extensao(Propriedade.TipoEnvio.EnvLoteRps).EnvioXML, Propriedade.Extensao(Propriedade.TipoEnvio.EnvLoteRps).RetornoXML, padraoNFSe, Servico, securityProtocolType); /// /// grava o arquivo no FTP string filenameFTP = Path.Combine(Empresas.Configuracoes[emp].PastaXmlRetorno, Functions.ExtrairNomeArq(NomeArquivoXML, Propriedade.Extensao(Propriedade.TipoEnvio.EnvLoteRps).EnvioXML) + "\\" + Propriedade.Extensao(Propriedade.TipoEnvio.EnvLoteRps).RetornoXML); if (File.Exists(filenameFTP)) { new GerarXML(emp).XmlParaFTP(emp, filenameFTP); } } } catch (Exception ex) { try { //Gravar o arquivo de erro de retorno para o ERP, caso ocorra TFunctions.GravarArqErroServico(NomeArquivoXML, Propriedade.Extensao(Propriedade.TipoEnvio.EnvLoteRps).EnvioXML, Propriedade.ExtRetorno.RetEnvLoteRps_ERR, ex); } catch { //Se falhou algo na hora de gravar o retorno .ERR (de erro) para o ERP, infelizmente não posso fazer mais nada. //Wandrey 31/08/2011 } } finally { try { Functions.DeletarArquivo(NomeArquivoXML); } catch { //Se falhou algo na hora de deletar o XML de cancelamento de NFe, infelizmente //não posso fazer mais nada, o UniNFe vai tentar mandar o arquivo novamente para o webservice, pois ainda não foi excluido. //Wandrey 31/08/2011 } } }
protected string dataGet(IPM pm, string name, bool forceEval) { if(content.ContainsKey(name)) { return forceEval ? evaluate(content[name]) : content[name]; } throw new NotFoundException($"Package of data with name '{name}' was not found."); }
protected string stProjectsFind(IPM pm) { ILevel level = pm.FirstLevel; // level of the `find` property if(level.Is(ArgumentType.StringDouble)) { string name = (string)level.Args[0].data; return projectCfg(getContextByProject(name), pm.pinTo(1)); } throw new ArgumentPMException(level, "find(string name)"); }
protected string stSolution(IPM pm) { if(!pm.Is(LevelType.Property, "solution")) { throw new IncorrectNodeException(pm); } // solution.current. if(pm.Is(1, LevelType.Property, "current")) { if(!env.IsOpenedSolution) { throw new NotSupportedOperationException("Property 'current' is not available. Open the Solution or use 'path()' method instead."); } return stSlnPMap(env.SolutionFile, pm.pinTo(2)); } // solution.path("file"). if(pm.Is(1, LevelType.Method, "path")) { ILevel lvlPath = pm.Levels[1]; lvlPath.Is("solution.path(string sln)", ArgumentType.StringDouble); return stSlnPMap((string)lvlPath.Args[0].data, pm.pinTo(2)); } throw new IncorrectNodeException(pm, 1); }
protected string projectCfg(SolutionContext context, IPM pm) { Debug.Assert(context != null); if(pm.It(LevelType.Property, "IsBuildable")) { if(pm.IsRight(LevelType.RightOperandStd)) { context.ShouldBuild = Value.toBoolean(pm.FirstLevel.Data); return Value.Empty; } if(pm.IsRight(LevelType.RightOperandEmpty)) { return Value.from(context.ShouldBuild); } } if(pm.It(LevelType.Property, "IsDeployable")) { if(pm.IsRight(LevelType.RightOperandStd)) { context.ShouldDeploy = Value.toBoolean(pm.FirstLevel.Data); return Value.Empty; } if(pm.IsRight(LevelType.RightOperandEmpty)) { return Value.from(context.ShouldDeploy); } } throw new IncorrectNodeException(pm); }
protected string stCancel(IPM pm) { if(!pm.It(LevelType.Property, "cancel") || !pm.IsRight(LevelType.RightOperandStd)) { throw new IncorrectNodeException(pm); } if(Value.toBoolean(pm.FirstLevel.Data)) { Log.Debug("attempt to cancel the build"); DTEO.exec("Build.Cancel"); } return Value.Empty; }
protected string stRepeat(IPM pm, string expression) { if(!pm.It(LevelType.Method, "repeat") || !pm.IsRight(LevelType.RightOperandColon)) { throw new IncorrectNodeException(pm); } Argument[] args = (new PM()).arguments(expression, ';'); if(args == null || args.Length > 2 || args.Length < 1) { throw new InvalidArgumentException($"Incorrect arguments: {args?.Length} `{expression}`"); } string condition = args[0].data.ToString(); bool silent = false; if(args.Length == 2) { if(args[1].type != ArgumentType.Boolean) { throw new InvalidArgumentException($"Incorrect type of argument `silent`: {args[1].type}"); } silent = (bool)args[1].data; } return doRepeat(condition, pm.FirstLevel.Data, null, silent); }
protected string stOut(IPM pm) { if(!pm.Is(LevelType.Property, "out") && !pm.Is(LevelType.Method, "out")) { throw new IncorrectNodeException(pm); } string item = Settings._.DefaultOWPItem; // by default for all bool isGuid = false; if(pm.Is(LevelType.Method, "out")) { ILevel lvlOut = pm.FirstLevel; if(!lvlOut.Is(ArgumentType.StringDouble) && !lvlOut.Is(ArgumentType.StringDouble, ArgumentType.Boolean)) { throw new InvalidArgumentException("Incorrect arguments to `out(string ident [, boolean isGuid])`"); } Argument[] args = lvlOut.Args; item = (string)args[0].data; isGuid = (args.Length == 2)? (bool)args[1].data : false; // optional isGuid param } Log.Trace("stOut: out = item('{0}'), isGuid('{1}')", item, isGuid); IItemEW ew = OWPItems._.getEW((isGuid)? new OWPIdent() { guid = item } : new OWPIdent() { item = item }); string raw = StringHandler.escapeQuotes(ew.Raw); // #[OWP out.All] / #[OWP out] / #[OWP out("Build").All] / #[OWP out("Build")] ... if(pm.FinalEmptyIs(1, LevelType.Property, "All") || pm.FinalEmptyIs(1, LevelType.RightOperandEmpty)) { return raw; } // #[OWP out.Warnings.Count] ... if(pm.Is(1, LevelType.Property, "Warnings") && pm.FinalEmptyIs(2, LevelType.Property, "Count")) { return Value.from(ew.WarningsCount); } // #[OWP out.Warnings.Codes] ... if(pm.Is(1, LevelType.Property, "Warnings") && pm.FinalEmptyIs(2, LevelType.Property, "Codes")) { return Value.from(ew.Warnings); } // #[OWP out.Warnings.Raw] / #[OWP out.Warnings] ... if((pm.Is(1, LevelType.Property, "Warnings") && pm.FinalEmptyIs(2, LevelType.Property, "Raw")) || pm.FinalEmptyIs(1, LevelType.Property, "Warnings")) { return (ew.IsWarnings)? raw : Value.Empty; } // #[OWP out.Errors.Count] ... if(pm.Is(1, LevelType.Property, "Errors") && pm.FinalEmptyIs(2, LevelType.Property, "Count")) { return Value.from(ew.ErrorsCount); } // #[OWP out.Errors.Codes] ... if(pm.Is(1, LevelType.Property, "Errors") && pm.FinalEmptyIs(2, LevelType.Property, "Codes")) { return Value.from(ew.Errors); } // #[OWP out.Errors.Raw] / #[OWP out.Errors] ... if((pm.Is(1, LevelType.Property, "Errors") && pm.FinalEmptyIs(2, LevelType.Property, "Raw")) || pm.FinalEmptyIs(1, LevelType.Property, "Errors")) { return (ew.IsErrors)? raw : Value.Empty; } throw new IncorrectNodeException(pm, 1); }
protected string stIterate(IPM pm, string expression) { if(!pm.It(LevelType.Method, "iterate") || !pm.IsRight(LevelType.RightOperandColon)) { throw new IncorrectNodeException(pm); } Argument[] args = (new PM()).arguments(expression, ';'); if(args == null || args.Length != 3) { throw new InvalidArgumentException($"Incorrect arguments `iterate(; condition; )`: {args?.Length} `{expression}`"); } string initializer = args[0].data.ToString(); string condition = args[1].data.ToString(); string iterator = args[2].data.ToString(); if(!String.IsNullOrWhiteSpace(initializer)) { evaluate($"$({initializer})"); } iterator = String.IsNullOrWhiteSpace(iterator) ? null : $"$({iterator})"; return doRepeat(condition, pm.FirstLevel.Data, iterator, false); }
protected string stOperators(IPM pm) { if(!pm.It(LevelType.Property, "operators")) { throw new IncorrectNodeException(pm); } ILevel lvlOp = pm.FirstLevel; if(pm.FinalEmptyIs(LevelType.Method, "sleep")) { lvlOp.Is("sleep(integer timeout)", ArgumentType.Integer); Thread.Sleep((int)lvlOp.Args[0].data); return String.Empty; } throw new IncorrectNodeException(pm); }
protected string stData(IPM pm) { if(!pm.It(LevelType.Property, "data")) { throw new IncorrectNodeException(pm); } ILevel level = pm.FirstLevel; if(pm.FinalIs(LevelType.Method, "pack")) { return dataPack(level, pm); } if(pm.FinalEmptyIs(LevelType.Method, "free")) { return dataFree(level, pm); } if(pm.FinalEmptyIs(LevelType.Method, "get")) { return dataGet(level, pm); } if(pm.FinalEmptyIs(LevelType.Method, "clone")) { return dataClone(level, pm); } throw new IncorrectNodeException(pm); }
protected string dataPack(IPM pm, string name, bool eval) { if(pm.FirstLevel.Type != LevelType.RightOperandColon) { throw new IncorrectNodeException(pm); // #[Box data.pack(name, eval): content] } if(content.ContainsKey(name)) { throw new LimitException($"Package of data with name '{name}' is already defined before. Use `data.free` to release data and avoid this error."); } Log.Trace($"`data.pack('{name}', {eval}): {pm.FirstLevel.Data}`"); content[name] = eval ? evaluate(pm.FirstLevel.Data) : pm.FirstLevel.Data; Log.Trace($"packed as `{content[name]}`"); return String.Empty; }
protected string dataPack(ILevel level, IPM pm) { if(level.Is(ArgumentType.StringDouble, ArgumentType.Boolean)) { return dataPack(pm.pinTo(1), (string)level.Args[0].data, (bool)level.Args[1].data); } throw new ArgumentPMException(level, "data.pack(string name, boolean eval)"); }
protected string dataFree(ILevel level, IPM pm) { if(level.Is(ArgumentType.StringDouble)) { return dataFree(pm.pinTo(1), (string)level.Args[0].data); } throw new ArgumentPMException(level, "data.free(string name)"); }
protected string stItemWrite(string name, bool newline, IPM pm) { if(!pm.IsMethodWithArgs("write", ArgumentType.Boolean) && !pm.IsMethodWithArgs("writeLine", ArgumentType.Boolean)) { throw new IncorrectNodeException(pm); } bool createIfNotExist = (bool)pm.FirstLevel.Args[0].data; if(pm.Levels[1].Type != LevelType.RightOperandColon) { throw new IncorrectNodeException(pm); } string content = pm.Levels[1].Data; EnvDTE.OutputWindowPane pane; if(!createIfNotExist) { try { pane = OWP.getByName(name, false); } catch(ArgumentException) { throw new NotFoundException("The item '{0}' does not exist. Use 'force' flag for automatic creation if needed.", name); } } else { pane = OWP.getByName(name, true); } if(newline) { content += System.Environment.NewLine; } pane.OutputString(content); return Value.Empty; }
protected string projectsMap(ProjectsMap.Project project, IPM pm) { if(pm.FinalEmptyIs(0, LevelType.Property, "name")) { return project.name; } if(pm.FinalEmptyIs(0, LevelType.Property, "path")) { return project.path; } if(pm.FinalEmptyIs(0, LevelType.Property, "type")) { return project.type; } if(pm.FinalEmptyIs(0, LevelType.Property, "guid")) { return project.guid; } throw new OperationNotFoundException("Failed projectsMap - '{0}' /'{1}'", pm.Levels[0].Data, pm.Levels[0].Type); }
protected string dataClone(ILevel level, IPM pm) { if(level.Is(ArgumentType.StringDouble, ArgumentType.Integer)) { return dataClone(pm.pinTo(1), (string)level.Args[0].data, (int)level.Args[1].data); } if(level.Is(ArgumentType.StringDouble, ArgumentType.Integer, ArgumentType.Boolean)) { return dataClone(pm.pinTo(1), (string)level.Args[0].data, (int)level.Args[1].data, (bool)level.Args[2].data); } throw new ArgumentPMException(level, "data.clone(string name, integer count [, boolean forceEval])"); }
protected string rawMethod(ILevel level, IPM pm) { if(level.Is(ArgumentType.StringDouble)) { gnt.raw((string)level.Args[0].data); return Value.Empty; } throw new InvalidArgumentException("Incorrect arguments to `gnt.raw(string command)`"); }
protected string stItemDelete(string name, IPM pm) { if(!pm.It(LevelType.Property, "delete") || !pm.IsRight(LevelType.RightOperandStd)) { throw new IncorrectNodeException(pm); } if(!Value.toBoolean(pm.FirstLevel.Data)) { #if DEBUG Log.Trace("skip removing '{0}'", name); #endif return Value.from(false); } Log.Debug("removing the item '{0}'", name); try { OWP.deleteByName(name); return Value.from(true); } catch(ArgumentException) { Log.Debug("Incorrect name of pane item `{0}`", name); } return Value.from(false); }
protected string projectsMap(ProjectsMap.Project project, IPM pm) { if(pm.FinalEmptyIs(LevelType.Property, "name")) { return project.name; } if(pm.FinalEmptyIs(LevelType.Property, "path")) { return project.path; } if(pm.FinalEmptyIs(LevelType.Property, "type")) { return project.type; } if(pm.FinalEmptyIs(LevelType.Property, "guid")) { return project.guid; } throw new IncorrectNodeException(pm); }
protected string stPackFiles(Argument[] files, string name, Argument[] except, OutArchiveFormat type, CompressionMethod method, CompressionLevel rate, IPM pm) { Log.Trace("stPackFiles: `{0}` : type({1}), method({2}), level({3})", name, type, method, rate); if (String.IsNullOrWhiteSpace(name)) { throw new InvalidArgumentException("The output name of archive is empty."); } if (files.Length < 1) { throw new InvalidArgumentException("List of files is empty."); } if (files.Any(p => p.type != ArgumentType.StringDouble)) { throw new InvalidArgumentException("Incorrect data from input files. Define as {\"f1\", \"f2\", ...}"); } if (except != null && except.Any(p => p.type != ArgumentType.StringDouble)) { throw new InvalidArgumentException("Incorrect data from the 'except' argument. Define as {\"f1\", \"f2\", ...}"); } // additional checking of input files. // The SevenZipSharp creates directories if input file is not exist o_O string[] input = files.Select((f, i) => pathToFile((string)f.data, i)).ToArray().ExtractFiles(); #if DEBUG Log.Trace("stPackFiles: Found files `{0}`", String.Join(", ", input)); #endif if (except != null) { input = input.Except(except .Where(f => !String.IsNullOrWhiteSpace((string)f.data)) .Select(f => location((string)f.data)) .ToArray() .ExtractFiles() ).ToArray(); } if (input.Length < 1) { throw new InvalidArgumentException("The input files was not found. Check your mask and the exception list if used."); } SevenZipCompressor zip = new SevenZipCompressor() { ArchiveFormat = type, CompressionMethod = method, CompressionLevel = rate, CompressionMode = CompressionMode.Create, FastCompression = true, // to disable some events inside SevenZip DirectoryStructure = true, }; compressFiles(zip, location(name), input); return(Value.Empty); }
protected string stProjects(IPM pm) { if(!pm.It(LevelType.Property, "projects")) { throw new IncorrectNodeException(pm); } if(pm.Is(LevelType.Method, "find")) { return stProjectsFind(pm); } throw new IncorrectNodeException(pm); }
protected string stItem(IPM pm) { if(!pm.Is(LevelType.Method, "item")) { throw new IncorrectNodeException(pm); } ILevel level = pm.FirstLevel; // level of the item() method if(!level.Is(ArgumentType.StringDouble)) { throw new ArgumentPMException(level, "item(string name)"); } string name = (string)level.Args[0].data; if(String.IsNullOrWhiteSpace(name) /*|| name.Trim().Equals(Settings.OWP_ITEM_VSSBE, StringComparison.OrdinalIgnoreCase)*/) { throw new NotSupportedOperationException("The OW pane '{0}' is not available for current operation.", name); } pm.pinTo(1); switch(pm.FirstLevel.Data) { case "write": { return stItemWrite(name, false, pm); } case "writeLine": { return stItemWrite(name, true, pm); } case "delete": { return stItemDelete(name, pm); } case "clear": { return stItemClear(name, pm); } case "activate": { return stItemActivate(name, pm); } } throw new IncorrectNodeException(pm); }
protected string stSlnPMap(string sln, IPM pm) { if(String.IsNullOrWhiteSpace(sln)) { throw new InvalidArgumentException("Failed stSlnPMap: sln is empty"); } ProjectsMap map = getProjectsMap(sln); if(pm.Is(LevelType.Property, "First")) { return projectsMap(map.FirstBy(env.BuildType), pm.pinTo(1)); } if(pm.Is(LevelType.Property, "Last")) { return projectsMap(map.LastBy(env.BuildType), pm.pinTo(1)); } if(pm.Is(LevelType.Property, "FirstRaw")) { return projectsMap(map.First, pm.pinTo(1)); } if(pm.Is(LevelType.Property, "LastRaw")) { return projectsMap(map.Last, pm.pinTo(1)); } if(pm.FinalEmptyIs(LevelType.Property, "GuidList")) { return Value.from(map.GuidList); } if(pm.Is(LevelType.Method, "projectBy")) { ILevel lvlPrjBy = pm.FirstLevel; lvlPrjBy.Is("projectBy(string guid)", ArgumentType.StringDouble); return projectsMap(map.getProjectBy((string)lvlPrjBy.Args[0].data), pm.pinTo(1)); } throw new IncorrectNodeException(pm); }
/// <summary> /// Prepares signatures: /// unpack(file [, output][, delete][, pwd]) /// </summary> /// <param name="level"></param> /// <param name="pm"></param> /// <returns></returns> protected string unpack(ILevel level, IPM pm) { // unpack(string file) if(level.Is(ArgumentType.StringDouble)) { return stUnpackMethod(pm, (string)level.Args[0].data); } // unpack(string file, string output) if(level.Is(ArgumentType.StringDouble, ArgumentType.StringDouble)) { return stUnpackMethod(pm, (string)level.Args[0].data, (string)level.Args[1].data); } // unpack(string file, string output, string pwd) if(level.Is(ArgumentType.StringDouble, ArgumentType.StringDouble, ArgumentType.StringDouble)) { return stUnpackMethod(pm, (string)level.Args[0].data, (string)level.Args[1].data, false, (string)level.Args[2].data); } // unpack(string file, string output, boolean delete) if(level.Is(ArgumentType.StringDouble, ArgumentType.StringDouble, ArgumentType.Boolean)) { return stUnpackMethod(pm, (string)level.Args[0].data, (string)level.Args[1].data, (bool)level.Args[2].data); } // unpack(string file, string output, boolean delete, string pwd) if(level.Is(ArgumentType.StringDouble, ArgumentType.StringDouble, ArgumentType.Boolean, ArgumentType.StringDouble)) { return stUnpackMethod(pm, (string)level.Args[0].data, (string)level.Args[1].data, (bool)level.Args[2].data, (string)level.Args[3].data); } // unpack(string file, boolean delete) if(level.Is(ArgumentType.StringDouble, ArgumentType.Boolean)) { return stUnpackMethod(pm, (string)level.Args[0].data, null, (bool)level.Args[1].data); } // unpack(string file, boolean delete, string pwd) if(level.Is(ArgumentType.StringDouble, ArgumentType.Boolean, ArgumentType.StringDouble)) { return stUnpackMethod(pm, (string)level.Args[0].data, null, (bool)level.Args[1].data, (string)level.Args[2].data); } throw new InvalidArgumentException("Incorrect arguments to `unpack(string file [, string output][, boolean delete][, string pwd])`"); }
protected string stType(IPM pm) { if(!pm.It(LevelType.Property, "type") || !pm.IsRight(LevelType.RightOperandEmpty)) { throw new IncorrectNodeException(pm); } return Value.from(env.BuildType); }
protected string StWrite(IPM pm, bool append, bool newline) { return(StWrite(pm, append, newline, defaultEncoding)); }
/// <summary> /// Packing directory for signature: /// pack.directory(string dir, string output) /// </summary> /// <param name="dir">Input directory.</param> /// <param name="name">Output archive.</param> /// <param name="pm"></param> /// <returns></returns> protected string stPackDirectory(string dir, string name, IPM pm) { return(stPackDirectory(dir, name, OutArchiveFormat.Zip, CompressionMethod.Deflate, CompressionLevel.Normal, pm)); }
protected string dataFree(IPM pm, string name) { if(content.ContainsKey(name)) { content.Remove(name); Log.Debug($"Package of data with name '{name}' has been removed"); } return String.Empty; }
protected string StWrite(IPM pm, bool append, bool newline, Encoding enc) { ILevel level = pm.FirstLevel; string file = null; string std = null; // basic method signatures if (level.Is(ArgumentType.StringDouble) && pm.IsData("write", "writeLine", "append", "appendLine")) { file = (string)level.Args[0].data; } else if (level.Is(ArgumentType.StringDouble, ArgumentType.Boolean, ArgumentType.Boolean, ArgumentType.StringDouble) && pm.IsData("write")) { file = (string)level.Args[0].data; append = (bool)level.Args[1].data; newline = (bool)level.Args[2].data; enc = GetEncoding((string)level.Args[3].data); } else if (level.Is(ArgumentType.EnumOrConst) && pm.IsData("write", "writeLine")) { std = (string)level.Args[0].data; } else if (level.Is(ArgumentType.EnumOrConst, ArgumentType.Boolean, ArgumentType.Boolean, ArgumentType.StringDouble) && pm.IsData("write")) { std = (string)level.Args[0].data; append = (bool)level.Args[1].data; newline = (bool)level.Args[2].data; enc = GetEncoding((string)level.Args[3].data); } else { throw new PMLevelException(level, "write( (string name | const STD) [, boolean append, boolean newline, string encoding]); writeLine(string name | const STD); append/appendLine(string name)"); } // content string fdata; if (pm.Levels[1].Type == LevelType.RightOperandColon) { fdata = pm.Levels[1].Data; } else { throw new IncorrectNodeException(pm); } // Text file if (file != null) { file = GetLocation(file); WriteToFile(file, fdata, append, newline, enc); LSender.Send(this, $"The data:{fdata.Length} is successfully written - `{file}` : {append}, {newline}, '{enc.EncodingName}'", MsgLevel.Trace); return(Value.Empty); } // Streams switch (std) { case "STDERR": { WriteToStdErr(fdata, newline); return(Value.Empty); } case "STDOUT": { WriteToStdOut(fdata, newline); return(Value.Empty); } default: { throw new IncorrectSyntaxException($"Incorrect stream type `{std}`"); } } throw new IncorrectNodeException(pm); }
public override void Execute() { int emp = Empresas.FindEmpresaByThread(); //Definir o serviço que será executado para a classe Servico = Servicos.NFSeRecepcionarLoteRps; try { Functions.DeletarArquivo(Empresas.Configuracoes[emp].PastaXmlRetorno + "\\" + Functions.ExtrairNomeArq(NomeArquivoXML, Propriedade.Extensao(Propriedade.TipoEnvio.EnvLoteRps).EnvioXML) + Propriedade.ExtRetorno.RetEnvLoteRps_ERR); Functions.DeletarArquivo(Empresas.Configuracoes[emp].PastaXmlErro + "\\" + NomeArquivoXML); oDadosEnvLoteRps = new DadosEnvLoteRps(emp); EnvLoteRps(emp, NomeArquivoXML); //Criar objetos das classes dos serviços dos webservices do SEFAZ PadroesNFSe padraoNFSe = Functions.PadraoNFSe(oDadosEnvLoteRps.cMunicipio); WebServiceProxy wsProxy = null; object envLoteRps = null; if (IsUtilizaCompilacaoWs(padraoNFSe)) { wsProxy = ConfiguracaoApp.DefinirWS(Servico, emp, oDadosEnvLoteRps.cMunicipio, oDadosEnvLoteRps.tpAmb, oDadosEnvLoteRps.tpEmis, padraoNFSe); if (wsProxy != null) { envLoteRps = wsProxy.CriarObjeto(wsProxy.NomeClasseWS); } } System.Net.SecurityProtocolType securityProtocolType = WebServiceProxy.DefinirProtocoloSeguranca(oDadosEnvLoteRps.cMunicipio, oDadosEnvLoteRps.tpAmb, oDadosEnvLoteRps.tpEmis, padraoNFSe, Servico); string cabecMsg = ""; switch (padraoNFSe) { case PadroesNFSe.IPM: //código da cidade da receita federal, este arquivo pode ser encontrado em ~\uninfe\doc\Codigos_Cidades_Receita_Federal.xls</para> //O código da cidade está hardcoded pois ainda está sendo usado apenas para campo mourão IPM ipm = new IPM(Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, oDadosEnvLoteRps.cMunicipio, Empresas.Configuracoes[emp].PastaXmlRetorno); if (ConfiguracaoApp.Proxy) { ipm.Proxy = Proxy.DefinirProxy(ConfiguracaoApp.ProxyServidor, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyPorta); } ipm.EmitirNF(NomeArquivoXML, (TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo); break; case PadroesNFSe.GINFES: if (oDadosEnvLoteRps.cMunicipio == 4125506) //São José dos Pinhais - PR { cabecMsg = "<ns2:cabecalho versao=\"3\" xmlns:ns2=\"http://nfe.sjp.pr.gov.br/cabecalho_v03.xsd\"><versaoDados>3</versaoDados></ns2:cabecalho>"; } else { cabecMsg = "<ns2:cabecalho versao=\"3\" xmlns:ns2=\"http://www.ginfes.com.br/cabecalho_v03.xsd\"><versaoDados>3</versaoDados></ns2:cabecalho>"; } break; case PadroesNFSe.BETHA: wsProxy = new WebServiceProxy(Empresas.Configuracoes[emp].X509Certificado); wsProxy.Betha = new Betha(); break; case PadroesNFSe.ABACO: case PadroesNFSe.CANOAS_RS: cabecMsg = "<cabecalho versao=\"201001\"><versaoDados>V2010</versaoDados></cabecalho>"; break; case PadroesNFSe.BLUMENAU_SC: EncryptAssinatura(); break; case PadroesNFSe.BHISS: cabecMsg = "<cabecalho xmlns=\"http://www.abrasf.org.br/nfse.xsd\" versao=\"1.00\"><versaoDados >1.00</versaoDados ></cabecalho>"; Servico = GetTipoServicoSincrono(Servico, NomeArquivoXML, PadroesNFSe.BHISS); break; case PadroesNFSe.WEBISS: cabecMsg = "<cabecalho xmlns=\"http://www.abrasf.org.br/nfse.xsd\" versao=\"1.00\"><versaoDados >1.00</versaoDados ></cabecalho>"; break; case PadroesNFSe.PAULISTANA: wsProxy = new WebServiceProxy(Empresas.Configuracoes[emp].X509Certificado); if (oDadosEnvLoteRps.tpAmb == 1) { envLoteRps = new Components.PSaoPauloSP.LoteNFe(); } else { throw new Exception("Município de São Paulo-SP não dispõe de ambiente de homologação para envio de NFS-e em teste."); } EncryptAssinatura(); break; case PadroesNFSe.NA_INFORMATICA: Servico = GetTipoServicoSincrono(Servico, NomeArquivoXML, PadroesNFSe.VVISS); wsProxy = new WebServiceProxy(Empresas.Configuracoes[emp].X509Certificado); if (oDadosEnvLoteRps.tpAmb == 1) { envLoteRps = new Components.PCorumbaMS.NfseWSService(); } else { envLoteRps = new Components.HCorumbaMS.NfseWSService(); } break; case PadroesNFSe.PORTOVELHENSE: cabecMsg = "<cabecalho versao=\"2.00\" xmlns:ns2=\"http://www.w3.org/2000/09/xmldsig#\" xmlns=\"http://www.abrasf.org.br/nfse.xsd\"><versaoDados>2.00</versaoDados></cabecalho>"; break; case PadroesNFSe.DSF: EncryptAssinatura(); break; case PadroesNFSe.TECNOSISTEMAS: cabecMsg = "<?xml version=\"1.0\" encoding=\"utf-8\"?><cabecalho xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" versao=\"20.01\" xmlns=\"http://www.nfse-tecnos.com.br/nfse.xsd\"><versaoDados>20.01</versaoDados></cabecalho>"; break; case PadroesNFSe.FINTEL: cabecMsg = "<cabecalho xmlns=\"http://iss.pontagrossa.pr.gov.br/Arquivos/nfse.xsd\" versao=\"1.00\"><versaoDados >1.00</versaoDados ></cabecalho>"; Servico = GetTipoServicoSincrono(Servico, NomeArquivoXML, PadroesNFSe.FINTEL); break; case PadroesNFSe.ACTCON: cabecMsg = "<cabecalho><versaoDados>2.01</versaoDados></cabecalho>"; Servico = GetTipoServicoSincrono(Servico, NomeArquivoXML, PadroesNFSe.ACTCON); break; case PadroesNFSe.SYSTEMPRO: #region SystemPro SystemPro syspro = new SystemPro((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, Empresas.Configuracoes[emp].X509Certificado); AssinaturaDigital ad = new AssinaturaDigital(); ad.Assinar(NomeArquivoXML, emp, oDadosEnvLoteRps.cMunicipio); syspro.EmiteNF(NomeArquivoXML); break; #endregion case PadroesNFSe.SIGCORP_SIGISS: #region SigCorp SigCorp sigcorp = new SigCorp((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio); sigcorp.EmiteNF(NomeArquivoXML); break; #endregion case PadroesNFSe.FIORILLI: #region Fiorilli Fiorilli fiorilli = new Fiorilli((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor); AssinaturaDigital ass = new AssinaturaDigital(); ass.Assinar(NomeArquivoXML, emp, oDadosEnvLoteRps.cMunicipio); fiorilli.EmiteNF(NomeArquivoXML); break; #endregion case PadroesNFSe.SIMPLISS: #region Simpliss SimplISS simpliss = new SimplISS((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor); AssinaturaDigital sign = new AssinaturaDigital(); sign.Assinar(NomeArquivoXML, emp, oDadosEnvLoteRps.cMunicipio); simpliss.EmiteNF(NomeArquivoXML); break; #endregion case PadroesNFSe.CONAM: #region Conam Conam conam = new Conam((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS); conam.EmiteNF(NomeArquivoXML); break; #endregion case PadroesNFSe.RLZ_INFORMATICA: #region RLZ Rlz_Informatica rlz = new Rlz_Informatica((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio); rlz.EmiteNF(NomeArquivoXML); break; #endregion case PadroesNFSe.EGOVERNE: #region E-Governe EGoverne egoverne = new EGoverne((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor, Empresas.Configuracoes[emp].X509Certificado); AssinaturaDigital assEGovoverne = new AssinaturaDigital(); assEGovoverne.Assinar(NomeArquivoXML, emp, oDadosEnvLoteRps.cMunicipio); egoverne.EmiteNF(NomeArquivoXML); break; #endregion case PadroesNFSe.EL: #region E&L EL el = new EL((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, (ConfiguracaoApp.Proxy ? ConfiguracaoApp.ProxyUsuario : ""), (ConfiguracaoApp.Proxy ? ConfiguracaoApp.ProxySenha : ""), (ConfiguracaoApp.Proxy ? ConfiguracaoApp.ProxyServidor : "")); el.EmiteNF(NomeArquivoXML); break; #endregion case PadroesNFSe.GOVDIGITAL: #region GOV-Digital GovDigital govdig = new GovDigital((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, Empresas.Configuracoes[emp].X509Certificado, oDadosEnvLoteRps.cMunicipio, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor); AssinaturaDigital adgovdig = new AssinaturaDigital(); adgovdig.Assinar(NomeArquivoXML, emp, oDadosEnvLoteRps.cMunicipio); govdig.EmiteNF(NomeArquivoXML); break; #endregion case PadroesNFSe.EQUIPLANO: cabecMsg = "1"; break; case PadroesNFSe.NATALENSE: cabecMsg = "<cabecalho xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" versao=\"1\" xmlns=\"http://www.abrasf.org.br/ABRASF/arquivos/nfse.xsd\"><versaoDados>1</versaoDados></cabecalho>"; break; case PadroesNFSe.PRODATA: cabecMsg = "<cabecalho><versaoDados>2.01</versaoDados></cabecalho>"; break; case PadroesNFSe.VVISS: Servico = GetTipoServicoSincrono(Servico, NomeArquivoXML, PadroesNFSe.VVISS); break; case PadroesNFSe.ELOTECH: #region EloTech EloTech elotech = new EloTech((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor, Empresas.Configuracoes[emp].X509Certificado); elotech.EmiteNF(NomeArquivoXML); break; #endregion case PadroesNFSe.METROPOLIS: #region METROPOLIS Metropolis metropolis = new Metropolis((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor, Empresas.Configuracoes[emp].X509Certificado); AssinaturaDigital metropolisdig = new AssinaturaDigital(); metropolisdig.Assinar(NomeArquivoXML, emp, oDadosEnvLoteRps.cMunicipio); metropolis.EmiteNF(NomeArquivoXML); break; #endregion case PadroesNFSe.MGM: #region MGM MGM mgm = new MGM((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS); mgm.EmiteNF(NomeArquivoXML); break; #endregion case PadroesNFSe.CONSIST: #region Consist Consist consist = new Consist((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor); consist.EmiteNF(NomeArquivoXML); break; #endregion case PadroesNFSe.NOTAINTELIGENTE: #region Nota Inteligente wsProxy = new WebServiceProxy(Empresas.Configuracoes[emp].X509Certificado); if (oDadosEnvLoteRps.tpAmb == 1) { //envLoteRps = new NFe.Components.PClaudioMG.api_portClient(); } else { throw new Exception("Município de São Paulo-SP não dispõe de ambiente de homologação para envio de NFS-e em teste."); } #endregion break; case PadroesNFSe.FREIRE_INFORMATICA: cabecMsg = "<cabecalho xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://www.abrasf.org.br/nfse.xsd\" versao=\"2.02\"><versaoDados>2.02</versaoDados></cabecalho>"; break; case PadroesNFSe.MEMORY: #region Memory Memory memory = new Memory((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosEnvLoteRps.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor); AssinaturaDigital sigMem = new AssinaturaDigital(); sigMem.Assinar(NomeArquivoXML, emp, oDadosEnvLoteRps.cMunicipio); memory.EmiteNF(NomeArquivoXML); break; #endregion case PadroesNFSe.CAMACARI_BA: cabecMsg = "<cabecalho><versaoDados>2.01</versaoDados><versao>2.01</versao></cabecalho>"; break; } if (IsInvocar(padraoNFSe)) { //Assinar o XML AssinaturaDigital ad = new AssinaturaDigital(); ad.Assinar(NomeArquivoXML, emp, oDadosEnvLoteRps.cMunicipio); //Invocar o método que envia o XML para o SEFAZ oInvocarObj.InvocarNFSe(wsProxy, envLoteRps, NomeMetodoWS(Servico, oDadosEnvLoteRps.cMunicipio), cabecMsg, this, Propriedade.Extensao(Propriedade.TipoEnvio.EnvLoteRps).EnvioXML, //"-env-loterps", Propriedade.Extensao(Propriedade.TipoEnvio.EnvLoteRps).RetornoXML, //"-ret-loterps", padraoNFSe, Servico, securityProtocolType); /// /// grava o arquivo no FTP string filenameFTP = Path.Combine(Empresas.Configuracoes[emp].PastaXmlRetorno, Functions.ExtrairNomeArq(NomeArquivoXML, Propriedade.Extensao(Propriedade.TipoEnvio.EnvLoteRps).EnvioXML) + "\\" + Propriedade.Extensao(Propriedade.TipoEnvio.EnvLoteRps).RetornoXML); if (File.Exists(filenameFTP)) { new GerarXML(emp).XmlParaFTP(emp, filenameFTP); } } } catch (Exception ex) { try { //Gravar o arquivo de erro de retorno para o ERP, caso ocorra TFunctions.GravarArqErroServico(NomeArquivoXML, Propriedade.Extensao(Propriedade.TipoEnvio.EnvLoteRps).EnvioXML, Propriedade.ExtRetorno.RetEnvLoteRps_ERR, ex); } catch { //Se falhou algo na hora de gravar o retorno .ERR (de erro) para o ERP, infelizmente não posso fazer mais nada. //Wandrey 31/08/2011 } } finally { try { Functions.DeletarArquivo(NomeArquivoXML); } catch { //Se falhou algo na hora de deletar o XML de cancelamento de NFe, infelizmente //não posso fazer mais nada, o UniNFe vai tentar mandar o arquivo novamente para o webservice, pois ainda não foi excluido. //Wandrey 31/08/2011 } } }
protected string stPackDirectory(string dir, string name, OutArchiveFormat type, CompressionMethod method, CompressionLevel rate, IPM pm) { Log.Trace("stPackDirectory: `{0}` -> `{1}` : type({2}), method({3}), level({4})", dir, name, type, method, rate); if (String.IsNullOrWhiteSpace(dir)) { throw new InvalidArgumentException("The path to directory is empty."); } if (String.IsNullOrWhiteSpace(name)) { throw new InvalidArgumentException("The output name of archive is empty."); } string fullpath = location(dir); // additional checking of input directory. // The SevenZipSharp creates empty file of archive even if the input directory is not exist o_O if (!Directory.Exists(fullpath)) { throw new NotFoundException("Directory `{0}` is not found. Looked as `{1}`", dir, fullpath); } SevenZipCompressor zip = new SevenZipCompressor() { ArchiveFormat = type, CompressionMethod = method, CompressionLevel = rate, CompressionMode = CompressionMode.Create, FastCompression = true, // to disable some events inside SevenZip IncludeEmptyDirectories = true }; compressDirectory(zip, fullpath, location(name)); return(Value.Empty); }
protected string dataClone(IPM pm, string name, int count, bool forceEval = false) { if(!content.ContainsKey(name)) { throw new NotFoundException($"Package of data with name '{name}' was not found."); } if(count < 1) { return String.Empty; } string val = forceEval ? evaluate(content[name]) : content[name]; string ret = String.Empty; for(int i = 0; i < count; ++i) { ret += val; } return ret; }
public override void Execute() { int emp = Empresas.FindEmpresaByThread(); //Definir o serviço que será executado para a classe Servico = Servicos.NFSeCancelar; try { Functions.DeletarArquivo(Empresas.Configuracoes[emp].PastaXmlRetorno + "\\" + Functions.ExtrairNomeArq(NomeArquivoXML, Propriedade.Extensao(Propriedade.TipoEnvio.PedCanNFSe).EnvioXML) + Propriedade.ExtRetorno.CanNfse_ERR); Functions.DeletarArquivo(Empresas.Configuracoes[emp].PastaXmlErro + "\\" + NomeArquivoXML); oDadosPedCanNfse = new DadosPedCanNfse(emp); //Ler o XML para pegar parâmetros de envio PedCanNfse(emp, NomeArquivoXML); PadroesNFSe padraoNFSe = Functions.PadraoNFSe(oDadosPedCanNfse.cMunicipio); WebServiceProxy wsProxy = null; object pedCanNfse = null; //Criar objetos das classes dos serviços dos webservices do SEFAZ if (IsUtilizaCompilacaoWs(padraoNFSe)) { wsProxy = ConfiguracaoApp.DefinirWS(Servico, emp, oDadosPedCanNfse.cMunicipio, oDadosPedCanNfse.tpAmb, oDadosPedCanNfse.tpEmis, padraoNFSe, oDadosPedCanNfse.cMunicipio); if (wsProxy != null) { pedCanNfse = wsProxy.CriarObjeto(wsProxy.NomeClasseWS); } } System.Net.SecurityProtocolType securityProtocolType = WebServiceProxy.DefinirProtocoloSeguranca(oDadosPedCanNfse.cMunicipio, oDadosPedCanNfse.tpAmb, oDadosPedCanNfse.tpEmis, padraoNFSe, Servico); string cabecMsg = ""; switch (padraoNFSe) { case PadroesNFSe.IPM: //código da cidade da receita federal, este arquivo pode ser encontrado em ~\uninfe\doc\Codigos_Cidades_Receita_Federal.xls</para> //O código da cidade está hardcoded pois ainda está sendo usado apenas para campo mourão IPM ipm = new IPM((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, oDadosPedCanNfse.cMunicipio); if (ConfiguracaoApp.Proxy) { ipm.Proxy = Proxy.DefinirProxy(ConfiguracaoApp.ProxyServidor, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyPorta); } ipm.CancelarNfse(NomeArquivoXML); break; case PadroesNFSe.ABASE: cabecMsg = "<cabecalho xmlns=\"http://nfse.abase.com.br/nfse.xsd\" versao =\"1.00\"><versaoDados>1.00</versaoDados></cabecalho>"; break; case PadroesNFSe.GINFES: cabecMsg = ""; //Cancelamento ainda tá na versão 2.0 então não tem o cabecMsg break; case PadroesNFSe.BETHA: #region Betha ConteudoXML.PreserveWhitespace = false; ConteudoXML.Load(NomeArquivoXML); if (!ConteudoXML.DocumentElement.Name.Contains("e:")) { padraoNFSe = PadroesNFSe.BETHA202; Components.Betha.NewVersion.Betha betha = new Components.Betha.NewVersion.Betha((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor); AssinaturaDigital signbetha = new AssinaturaDigital(); signbetha.Assinar(NomeArquivoXML, emp, 202); betha.CancelarNfse(NomeArquivoXML); } else { wsProxy = new WebServiceProxy(Empresas.Configuracoes[emp].X509Certificado); wsProxy.Betha = new Betha(); } break; #endregion Betha case PadroesNFSe.ABACO: case PadroesNFSe.CANOAS_RS: cabecMsg = "<cabecalho versao=\"201001\"><versaoDados>V2010</versaoDados></cabecalho>"; break; case PadroesNFSe.BHISS: cabecMsg = "<cabecalho xmlns=\"http://www.abrasf.org.br/nfse.xsd\" versao=\"1.00\"><versaoDados >1.00</versaoDados ></cabecalho>"; break; case PadroesNFSe.WEBISS: cabecMsg = "<cabecalho xmlns=\"http://www.abrasf.org.br/nfse.xsd\" versao=\"1.00\"><versaoDados >1.00</versaoDados ></cabecalho>"; break; case PadroesNFSe.WEBISS_202: cabecMsg = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><cabecalho xmlns=\"http://www.abrasf.org.br/nfse.xsd\" versao=\"2.02\"><versaoDados>2.02</versaoDados></cabecalho>"; break; case PadroesNFSe.PAULISTANA: wsProxy = new WebServiceProxy(Empresas.Configuracoes[emp].X509Certificado); if (oDadosPedCanNfse.tpAmb == 1) { pedCanNfse = new NFe.Components.PSaoPauloSP.LoteNFe(); } else { throw new Exception("Município de São Paulo-SP não dispõe de ambiente de homologação para envio de NFS-e em teste."); } EncryptAssinatura(); break; case PadroesNFSe.DSF: if (oDadosPedCanNfse.cMunicipio == 3549904) { cabecMsg = "<cabecalho versao=\"3\" xmlns=\"http://www.abrasf.org.br/nfse.xsd\"><versaoDados>3</versaoDados></cabecalho>"; } else { EncryptAssinatura(); } break; case PadroesNFSe.TECNOSISTEMAS: cabecMsg = "<?xml version=\"1.0\" encoding=\"utf-8\"?><cabecalho xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" versao=\"20.01\" xmlns=\"http://www.nfse-tecnos.com.br/nfse.xsd\"><versaoDados>20.01</versaoDados></cabecalho>"; break; case PadroesNFSe.FINTEL: cabecMsg = "<cabecalho versao=\"2.02\" xmlns=\"http://iss.irati.pr.gov.br/Arquivos/nfseV202.xsd\"><versaoDados>2.02</versaoDados></cabecalho>"; break; case PadroesNFSe.SYSTEMPRO: SystemPro syspro = new SystemPro((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, Empresas.Configuracoes[emp].X509Certificado, oDadosPedCanNfse.cMunicipio); AssinaturaDigital ad = new AssinaturaDigital(); ad.Assinar(NomeArquivoXML, emp, oDadosPedCanNfse.cMunicipio); syspro.CancelarNfse(NomeArquivoXML); break; case PadroesNFSe.SIGCORP_SIGISS: SigCorp sigcorp = new SigCorp((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio); sigcorp.CancelarNfse(NomeArquivoXML); break; case PadroesNFSe.SIGCORP_SIGISS_203: cabecMsg = "<cabecalho versao=\"2.03\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://www.abrasf.org.br/nfse.xsd\"><versaoDados>2.03</versaoDados></cabecalho>"; break; case PadroesNFSe.METROPOLIS: #region METROPOLIS Metropolis metropolis = new Metropolis((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor, Empresas.Configuracoes[emp].X509Certificado); AssinaturaDigital metropolisdig = new AssinaturaDigital(); metropolisdig.Assinar(NomeArquivoXML, emp, oDadosPedCanNfse.cMunicipio); metropolis.CancelarNfse(NomeArquivoXML); break; #endregion METROPOLIS case PadroesNFSe.FIORILLI: Fiorilli fiorilli = new Fiorilli((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor, Empresas.Configuracoes[emp].X509Certificado); AssinaturaDigital ass = new AssinaturaDigital(); ass.Assinar(NomeArquivoXML, emp, oDadosPedCanNfse.cMunicipio); fiorilli.CancelarNfse(NomeArquivoXML); break; case PadroesNFSe.SIMPLISS: SimplISS simpliss = new SimplISS((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor); AssinaturaDigital sing = new AssinaturaDigital(); sing.Assinar(NomeArquivoXML, emp, oDadosPedCanNfse.cMunicipio); simpliss.CancelarNfse(NomeArquivoXML); break; case PadroesNFSe.CONAM: Conam conam = new Conam((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS); conam.CancelarNfse(NomeArquivoXML); break; case PadroesNFSe.EGOVERNE: #region E-Governe EGoverne egoverne = new EGoverne((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor, Empresas.Configuracoes[emp].X509Certificado); AssinaturaDigital assegov = new AssinaturaDigital(); assegov.Assinar(NomeArquivoXML, emp, oDadosPedCanNfse.cMunicipio); egoverne.CancelarNfse(NomeArquivoXML); #endregion E-Governe break; case PadroesNFSe.COPLAN: #region Coplan Coplan coplan = new Coplan((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor, Empresas.Configuracoes[emp].X509Certificado); AssinaturaDigital assCoplan = new AssinaturaDigital(); assCoplan.Assinar(NomeArquivoXML, emp, oDadosPedCanNfse.cMunicipio); coplan.CancelarNfse(NomeArquivoXML); break; #endregion Coplan case PadroesNFSe.EL: #region E&L EL el = new EL((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, (ConfiguracaoApp.Proxy ? ConfiguracaoApp.ProxyUsuario : ""), (ConfiguracaoApp.Proxy ? ConfiguracaoApp.ProxySenha : ""), (ConfiguracaoApp.Proxy ? ConfiguracaoApp.ProxyServidor : "")); el.CancelarNfse(NomeArquivoXML); #endregion E&L break; case PadroesNFSe.GOVDIGITAL: GovDigital govdig = new GovDigital((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, Empresas.Configuracoes[emp].X509Certificado, oDadosPedCanNfse.cMunicipio, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor); AssinaturaDigital adgovdig = new AssinaturaDigital(); adgovdig.Assinar(NomeArquivoXML, emp, oDadosPedCanNfse.cMunicipio); govdig.CancelarNfse(NomeArquivoXML); break; case PadroesNFSe.BSITBR: wsProxy = new WebServiceProxy(Empresas.Configuracoes[emp].X509Certificado); if (oDadosPedCanNfse.tpAmb == 1) { switch (oDadosPedCanNfse.cMunicipio) { case 5211800: pedCanNfse = new Components.PJaraguaGO.nfseWS(); break; case 5220454: pedCanNfse = new Components.PSenadorCanedoGO.nfseWS(); break; } } else { switch (oDadosPedCanNfse.cMunicipio) { case 5211800: //Jaraguá - GO throw new Exception("Município de Jaraguá-GO não dispõe de ambiente de homologação para envio de NFS-e em teste."); case 5220454: //Senador Canedo - GO throw new Exception("Município de Senador Canedo-GO não dispõe de ambiente de homologação para envio de NFS-e em teste."); } } break; case PadroesNFSe.EQUIPLANO: cabecMsg = "1"; break; case PadroesNFSe.PORTALFACIL_ACTCON_202: cabecMsg = "<cabecalho><versaoDados>2.02</versaoDados></cabecalho>"; break; case PadroesNFSe.PORTALFACIL_ACTCON: case PadroesNFSe.PRODATA: cabecMsg = "<cabecalho><versaoDados>2.01</versaoDados></cabecalho>"; break; case PadroesNFSe.MGM: #region MGM MGM mgm = new MGM((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS); mgm.CancelarNfse(NomeArquivoXML); break; #endregion MGM case PadroesNFSe.NATALENSE: cabecMsg = "<cabecalho xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" versao=\"1\" xmlns=\"http://www.abrasf.org.br/ABRASF/arquivos/nfse.xsd\"><versaoDados>1</versaoDados></cabecalho>"; break; case PadroesNFSe.CONSIST: #region Consist Consist consist = new Consist((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor); consist.CancelarNfse(NomeArquivoXML); break; #endregion Consist case PadroesNFSe.MEMORY: #region Memory Memory memory = new Memory((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor); memory.CancelarNfse(NomeArquivoXML); break; #endregion Memory case PadroesNFSe.CAMACARI_BA: cabecMsg = "<cabecalho><versaoDados>2.01</versaoDados><versao>2.01</versao></cabecalho>"; break; case PadroesNFSe.NA_INFORMATICA: wsProxy = new WebServiceProxy(Empresas.Configuracoes[emp].X509Certificado); //if (oDadosPedCanNfse.tpAmb == 1) // pedCanNfse = new Components.PCorumbaMS.NfseWSService(); //else // pedCanNfse = new Components.HCorumbaMS.NfseWSService(); break; case PadroesNFSe.PRONIN: if (oDadosPedCanNfse.cMunicipio == 4109401 || oDadosPedCanNfse.cMunicipio == 3131703 || oDadosPedCanNfse.cMunicipio == 4303004 || oDadosPedCanNfse.cMunicipio == 3556602 || oDadosPedCanNfse.cMunicipio == 3512803 || oDadosPedCanNfse.cMunicipio == 4323002 || oDadosPedCanNfse.cMunicipio == 3505807 || oDadosPedCanNfse.cMunicipio == 3530300 || oDadosPedCanNfse.cMunicipio == 4308904 || oDadosPedCanNfse.cMunicipio == 4118501 || oDadosPedCanNfse.cMunicipio == 3554300 || oDadosPedCanNfse.cMunicipio == 3542404 || oDadosPedCanNfse.cMunicipio == 5005707 || oDadosPedCanNfse.cMunicipio == 4314423 || oDadosPedCanNfse.cMunicipio == 3511102 || oDadosPedCanNfse.cMunicipio == 3535804 || oDadosPedCanNfse.cMunicipio == 4306932) { Pronin pronin = new Pronin((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor, Empresas.Configuracoes[emp].X509Certificado); AssinaturaDigital assPronin = new AssinaturaDigital(); assPronin.Assinar(NomeArquivoXML, emp, oDadosPedCanNfse.cMunicipio); pronin.CancelarNfse(NomeArquivoXML); } break; case PadroesNFSe.EGOVERNEISS: #region EGoverne ISS EGoverneISS egoverneiss = new EGoverneISS((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor); egoverneiss.CancelarNfse(NomeArquivoXML); break; #endregion EGoverne ISS case PadroesNFSe.BAURU_SP: Bauru_SP bauru_SP = new Bauru_SP((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio); bauru_SP.CancelarNfse(NomeArquivoXML); break; case PadroesNFSe.SMARAPD: if (Empresas.Configuracoes[emp].UnidadeFederativaCodigo == 3201308) //Município de Cariacica-ES { throw new Exception("Município de Cariacica-ES não permite cancelamento de NFS-e via webservice."); } break; case PadroesNFSe.SMARAPD_204: cabecMsg = "<cabecalho versao=\"2.04\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://www.abrasf.org.br/nfse.xsd\"><versaoDados>2.04</versaoDados></cabecalho>"; break; #region Tinus case PadroesNFSe.TINUS: Tinus tinus = new Tinus((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor, Empresas.Configuracoes[emp].X509Certificado); AssinaturaDigital tinusAss = new AssinaturaDigital(); tinusAss.Assinar(NomeArquivoXML, emp, oDadosPedCanNfse.cMunicipio); tinus.CancelarNfse(NomeArquivoXML); break; #endregion Tinus #region SH3 case PadroesNFSe.SH3: cabecMsg = "<cabecalho xmlns=\"http://www.abrasf.org.br/nfse.xsd\" versao=\"1.00\"><versaoDados >1.00</versaoDados ></cabecalho>"; break; #endregion SH3 #if _fw46 #region SOFTPLAN case PadroesNFSe.SOFTPLAN: Components.SOFTPLAN.SOFTPLAN softplan = new Components.SOFTPLAN.SOFTPLAN((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, Empresas.Configuracoes[emp].TokenNFse, Empresas.Configuracoes[emp].TokenNFSeExpire, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, Empresas.Configuracoes[emp].ClientID, Empresas.Configuracoes[emp].ClientSecret); AssinaturaDigital softplanAssinatura = new AssinaturaDigital(); softplanAssinatura.Assinar(NomeArquivoXML, emp, oDadosPedCanNfse.cMunicipio); // Validar o Arquivo XML ValidarXML softplanValidar = new ValidarXML(NomeArquivoXML, Empresas.Configuracoes[emp].UnidadeFederativaCodigo, false); string validacao = softplanValidar.ValidarArqXML(NomeArquivoXML); if (validacao != "") { throw new Exception(validacao); } if (ConfiguracaoApp.Proxy) { softplan.Proxy = Proxy.DefinirProxy(ConfiguracaoApp.ProxyServidor, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyPorta); } AssinaturaDigital softplanAss = new AssinaturaDigital(); softplanAss.Assinar(NomeArquivoXML, emp, oDadosPedCanNfse.cMunicipio, AlgorithmType.Sha256); softplan.CancelarNfse(NomeArquivoXML); if (Empresas.Configuracoes[emp].TokenNFse != softplan.Token) { Empresas.Configuracoes[emp].SalvarConfiguracoesNFSeSoftplan(softplan.Usuario, softplan.Senha, softplan.ClientID, softplan.ClientSecret, softplan.Token, softplan.TokenExpire, Empresas.Configuracoes[emp].CNPJ); } break; #endregion SOFTPLAN #endif case PadroesNFSe.INTERSOL: cabecMsg = "<?xml version=\"1.0\" encoding=\"utf-8\"?><p:cabecalho versao=\"1\" xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:p=\"http://ws.speedgov.com.br/cabecalho_v1.xsd\" xmlns:p1=\"http://ws.speedgov.com.br/tipos_v1.xsd\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://ws.speedgov.com.br/cabecalho_v1.xsd cabecalho_v1.xsd \"><versaoDados>1</versaoDados></p:cabecalho>"; break; case PadroesNFSe.JOINVILLE_SC: wsProxy = new WebServiceProxy(Empresas.Configuracoes[emp].X509Certificado); if (oDadosPedCanNfse.tpAmb == 2) { pedCanNfse = new Components.HJoinvilleSC.Servicos(); } else { pedCanNfse = new Components.PJoinvilleSC.Servicos(); } break; case PadroesNFSe.AVMB_ASTEN: cabecMsg = "<cabecalho versao=\"2.02\" xmlns=\"http://www.abrasf.org.br/nfse.xsd\"><versaoDados>2.02</versaoDados></cabecalho>"; wsProxy = new WebServiceProxy(Empresas.Configuracoes[emp].X509Certificado); if (oDadosPedCanNfse.tpAmb == 2) { pedCanNfse = new Components.HPelotasRS.INfseservice(); } else { pedCanNfse = new Components.PPelotasRS.INfseservice(); } break; case PadroesNFSe.EMBRAS: cabecMsg = "<cabecalho versao=\"2.02\" xmlns=\"http://www.abrasf.org.br/nfse.xsd\"><versaoDados>2.02</versaoDados></cabecalho>"; break; case PadroesNFSe.MODERNIZACAO_PUBLICA: cabecMsg = "<cabecalho xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://www.abrasf.org.br/nfse.xsd\" versao=\"2.02\"><versaoDados>2.02</versaoDados></cabecalho>"; break; case PadroesNFSe.E_RECEITA: cabecMsg = "<cabecalho xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://www.abrasf.org.br/nfse.xsd\" versao=\"2.02\"><versaoDados>2.02</versaoDados></cabecalho>"; break; case PadroesNFSe.TIPLAN_203: case PadroesNFSe.INDAIATUBA_SP: cabecMsg = "<cabecalho versao=\"2.03\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://www.abrasf.org.br/nfse.xsd\"><versaoDados>2.03</versaoDados></cabecalho>"; break; #if _fw46 case PadroesNFSe.ADM_SISTEMAS: cabecMsg = "<cabecalho versao=\"2.01\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://www.abrasf.org.br/nfse.xsd\"><versaoDados>2.01</versaoDados></cabecalho>"; wsProxy = new WebServiceProxy(Empresas.Configuracoes[emp].X509Certificado); pedCanNfse = oDadosPedCanNfse.tpAmb == 1 ? new Components.PAmargosaBA.InfseClient(GetBinding(), new EndpointAddress("https://demo.saatri.com.br/servicos/nfse.svc")) : new Components.HAmargosaBA.InfseClient(GetBinding(), new EndpointAddress("https://homologa-demo.saatri.com.br/servicos/nfse.svc")) as object; SignUsingCredentials(emp, pedCanNfse); break; #endif case PadroesNFSe.PUBLIC_SOFT: if (oDadosPedCanNfse.cMunicipio.Equals(2610707)) { cabecMsg = "N9M="; } break; case PadroesNFSe.SIMPLE: Simple simple = new Simple((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor, Empresas.Configuracoes[emp].X509Certificado); simple.CancelarNfse(NomeArquivoXML); break; case PadroesNFSe.SISPMJP: cabecMsg = "<cabecalho versao=\"2.02\" xmlns=\"http://www.abrasf.org.br/nfse.xsd\" ><versaoDados>2.02</versaoDados></cabecalho>"; break; case PadroesNFSe.D2TI: cabecMsg = "<cabecalhoCancelamentoNfseLote xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://www.ctaconsult.com/nfse\"><versao>1.00</versao><ambiente>2</ambiente></cabecalhoCancelamentoNfseLote>"; break; case PadroesNFSe.VERSATECNOLOGIA: VersaTecnologia versa = new VersaTecnologia((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor, Empresas.Configuracoes[emp].X509Certificado); AssinaturaDigital assVersa = new AssinaturaDigital(); assVersa.Assinar(NomeArquivoXML, emp, oDadosPedCanNfse.cMunicipio); versa.CancelarNfse(NomeArquivoXML); break; case PadroesNFSe.IIBRASIL: cabecMsg = "<cabecalho xmlns=\"http://www.abrasf.org.br/nfse.xsd\" versao=\"2.04\"><versaoDados>2.04</versaoDados></cabecalho>"; //wsProxy = new WebServiceProxy(Empresas.Configuracoes[emp].X509Certificado); //if (oDadosPedCanNfse.tpAmb == 2) //{ // pedCanNfse = new Components.HLimeiraSP.NfseWSService(); //} //else //{ // throw new Exception("Município de São Paulo-SP não dispõe de ambiente de homologação para envio de NFS-e em teste."); //} break; } if (IsInvocar(padraoNFSe, Servico, Empresas.Configuracoes[emp].UnidadeFederativaCodigo)) { //Assinar o XML AssinaturaDigital ad = new AssinaturaDigital(); ad.Assinar(NomeArquivoXML, emp, oDadosPedCanNfse.cMunicipio); //Invocar o método que envia o XML para o SEFAZ oInvocarObj.InvocarNFSe(wsProxy, pedCanNfse, NomeMetodoWS(Servico, oDadosPedCanNfse.cMunicipio), cabecMsg, this, Propriedade.Extensao(Propriedade.TipoEnvio.PedCanNFSe).EnvioXML, //"-ped-cannfse", Propriedade.Extensao(Propriedade.TipoEnvio.PedCanNFSe).RetornoXML, //"-cannfse", padraoNFSe, Servico, securityProtocolType); /// grava o arquivo no FTP string filenameFTP = Path.Combine(Empresas.Configuracoes[emp].PastaXmlRetorno, Functions.ExtrairNomeArq(NomeArquivoXML, Propriedade.Extensao(Propriedade.TipoEnvio.PedCanNFSe).EnvioXML) + Propriedade.Extensao(Propriedade.TipoEnvio.PedCanNFSe).RetornoXML); if (File.Exists(filenameFTP)) { new GerarXML(emp).XmlParaFTP(emp, filenameFTP); } } } catch (Exception ex) { var strErro = ex.HResult.ToString(); var strMesagemErro = ex.Message; try { //Gravar o arquivo de erro de retorno para o ERP, caso ocorra TFunctions.GravarArqErroServico(NomeArquivoXML, Propriedade.Extensao(Propriedade.TipoEnvio.PedCanNFSe).EnvioXML, Propriedade.ExtRetorno.CanNfse_ERR, ex); } catch { //Se falhou algo na hora de gravar o retorno .ERR (de erro) para o ERP, infelizmente não posso fazer mais nada. //Wandrey 31/08/2011 RetornoErroERP.GeraArquivoErroERP(NomeArquivoXML, strErro, strMesagemErro, Propriedade.ExtRetorno.CanNfse_ERR); } } finally { try { Functions.DeletarArquivo(NomeArquivoXML); } catch { //Se falhou algo na hora de deletar o XML de cancelamento de NFe, infelizmente //não posso fazer mais nada, o UniNFe vai tentar mandar o arquivo novamente para o webservice, pois ainda não foi excluido. //Wandrey 31/08/2011 } } }
/// <summary> /// Checking archive for signature: /// check(string file [, string pwd]) /// </summary> /// <param name="pm"></param> /// <param name="file">Archive for unpacking.</param> /// <param name="pwd">password of archive if used.</param> /// <returns></returns> protected string stCheckMethod(IPM pm, string file, string pwd = null) { Log.Trace("stUnpackMethod: `{0}` pwd({1})", file, (pwd == null)? "none" : "***"); return(checkArchive(pathToFile(file), pwd)); }
public override void Execute() { int emp = Empresas.FindEmpresaByThread(); //Definir o serviço que será executado para a classe Servico = Servicos.NFSeCancelar; try { Functions.DeletarArquivo(Empresas.Configuracoes[emp].PastaXmlRetorno + "\\" + Functions.ExtrairNomeArq(NomeArquivoXML, Propriedade.Extensao(Propriedade.TipoEnvio.PedCanNFSe).EnvioXML) + Propriedade.ExtRetorno.CanNfse_ERR); Functions.DeletarArquivo(Empresas.Configuracoes[emp].PastaXmlErro + "\\" + NomeArquivoXML); oDadosPedCanNfse = new DadosPedCanNfse(emp); //Ler o XML para pegar parâmetros de envio PedCanNfse(emp, NomeArquivoXML); PadroesNFSe padraoNFSe = Functions.PadraoNFSe(oDadosPedCanNfse.cMunicipio); WebServiceProxy wsProxy = null; object pedCanNfse = null; //Criar objetos das classes dos serviços dos webservices do SEFAZ if (IsUtilizaCompilacaoWs(padraoNFSe)) { wsProxy = ConfiguracaoApp.DefinirWS(Servico, emp, oDadosPedCanNfse.cMunicipio, oDadosPedCanNfse.tpAmb, oDadosPedCanNfse.tpEmis, padraoNFSe, oDadosPedCanNfse.cMunicipio); if (wsProxy != null) { pedCanNfse = wsProxy.CriarObjeto(wsProxy.NomeClasseWS); } } System.Net.SecurityProtocolType securityProtocolType = WebServiceProxy.DefinirProtocoloSeguranca(oDadosPedCanNfse.cMunicipio, oDadosPedCanNfse.tpAmb, oDadosPedCanNfse.tpEmis, padraoNFSe, Servico); string cabecMsg = ""; switch (padraoNFSe) { case PadroesNFSe.IPM: //código da cidade da receita federal, este arquivo pode ser encontrado em ~\uninfe\doc\Codigos_Cidades_Receita_Federal.xls</para> //O código da cidade está hardcoded pois ainda está sendo usado apenas para campo mourão IPM ipm = new IPM((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, oDadosPedCanNfse.cMunicipio); if (ConfiguracaoApp.Proxy) { ipm.Proxy = Proxy.DefinirProxy(ConfiguracaoApp.ProxyServidor, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyPorta); } ipm.EmiteNF(NomeArquivoXML, true); break; case PadroesNFSe.ABASE: cabecMsg = "<cabecalho xmlns=\"http://nfse.abase.com.br/nfse.xsd\" versao =\"1.00\"><versaoDados>1.00</versaoDados></cabecalho>"; break; case PadroesNFSe.GINFES: cabecMsg = ""; //Cancelamento ainda tá na versão 2.0 então não tem o cabecMsg break; case PadroesNFSe.BETHA: #region Betha ConteudoXML.PreserveWhitespace = false; ConteudoXML.Load(NomeArquivoXML); if (!ConteudoXML.DocumentElement.Name.Contains("e:")) { padraoNFSe = PadroesNFSe.BETHA202; Components.Betha.NewVersion.Betha betha = new Components.Betha.NewVersion.Betha((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor); AssinaturaDigital signbetha = new AssinaturaDigital(); signbetha.Assinar(NomeArquivoXML, emp, 202); betha.CancelarNfse(NomeArquivoXML); } else { wsProxy = new WebServiceProxy(Empresas.Configuracoes[emp].X509Certificado); wsProxy.Betha = new Betha(); } break; #endregion Betha case PadroesNFSe.ABACO: case PadroesNFSe.CANOAS_RS: cabecMsg = "<cabecalho versao=\"201001\"><versaoDados>V2010</versaoDados></cabecalho>"; break; case PadroesNFSe.BLUMENAU_SC: EncryptAssinatura(); break; case PadroesNFSe.BHISS: cabecMsg = "<cabecalho xmlns=\"http://www.abrasf.org.br/nfse.xsd\" versao=\"1.00\"><versaoDados >1.00</versaoDados ></cabecalho>"; break; case PadroesNFSe.WEBISS: cabecMsg = "<cabecalho xmlns=\"http://www.abrasf.org.br/nfse.xsd\" versao=\"1.00\"><versaoDados >1.00</versaoDados ></cabecalho>"; break; case PadroesNFSe.WEBISS_202: cabecMsg = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><cabecalho xmlns=\"http://www.abrasf.org.br/nfse.xsd\" versao=\"2.02\"><versaoDados>2.02</versaoDados></cabecalho>"; break; case PadroesNFSe.PAULISTANA: wsProxy = new WebServiceProxy(Empresas.Configuracoes[emp].X509Certificado); if (oDadosPedCanNfse.tpAmb == 1) { pedCanNfse = new NFe.Components.PSaoPauloSP.LoteNFe(); } else { throw new Exception("Município de São Paulo-SP não dispõe de ambiente de homologação para envio de NFS-e em teste."); } EncryptAssinatura(); break; case PadroesNFSe.DSF: EncryptAssinatura(); break; case PadroesNFSe.TECNOSISTEMAS: cabecMsg = "<?xml version=\"1.0\" encoding=\"utf-8\"?><cabecalho xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" versao=\"20.01\" xmlns=\"http://www.nfse-tecnos.com.br/nfse.xsd\"><versaoDados>20.01</versaoDados></cabecalho>"; break; case PadroesNFSe.FINTEL: cabecMsg = "<cabecalho versao=\"2.02\" xmlns=\"http://iss.irati.pr.gov.br/Arquivos/nfseV202.xsd\"><versaoDados>2.02</versaoDados></cabecalho>"; break; case PadroesNFSe.SYSTEMPRO: SystemPro syspro = new SystemPro((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, Empresas.Configuracoes[emp].X509Certificado); AssinaturaDigital ad = new AssinaturaDigital(); ad.Assinar(NomeArquivoXML, emp, oDadosPedCanNfse.cMunicipio); syspro.CancelarNfse(NomeArquivoXML); break; case PadroesNFSe.SIGCORP_SIGISS: SigCorp sigcorp = new SigCorp((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio); sigcorp.CancelarNfse(NomeArquivoXML); break; case PadroesNFSe.METROPOLIS: #region METROPOLIS Metropolis metropolis = new Metropolis((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor, Empresas.Configuracoes[emp].X509Certificado); AssinaturaDigital metropolisdig = new AssinaturaDigital(); metropolisdig.Assinar(NomeArquivoXML, emp, oDadosPedCanNfse.cMunicipio); metropolis.CancelarNfse(NomeArquivoXML); break; #endregion METROPOLIS case PadroesNFSe.FIORILLI: Fiorilli fiorilli = new Fiorilli((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor, Empresas.Configuracoes[emp].X509Certificado); AssinaturaDigital ass = new AssinaturaDigital(); ass.Assinar(NomeArquivoXML, emp, oDadosPedCanNfse.cMunicipio); fiorilli.CancelarNfse(NomeArquivoXML); break; case PadroesNFSe.SIMPLISS: SimplISS simpliss = new SimplISS((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor); AssinaturaDigital sing = new AssinaturaDigital(); sing.Assinar(NomeArquivoXML, emp, oDadosPedCanNfse.cMunicipio); simpliss.CancelarNfse(NomeArquivoXML); break; case PadroesNFSe.CONAM: Conam conam = new Conam((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS); conam.CancelarNfse(NomeArquivoXML); break; case PadroesNFSe.EGOVERNE: #region E-Governe EGoverne egoverne = new EGoverne((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor, Empresas.Configuracoes[emp].X509Certificado); AssinaturaDigital assegov = new AssinaturaDigital(); assegov.Assinar(NomeArquivoXML, emp, oDadosPedCanNfse.cMunicipio); egoverne.CancelarNfse(NomeArquivoXML); #endregion E-Governe break; case PadroesNFSe.COPLAN: #region Coplan Coplan coplan = new Coplan((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor, Empresas.Configuracoes[emp].X509Certificado); AssinaturaDigital assCoplan = new AssinaturaDigital(); assCoplan.Assinar(NomeArquivoXML, emp, oDadosPedCanNfse.cMunicipio); coplan.CancelarNfse(NomeArquivoXML); break; #endregion Coplan case PadroesNFSe.EL: #region E&L EL el = new EL((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, (ConfiguracaoApp.Proxy ? ConfiguracaoApp.ProxyUsuario : ""), (ConfiguracaoApp.Proxy ? ConfiguracaoApp.ProxySenha : ""), (ConfiguracaoApp.Proxy ? ConfiguracaoApp.ProxyServidor : "")); el.CancelarNfse(NomeArquivoXML); #endregion E&L break; case PadroesNFSe.GOVDIGITAL: GovDigital govdig = new GovDigital((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, Empresas.Configuracoes[emp].X509Certificado, oDadosPedCanNfse.cMunicipio, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor); AssinaturaDigital adgovdig = new AssinaturaDigital(); adgovdig.Assinar(NomeArquivoXML, emp, oDadosPedCanNfse.cMunicipio); govdig.CancelarNfse(NomeArquivoXML); break; case PadroesNFSe.BSITBR: wsProxy = new WebServiceProxy(Empresas.Configuracoes[emp].X509Certificado); if (oDadosPedCanNfse.tpAmb == 1) { pedCanNfse = new Components.PJaraguaGO.nfseWS(); } else { throw new Exception("Município de Jaraguá-GO não dispõe de ambiente de homologação para envio de NFS-e em teste."); } break; case PadroesNFSe.EQUIPLANO: cabecMsg = "1"; break; case PadroesNFSe.PORTALFACIL_ACTCON_202: cabecMsg = "<cabecalho><versaoDados>2.02</versaoDados></cabecalho>"; break; case PadroesNFSe.PORTALFACIL_ACTCON: case PadroesNFSe.PRODATA: cabecMsg = "<cabecalho><versaoDados>2.01</versaoDados></cabecalho>"; break; case PadroesNFSe.ELOTECH: #region EloTech EloTech elotech = new EloTech((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor, Empresas.Configuracoes[emp].X509Certificado); elotech.CancelarNfse(NomeArquivoXML); break; #endregion EloTech case PadroesNFSe.MGM: #region MGM MGM mgm = new MGM((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS); mgm.CancelarNfse(NomeArquivoXML); break; #endregion MGM case PadroesNFSe.NATALENSE: cabecMsg = @" <![CDATA[<?xml version=""1.0""?> <cabecalho xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" versao =""1"" xmlns =""http://www.abrasf.org.br/ABRASF/arquivos/nfse.xsd"" > <versaoDados>1</versaoDados></cabecalho> "; break; case PadroesNFSe.CONSIST: #region Consist Consist consist = new Consist((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor); consist.CancelarNfse(NomeArquivoXML); break; #endregion Consist case PadroesNFSe.FREIRE_INFORMATICA: cabecMsg = "<cabecalho xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://www.abrasf.org.br/nfse.xsd\" versao=\"2.02\"><versaoDados>2.02</versaoDados></cabecalho>"; break; case PadroesNFSe.MEMORY: #region Memory Memory memory = new Memory((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor); memory.CancelarNfse(NomeArquivoXML); break; #endregion Memory case PadroesNFSe.CAMACARI_BA: cabecMsg = "<cabecalho><versaoDados>2.01</versaoDados><versao>2.01</versao></cabecalho>"; break; case PadroesNFSe.NA_INFORMATICA: wsProxy = new WebServiceProxy(Empresas.Configuracoes[emp].X509Certificado); //if (oDadosPedCanNfse.tpAmb == 1) // pedCanNfse = new Components.PCorumbaMS.NfseWSService(); //else // pedCanNfse = new Components.HCorumbaMS.NfseWSService(); break; case PadroesNFSe.PRONIN: if (oDadosPedCanNfse.cMunicipio == 4109401 || oDadosPedCanNfse.cMunicipio == 3131703 || oDadosPedCanNfse.cMunicipio == 4303004) { Pronin pronin = new Pronin((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor, Empresas.Configuracoes[emp].X509Certificado); AssinaturaDigital assPronin = new AssinaturaDigital(); assPronin.Assinar(NomeArquivoXML, emp, oDadosPedCanNfse.cMunicipio); pronin.CancelarNfse(NomeArquivoXML); } break; case PadroesNFSe.EGOVERNEISS: #region EGoverne ISS EGoverneISS egoverneiss = new EGoverneISS((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor); egoverneiss.CancelarNfse(NomeArquivoXML); break; #endregion EGoverne ISS case PadroesNFSe.BAURU_SP: Bauru_SP bauru_SP = new Bauru_SP((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio); bauru_SP.CancelarNfse(NomeArquivoXML); break; case PadroesNFSe.SMARAPD: if (Empresas.Configuracoes[emp].UnidadeFederativaCodigo == 3201308) //Município de Cariacica-ES { throw new Exception("Município de Cariacica-ES não permite cancelamento de NFS-e via webservice."); } break; #region Tinus case PadroesNFSe.TINUS: Tinus tinus = new Tinus((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, oDadosPedCanNfse.cMunicipio, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyServidor, Empresas.Configuracoes[emp].X509Certificado); AssinaturaDigital tinusAss = new AssinaturaDigital(); tinusAss.Assinar(NomeArquivoXML, emp, oDadosPedCanNfse.cMunicipio); tinus.CancelarNfse(NomeArquivoXML); break; #endregion Tinus #region SH3 case PadroesNFSe.SH3: cabecMsg = "<cabecalho xmlns=\"http://www.abrasf.org.br/nfse.xsd\" versao=\"1.00\"><versaoDados >1.00</versaoDados ></cabecalho>"; break; #endregion SH3 #region SOFTPLAN case PadroesNFSe.SOFTPLAN: SOFTPLAN softplan = new SOFTPLAN((TipoAmbiente)Empresas.Configuracoes[emp].AmbienteCodigo, Empresas.Configuracoes[emp].PastaXmlRetorno, Empresas.Configuracoes[emp].UsuarioWS, Empresas.Configuracoes[emp].SenhaWS, Empresas.Configuracoes[emp].ClientID, Empresas.Configuracoes[emp].ClientSecret); if (ConfiguracaoApp.Proxy) { softplan.Proxy = Proxy.DefinirProxy(ConfiguracaoApp.ProxyServidor, ConfiguracaoApp.ProxyUsuario, ConfiguracaoApp.ProxySenha, ConfiguracaoApp.ProxyPorta); } softplan.CancelarNfse(NomeArquivoXML); break; #endregion SOFTPLAN case PadroesNFSe.INTERSOL: cabecMsg = "<?xml version=\"1.0\" encoding=\"utf-8\"?><p:cabecalho versao=\"1\" xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:p=\"http://ws.speedgov.com.br/cabecalho_v1.xsd\" xmlns:p1=\"http://ws.speedgov.com.br/tipos_v1.xsd\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://ws.speedgov.com.br/cabecalho_v1.xsd cabecalho_v1.xsd \"><versaoDados>1</versaoDados></p:cabecalho>"; break; } if (IsInvocar(padraoNFSe, Servico, Empresas.Configuracoes[emp].UnidadeFederativaCodigo)) { //Assinar o XML AssinaturaDigital ad = new AssinaturaDigital(); ad.Assinar(NomeArquivoXML, emp, oDadosPedCanNfse.cMunicipio); //Invocar o método que envia o XML para o SEFAZ oInvocarObj.InvocarNFSe(wsProxy, pedCanNfse, NomeMetodoWS(Servico, oDadosPedCanNfse.cMunicipio), cabecMsg, this, Propriedade.Extensao(Propriedade.TipoEnvio.PedCanNFSe).EnvioXML, //"-ped-cannfse", Propriedade.Extensao(Propriedade.TipoEnvio.PedCanNFSe).RetornoXML, //"-cannfse", padraoNFSe, Servico, securityProtocolType); /// /// grava o arquivo no FTP string filenameFTP = Path.Combine(Empresas.Configuracoes[emp].PastaXmlRetorno, Functions.ExtrairNomeArq(NomeArquivoXML, Propriedade.Extensao(Propriedade.TipoEnvio.PedCanNFSe).EnvioXML) + Propriedade.Extensao(Propriedade.TipoEnvio.PedCanNFSe).RetornoXML); if (File.Exists(filenameFTP)) { new GerarXML(emp).XmlParaFTP(emp, filenameFTP); } } } catch (Exception ex) { try { //Gravar o arquivo de erro de retorno para o ERP, caso ocorra TFunctions.GravarArqErroServico(NomeArquivoXML, Propriedade.Extensao(Propriedade.TipoEnvio.PedCanNFSe).EnvioXML, Propriedade.ExtRetorno.CanNfse_ERR, ex); } catch { //Se falhou algo na hora de gravar o retorno .ERR (de erro) para o ERP, infelizmente não posso fazer mais nada. //Wandrey 31/08/2011 } } finally { try { Functions.DeletarArquivo(NomeArquivoXML); } catch { //Se falhou algo na hora de deletar o XML de cancelamento de NFe, infelizmente //não posso fazer mais nada, o UniNFe vai tentar mandar o arquivo novamente para o webservice, pois ainda não foi excluido. //Wandrey 31/08/2011 } } }
protected string stGNT(IPM pm) { if(!pm.Is(LevelType.Property, "gnt")) { throw new IncorrectNodeException(pm); } ILevel level = pm.Levels[1]; // level of the gnt property if(pm.FinalEmptyIs(1, LevelType.Method, "raw")) { return rawMethod(level, pm); } // TODO: +gnt.get(object list [, string path [, string server]]) + config files // +gnt.pack(string nuspec [, string path]) throw new IncorrectNodeException(pm, 1); }
protected string stSlnPMap(string sln, IPM pm) { if(String.IsNullOrWhiteSpace(sln)) { throw new InvalidArgumentException("Failed stSlnPMap: sln is empty"); } ProjectsMap map = getProjectsMap(sln); if(pm.Is(0, LevelType.Property, "First")) { return projectsMap(map.FirstBy(env.BuildType), pm.pinTo(1)); } if(pm.Is(0, LevelType.Property, "Last")) { return projectsMap(map.LastBy(env.BuildType), pm.pinTo(1)); } if(pm.Is(0, LevelType.Property, "FirstRaw")) { return projectsMap(map.First, pm.pinTo(1)); } if(pm.Is(0, LevelType.Property, "LastRaw")) { return projectsMap(map.Last, pm.pinTo(1)); } if(pm.FinalEmptyIs(0, LevelType.Property, "GuidList")) { return Value.from(map.GuidList); } if(pm.Is(0, LevelType.Method, "projectBy")) { Argument[] args = pm.Levels[0].Args; if(args.Length != 1 || args[0].type != ArgumentType.StringDouble) { throw new InvalidArgumentException("stSlnPMap: incorrect arguments to `projectBy(string guid)`"); } return projectsMap(map.getProjectBy((string)args[0].data), pm.pinTo(1)); } throw new OperationNotFoundException("stSlnPMap: not found - '{0}' /'{1}'", pm.Levels[0].Data, pm.Levels[0].Type); }
/// <summary> /// For work with events of logging. /// `log.Message` /// `log.Level` /// </summary> /// <param name="pm"></param> /// <returns></returns> //[Property("log", "Provides data from events of logging.")] //[Property("Message", "Current message from log.", "log", "stLog", CValueType.String)] //[Property("Level", "The Level of current Message.", "log", "stLog", CValueType.String)] protected string stLog(IPM pm) { if(pm.It(LevelType.Property, "log")) { if(pm.It(LevelType.Property, "Message")) { return Value.from(logcopy.Message); } if(pm.It(LevelType.Property, "Level")) { return Value.from(logcopy.Level); } throw new IncorrectNodeException(pm); } throw new IncorrectNodeException(pm); }