private void iniciarServicosUniNFe() { Propriedade.TipoAplicativo = TipoAplicativo.Todos; ConfiguracaoApp.StartVersoes(); Empresas.CarregaConfiguracao(); string filenameWS1 = Propriedade.NomeArqXMLMunicipios; string filenameWS2 = Propriedade.NomeArqXMLWebService_NFSe; string filenameWS3 = Propriedade.NomeArqXMLWebService_NFe; string msg = ""; bool error = false; Propriedade.VerificaArquivos(out error, out msg); if (error) { this.WriteLog(msg); } else { foreach (Empresa empresa in Empresas.Configuracoes) { if (empresa.X509Certificado == null && empresa.UsaCertificado) { msg = "Não pode ler o certificado da empresa: " + empresa.CNPJ + "=>" + empresa.Nome + "=>" + empresa.Servico.ToString(); string f = Path.Combine(empresa.PastaXmlRetorno, "uninfeServico_" + DateTime.Now.ToString("yyyy-MMM-dd_hh-mm-ss") + ".txt"); System.IO.File.WriteAllText(f, msg); error = true; WriteLog(msg); } } } if (!error) { // Executar as conversões de atualizações de versão quando tiver Auxiliar.ConversaoNovaVersao(string.Empty); ThreadService.Start(); new ThreadControlEvents(); } else { WriteLog("Servico do UniNFe não está sendo executado "); } }
private void Form1_Load(object sender, EventArgs e) { bool error = false; try { // //SERVICO: danasa 7/2011 //servico está instalado e rodando? this.servicoInstaladoErodando = Propriedade.ServicoRodando; this.tbSeparator1.Visible = this.tbRestartServico.Visible = this.tbPararServico.Visible = this.servicoInstaladoErodando; /// /// danasa 9-2009 /// this.MinimumSize = new Size(800, 630); this.MaximumSize = new Size(800, 630); //Trazer minimizado e no systray this.notifyIcon1.Text = NFe.Components.Propriedade.NomeAplicacao + " - " + NFe.Components.Propriedade.DescricaoAplicacao; this.notifyIcon1.Visible = true; this.WindowState = FormWindowState.Minimized; this.Visible = false; this.ShowInTaskbar = false; ConfiguracaoApp.StartVersoes(); _menu = new menu(); Controls.Add(_menu); _menu.Dock = DockStyle.Fill; notifyIcon1.Icon = Icon = Properties.Resources.uninfe_icon; cmAbrir.Text = "Abrir " + Propriedade.NomeAplicacao; cmFechar.Text = "Fechar " + Propriedade.NomeAplicacao; cmSobre.Text = "Sobre o " + Propriedade.NomeAplicacao; cmManual.Text = "Manual do " + Propriedade.NomeAplicacao; cmManual.Enabled = File.Exists(Path.Combine(Propriedade.PastaExecutavel, Propriedade.NomeAplicacao + ".pdf")); string msg = ""; Propriedade.VerificaArquivos(out error, out msg); if (error) { MetroFramework.MetroMessageBox.Show(this, msg, "", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); return; } if (!this.servicoInstaladoErodando) //danasa 12/8/2011 //Definir eventos de controles de execução das thread´s de serviços do UniNFe. Wandrey 26/07/2011 { new ThreadControlEvents(); //danasa 12/8/2011 } //Executar os serviços do UniNFe em novas threads //Tem que ser carregado depois que o formulário da MainForm estiver totalmente carregado para evitar Erros. Wandrey 19/10/2010 this.ExecutaServicos(); } finally { if (!error) { this.updateControleDoServico(); } } }