コード例 #1
0
 public belVersionamento()
 {
     InternetCS objIcs = new InternetCS();
     bstateInternet = objIcs.Conexao();
     bHLP = belUtil.VerificaSeEstaNaHLP();
 }
コード例 #2
0
        public bool VerificaStatusServico()
        {
            bool ret = true;
            try
            {
                InternetCS objVerificaInternet = new InternetCS();
                if (objVerificaInternet.Conexao())
                {
                    cert = new X509Certificate2();
                    cert = belCertificadoDigital.BuscaNome("");
                    if (!belCertificadoDigital.ValidaCertificado(cert))
                    {
                        lblStatus.Text = "";
                        ret = false;
                        throw new InvalidOperationException("Certificado não Selecionado.");
                    }
                    if (belCertificadoDigital.ValidaCertificado(cert))
                    {
                        objCriaXml = new belCriaXml(cert);
                        List<belStatusCte> ListaStatus = objCriaXml.GerarXmlConsultaStatus();
                        KryptonMessageBox.Show(belTrataMensagem.RetornaMensagem(ListaStatus, belTrataMensagem.Tipo.Status), "STATUS WEBSERVICE ", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        foreach (belStatusCte status in ListaStatus)
                        {
                            if (status.CodRetorno == "107")
                            {
                                lblStatusSefaz.Text = "Sistema em Operação";
                                belStatic.bModoContingencia = false;
                                VerificaPendenciasContingencia();
                                Operacao = true;
                            }
                            else
                            {
                                if (KryptonMessageBox.Show("O Sistema está Indisponível" + Environment.NewLine + "Deseja imprimir DACTE em Modo de Contingência?", "STATUS WEBSERVICE ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                                {
                                    belStatic.bModoContingencia = true;
                                    lblStatusSefaz.Text = "Sistema em Modo de Contingência";
                                }
                                else
                                {
                                    lblStatusSefaz.Text = "Sistema Inoperante";
                                }
                                Operacao = false;
                            }
                        }
                    }
                }
                else
                {
                    FalhaInternet();
                }
            }
            catch (InvalidOperationException io)
            {
                KryptonMessageBox.Show(null, _sMessageException + (io.InnerException != null ? io.InnerException.Message : io.Message).ToString(), "CT-e - AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            catch (Exception ex)
            {
                FalhaInternet();
            }
            return ret;

        }
コード例 #3
0
        private void VerificaStatusSefaz()
        {
            try
            {
                InternetCS objVerificaInternet = new InternetCS();

                if (objVerificaInternet.Conexao())
                {

                    objnfeStatusServicoNF = new belnfeStatusServicoNF("2.00", this.cd_ufnor, cert, Uf_Empresa);
                    string sTempo = string.Empty;
                    if (objnfeStatusServicoNF.Tmed > 1)
                    {
                        sTempo = "Segundos";
                    }
                    else
                    {
                        sTempo = "Segundo";
                    }
                    string sMenssagem = string.Format("Status do servidor: {0} - {1} " + " - Layout: {2}",
                                                          objnfeStatusServicoNF.Cstat,
                                                          objnfeStatusServicoNF.Xmotivo,
                                                          objnfeStatusServicoNF.Versao
                                                          );

                    if ((objnfeStatusServicoNF.Cstat == 108) || (objnfeStatusServicoNF.Cstat == 109) || (objnfeStatusServicoNF.iTentativasWebServices == 1)) // Serviço do Estado Inoperante
                    {
                        #region Tratamento SCAN
                        if (belStatic.iStatusAtualSistema != 3)
                        {
                            belStatic.iStatusAtualSistema = 3;
                            if (belStatic.bModoSCAN)
                            {
                                KryptonMessageBox.Show(null, "Ocorreu uma Excessão com o Serviço do SEFAZ." +
                                        Environment.NewLine +
                                        sMenssagem +
                                        Environment.NewLine +
                                        Environment.NewLine +
                                        "O Sistema já está configurado para Enviar Notas no Modo Contingencia SCAN" +
                                        Environment.NewLine +
                                        Environment.NewLine +
                                        "Série SCAN : " + belStatic.iSerieSCAN.ToString(), "I N F O R M A Ç Ã O", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                lblStatusContingencia.Text = "Série SCAN: " + belStatic.iSerieSCAN.ToString();
                                objfrmPrincipal.sStatusSefaz = "Sistema em Modo de Contingência ( SCAN )";
                            }
                            else
                            {
                                KryptonMessageBox.Show(null, "Ocorreu uma Excessão com o Serviço do SEFAZ." +
                                        Environment.NewLine +
                                        sMenssagem +
                                        Environment.NewLine +
                                        Environment.NewLine +
                                        "O Sistema não está Configurado Para Enviar Notas no Modo Contingência SCAN " +
                                        Environment.NewLine +
                                        "E O GeraXML não será Inicializado!" +
                                        Environment.NewLine, "I N F O R M A Ç Ã O", MessageBoxButtons.OK, MessageBoxIcon.Error);

                                timerWebServices.Enabled = false;
                                frmConfiguracao objfrm = new frmConfiguracao(4);
                                objfrm.ShowDialog();
                                Inicializacao();
                                Object sender = new object();
                                EventArgs e = new EventArgs();
                                this.frmArquivosXml_Load(sender, e);
                            }
                        }
                        #endregion
                    }
                    else if ((objnfeStatusServicoNF.Cstat == 107))
                    {

                        if (belStatic.iStatusAtualSistema != 1)
                        {
                            if (belStatic.bModoSCAN == false)
                            {

                                string sMensg = string.Format("Verificação Web Service: {0}{1}" + "Status do servidor: {2}{3}Motivo: {4}",
                                                              Environment.NewLine,
                                                              Environment.NewLine,
                                                              objnfeStatusServicoNF.Cstat,
                                                              Environment.NewLine,
                                                              objnfeStatusServicoNF.Xmotivo);

                                KryptonMessageBox.Show(null, sMensg +
                                            Environment.NewLine, "I N F O R M A Ç Ã O", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                if (belStatic.iStatusAtualSistema != 0)
                                {
                                    Inicializacao();
                                    Object sender = new object();
                                    EventArgs e = new EventArgs();
                                    this.frmArquivosXml_Load(sender, e);
                                }
                                this.objfrmPrincipal.sStatusSefaz = sMenssagem;
                                lblStatusContingencia.Text = "";
                                VerificaNotasPendentesEnvio();
                                belStatic.iStatusAtualSistema = 1;
                            }
                            else
                            {
                                belStatic.iStatusAtualSistema = 3;
                                sFormaEmissao = "3";
                                string sMensg = string.Format("Verificação Web Service. :{0}{1}" + "Status do servidor: {2}{3}Motivo: {4}",
                                                              Environment.NewLine,
                                                              Environment.NewLine,
                                                              objnfeStatusServicoNF.Cstat,
                                                              Environment.NewLine,
                                                              objnfeStatusServicoNF.Xmotivo
                                                              + Environment.NewLine + Environment.NewLine
                                                              + "Sistema configurado para Emitir NF-e em Contingência SCAN !");
                                KryptonMessageBox.Show(null, sMensg, "I N F O R M A Ç Ã O", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                this.objfrmPrincipal.sStatusSefaz = sMenssagem;
                                lblStatusContingencia.Text = "";
                            }
                        }
                    }
                }
                else
                {
                    throw new Exception("A internet parece estar indisponível !");
                }
            }
            catch (HLPexception hlp)
            {
            }
            catch (Exception ex)
            {
                FalhaInternet(ex);
            }
        }