private DataTable Preencher_DataRow_Sitef_Log_Servico(string strEnderecoIPrimario, Status_Sitef enuStatusSitef) { try { Sitef_Log_ServicoBUS busSitefLogServico = new Sitef_Log_ServicoBUS(); DataTable dttSitefLogServico = busSitefLogServico.Retornar_Estrutura_Tabela(); DataRow dtrSitefLogServico = dttSitefLogServico.NewRow(); dtrSitefLogServico["Sitef_Log_Servico_IP_Servidor"] = strEnderecoIPrimario; dtrSitefLogServico["Enum_Status_ID"] = enuStatusSitef; DBUtil objUtil = new DBUtil(); DateTime dtmSitefLogServicoData = objUtil.Obter_Data_do_Servidor(true, TipoServidor.LojaAtual); dtrSitefLogServico["Sitef_Log_Servico_Data"] = dtmSitefLogServicoData; dtrSitefLogServico["Sitef_Log_Servico_Observacao"] = string.Empty; dttSitefLogServico.Rows.Add(dtrSitefLogServico); return(dttSitefLogServico); } catch (Exception) { throw; } }
private void Registrar_Sitef_Log_Servico(DataTable dttSitefLogServico) { try { if (dttSitefLogServico.Rows.Count == 0) { return; } Sitef_Log_ServicoBUS busSitefLogServico = new Sitef_Log_ServicoBUS(); busSitefLogServico.Incluir(dttSitefLogServico.Rows[0]); } catch (Exception) { throw; } }
private void Processar_Monitor_Sitef() { try { // Obter o endereço de Ip Primario Log.Info("LOG_WS_MONITOR_SITEF", 0, "Serviço conexao: Obtem o link do IP Primario."); string strEnderecoIPrimario = Root.Servidor.Retornar_Endereco_Servidor(this.intLojasID, Servidor.Tipo_Servidor.Sitef, Constantes_Sitef.SITEF_MONITOR_DESCRICAO_SERVIDOR_SITEF_PRIMARIO); // Obter o endereço de Ip Secundario Log.Info("LOG_WS_MONITOR_SITEF", 0, "Serviço conexao: Obtem o link do IP Secundario."); string strEnderecoIPSecundario = Root.Servidor.Retornar_Endereco_Servidor(this.intLojasID, Servidor.Tipo_Servidor.Sitef, Constantes_Sitef.SITEF_MONITOR_DESCRICAO_SERVIDOR_SITEF_SECUNDARIO); // Obter o endereço de IP de conexão Log.Info("LOG_WS_MONITOR_SITEF", 0, "Obtem paramentro ip do servidor de conexao."); string strEnderecoConexaoIP = Root.Parametros_Sistema.Retornar_Parametro_Sistema_Valor_Por_Tipo("IP_SITEF_SERVIDOR_CONEXAO", this.intLojasID); bool blnFalhaSitef = false; Rede objRede = new Rede(); // Servidor Loja if (strEnderecoConexaoIP != null && strEnderecoConexaoIP != string.Empty) { // Verificar se o link está ativo Log.Info("LOG_WS_MONITOR_SITEF", 0, "Serviço loja: Verifica link ativo."); if (objRede.Ping(strEnderecoConexaoIP, Constantes_Sitef.SITEF_MONITOR_PING_TIMEOUT) == false) { // Em caso de falha registra na tabela Sitef_Log_Loja Log.Info("LOG_WS_MONITOR_SITEF", 0, "Serviço loja: Registra falha no link."); this.Registrar_Sitef_Log_Loja(this.Preencher_DataRow_Sitef_Log_Loja(this.intLojasID, Status_Sitef.Link_OffLine)); blnFalhaSitef = true; } } else { // Servidor Conexao // Verificar se o link está ativo Log.Info("LOG_WS_MONITOR_SITEF", 0, "Serviço conexao: Verifica o link do IP Primario."); if (objRede.Ping(strEnderecoIPrimario, Constantes_Sitef.SITEF_MONITOR_PING_TIMEOUT) == false) { // Em caso de falha registra na tabela Sitef_Log_Servico Log.Info("LOG_WS_MONITOR_SITEF", 0, "Serviço conexao: Registra falha no link Primario."); this.Registrar_Sitef_Log_Servico(this.Preencher_DataRow_Sitef_Log_Servico(strEnderecoIPrimario, Status_Sitef.Link_OffLine)); } // Verifica se o Sitef está ativo Log.Info("LOG_WS_MONITOR_SITEF", 0, "Serviço conexao: Verifica monitor sitef online."); string strMensgem = string.Empty; if (this.Monitor_Sitef(strEnderecoIPrimario, ref strMensgem) == false) { // Em caso de falha registra na tabela Sitef_Log_Servico Log.Info("LOG_WS_MONITOR_SITEF", 0, "Serviço conexao: Falha na conexão com Sitef. " + strMensgem); this.Registrar_Sitef_Log_Servico(this.Preencher_DataRow_Sitef_Log_Servico(strEnderecoIPrimario, Status_Sitef.OffLine)); } } if (blnFalhaSitef) { // FALHA NO LINK: Atualiza a tabela Sitef_Status Log.Info("LOG_WS_MONITOR_SITEF", 0, "Serviço loja: Atualiza tabela Sitef_Status, falha no link. "); this.Registrar_Sitef_Status(this.Preencher_DataRow_Sitef_Status(this.intLojasID, Status_Sitef.OffLine)); } else { // Verifica se existe registro de log na tabela Sitef_Log_Servico no servidor Primario e Secundario DBUtil objUtil = new DBUtil(); DateTime dtmSitefLogServicoData = objUtil.Obter_Data_do_Servidor(true, TipoServidor.LojaAtual); int intTimerIdentificaFalha = Root.Parametros_Sistema.Retornar_Parametro_Sistema_Valor_Por_Tipo("TIMER_MONITOR_SITEF_IDENTIFICA_FALHA").DefaultInteger(); double dblIdentificaFalhaMinutos = TimeSpan.FromMilliseconds(intTimerIdentificaFalha).TotalMinutes; DateTime dtmDataIdentificaFalha = new DateTime(dtmSitefLogServicoData.Year, dtmSitefLogServicoData.Month, dtmSitefLogServicoData.Day, dtmSitefLogServicoData.Hour, (dtmSitefLogServicoData.Minute - dblIdentificaFalhaMinutos).DefaultInteger(), dtmSitefLogServicoData.Second); Sitef_Log_ServicoBUS busSitefLogServico = new Sitef_Log_ServicoBUS(); if (busSitefLogServico.Selecionar_Por_Servidor_Data(strEnderecoIPrimario, dtmDataIdentificaFalha).Rows.Count > 0 && busSitefLogServico.Selecionar_Por_Servidor_Data(strEnderecoIPSecundario, dtmDataIdentificaFalha).Rows.Count > 0) { // FALHA: Atualiza a tabela Sitef_Status, falha no servidor primario Log.Info("LOG_WS_MONITOR_SITEF", 0, "Serviço conexao: Atualiza tabela Sitef_Status, falha servidor primario ou secundario."); this.Registrar_Sitef_Status(this.Preencher_DataRow_Sitef_Status(this.intLojasID, Status_Sitef.OffLine)); } else { // Atualiza a tabela Sitef_Status para ONLINE Log.Info("LOG_WS_MONITOR_SITEF", 0, "Atualiza tabela Sitef_Status, sitef online."); this.Registrar_Sitef_Status(this.Preencher_DataRow_Sitef_Status(this.intLojasID, Status_Sitef.Online)); } } } catch (Exception) { throw; } }